mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:17:35 +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:
parent
40ffa8c626
commit
fbeaf76f96
4 changed files with 11 additions and 1 deletions
|
@ -120,4 +120,10 @@ void ImageEditor::set_active_tool(Tool* tool)
|
||||||
m_active_tool->setup(*this);
|
m_active_tool->setup(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImageEditor::layers_did_change()
|
||||||
|
{
|
||||||
|
static_cast<LayerModel&>(m_image->layer_model()).update_without_invalidating_indexes();
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
Tool* active_tool() { return m_active_tool; }
|
Tool* active_tool() { return m_active_tool; }
|
||||||
void set_active_tool(Tool*);
|
void set_active_tool(Tool*);
|
||||||
|
|
||||||
|
void layers_did_change();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageEditor();
|
ImageEditor();
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,8 @@ public:
|
||||||
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override;
|
||||||
virtual void update() override { did_update(); }
|
virtual void update() override { did_update(); }
|
||||||
|
|
||||||
|
void update_without_invalidating_indexes() { did_update(0); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit LayerModel(Image&);
|
explicit LayerModel(Image&);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ void MoveTool::on_mousemove(Layer&, GUI::MouseEvent&, GUI::MouseEvent& original_
|
||||||
return;
|
return;
|
||||||
auto delta = original_event.position() - m_event_origin;
|
auto delta = original_event.position() - m_event_origin;
|
||||||
m_layer_being_moved->set_location(m_layer_origin.translated(delta));
|
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&)
|
void MoveTool::on_mouseup(Layer&, GUI::MouseEvent& event, GUI::MouseEvent&)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue