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

PaintBrush: Update the LayerModel when moving layers around

This ensures that the layer table view always shows the correct
coordinates for the layer.
This commit is contained in:
Andreas Kling 2020-05-13 00:21:13 +02:00
parent 40ffa8c626
commit fbeaf76f96
4 changed files with 11 additions and 1 deletions

View file

@ -120,4 +120,10 @@ void ImageEditor::set_active_tool(Tool* tool)
m_active_tool->setup(*this);
}
void ImageEditor::layers_did_change()
{
static_cast<LayerModel&>(m_image->layer_model()).update_without_invalidating_indexes();
update();
}
}

View file

@ -49,6 +49,8 @@ public:
Tool* active_tool() { return m_active_tool; }
void set_active_tool(Tool*);
void layers_did_change();
private:
ImageEditor();

View file

@ -49,6 +49,8 @@ public:
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
virtual void update() override { did_update(); }
void update_without_invalidating_indexes() { did_update(0); }
private:
explicit LayerModel(Image&);

View file

@ -59,7 +59,7 @@ void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& original_
return;
auto delta = original_event.position() - m_event_origin;
m_layer_being_moved->set_location(m_layer_origin.translated(delta));
m_editor->update();
m_editor->layers_did_change();
}
void MoveTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)