diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-12-19 18:01:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-12-20 10:30:06 +0100 |
commit | 75ea339ee96f2dcc8bb24fff67e3d71ad16d42b6 (patch) | |
tree | 69ff76179fb920ca6235fe65ab269a064459da8e /Userland/Libraries | |
parent | 89061883f28e36d397ac915c144c765834f6e20b (diff) | |
download | serenity-75ea339ee96f2dcc8bb24fff67e3d71ad16d42b6.zip |
LibGUI: Fix bug in the ColorPicker's spinbox not changing colors
Before this patch, when having the initial spinbox color value
(Color::White), if you changed the color value in the vertical color
picker it didn't update the spinbox's colors.
This is fixed by manually calling update() in the color picker's
onchange() handler if the new color is equal to the previous color,
which is the case in the initial spinbox's case as it will always be
white unless it is changed (and won't be affected by the vertical
color picker).
I added a NOTE in the source to explain this "opaque" update() call :))
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/ColorPicker.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 231c4149da..efb36f5415 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -283,8 +283,13 @@ void ColorPicker::build_ui_custom(Widget& root_container) m_custom_color = horizontal_container.add<CustomColorWidget>(m_color); m_custom_color->set_preferred_size(299, 260); m_custom_color->on_pick = [this](Color color) { - if (m_color == color) + if (m_color == color) { + // NOTE: This call to update() is needed so that when changing the vertical color slider with the initial Color::White + // selected value (which doesn't change with that slider as in all the slider's values the new color at that position + // will still be Color::White) the spinbox colors are updated. + update(); return; + } m_color = color; update_color_widgets(); |