1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +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

@ -144,6 +144,18 @@ int main(int argc, char** argv)
edit_menu.add_action(paste_action);
auto undo_action = GUI::CommonActions::make_undo_action([&](auto&) {
ASSERT(image_editor.image());
image_editor.undo();
});
edit_menu.add_action(undo_action);
auto redo_action = GUI::CommonActions::make_redo_action([&](auto&) {
ASSERT(image_editor.image());
image_editor.redo();
});
edit_menu.add_action(redo_action);
auto& tool_menu = menubar->add_menu("Tool");
toolbox.for_each_tool([&](auto& tool) {
if (tool.action())