Skip to content
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 vertical icon alignment for buttons #74369

Merged
merged 1 commit into from
May 8, 2023

Conversation

Dragoncraft89
Copy link
Contributor

Buttons already support aligning the icon to the left/right of the text. However this is a bit limiting, as it may also be desired to have the text above/below the icon.

This PR therefore adds the option to align the icon vertically by adding a vertical_icon_alignment property to the button class.

Here is an example image showing all combinations:
20230303_21h53m07s_grim

Here's the same image with expand_icon turned on:
20230303_21h53m23s_grim

Feel free to test the button behavior on my test project:
vertical_button_test.zip

@Dragoncraft89 Dragoncraft89 requested review from a team as code owners March 4, 2023 16:44
@Chaosus Chaosus added this to the 4.1 milestone Mar 6, 2023
scene/gui/button.cpp Outdated Show resolved Hide resolved
@KoBeWi
Copy link
Member

KoBeWi commented Apr 29, 2023

Needs rebase.

@Dragoncraft89
Copy link
Contributor Author

@KoBeWi Done

@@ -58,7 +58,7 @@
To edit margin and spacing of the icon, use [theme_item h_separation] theme property and [code]content_margin_*[/code] properties of the used [StyleBox]es.
</member>
<member name="icon_alignment" type="int" setter="set_icon_alignment" getter="get_icon_alignment" enum="HorizontalAlignment" default="0">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess a better name is horizontal_icon_alignment, but to keep backwards compatibility it is better to not touch it.
Still maybe an idea in the future.

Copy link
Contributor

@Maran23 Maran23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. And a nice addition which I needed several times already. :)

@akien-mga akien-mga merged commit eebb1d8 into godotengine:master May 8, 2023
@akien-mga
Copy link
Member

Thanks!

@Rindbee
Copy link
Contributor

Rindbee commented May 12, 2023

What is the expected behavior of those Button derived classes (OptionButton, CheckButton, etc.) with themed icons? The rest of the button except the theme icon is drawn like Button? I am trying to perfect #64351.

0

When expand_icon is enabled, it is still possible to reserve height for icons, is this expected behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants