Currently porting some things from Mockba Modular - wondering how I might debug weird issues with seemingly invisible Knob and Jack graphics? I’ve compared their implementation to a working metamodule plugin and I can’t seem to see any difference in how they’ve implemented it.
This is some issue with z-index rendering. I am not sure why Metamodule ignores the z-indices of jacks/ports and makes them render underneath certain graphics?
After more digging, it seems like SvgWidgets are rendering on top of other elements all the time, such as ports or inputs. Not sure if this is intended either.
I see, yeah the MM draws the Z-index of dynamic widgets the highest. I think Rack sets the Z-index just by drawing parents below children? Do you know if that’s right? In which case I’m not sure how to automatically track that since the relationships between widgets in Rack doesn’t 1:1 translate to the MM elements.
But maybe we could just render knobs, jacks, etc on top, which make sense since you would always want to see these. So it would go:
That would be awesome. Would fix a bunch of my ports!
regarding the default VCV Rack order, sorry - I don’t know if that’s right, I’m honestly learning more about VCV Rack plugin structure because of the metamodule and didn’t start from the other way around. It seems like VCV Rack just puts things in order though, as in addChild just adds widgets above each other. But don’t quote me on that.
OK, I changed this in v2.0-dev. The z-index is now set so that dynamic elements (TransparentWidgets and some other stuff) are drawn below the knobs, jacks, lights, etc.
Also – I am correcting a lot of issue with graphics right now, it turns out I didn’t really understand how GPU rendering works and was not properly converting the polygons before doing software rendering. Right now you can see sometimes lines that should be vertical or horizontal are a little bit diagonal. (DrumKit Gnome, and kocmoc TRG were the two examples I noticed). Anyways, you might be running into this as well. I’ve fixed it on the patchview-displays branch, and the added benefit is that things render a lot faster!
Also I’m adding in a real vector library (thorvg) to handle the back-end rendering which means we’ll be able to do filled concave polygons. Part of this refactoring is to let us boost the graphics refresh rate by just refreshing the displays that changed (e.g. a large module with several small displays can just redraw the ones that changed). The thorvg library should be able to load SVG files without converting to PNG, so that’ll be cool.
OK, I misunderstood, I’ve been doing all the dynamic drawing stuff lately, I though you were talking about that. But actually SvgWidgets are not dynamically drawn, they’re just a static. So I just made it so that they are put in the background (above the faceplate, but below all the other stuff).
This won’t work out well if the module depends on multiple layers of SVGs with masking, but in that case they probably should be merged into a single PNG anyways for sake of efficiency.
I’ll push this to the v2.0-dev branch. Are you running firmware you compile from v2.0-dev, or are you using the v2.0-dev releases?
I’ve been using the releases so that I’m not compiling into anything that the users don’t have access to atm. Thanks!
Hmm what you described should work still though right? Wouldn’t multiple layers of SVGs (which then are converted to PNGs, with transparency) just end up stacking up together as intended?
They’ll end up stacking together, but not necessarily in the intended order.
Rack uses the order that siblings were added to the parent to determine z-index. But in MetaModule we re-order the elements so that jacks are grouped together, knobs are grouped together, etc. This makes navigation with an encoder nicer since everything’s in order.
Probably SvgWidgets will keep the same order?? But it’s not guaranteed because the the sorting algorithm considers all those elements to be equivalent and therefore does whatever is easiest to sort the things that (it thinks) matters and doesn’t do anything special to maintain the order of all the other elements.
Hmm okay. Ideally if we can somehow maintain order that would be great - I’ve seen some strange patterns in VCV Rack module coding where folks use SvgWidgets in lieu of setting a panel.
Excited for these - these changes will fix Sanguine Mutants and Mockba Modular ports.