-
-
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
Implement center window function #81012
Conversation
This CI fail might be because I manually moved the doc in the XML after running |
Indeed you should keep it where it's generated, it's alphabetically ordered. |
I share the concerns from #65843 (comment) in the original PR. I think "center" for the method name is confusing since it can be interpreted as a noun. Can we consider calling it |
In my opinion it's clear enough, since it's a name of a method. Consistent with |
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.
Implementation looks good to me.
The method has problems in the embedded case, when used within a window that has content_scale_stretch = Window.CONTENT_SCALE_STRETCH_INTEGER
.
MRP: empty_project.zip
WindowCenter.mp4
I'm not sure, if this is a limitation of CONTENT_SCALE_STRETCH_INTEGER
which was introduced in #75784 or if this can/should be worked around.
This problem with integer scaling happens only when the screen is reduced in size. The code in that PR doesn't allow the scale factor to be less than 1, which makes sense. I'm not sure this case needs handling, since doing this would be almost always undesired anyway. If anything, it would be sensible to set the minimum size of the screen to the original viewport size in integer scaling mode. |
I had the same thought. So the mentioned problematic case can be ignored here. Also please squash your commits together as explained in the docs: |
Done, also renamed to |
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.
Implementation looks good. Tested also functionality.
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.
Looks good.
Thanks! And congrats for your first merged Godot contribution 🎉 |
Why I can't found |
Following the discussion in #65843, implements a
center()
function inWindow
.Closes godotengine/godot-proposals#5232.
Took inspiration (copied and modified) from the implementation of
Window.popup_centered()
.Edit: Confused myself from following the popup logic... every non-embedded window will now center itself on it's own screen, while embedded windows will center themselves on the parent window.
Quick and dirty test project (test with embed_subwindows on and off):
empty_project.zip