-
-
Notifications
You must be signed in to change notification settings - Fork 23.4k
Add Horizontal and Vertical Content Alignment Options to ScrollContainer #111680
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
base: master
Are you sure you want to change the base?
Add Horizontal and Vertical Content Alignment Options to ScrollContainer #111680
Conversation
Add Vertical and Horizontal content Alignment options to ScrollContainer
Co-authored-by: A Thousand Ships <[email protected]>
Co-authored-by: A Thousand Ships <[email protected]>
Thanks for opening a pull request! Feature pull requests should be associated to a feature proposal to justify the need for implementing the feature in Godot core. Please open a proposal on the Godot proposals repository (and link to this pull request in the proposal's body). |
Thank you for the guidance! This is my first pull request, so I really appreciate your help. I will create a feature proposal on the Godot proposals repository and link this pull request in the proposal. |
How is this different from using size flags? godot.windows.editor.dev.x86_64_LfJ6lo4WnG.mp4 |
Thanks for asking! Size flags control how a child expands or fills space, but they don’t let you explicitly align content inside a With the proposed |
But it doesn't need any "extra" nodes. The ScrollContainer already requires one content node (BoxContainer, GridContainer etc.), and that node is the subject to size flags. You even have one in your video, I replicated that layout. You can set the alignment from GDScript using |
Yes, you are right, but i just added this feature for easier use. it's easy to find and use from the inspector panel. |
Add missing newline at the end of ScrollContainer.xml
public: | ||
virtual void gui_input(const Ref<InputEvent> &p_gui_input) override; | ||
|
||
void set_horizontal_content_align(int p_align); |
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.
Should still use the enum type, for both
H_ALIGN_LEFT = 0, | ||
H_ALIGN_CENTER = 1, | ||
H_ALIGN_RIGHT = 2, |
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.
H_ALIGN_LEFT = 0, | |
H_ALIGN_CENTER = 1, | |
H_ALIGN_RIGHT = 2, | |
CONTENT_H_ALIGN_LEFT, | |
CONTENT_H_ALIGN_CENTER, | |
CONTENT_H_ALIGN_RIGHT, |
And both should be registered with VARIANT_ENUM_CAST
below
V_ALIGN_TOP = 0, | ||
V_ALIGN_CENTER = 1, | ||
V_ALIGN_BOTTOM = 2, |
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.
V_ALIGN_TOP = 0, | |
V_ALIGN_CENTER = 1, | |
V_ALIGN_BOTTOM = 2, | |
CONTENT_V_ALIGN_TOP, | |
CONTENT_V_ALIGN_CENTER, | |
CONTENT_V_ALIGN_BOTTOM, |
|
||
ClassDB::bind_integer_constant("ScrollContainer", "ContentVAlign", "V_ALIGN_TOP", V_ALIGN_TOP, false); | ||
ClassDB::bind_integer_constant("ScrollContainer", "ContentVAlign", "V_ALIGN_CENTER", V_ALIGN_CENTER, false); | ||
ClassDB::bind_integer_constant("ScrollContainer", "ContentVAlign", "V_ALIGN_BOTTOM", V_ALIGN_BOTTOM, false); |
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.
Should still be registered using the correct type, with BIND_ENUM_CONSTANT
like below, and below the other ones
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 tried it but it's not working. And engine compilation fails. But this way it works properly. But I will try again.
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.
It should work if done correctly
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.
This file needs to be restored from all the unnecessary changes
Added two new properties to ScrollContainer:
horizontal_content_align
vertical_content_align
Allows ScrollContainer content to be aligned left/center/right and top/center/bottom from Inspector or using GDScript.
And also updated Documentation in doc/classes/ScrollContainer.xml.
Here is a demo video of
ScrollContainer
Content Alignment Feature:Scroll.Container.Content.Alignment.Feature.mp4