mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:17:35 +00:00
PixelPaint: Set Tool on_*_color_change logic using virtual functions
Previously, we were rewriting the on_primary_color_change in the Text Tool and Gradient, which made the palette widget no longer update after picking a color from an image. Additionally, it also crashed the program after leaving the Gradient tool and trying to change color.
This commit is contained in:
parent
cb96c892cc
commit
d27d19f012
7 changed files with 23 additions and 18 deletions
|
@ -1229,6 +1229,17 @@ ImageEditor& MainWidget::create_new_editor(NonnullRefPtr<Image> image)
|
|||
},
|
||||
100);
|
||||
|
||||
image_editor.on_primary_color_change = [&](Color color) {
|
||||
m_palette_widget->set_primary_color(color);
|
||||
if (image_editor.active_tool())
|
||||
image_editor.active_tool()->on_primary_color_change(color);
|
||||
};
|
||||
image_editor.on_secondary_color_change = [&](Color color) {
|
||||
m_palette_widget->set_secondary_color(color);
|
||||
if (image_editor.active_tool())
|
||||
image_editor.active_tool()->on_secondary_color_change(color);
|
||||
};
|
||||
|
||||
if (image->layer_count())
|
||||
image_editor.set_active_layer(&image->layer(0));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue