Skip to content

Commit

Permalink
Modify color in ColorPicker with keyboard or joypad
Browse files Browse the repository at this point in the history
  • Loading branch information
FeniXb3 committed Jan 21, 2025
1 parent 1b7b009 commit 4fe7a5c
Show file tree
Hide file tree
Showing 6 changed files with 443 additions and 4 deletions.
9 changes: 9 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,11 @@
<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_items>
</class>
7 changes: 7 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,10 @@ 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("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

0 comments on commit 4fe7a5c

Please sign in to comment.