Skip to content

Commit

Permalink
PixelPaint: Update palette colors in real-time while picking
Browse files Browse the repository at this point in the history
Palette color selections in `PaletteWidget` now update while interacting
with `GUI::ColorPicker`
  • Loading branch information
vkoskiv authored and alimpfard committed Jul 24, 2023
1 parent 5866a3a commit 0388bb0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Userland/Applications/PixelPaint/PaletteWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class ColorWidget : public GUI::Frame {
{
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)
Expand Down Expand Up @@ -72,8 +73,10 @@ class SelectedColorWidget : public GUI::Frame {
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)
Expand Down

0 comments on commit 0388bb0

Please sign in to comment.