-
-
Notifications
You must be signed in to change notification settings - Fork 44
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
Fixing GodSVG's messy infrastructure. #30
Comments
This should be a Something like
maybe they should be listening directly to things that are emitted by the SVGTag instead of the whole SVG? |
Alrighty, having such a signal in the SVG singleton really seems like the best option. |
Issue #30 explains for the most part what I did.
Issue #30 explains for the most part what I did.
Just writing out what's on my mind right now, as I try to figure out a good infrastructure that would allow to make SVG elements and attributes configurable from multiple places.
This post might be edited a few times as I rethink things.
New approach
SVG singleton
The core idea is that the SVG singleton will hold data, which will be the defacto way to manipulate anything about the SVG. This data will be independently able to be manipulated by:
Data structures
As before, there will be:
This is a rough simplification. So, these RefCounteds should also emit specific signals when they are changed.
value_changed()
attribute. SVGTag would be subscribed to this and emitattribute_changed()
itself.attribute_changed()
signal for now. SVGData will be subscribed to this signal and emitattribute_changed()
itself.attribute_changed()
signal as explained. It will also haveresized()
,tag_deleted()
,tag_added()
,tag_moved()
, andtags_changed_unknown()
signals.TODO: What about individual path commands in a path definition?
TODO: How to signal information about which specific things updated?
Display
The "Display" TextureRect will be subscribed to all SVGData signals with its
queue_svg_update()
function, always updating the SVG when something changes.CodeEdit
Talking: When I make it editable, I plan to make it so after every edit, the text is checked for being a valid svg string. If it is, then gather from it all the values needed to make up a width, a height (I'll address viewBox later), and an array of SVGTags, and assign all that to the existing SVGData. This will emit the
tags_changed_unknown()
andresized()
signals.Listening: It will listen to all SVGData signals and use
tags_to_string()
to translate the data. But if it's currently being edited, it won't change its text. Unlike other ways to edit the SVG, we don't want to change the text to a standard generated one while the user is editing it.Draggable handles
They will be handled in a TextureRect overlaid on top of the SVG.
Talking: Each handle will hold a reference to its the relevant SVGAttributes in the svg data: one for its x-pos, and one for its y-pos. While a handle is being dragged, it will use its X and Y position to update these two attributes.
Listening: All SVGData signals except for
tag_moved()
will be listened to. They will trigger a full rebuild of the handles, except forattribute_changed()
which will search for the appropriate handle and update its x or y position.TODO: What about individual path commands in a path definition?
Inspector
Talking: Each tag editor will hold a reference to its relevant SVGTag in the SVGData, and likewise each of the fields will hold a reference to its relevant SVGAttribute. The signals that will be emitted on each possible action are pretty self-explanatory.
Listening: All SVGData signals except for
resized()
will be listened to.tags_changed_unknown()
will trigger a full rebuild, while the others will only change the relevant parts.TODO: How to find which tag editor or attribute editor corresponds to a certain tag? Iterating and checking?
TODO: How to handle selections? Eventually, I want to have it so selecting a tag or a handle or such is reflected in all three places (e.g. clicking on a tag highlights its handles, and also highlights it subtly in the CodeEdit)
The text was updated successfully, but these errors were encountered: