Skip to content

Commit

Permalink
Merge pull request #78100 from KoBeWi/commit_necromancy
Browse files Browse the repository at this point in the history
Use S, V in hue bar of ColorPicker
  • Loading branch information
YuriSizov committed Jul 12, 2023
2 parents 9547de5 + e22319c commit 5058831
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions scene/gui/color_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ void ColorModeHSV::slider_draw(int p_which) {
right_color = color;
right_color.a = 1;
} else if (p_which == 0) {
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker"));
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false);
return;
float v = color.get_v();
left_color = Color(v, v, v);
right_color = left_color;
} else {
Color s_col;
Color v_col;
Expand All @@ -191,6 +191,11 @@ void ColorModeHSV::slider_draw(int p_which) {
pos.set(3, Vector2(0, margin));

slider->draw_polygon(pos, col);

if (p_which == 0) { // H
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_hue"), SNAME("ColorPicker"));
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false, Color::from_hsv(0, 0, color.get_v(), color.get_s()));
}
}

String ColorModeRAW::get_slider_label(int idx) const {
Expand Down Expand Up @@ -299,12 +304,6 @@ void ColorModeOKHSL::slider_draw(int p_which) {
Size2 size = slider->get_size();
const real_t margin = 16 * color_picker->get_theme_default_base_scale();

if (p_which == 0) { // H
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_okhsl_hue"), SNAME("ColorPicker"));
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false);
return;
}

Vector<Vector2> pos;
Vector<Color> col;
Color left_color;
Expand All @@ -331,7 +330,7 @@ void ColorModeOKHSL::slider_draw(int p_which) {
pos.set(3, Vector2(size.x, margin));
pos.set(4, Vector2(size.x * 0.5, margin));
pos.set(5, Vector2(0, margin));
} else { // A / S
} else {
pos.resize(4);
col.resize(4);

Expand All @@ -342,6 +341,10 @@ void ColorModeOKHSL::slider_draw(int p_which) {
left_color.a = 0;
right_color = color;
right_color.a = 1;
} else if (p_which == 0) {
float l = color.get_ok_hsl_l();
left_color = Color(l, l, l);
right_color = left_color;
} else {
left_color.set_ok_hsl(color.get_ok_hsl_h(), 0, color.get_ok_hsl_l());
right_color.set_ok_hsl(color.get_ok_hsl_h(), 1, color.get_ok_hsl_l());
Expand All @@ -358,4 +361,10 @@ void ColorModeOKHSL::slider_draw(int p_which) {
}

slider->draw_polygon(pos, col);

if (p_which == 0) { // H
Ref<Texture2D> hue = color_picker->get_theme_icon(SNAME("color_okhsl_hue"), SNAME("ColorPicker"));
slider->draw_texture_rect(hue, Rect2(Vector2(), Vector2(size.x, margin)), false, Color::from_hsv(0, 0, color.get_ok_hsl_l() * 2.0, color.get_ok_hsl_s()));
return;
}
}

0 comments on commit 5058831

Please sign in to comment.