From 0388bb019f71d8e835f0e27b4046dac44527283e Mon Sep 17 00:00:00 2001 From: Valtteri Koskivuori Date: Fri, 21 Jul 2023 00:58:32 +0300 Subject: [PATCH] PixelPaint: Update palette colors in real-time while picking Palette color selections in `PaletteWidget` now update while interacting with `GUI::ColorPicker` --- Userland/Applications/PixelPaint/PaletteWidget.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index c2aa10ee65..ddbbab69b3 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -33,13 +33,14 @@ public: { if (event.modifiers() & KeyModifier::Mod_Ctrl) { auto dialog = GUI::ColorPicker::construct(m_color, window()); - if (dialog->exec() == GUI::Dialog::ExecResult::OK) { - m_color = dialog->color(); + dialog->on_color_changed = [this](Gfx::Color color) { + m_color = color; auto pal = palette(); pal.set_color(ColorRole::Background, m_color); set_palette(pal); update(); - } + }; + dialog->exec(); } if (event.button() == GUI::MouseButton::Primary) @@ -72,8 +73,10 @@ public: return; auto dialog = GUI::ColorPicker::construct(m_color, window()); - if (dialog->exec() == GUI::Dialog::ExecResult::OK) - on_color_change(dialog->color()); + dialog->on_color_changed = [this](Gfx::Color color) { + on_color_change(color); + }; + dialog->exec(); } void set_background_color(Color color)