From 18c5ef547332c0fd9757ef728b099c5b25ee6bec Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Thu, 2 Apr 2020 13:15:40 +0200 Subject: [PATCH] Add style for highlighted Slider grab area (cherry picked from commit 4c8173af0f58ad36515f6fd1cd6922525ac4d052) --- editor/editor_themes.cpp | 2 ++ scene/gui/slider.cpp | 5 +++-- scene/resources/default_theme/default_theme.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 4fd44ebb4cc..dd95381c978 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -958,12 +958,14 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_icon("grabber", "HSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_stylebox("slider", "HSlider", make_flat_stylebox(dark_color_3, 0, default_margin_size / 2, 0, default_margin_size / 2)); theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); + theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(contrast_color_1, 0, default_margin_size / 2, 0, default_margin_size / 2)); // VSlider theme->set_icon("grabber", "VSlider", theme->get_icon("GuiSliderGrabber", "EditorIcons")); theme->set_icon("grabber_highlight", "VSlider", theme->get_icon("GuiSliderGrabberHl", "EditorIcons")); theme->set_stylebox("slider", "VSlider", make_flat_stylebox(dark_color_3, default_margin_size / 2, 0, default_margin_size / 2, 0)); theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); + theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(contrast_color_1, default_margin_size / 2, 0, default_margin_size / 2, 0)); //RichTextLabel theme->set_color("default_color", "RichTextLabel", font_color); diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index 9b3ed35e6eb..1999341a37f 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -166,8 +166,9 @@ void Slider::_notification(int p_what) { RID ci = get_canvas_item(); Size2i size = get_size(); Ref style = get_stylebox("slider"); - Ref grabber_area = get_stylebox("grabber_area"); - Ref grabber = get_icon(editable ? ((mouse_inside || has_focus()) ? "grabber_highlight" : "grabber") : "grabber_disabled"); + bool highlighted = mouse_inside || has_focus(); + Ref grabber_area = get_stylebox(highlighted ? "grabber_area_highlight" : "grabber_area"); + Ref grabber = get_icon(editable ? (highlighted ? "grabber_highlight" : "grabber") : "grabber_disabled"); Ref tick = get_icon("tick"); double ratio = Math::is_nan(get_as_ratio()) ? 0 : get_as_ratio(); diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 00c56e5eb22..18bf7bc2f2a 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -496,6 +496,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_stylebox("slider", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4)); theme->set_stylebox("grabber_area", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4)); + theme->set_stylebox("grabber_area_highlight", "HSlider", make_stylebox(hslider_bg_png, 4, 4, 4, 4)); theme->set_icon("grabber", "HSlider", make_icon(hslider_grabber_png)); theme->set_icon("grabber_highlight", "HSlider", make_icon(hslider_grabber_hl_png)); @@ -506,6 +507,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_stylebox("slider", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4)); theme->set_stylebox("grabber_area", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4)); + theme->set_stylebox("grabber_area_highlight", "VSlider", make_stylebox(vslider_bg_png, 4, 4, 4, 4)); theme->set_icon("grabber", "VSlider", make_icon(vslider_grabber_png)); theme->set_icon("grabber_highlight", "VSlider", make_icon(vslider_grabber_hl_png));