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

Improve ColorPicker picker shape keyboard and joypad accessibility #99374

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

FeniXb3
Copy link

@FeniXb3 FeniXb3 commented Nov 17, 2024

While experimenting with accessibility, I realized that ColorPicker does not allow you to move the picker cursor around the color rectangle/wheel with keyboard or joypad (and I needed it, as it's the only part of ColorPicker that I want to show).

This PR implements:

  • ability of both parts of picker shape to grab focus,
  • setting picker focus StyleBox in theme,
  • modifying picker cursor position with keyboard or joypad,
  • keeping focus on proper control while changing picker shape,
  • automatic focusing on the picker shape if it is visible and the HTML LineEdit is not visible (as it's what is currently being focused by default).

How it works in game and in the editor:

ColorPicker.keyaboard.and.joypad.game.mp4
ColorPicker.keyboard.editor.mp4

I don't really like how it works with the controller, as I'm using gui_input to check for actions and the controller does not send echo events, but it's possible to use the controller at least.

@AThousandShips AThousandShips changed the title Colorpicker picker shape keyboard and joypad accessibility Improve ColorPicker picker shape keyboard and joypad accessibility Nov 18, 2024
Copy link
Member

@fire fire left a comment

Choose a reason for hiding this comment

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

I support this usability improvement in the proposal design, but it needs technical review.

scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
@Calinou
Copy link
Member

Calinou commented Nov 20, 2024

I don't really like how it works with the controller, as I'm using gui_input to check for actions and the controller does not send echo events, but it's possible to use the controller at least.

We should make the controller send fake echo events in this case, so that various GUI nodes can handle these directly. However, this should also be done in a way that doesn't affect existing game logic, which is going to be difficult to handle. Perhaps this should only be done for the built-in actions (those starting with ui_)?

Edit: Proposal opened:

scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
scene/gui/color_picker.cpp Outdated Show resolved Hide resolved
doc/classes/ColorPicker.xml Outdated Show resolved Hide resolved
Co-authored-by: A Thousand Ships <[email protected]>
@Repiteo Repiteo modified the milestones: 4.x, 4.4 Nov 22, 2024
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it works as expected.

Some usability comments:

  • The hue slider should go faster when you adjust it with the keyboard arrows or gamepad buttons. Compare its speed to the color value on the left:
color_value_vs_hue_slider.mp4

Ideally, the speed at which the hue is adjusted should match the color value on the left, which is probably 3× to 4× faster. This can be done by increasing the increment for each button press on the hue slider.

  • When using a color picker with a wheel shape, moving upwards should "slide" along the circle when you've reached the top (same for any other edge):
color_value_wheel_slide.mp4

Right now, it stops so you need to manually move to the left then move back up again.

Comment on lines +2167 to +2173
// HACK: I cannot draw focus stylebox on the wheel itself, as it's drawing based on shader.
wheel_h_focus_display = memnew(Control);
wheel_margin->add_child(wheel_h_focus_display);
wheel_h_focus_display->set_mouse_filter(MOUSE_FILTER_PASS);
wheel_h_focus_display->set_focus_mode(FOCUS_ALL);
wheel_h_focus_display->connect(SceneStringName(draw), callable_mp(this, &ColorPicker::_hsv_draw).bind(3, wheel_h_focus_display));
wheel_h_focus_display->connect(SceneStringName(gui_input), callable_mp(this, &ColorPicker::_uv_input).bind(wheel_h_focus_display));
Copy link
Member

@Calinou Calinou Nov 25, 2024

Choose a reason for hiding this comment

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

We should be able to draw a special circle focus stylebox (using a dedicated StyleBoxFlat in the editor theme/default project theme), so it matches the wheel's shape. This can be left for a future PR as it's not essential.

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