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

Replace flat buttons with flat-styled buttons with a visible pressed state #81939

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

YuriSizov
Copy link
Contributor

@YuriSizov YuriSizov commented Sep 19, 2023

ToolButton is back, baby!.. Wait, no, that sounds wrong. But we do have a usability problem which ToolButton could've solved.

The problem

We use flat buttons throughout the editor UI, and in a couple of Control nodes (GraphEdit and FileDialog). The problem with flat buttons is that they by design don't render any styleboxes except for the focus outline. So no visible pressed state for them, except for slightly tinted icon and/or text. In the editor, by default, it's a light blue color, and in the default theme it's a slightly different shade of white (which makes the pressed state completely invisible in the GraphEdit toolbar).

image
Which of these buttons is toggled on and which are toggled off? This is not a trick question!

Within the editor users have expressed trouble noticing when some tools are enabled. This can depend a lot on the exact theme and theme colors used, but the default look definitely has this issue where lightly colored blue text or blue icon is getting lost on top of a bluish background.

https://youtu.be/nu6g942bAIU?t=846

The solution

One way to solve this problem is to make flat buttons render the pressed state as well, but that would break compatibility and expectation compared to what we have right now.

Thankfully, we have theme type variations. So I propose we use them here and introduce the FlatButton type variation (and also FlatMenuButton for MenuButton), which would have empty styles for everything except for the pressed state. This would make them look like exactly like flat buttons, but with a proper style for when these buttons are pressed.

godot.windows.editor.dev.x86_64_2023-09-19_16-17-39.mp4

With this PR these variations are present in the default theme and used in GraphEdit and FileDialog as well:

godot windows editor dev x86_64_2023-09-19_17-58-29

It's going to look even better with #81582.

The implementation

I went through all toolbars and toolbar-alikes in the editor that use flat buttons and updated them to use this approach. Here are a few examples:

Videos and pictures!
godot.windows.editor.dev.x86_64_2023-09-19_16-21-52.mp4
godot.windows.editor.dev.x86_64_2023-09-19_16-22-32.mp4
godot windows editor dev x86_64_2023-09-19_17-58-56 godot windows editor dev x86_64_2023-09-19_18-00-46 godot windows editor dev x86_64_2023-09-19_18-01-13

I went mostly by code, and replaced flat buttons based on my memory of the tool, but I didn't check everything. I skipped some places too. So if you think I was too conservative or the other way around with the changes, do let me know and I will remove/add whatever is needed. Adjustments can also be done in a follow-up, of course.


Of course, the exact styling may require some adjustments. For example, it doesn't look too dissimilar from a non-flat button right now. But I think it's an overall usability improvement.

godot windows editor dev x86_64_2023-09-19_18-01-35

@Zireael07
Copy link
Contributor

As a glasses user, THANK YOU <3

@MewPurPur
Copy link
Contributor

Does light theme look good?

@KoBeWi
Copy link
Member

KoBeWi commented Sep 19, 2023

Seems barely visible in light theme
image
Although the accent color is more visible.

editor/editor_themes.cpp Outdated Show resolved Hide resolved
@Calinou
Copy link
Member

Calinou commented Sep 19, 2023

Could a translucent accent color be used for pressed flat buttons? This would make them easier to distinguish from other UI elements such as dropdowns.

@YuriSizov YuriSizov force-pushed the gui-flat-and-depressed branch from 1145275 to 4bd569b Compare September 19, 2023 20:36
@YuriSizov
Copy link
Contributor Author

Could a translucent accent color be used for pressed flat buttons? This would make them easier to distinguish from other UI elements such as dropdowns.

Like this?

godot windows editor dev x86_64_2023-09-19_22-33-20 godot windows editor dev x86_64_2023-09-19_22-33-46
godot windows editor dev x86_64_2023-09-19_22-33-06 godot windows editor dev x86_64_2023-09-19_22-35-05

@@ -949,7 +949,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
toolbar_stylebox->set_border_color(accent_color);
toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
toolbar_stylebox->set_content_margin(SIDE_BOTTOM, 0);
toolbar_stylebox->set_expand_margin_all(2 * EDSCALE);
toolbar_stylebox->set_expand_margin_individual(4 * EDSCALE, 2 * EDSCALE, 4 * EDSCALE, 4 * EDSCALE);
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That stylebox is actually clipping buttons, but it's not noticeable if you don't have styles rendered on them. And the sides were too close with the pressed style on, so I extended them a bit.

Copy link
Member

@KoBeWi KoBeWi Sep 19, 2023

Choose a reason for hiding this comment

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

image
Without this change, the side margins match the top margin (bottom does look bad though).
idk, maybe your change is ok.

@Calinou
Copy link
Member

Calinou commented Sep 19, 2023

Like this?

Looks good! Maybe the blue accent could be a bit more prominent, as it's quite subtle right now and can be hard to see (especially under sunlight).

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

The new style and implementation looks good.
I didn't check whether we should apply it to more buttons.

@YuriSizov
Copy link
Contributor Author

Maybe the blue accent could be a bit more prominent, as it's quite subtle right now and can be hard to see (especially under sunlight).

I get why you would want this, but the trouble is the content is also colored with the accent color. The closer we get to it, the less recognizable the content is going to be. There may be another way to style it entirely, without coloring the icon and the text with the accent color, perhaps.

We could probably bikeshed and experiment more, but it's also something that we can tune afterwards, I think.

@MewPurPur
Copy link
Contributor

On the contrary, I think we're at a good place between it being obvious and it not sticking out too much.

@akien-mga akien-mga merged commit 8ddf73c into godotengine:master Sep 25, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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.

6 participants