godot icon indicating copy to clipboard operation
godot copied to clipboard

Add DRAW_FOCUS_PRESSED to facilitate font_focus_pressed_color on Button

Open Frozenfire92 opened this issue 1 year ago • 1 comments

Background

While implementing controller support to the UI in my game, I noticed buttons have a special color font_hover_pressed_color but no equivalent for focus. This means that mouse will be able to get a special color while the controller will not for its primary "hover/selected" state. This seems to be particularly used for CheckBox and CheckButton. This PR attempts to add font_focus_pressed_color to allow consistent font color styling behavior between mouse and controller

Questions

  • Should this PR also add a stylebox for focus_pressed akin to the existing hover_pressed?
  • Should this PR also add an icon color for icon_hover_focus_color akin to the existing icon_hover_pressed_color?
  • Is there anything else I need to add for this PR to be considered for merge?
  • It did not seem that there are existing button tests, happy to add if needed and with guidance
  • I had to update LinkButton, TextureButton, and OptionButton to get CI test suite passing, should there be further updates here?

Screenshots

Problem in 4.2

2024_04_27_0 The first part of the gif is using the controller when the checkbox is pressed and has focus, it remains yellow. The second part of the gif is using the mouse when the checkbox is pressed and has hover, it is red

Fixed with this PR

2024_04_27_1 The first part of the gif is using the controller when the checkbox is pressed and has focus, it is orange, when pressed and not focused it is yellow. The second part of the gif is using the mouse when the checkbox is pressed and has hover it is red, when not hovered it is yellow

Theme

image

Demo project

ButtonFocusPressed.zip

Frozenfire92 avatar Apr 27 '24 03:04 Frozenfire92

This makes hover pressed color ignored. Set hover pressed and focus pressed to different colors and click a button - it will use focus color. Also when a focused button is activated using a shortcut, it uses pressed color instead of focus pressed.

I'm not sure how useful is this feature 🤔 When you press a button, it's almost always also focused, so you can just use font pressed color. The only exception is when you activate an unfocused button with a shortcut.

https://github.com/godotengine/godot/assets/2223172/e65a392b-3041-4b43-853f-0ff36f5f280e

Should this PR also add a stylebox for focus_pressed akin to the existing hover_pressed?

Focus stylebox is drawn over the base stylebox, so a new variation is not necessary.

Should this PR also add an icon color for icon_hover_focus_color akin to the existing icon_hover_pressed_color?

Unrelated to this PR, but icon hover pressed color does not seem to do anything. But assuming it gets fixed, focus pressed color for parity makes sense.

Is there anything else I need to add for this PR to be considered for merge?

Open/link a proposal. While this seems like obvious feature, I commented above how the use-case is not clear.

KoBeWi avatar May 01 '24 14:05 KoBeWi

Hi @KoBeWi, Thank you for the feedback, I appreciate it! I have opened a proposal and hopefully explain the use case a bit better 🙂 https://github.com/godotengine/godot-proposals/issues/9650

This makes hover pressed color ignored. Set hover pressed and focus pressed to different colors and click a button - it will use focus color.

I don't believe so, see attached screenshot/video

image

2024_05_01_2.webm

Also when a focused button is activated using a shortcut, it uses pressed color instead of focus pressed

I tested this and it seems to be using focus pressed color for me (same theme as above in this comment) shortcut is for the third CheckBox

2024_05_01_3.webm

I'm not sure how useful is this feature 🤔 When you press a button, it's almost always also focused, so you can just use font pressed color

I hope that my proposal (https://github.com/godotengine/godot-proposals/issues/9650) explains the use case a bit further, it's goal is to provide consistency of keyboard/controller navigation with mouse navigation. It's particularly useful when the focus stylebox is StyleBoxEmpty

Unrelated to this PR, but icon hover pressed color does not seem to do anything. But assuming it gets fixed, focus pressed color for parity makes sense.

It seems to work for me

image

2024_05_01_4.webm

Frozenfire92 avatar May 02 '24 02:05 Frozenfire92

I tested my reported issues again and for some reason the colors are only functional when the button is in toggle mode 🤔

KoBeWi avatar May 02 '24 10:05 KoBeWi