1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:15:07 +00:00

LibGUI: Don't recalcuate color from hue if it was not set by hue

Basically, setting the hue is numerically sensitive when the value or
saturation are low.
This commit is contained in:
Peter Elliott 2020-09-16 18:34:18 -07:00 committed by Andreas Kling
parent 9670d9ad50
commit 1720030625

View file

@ -68,6 +68,7 @@ public:
Function<void(Color)> on_pick;
void set_color(Color);
void set_hue(double);
void set_hue_from_pick(double);
private:
ColorField(Color color);
@ -469,7 +470,7 @@ CustomColorWidget::CustomColorWidget(Color color)
auto slider_width = 24 + (m_color_slider->frame_thickness() * 2);
m_color_slider->set_preferred_size(slider_width, size);
m_color_slider->on_pick = [this](double value) {
m_color_field->set_hue(value);
m_color_field->set_hue_from_pick(value);
};
}
@ -538,9 +539,13 @@ void ColorField::set_hue(double hue)
auto color = Color::from_hsv(hsv);
color.set_alpha(m_color.alpha());
set_color(color);
}
void ColorField::set_hue_from_pick(double hue)
{
set_hue(hue);
if (on_pick)
on_pick(color);
on_pick(m_color);
}
void ColorField::pick_color_at_position(GUI::MouseEvent& event)