mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:57:34 +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
|
@ -26,6 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "History.h"
|
||||
#include "Image.h"
|
||||
#include <LibGUI/Frame.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
@ -54,6 +55,10 @@ public:
|
|||
Tool* active_tool() { return m_active_tool; }
|
||||
void set_active_tool(Tool*);
|
||||
|
||||
void did_complete_action();
|
||||
bool undo();
|
||||
bool redo();
|
||||
|
||||
void layers_did_change();
|
||||
|
||||
Layer* layer_at_editor_position(const Gfx::IntPoint&);
|
||||
|
@ -94,6 +99,7 @@ private:
|
|||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
virtual void image_did_change() override;
|
||||
virtual void image_select_layer(Layer*) override;
|
||||
|
||||
GUI::MouseEvent event_adjusted_for_layer(const GUI::MouseEvent&, const Layer&) const;
|
||||
GUI::MouseEvent event_with_pan_and_scale_applied(const GUI::MouseEvent&) const;
|
||||
|
@ -102,6 +108,7 @@ private:
|
|||
|
||||
RefPtr<Image> m_image;
|
||||
RefPtr<Layer> m_active_layer;
|
||||
History m_history;
|
||||
|
||||
Tool* m_active_tool { nullptr };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue