mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +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
|
@ -163,13 +163,14 @@ void GradientTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
|
|||
draw_gradient(painter, true, m_editor->content_to_frame_position(Gfx::IntPoint(0, 0)), m_editor->scale(), m_editor->content_rect());
|
||||
}
|
||||
|
||||
void GradientTool::on_primary_color_change(Color)
|
||||
{
|
||||
if (m_gradient_end.has_value())
|
||||
m_editor->update();
|
||||
}
|
||||
|
||||
void GradientTool::on_tool_activation()
|
||||
{
|
||||
m_editor->on_primary_color_change = [this](Color) {
|
||||
if (m_gradient_end.has_value())
|
||||
m_editor->update();
|
||||
};
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue