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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions core/input/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
{ "ui_filedialog_show_hidden", TTRC("Show Hidden") },
{ "ui_swap_input_direction ", TTRC("Swap Input Direction") },
{ "ui_unicode_start", TTRC("Start Unicode Character Input") },
{ "ui_colorpicker_delete_preset", TTRC("Delete ColorPicker Preset") },
{ "", ""}
/* clang-format on */
};
Expand All @@ -425,6 +426,7 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
}

List<Ref<InputEvent>> inputs;
inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::A));
inputs.push_back(InputEventKey::create_reference(Key::ENTER));
inputs.push_back(InputEventKey::create_reference(Key::KP_ENTER));
inputs.push_back(InputEventKey::create_reference(Key::SPACE));
Expand All @@ -436,14 +438,17 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
default_builtin_cache.insert("ui_select", inputs);

inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::B));
inputs.push_back(InputEventKey::create_reference(Key::ESCAPE));
default_builtin_cache.insert("ui_cancel", inputs);

inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::RIGHT_SHOULDER));
inputs.push_back(InputEventKey::create_reference(Key::TAB));
default_builtin_cache.insert("ui_focus_next", inputs);

inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::LEFT_SHOULDER));
inputs.push_back(InputEventKey::create_reference(Key::TAB | KeyModifierMask::SHIFT));
default_builtin_cache.insert("ui_focus_prev", inputs);

Expand Down Expand Up @@ -789,6 +794,12 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
inputs.push_back(InputEventKey::create_reference(Key::QUOTELEFT | KeyModifierMask::CMD_OR_CTRL));
default_builtin_cache.insert("ui_swap_input_direction", inputs);

// ///// UI ColorPicker Shortcuts /////
inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventJoypadButton::create_reference(JoyButton::X));
inputs.push_back(InputEventKey::create_reference(Key::KEY_DELETE));
default_builtin_cache.insert("ui_colorpicker_delete_preset", inputs);

return default_builtin_cache;
}

Expand Down
12 changes: 12 additions & 0 deletions doc/classes/ColorPicker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
</constant>
</constants>
<theme_items>
<theme_item name="focused_not_editing_cursor_color" data_type="color" type="Color" default="Color(1, 1, 1, 0.275)">
Color of rectangle or circle drawn when a picker shape part is focused but not editable via keyboard or joypad. Displayed [i]over[/i] the picker shape, so a partially transparent color should be used to ensure the picker shape remains visible.
</theme_item>
<theme_item name="center_slider_grabbers" data_type="constant" type="int" default="1">
Overrides the [theme_item Slider.center_grabber] theme property of the sliders.
</theme_item>
Expand Down Expand Up @@ -204,5 +207,14 @@
<theme_item name="shape_rect_wheel" data_type="icon" type="Texture2D">
The icon for rectangular wheel picker shapes.
</theme_item>
<theme_item name="picker_focus_circle" data_type="style" type="StyleBox">
The [StyleBox] used when the circle-shaped part of the picker is focused. Displayed [i]over[/i] the picker shape, so a partially transparent [StyleBox] should be used to ensure the picker shape remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
</theme_item>
<theme_item name="picker_focus_rectangle" data_type="style" type="StyleBox">
The [StyleBox] used when the rectangle-shaped part of the picker is focused. Displayed [i]over[/i] the picker shape, so a partially transparent [StyleBox] should be used to ensure the picker shape remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
</theme_item>
<theme_item name="sample_focus" data_type="style" type="StyleBox">
The [StyleBox] used for the old color sample part when it is focused. Displayed [i]over[/i] the sample, so a partially transparent [StyleBox] should be used to ensure the picker shape remains visible. A [StyleBox] that represents an outline or an underline works well for this purpose. To disable the focus visual effect, assign a [StyleBoxEmpty] resource. Note that disabling the focus visual effect will harm keyboard/controller navigation usability, so this is not recommended for accessibility reasons.
</theme_item>
</theme_items>
</class>
4 changes: 4 additions & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,10 @@
Default [InputEventAction] to discard a modal or pending input.
[b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified.
</member>
<member name="input/ui_colorpicker_delete_preset" type="Dictionary" setter="" getter="">
Default [InputEventAction] to delete a color preset in a [ColorPicker].
[b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified.
</member>
<member name="input/ui_copy" type="Dictionary" setter="" getter="">
Default [InputEventAction] to copy a selection to the clipboard.
[b]Note:[/b] Default [code]ui_*[/code] actions cannot be removed as they are necessary for the internal logic of several [Control]s. The events assigned to the action can however be modified.
Expand Down
8 changes: 8 additions & 0 deletions editor/themes/editor_theme_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,9 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
// ColorPicker and related nodes.
{
// ColorPicker.
p_config.circle_style_focus = p_config.button_style_focus->duplicate();
p_config.circle_style_focus->set_corner_radius_all(256 * EDSCALE);
p_config.circle_style_focus->set_corner_detail(32 * EDSCALE);

p_theme->set_constant("margin", "ColorPicker", p_config.base_margin);
p_theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
Expand All @@ -1757,6 +1760,11 @@ void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_the
p_theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
p_theme->set_constant("center_slider_grabbers", "ColorPicker", 1);

p_theme->set_stylebox("sample_focus", "ColorPicker", p_config.button_style_focus);
p_theme->set_stylebox("picker_focus_rectangle", "ColorPicker", p_config.button_style_focus);
p_theme->set_stylebox("picker_focus_circle", "ColorPicker", p_config.circle_style_focus);
p_theme->set_color("focused_not_editing_cursor_color", "ColorPicker", p_config.highlight_color);

p_theme->set_icon("screen_picker", "ColorPicker", p_theme->get_icon(SNAME("ColorPick"), EditorStringName(EditorIcons)));
p_theme->set_icon("shape_circle", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeCircle"), EditorStringName(EditorIcons)));
p_theme->set_icon("shape_rect", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangle"), EditorStringName(EditorIcons)));
Expand Down
2 changes: 2 additions & 0 deletions editor/themes/editor_theme_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class EditorThemeManager {
Ref<StyleBoxFlat> button_style_pressed;
Ref<StyleBoxFlat> button_style_hover;

Ref<StyleBoxFlat> circle_style_focus;

Ref<StyleBoxFlat> popup_style;
Ref<StyleBoxFlat> popup_border_style;
Ref<StyleBoxFlat> window_style;
Expand Down
Loading