-
-
Notifications
You must be signed in to change notification settings - Fork 49
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
Refactor class hierarchy, markup and ports #18
Conversation
Wow, that's a lot of changes. I'm currently busy with other things (including teaching a course utilizing DigitalJS), but I'll try to review this as soon as possible. |
I'm completely fine with wider lines for boxes, but there is a visual change which looks bad: the symbol on arithmetic nodes are (at least in my browser) not centered anymore. |
In general I like the changes - they remove much of the ugliness of the previous solution. Good work! I'd still like to look for possible issues before merging. |
That's strange, on mine (Firefox) they are. Which browser are you using?
These memory effects are gone after changing the defaults as you mentioned. |
Confirmed. Now my best example (the riscv_simple core) runs OK with your version, without apparent correctness or performance issues. I will merge when the visual problem is fixed. |
Firefox 68.8 ESR on Linux here, looks normal for me. Could you post the corresponding SVG code and check whether any further CSS is applied? Here's mine: <text class="oper" id="v-319" font-size="12pt" xml:space="preserve" y="0.8em" fill="black" transform="matrix(1,0,0,1,13.5,12.699999809265137)">
<tspan class="v-line" dy="0">+</tspan>
</text> |
My SVG code: <text class="oper" id="v-271" font-size="12pt" xml:space="preserve" y="0.8em" fill="black" transform="matrix(1,0,0,1,13.399999618530273,13.699999809265137)">
<tspan class="v-line" dy="0">+</tspan>
</text> I see nothing weird in the CSS. I just checked Chrome and the issue is there too. And it's not just digitaljs_online - I see the same issue in the stand-alone tests. |
I've tried to change the My svg now looks like: <text class="oper" id="v-319" font-size="12pt" xml:space="preserve" fill="black" text-anchor="middle" transform="matrix(1,0,0,1,20,20)">
<tspan class="v-line" dy="0.3em">+</tspan>
</text> |
Great to hear! I'll change other occurrences then, too.
I'll look into it. There's another issue: port bits are not displayed initially. It should be sort of a one-liner, but just for the record. |
Would you prefer additional commits or a force-pushed version of this branch? |
I think having a history of fixes here is not really helpful, so force push is probably OK. I could then merge the commits as they are without squashing. |
Another question: are tooltips shown as expected in your browsers? I was unsure if |
The tooltips seem to work fine in both Firefox and Chrome. |
Unfortunately, this seems to be more difficult than it might appear at first sight. The layout is computed using the model's size which is just the height of the Mux element itself. This can't be changed as it would alter the ports positioning too. The only way I see for now is to set a higher See also clientIO/joint#1292 Edit: thanks to a quick answer over at jointJS' github, I was able to fix the problem. See |
I've force-pushed the branch with the necessary fixes. If you don't find any further issues, it would be ready to be merged from my side. |
Good catch, I've made the port wires 5pt longer each s.th. two digits fit well. Three digits would still not fit, but I guess we could ignore this case for reasonable circuits? |
I'll play around with this and see if I can find more issues. If not, I think this is ready to merge. |
This PR tries to simplify some of the core codebase by moving to the standard jointJS solution for ports, markup, initialization and styling (via
attrs
) and by using a slightly clearer gate hierarchy.I'm aware this branch contains a lot of changed lines, but most of the changes are connected and could not be committed separately (e.g.
addPort
only works after theconstructor
has already been called). I will try to give a quick overview over the changes here, feel free to ask if something is unclear.Fixes #13 by switching to the standard jointJS port solutions and a second move forwards towards #2 as several properties can now be changed including the
bits
and (at least some of) the gates should react on it properly.gates.json
file toexamples
to be able to see all ports in one paperconstructor
is replaced byinitialize
to be able to calladdPort()
while initializing gates (this is also the recommended way for backbone.js)this.listenTo(this, ...)
calls have been replaced bythis.on(...)
(see backbone.js)markup
is moved to be a prototype property as recommended by jointJS and is thus shared between different instances of the same cell. Alsomarkup
has been migrated to use JSON markup style and is extended by sub-celltypes.attrs
are changed to use mostly relative dimensions (using jointJSref*
special attributes) to account forsize
changes automaticallyunsupportedPropChanges
) and prints a warning to the console if one of these properties changesbits
property change (usingsetPortBits()
, but still print a warning as connected wires are currently not handledThe last two points could be addressed in upcoming PRs.
Changes for specific celltypes:
Gate
:Gate
has two port groups by default with specific styling (attrs):in
(left) andout
(right)Gate
has always alabel
(markup and attrs) and reacts onlabel
property change displaying the new labeladdWire
has been replaced by overridingaddPort
(the properinputSignals
/outputSignals
are set withinresetPortBits
). AlsoaddLabelledWire
has be incorporated intoaddPort
by always adding an optionalportlabel
.addPorts
,removePort
andremovePorts
are also overriddenBox
:rect
to its markup with default styling (allrects
now also usestrokeWidth: 2
- I'm aware this is a visual appearance change, but it looked nicer to me. If you object to this change, it would be quite easy to make it look again as before)clk
input symbolautoResizeBox
) and influence the calculated width usingcalculateBoxWidth
Arith
is a new super cell type which defines common markup, attrs and slightly changed port groups (to cope with the circular shape) for all arithmetic cellsGateSVG
is another new super cell type with common markup, attrs and slightly changed port groups (to cope with the svg images which don't cover the whole rectangle) for all logic cells currently displayed using an external svg imageGenMux
decor
is used to display the clock symbol on other cells' ports)I would really appreciate if you could have a look at these changes, leave your comments, perhaps find problems or propose further changes.