-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Follow the CSS-style "top, right, bottom, left" order in methods that specify coordinates in 4 directions #2141
Comments
That's not Godot-specific order. It's the same for example in Android's Rect.
Indeed such order is used but it's not CSS-specific. It's the same for example in Android's RoundRectShape (order of data in the
I guess we could argue that Godot is already following an established de facto standard order such as the Android's direction order. The thing is there are always many different approaches/standards and I'd say the question should be: which one of them makes the most sense to follow? In this proposal I don't see actual arguments why the proposed order (top-right-bottom-left) is better than the current one (left-top-right-bottom). For me what's being proposed is to follow an arbitrarily choosen approach (CSS-like) just for the sake of following it. Personally, I find the left-top-right-bottom order more intuitive because rectangles are usually defined by position (x, y) and size (width, height) in such order and kinda the same order is being reflected in the left-top-right-bottom order:
|
We actually don't follow any specific order in a lot of places, so for unification sake we can choose any single one of them. |
As mentioned in godotengine/godot#52624 I think I agree with @kleonc, after some consideration. Left-top-right-bottom matches the X/Y order and the Rect definition order. It just makes more sense in terms of screen space and matches a lot of existing logic. We probably still need to break compatibility in some places that don't use that order. |
In terms of X/Y order, the best for that would be left-right-top-bottom. This is the order I used for |
We discussed this in a proposals review meeting and agreed to stick to Left Top Right Bottom, which seems to be the convention used in OpenGL (according to reduz) and which seems intuitive with regard to x/y/width/height as described by @kleonc. |
Describe the project you are working on
The Godot editor 🙂
Describe the problem or limitation you are having in your project
In classes such as Rect2 and StyleBoxFlat, there are methods that specify coordinates in all directions. A Godot-specific order is used:
Godot already uses the CSS order for methods whose parameters refer to individual corners (such as
StyleBoxFlat::set_corner_radius_individual()
:Therefore, this proposal is only about sides/directions, not corners.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Use an established de facto standard order such as the CSS direction order. This order similar to the current one (it's clockwise), except it starts at the top instead of the left. The four directions in order are:
For methods that specify 3 coordinates in the form of "top/sides/bottom", the order is:
I'm not sure if any methods that accept 3 directions exist in Godot, but it's worth checking for anyway.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
For instance, turn Rect2's
grow_individual()
method signature:Into:
This change will break compatibility and should be considered for 4.0 only, given that it's difficult to find it out naturally – scripts won't break after this change. Still, I think it's worth pursuing to get a more consistent API that reuses web developers' muscle memory 🙂
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, as this is a core API change.
Is there a reason why this should be core and not an add-on in the asset library?
This is a core API change.
The text was updated successfully, but these errors were encountered: