1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 19:37:36 +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:
BenJilks 2020-10-17 16:47:34 +00:00 committed by Andreas Kling
parent 5aeab9878e
commit 1c27568ab0
21 changed files with 256 additions and 2 deletions

View file

@ -47,6 +47,7 @@ public:
virtual void image_did_modify_layer(size_t) { }
virtual void image_did_modify_layer_stack() { }
virtual void image_did_change() { }
virtual void image_select_layer(Layer*) { }
};
class Image : public RefCounted<Image> {
@ -61,6 +62,8 @@ public:
Gfx::IntRect rect() const { return { {}, m_size }; }
void add_layer(NonnullRefPtr<Layer>);
RefPtr<Image> take_snapshot() const;
void restore_snapshot(const Image&);
void paint_into(GUI::Painter&, const Gfx::IntRect& dest_rect);
@ -70,6 +73,7 @@ public:
void move_layer_down(Layer&);
void change_layer_index(size_t old_index, size_t new_index);
void remove_layer(Layer&);
void select_layer(Layer*);
void add_client(ImageClient&);
void remove_client(ImageClient&);