Skip to content

Commit

Permalink
Merge pull request #783 from Spartan322/4.3-correct/colorpicker-raw-s…
Browse files Browse the repository at this point in the history
…liders

[4.3] Unify `ColorPicker` color mode slider colors
  • Loading branch information
Spartan322 authored Oct 25, 2024
2 parents 17ad602 + e3650df commit 8e47d76
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
39 changes: 18 additions & 21 deletions scene/gui/color_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion scene/gui/color_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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){};
Expand Down

0 comments on commit 8e47d76

Please sign in to comment.