Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use S, V in hue bar of ColorPicker #78100

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions scene/gui/color_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,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 @@ -179,6 +179,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 @@ -287,12 +292,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 @@ -319,7 +318,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 @@ -330,6 +329,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 @@ -346,4 +349,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;
}
}