Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always add bits label to ports markup #14

Merged
merged 1 commit into from
Apr 6, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/cells/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,27 @@ export const Gate = joint.shapes.basic.Generic.define('Gate', {
_.set(args, ['attrs', 'path.wire.port_' + port.id], wire_args);
_.set(args, ['attrs', 'circle.port_' + port.id], circle_args);
let markup = '<path class="wire port_' + port.id + '"/><circle class="port ' + port.dir + ' port_' + port.id + '"/>';
if (port.bits > 1) {
markup += '<text class="bits port_' + port.id + '"/>';
const bits_args = {
text: port.bits,
ref: 'circle.port_' + port.id
};
if (vert) {
// TODO
} else {
bits_args['ref-y'] = -3;
bits_args['text-anchor'] = 'middle';
}
if (side == 'left') {
bits_args['ref-dx'] = 6;
} else if (side == 'right') {
bits_args['ref-x'] = -6;
} else if (side == 'top') {
bits_args['ref-y'] = 6;
} else console.assert(false);
_.set(args, ['attrs', 'text.bits.port_' + port.id], bits_args);

markup += '<text class="bits port_' + port.id + '"/>';
const bits_args = {
text: port.bits > 1 ? port.bits : "",
ref: 'circle.port_' + port.id
};
if (vert) {
// TODO
} else {
bits_args['ref-y'] = -3;
bits_args['text-anchor'] = 'middle';
}
if (side == 'left') {
bits_args['ref-dx'] = 6;
} else if (side == 'right') {
bits_args['ref-x'] = -6;
} else if (side == 'top') {
bits_args['ref-y'] = 6;
} else console.assert(false);
_.set(args, ['attrs', 'text.bits.port_' + port.id], bits_args);

const signame = port.dir == 'in' ? 'inputSignals' : 'outputSignals';
if (_.get(args, [signame, port.id]) === undefined) {
_.set(args, [signame, port.id], Vector3vl.xes(port.bits));
Expand Down