diff --git a/doc/classes/HScrollBar.xml b/doc/classes/HScrollBar.xml index 79d524899ab..abdde0c9307 100644 --- a/doc/classes/HScrollBar.xml +++ b/doc/classes/HScrollBar.xml @@ -19,6 +19,9 @@ Displayed when the mouse cursor hovers over the decrement button. + + Displayed when the decrement button is being pressed. + Used as texture for the grabber, the draggable element representing current scroll. @@ -34,6 +37,9 @@ Displayed when the mouse cursor hovers over the increment button. + + Displayed when the increment button is being pressed. + Used as background of this [ScrollBar]. diff --git a/doc/classes/VScrollBar.xml b/doc/classes/VScrollBar.xml index c837da6ac03..809793cbb1b 100644 --- a/doc/classes/VScrollBar.xml +++ b/doc/classes/VScrollBar.xml @@ -23,6 +23,9 @@ Displayed when the mouse cursor hovers over the decrement button. + + Displayed when the decrement button is being pressed. + Used as texture for the grabber, the draggable element representing current scroll. @@ -38,6 +41,9 @@ Displayed when the mouse cursor hovers over the increment button. + + Displayed when the increment button is being pressed. + Used as background of this [ScrollBar]. diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index fa26bec5ed2..220842103b6 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1037,8 +1037,10 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_icon("increment", "HScrollBar", empty_icon); theme->set_icon("increment_highlight", "HScrollBar", empty_icon); + theme->set_icon("increment_pressed", "HScrollBar", empty_icon); theme->set_icon("decrement", "HScrollBar", empty_icon); theme->set_icon("decrement_highlight", "HScrollBar", empty_icon); + theme->set_icon("decrement_pressed", "HScrollBar", empty_icon); // VScrollBar theme->set_stylebox("scroll", "VScrollBar", make_stylebox(theme->get_icon("GuiScrollBg", "EditorIcons"), 5, 5, 5, 5, 0, 0, 0, 0)); @@ -1049,8 +1051,10 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_icon("increment", "VScrollBar", empty_icon); theme->set_icon("increment_highlight", "VScrollBar", empty_icon); + theme->set_icon("increment_pressed", "VScrollBar", empty_icon); theme->set_icon("decrement", "VScrollBar", empty_icon); theme->set_icon("decrement_highlight", "VScrollBar", empty_icon); + theme->set_icon("decrement_pressed", "VScrollBar", empty_icon); // HSlider theme->set_icon("grabber_highlight", "HSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 1e91b3db55d..652bcecc349 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -79,12 +79,16 @@ void ScrollBar::_gui_input(Ref p_event) { double total = orientation == VERTICAL ? get_size().height : get_size().width; if (ofs < decr_size) { + decr_active = true; set_value(get_value() - (custom_step >= 0 ? custom_step : get_step())); + update(); return; } if (ofs > total - incr_size) { + incr_active = true; set_value(get_value() + (custom_step >= 0 ? custom_step : get_step())); + update(); return; } @@ -129,6 +133,8 @@ void ScrollBar::_gui_input(Ref p_event) { } } else { + incr_active = false; + decr_active = false; drag.active = false; update(); } @@ -214,8 +220,24 @@ void ScrollBar::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { RID ci = get_canvas_item(); - Ref decr = highlight == HIGHLIGHT_DECR ? get_icon("decrement_highlight") : get_icon("decrement"); - Ref incr = highlight == HIGHLIGHT_INCR ? get_icon("increment_highlight") : get_icon("increment"); + Ref decr, incr; + + if (decr_active) { + decr = get_icon("decrement_pressed"); + } else if (highlight == HIGHLIGHT_DECR) { + decr = get_icon("decrement_highlight"); + } else { + decr = get_icon("decrement"); + } + + if (incr_active) { + incr = get_icon("increment_pressed"); + } else if (highlight == HIGHLIGHT_INCR) { + incr = get_icon("increment_highlight"); + } else { + incr = get_icon("increment"); + } + Ref bg = has_focus() ? get_stylebox("scroll_focus") : get_stylebox("scroll"); Ref grabber; diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index f54f545bab5..22cee0d40f1 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -51,6 +51,9 @@ class ScrollBar : public Range { HighlightStatus highlight; + bool incr_active = false; + bool decr_active = false; + struct Drag { bool active; float pos_at_click; diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index e84982e1a26..e08421e8306 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -502,8 +502,10 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_icon("increment", "HScrollBar", empty_icon); theme->set_icon("increment_highlight", "HScrollBar", empty_icon); + theme->set_icon("increment_pressed", "HScrollBar", empty_icon); theme->set_icon("decrement", "HScrollBar", empty_icon); theme->set_icon("decrement_highlight", "HScrollBar", empty_icon); + theme->set_icon("decrement_pressed", "HScrollBar", empty_icon); // VScrollBar @@ -515,8 +517,10 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_icon("increment", "VScrollBar", empty_icon); theme->set_icon("increment_highlight", "VScrollBar", empty_icon); + theme->set_icon("increment_pressed", "VScrollBar", empty_icon); theme->set_icon("decrement", "VScrollBar", empty_icon); theme->set_icon("decrement_highlight", "VScrollBar", empty_icon); + theme->set_icon("decrement_pressed", "VScrollBar", empty_icon); // HSlider