Add a focus border on ScrollContainer

Also added new unit tests for `Control`.

Co-authored-by: ator-dev <dominic.codedeveloper@gmail.com>
This commit is contained in:
Pablo Andres Fuente
2024-09-23 14:30:07 -03:00
committed by Pablo Andres Fuente
parent 0c45ace151
commit 86ea0127a3
9 changed files with 127 additions and 2 deletions

View File

@ -157,7 +157,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
const Ref<StyleBoxFlat> button_pressed = make_flat_stylebox(style_pressed_color);
const Ref<StyleBoxFlat> button_disabled = make_flat_stylebox(style_disabled_color);
Ref<StyleBoxFlat> focus = make_flat_stylebox(style_focus_color, default_margin, default_margin, default_margin, default_margin, default_corner_radius, false, 2);
// Make the focus outline appear to be flush with the buttons it's focusing.
// Make the focus outline appear to be flush with the buttons it's focusing, so not draw on top of the content.
focus->set_expand_margin_all(Math::round(2 * scale));
theme->set_stylebox(CoreStringName(normal), "Button", button_normal);
@ -659,6 +659,14 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
empty.instantiate();
theme->set_stylebox(SceneStringName(panel), "ScrollContainer", empty);
const Ref<StyleBoxFlat> focus_style = make_flat_stylebox(style_focus_color);
// Make the focus outline appear to be flush with the buttons it's focusing, so not draw on top of the content.
sb_expand(focus_style, 4, 4, 4, 4);
focus_style->set_border_width_all(Math::round(2 * scale));
focus_style->set_draw_center(false);
focus_style->set_border_color(style_focus_color);
theme->set_stylebox("focus", "ScrollContainer", focus_style);
// Window
theme->set_stylebox("embedded_border", "Window", sb_expand(make_flat_stylebox(style_popup_color, 10, 28, 10, 8), 8, 32, 8, 6));