diff options
author | Peter Elliott <pelliott@ualberta.ca> | 2020-09-16 18:34:18 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-09-17 09:47:05 +0200 |
commit | 17200306255b3a1d7ce71bc7cdabdb18807ce8d0 (patch) | |
tree | ba23e0e222d698fa05be61ef8698cb4459c98c76 /Libraries/LibGUI | |
parent | 9670d9ad50fd0fb33b5fbef4af11bb102ad0478c (diff) | |
download | serenity-17200306255b3a1d7ce71bc7cdabdb18807ce8d0.zip |
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.
Diffstat (limited to 'Libraries/LibGUI')
-rw-r--r-- | Libraries/LibGUI/ColorPicker.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Libraries/LibGUI/ColorPicker.cpp b/Libraries/LibGUI/ColorPicker.cpp index 390d212a01..f358d22455 100644 --- a/Libraries/LibGUI/ColorPicker.cpp +++ b/Libraries/LibGUI/ColorPicker.cpp @@ -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) |