From e3650df0e4c15a188ba34617eb62cf6e14fd3e74 Mon Sep 17 00:00:00 2001 From: Spartan322 Date: Wed, 23 Oct 2024 04:15:30 -0400 Subject: [PATCH] Unify `ColorPicker` color mode slider colors (cherry picked from commit blazium-engine/blazium@f7c6762df94867d93465612ec6be86b28593dc47) Co-authored-by: Mounir Tohami <53877170+WhalesState@users.noreply.github.com> --- scene/gui/color_mode.cpp | 39 ++++++++++++++++++--------------------- scene/gui/color_mode.h | 1 - 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/scene/gui/color_mode.cpp b/scene/gui/color_mode.cpp index 54dbcdf6ee6..eb3abfef07b 100644 --- a/scene/gui/color_mode.cpp +++ b/scene/gui/color_mode.cpp @@ -254,30 +254,27 @@ void ColorModeRAW::slider_draw(int p_which) { left_color.a = 0; right_color = color; right_color.a = 1; - - col.set(0, left_color); - col.set(1, right_color); - col.set(2, right_color); - col.set(3, left_color); - pos.set(0, Vector2(0, 0)); - pos.set(1, Vector2(size.x, 0)); - pos.set(2, Vector2(size.x, margin)); - pos.set(3, Vector2(0, margin)); - - slider->draw_polygon(pos, col); + } else { + left_color = Color( + p_which == 0 ? 0 : color.r, + p_which == 1 ? 0 : color.g, + p_which == 2 ? 0 : color.b); + right_color = Color( + p_which == 0 ? 1 : color.r, + p_which == 1 ? 1 : color.g, + p_which == 2 ? 1 : color.b); } -} -bool ColorModeRAW::apply_theme() const { - for (int i = 0; i < 4; i++) { - HSlider *slider = color_picker->get_slider(i); - slider->remove_theme_icon_override("grabber"); - slider->remove_theme_icon_override("grabber_highlight"); - slider->remove_theme_style_override("slider"); - slider->remove_theme_constant_override("grabber_offset"); - } + col.set(0, left_color); + col.set(1, right_color); + col.set(2, right_color); + col.set(3, left_color); + pos.set(0, Vector2(0, 0)); + pos.set(1, Vector2(size.x, 0)); + pos.set(2, Vector2(size.x, margin)); + pos.set(3, Vector2(0, margin)); - return true; + slider->draw_polygon(pos, col); } void ColorModeOKHSL::_value_changed() { diff --git a/scene/gui/color_mode.h b/scene/gui/color_mode.h index dd2db5bf272..1dd8fed5bb5 100644 --- a/scene/gui/color_mode.h +++ b/scene/gui/color_mode.h @@ -121,7 +121,6 @@ class ColorModeRAW : public ColorMode { virtual Color get_color() const override; virtual void slider_draw(int p_which) override; - virtual bool apply_theme() const override; ColorModeRAW(ColorPicker *p_color_picker) : ColorMode(p_color_picker){};