1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:07:34 +00:00

PixelPaint: Update palette colors in real-time while picking

Palette color selections in `PaletteWidget` now update while interacting
with `GUI::ColorPicker`
This commit is contained in:
Valtteri Koskivuori 2023-07-21 00:58:32 +03:00 committed by Ali Mohammad Pur
parent 5866a3a731
commit 0388bb019f

View file

@ -33,13 +33,14 @@ public:
{ {
if (event.modifiers() & KeyModifier::Mod_Ctrl) { if (event.modifiers() & KeyModifier::Mod_Ctrl) {
auto dialog = GUI::ColorPicker::construct(m_color, window()); auto dialog = GUI::ColorPicker::construct(m_color, window());
if (dialog->exec() == GUI::Dialog::ExecResult::OK) { dialog->on_color_changed = [this](Gfx::Color color) {
m_color = dialog->color(); m_color = color;
auto pal = palette(); auto pal = palette();
pal.set_color(ColorRole::Background, m_color); pal.set_color(ColorRole::Background, m_color);
set_palette(pal); set_palette(pal);
update(); update();
} };
dialog->exec();
} }
if (event.button() == GUI::MouseButton::Primary) if (event.button() == GUI::MouseButton::Primary)
@ -72,8 +73,10 @@ public:
return; return;
auto dialog = GUI::ColorPicker::construct(m_color, window()); auto dialog = GUI::ColorPicker::construct(m_color, window());
if (dialog->exec() == GUI::Dialog::ExecResult::OK) dialog->on_color_changed = [this](Gfx::Color color) {
on_color_change(dialog->color()); on_color_change(color);
};
dialog->exec();
} }
void set_background_color(Color color) void set_background_color(Color color)