Visualize MarginContainer margins when selected#111095
Visualize MarginContainer margins when selected#111095Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
|
This should be done via a dedicated EditorPlugin for MarginContainer instead of hard-coding it in CanvasItemEditor. |
|
Ah alrighty, thanks! I'll look into moving the code there 😄 |
1406401 to
ac80478
Compare
|
I can certainly implement that later today! Something of a side note: I noticed while working on this that the orange color is not theme-based or customizable, but instead hard-coded in. It's out of scope for this PR but I could see people wanting to be able to customize it for different themes. As such, it might be good to have those colors be made theme-dependent. At the very least, moving them from an inline definition to a constant definition somewhere that various code files could reference would be nice – I'm currently just copying the color definition from its original location, which means the two of them could fall out of sync easily... |
|
Modifying margins does not update viewport immediately. You could connect MarginContainer's |
| return; | ||
| } | ||
|
|
||
| bool item_locked = margin_container->has_meta("_edit_lock_"); |
There was a problem hiding this comment.
I wonder if it's worth it to mimic 2D editor colors that much. Maybe you could use a different color altogether, like the one used by Camera2D limits. Then you could ignore locking etc.
Although that might cause margins to appear above the box selection, so not sure 🤔
There was a problem hiding this comment.
I can certainly give that a try! Admittedly I have found in the past that other editors' lines have been hard to see on my screen, while the bright orange from the bounding box editor is much easier to see. But there's no harm in giving it a go, and perhaps those problems can be addressed in a separate proposal.
1916bcd to
8098d31
Compare
|
Thanks for the code review! I've implemented the changes. It looks pretty good to me, with the minor exception that there is a moment of lag between selecting a MarginContainer and its margins actually being drawn. I haven't had the chance to test if this is also behavior that happens with other editor plugins, though: Godot.MarginContainer.Visualizer.mp4 |
I saw the same thing with the 2D polygon editor plugin about 3 hours ago. |
If you are using dev build, that's because of inspector loading new node. |
This time as an EditorPlugin! Improve rendering of inner area of MarginContainer Decrease thickness and opacity of lines, and render margins as a rectangle rather than lines extending to the edges of the bounding box Apply suggestions from code review Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com> Use `get_margin_size`, change color of viz border, and trigger redraw on MarginContainer's draw signal
8098d31 to
36c7bbb
Compare
|
Thanks! |
|
I like this change, it reminds me of the functionality found in browser developer tools. However, I'd like to point out that this feature could potentially be extended to other controls ( |




Closes godotengine/godot-proposals#8961 .
This PR adds lines depicting the margins for a MarginContainer, when it is selected: