mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:37:44 +00:00
PixelPaint: Undo and redo actions
The most used feature of any image editor, undo. Each tool now notifies the ImageEditor that they completed an action, where it'll take a snapshot if its current state. For now, a snapshot is just a copy of the whole image and its layers. There's a hard limit on the amount of actions it stores.
This commit is contained in:
parent
5aeab9878e
commit
1c27568ab0
21 changed files with 256 additions and 2 deletions
|
@ -52,6 +52,16 @@ RefPtr<Layer> Layer::create_with_bitmap(Image& image, const Gfx::Bitmap& bitmap,
|
|||
return adopt(*new Layer(image, bitmap, name));
|
||||
}
|
||||
|
||||
RefPtr<Layer> Layer::create_snapshot(Image& image, const Layer& layer)
|
||||
{
|
||||
auto snapshot = create_with_bitmap(image, *layer.bitmap().clone(), layer.name());
|
||||
snapshot->set_opacity_percent(layer.opacity_percent());
|
||||
snapshot->set_visible(layer.is_visible());
|
||||
snapshot->set_selected(layer.is_selected());
|
||||
snapshot->set_location(layer.location());
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
Layer::Layer(Image& image, const Gfx::IntSize& size, const String& name)
|
||||
: m_image(image)
|
||||
, m_name(name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue