-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Rename Control margin to offset #44605
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not check everything line by line, but it seems good overall.
Thanks! |
What about the names of the methods with "margin" in them? For example, I think |
See #44751. Are there any others? |
Any of the methods affected in the diffs of this PR are candidates, but I'm not sure which should be changed. I think each would need to be investigated individually. Here's a not-necessarily-comprehensive list: Camera2D:
NinePatchRect:
StyleBox:
StyleBoxFlat:
StyleBoxTexture:
TextureProgressBar:
|
At the moment, all control positions are broken when opening a previous project on master and it's cumbersome to fix by hand. What would the best way to convert the scenes automatically when they are opened? Would extra compatibility code in |
@aaronfranke My assessment:
In conclusion, I don't think any of the others need changing. |
hmm, I though we add a way to register this kind of rename. But we have it only for classes, not properties if i am not mistaking. It's likely worth implementing though. |
I've opened #44820 for the issue with backward compatibility. It needs to be addressed for 4.0 release since there is currently no warning when it breaks. |
I was using Godot 2.1 for testing and I noticed that in Godot 2.1 margins are actually margins, that is, a larger value for the right and bottom margins means moving left and up instead of right and down, and margins of all 10 lead to a 10px border. I wonder why this was changed in the first place? And why whoever changed the behavior for Godot 3.0 didn't rename the properties? (This PR is good, this is just a fun fact I noticed). |
I did made the change. Inverting the right and bottom margin made sense for consistency reasons. I understand keeping them that way would have made sense if all controls were setup in the "wide" preset, where the margins were effectively acting as margins. But for all other situations (anchored at top left for example), this setup was more confusing. Now, whatever its layout, a control's vertical side with a negative/positive margin (offset) is at the left/right of its anchor, and similarly for horizontal sides. Not sure for why we did not rename them right away, probably for compatibility reasons, or because we did not ask ourselves the question I suppose. |
As originally identified here,
Control
'smargin
is actually anoffset
(relative to theanchor
). In addition,margin
uses theenum
Margin
to specify the side. However, theMargin
enum
is not just used byControl
'smargin
, it is also used by other properties to specify the side. Since these properties are not limited to other margins, for exampleControl
'sanchor
also uses it, theenum
Margin
should be renamedSide
and its elementsSIDE_*
.Therefore, this PR:
Control
'smargin
tooffset
enum
Margin
toSide
and its elements fromMARGIN_*
toSIDE_*
GraphNode
'soffset
toposition_offset
Note:
GraphNode
'soffset
property needed to be renamed to avoid hiding its parent's newoffset
property. It was renamedposition_offset
to reflect its use and to align withGraphEdit
'sscroll_offset
to which it is relative to.Part of #16863.