From dc58651f797b8e3b63e5b8208e0ce578f2508d43 Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 30 Mar 2011 18:27:52 -0700 Subject: [PATCH] Remove UndoHistory::undo_* member functions to use Undoers directly and to avoid undo-lib <-> undoers circular dependency. --- src/commands/cmd_duplicate_layer.cpp | 17 +- src/commands/cmd_invert_mask.cpp | 3 +- src/commands/cmd_load_mask.cpp | 3 +- src/commands/cmd_mask_all.cpp | 3 +- src/commands/cmd_merge_down_layer.cpp | 41 +++-- src/commands/cmd_palette_editor.cpp | 4 +- src/commands/cmd_reselect_mask.cpp | 3 +- src/commands/filters/filter_manager_impl.cpp | 9 +- src/dialogs/maskcol.cpp | 3 +- src/document.cpp | 18 +- src/tools/inks.h | 6 +- src/undo/CMakeLists.txt | 1 - src/undo/undo_history.h | 39 ----- src/undo/undo_history_backward.cpp | 166 ------------------- src/undo_transaction.cpp | 125 +++++++++----- src/undoers/flip_image.cpp | 12 +- src/undoers/flip_image.h | 6 +- src/util/celmove.cpp | 50 +++--- src/util/clipboard.cpp | 12 +- src/widgets/editor/editor.cpp | 33 ++-- 20 files changed, 227 insertions(+), 327 deletions(-) delete mode 100644 src/undo/undo_history_backward.cpp diff --git a/src/commands/cmd_duplicate_layer.cpp b/src/commands/cmd_duplicate_layer.cpp index 5c8542d0b..b12fa4adf 100644 --- a/src/commands/cmd_duplicate_layer.cpp +++ b/src/commands/cmd_duplicate_layer.cpp @@ -28,6 +28,9 @@ #include "raster/sprite.h" #include "undo/undo_history.h" #include "undo_transaction.h" +#include "undoers/add_layer.h" +#include "undoers/move_layer.h" +#include "undoers/set_current_layer.h" ////////////////////////////////////////////////////////////////////// // Duplicate Layer command @@ -68,15 +71,23 @@ void DuplicateLayerCommand::onExecute(Context* context) // Create a new layer UniquePtr newLayerPtr(new LayerImage(sprite)); + // Disable undo because the layer content is added as a whole with + // AddLayer() undoer. + document->getUndoHistory()->setEnabled(false); + // Copy the layer content (cels + images) document->copyLayerContent(sourceLayer, document, newLayerPtr); + // Restore enabled status. + document->getUndoHistory()->setEnabled(undoTransaction.isEnabled()); + // Copy the layer name newLayerPtr->setName(newLayerPtr->getName() + " Copy"); // Add the new layer in the sprite. if (undo->isEnabled()) - undo->undo_add_layer(sourceLayer->get_parent(), newLayerPtr); + undo->pushUndoer(new undoers::AddLayer(undo->getObjects(), + sourceLayer->get_parent(), newLayerPtr)); sourceLayer->get_parent()->add_layer(newLayerPtr); @@ -84,8 +95,8 @@ void DuplicateLayerCommand::onExecute(Context* context) Layer* newLayer = newLayerPtr.release(); if (undo->isEnabled()) { - undo->undo_move_layer(newLayer); - undo->undo_set_layer(sprite); + undo->pushUndoer(new undoers::MoveLayer(undo->getObjects(), newLayer)); + undo->pushUndoer(new undoers::SetCurrentLayer(undo->getObjects(), sprite)); } undoTransaction.commit(); diff --git a/src/commands/cmd_invert_mask.cpp b/src/commands/cmd_invert_mask.cpp index 5e1562842..e8daa9f21 100644 --- a/src/commands/cmd_invert_mask.cpp +++ b/src/commands/cmd_invert_mask.cpp @@ -26,6 +26,7 @@ #include "raster/mask.h" #include "raster/sprite.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" ////////////////////////////////////////////////////////////////////// // invert_mask @@ -80,7 +81,7 @@ void InvertMaskCommand::onExecute(Context* context) if (undo->isEnabled()) { undo->setLabel("Mask Invert"); undo->setModification(undo::DoesntModifyDocument); - undo->undo_set_mask(document); + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), document)); } /* create a new mask */ diff --git a/src/commands/cmd_load_mask.cpp b/src/commands/cmd_load_mask.cpp index 99337bbd4..7f0b42bd7 100644 --- a/src/commands/cmd_load_mask.cpp +++ b/src/commands/cmd_load_mask.cpp @@ -27,6 +27,7 @@ #include "raster/mask.h" #include "raster/sprite.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" #include "util/msk_file.h" class LoadMaskCommand : public Command @@ -89,7 +90,7 @@ void LoadMaskCommand::onExecute(Context* context) if (undo->isEnabled()) { undo->setLabel("Mask Load"); undo->setModification(undo::DoesntModifyDocument); - undo->undo_set_mask(documentWriter); + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), documentWriter)); } documentWriter->setMask(mask); diff --git a/src/commands/cmd_mask_all.cpp b/src/commands/cmd_mask_all.cpp index bb98a0fc3..b48d3c241 100644 --- a/src/commands/cmd_mask_all.cpp +++ b/src/commands/cmd_mask_all.cpp @@ -24,6 +24,7 @@ #include "raster/mask.h" #include "raster/sprite.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" ////////////////////////////////////////////////////////////////////// // mask_all @@ -62,7 +63,7 @@ void MaskAllCommand::onExecute(Context* context) if (undo->isEnabled()) { undo->setLabel("Mask All"); undo->setModification(undo::DoesntModifyDocument); - undo->undo_set_mask(document); + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), document)); } // Change the selection diff --git a/src/commands/cmd_merge_down_layer.cpp b/src/commands/cmd_merge_down_layer.cpp index b66abbc23..762ba2260 100644 --- a/src/commands/cmd_merge_down_layer.cpp +++ b/src/commands/cmd_merge_down_layer.cpp @@ -29,7 +29,14 @@ #include "raster/sprite.h" #include "raster/stock.h" #include "undo/undo_history.h" +#include "undoers/add_cel.h" +#include "undoers/add_image.h" +#include "undoers/close_group.h" +#include "undoers/open_group.h" +#include "undoers/remove_layer.h" +#include "undoers/replace_image.h" #include "undoers/set_cel_position.h" +#include "undoers/set_current_layer.h" ////////////////////////////////////////////////////////////////////// // merge_down_layer @@ -86,15 +93,15 @@ void MergeDownLayerCommand::onExecute(Context* context) if (undo->isEnabled()) { undo->setLabel("Merge Down Layer"); undo->setModification(undo::ModifyDocument); - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); } for (frpos=0; frposgetTotalFrames(); ++frpos) { - /* get frames */ + // Get frames src_cel = static_cast(src_layer)->getCel(frpos); dst_cel = static_cast(dst_layer)->getCel(frpos); - /* get images */ + // Get images if (src_cel != NULL) src_image = sprite->getStock()->getImage(src_cel->getImage()); else @@ -105,27 +112,28 @@ void MergeDownLayerCommand::onExecute(Context* context) else dst_image = NULL; - /* with source image? */ + // With source image? if (src_image != NULL) { - /* no destination image */ - if (dst_image == NULL) { /* only a transparent layer can have a null cel */ - /* copy this cel to the destination layer... */ + // No destination image + if (dst_image == NULL) { // Only a transparent layer can have a null cel + // Copy this cel to the destination layer... - /* creating a copy of the image */ + // Creating a copy of the image dst_image = image_new_copy(src_image); - /* adding it in the stock of images */ + // Adding it in the stock of images index = sprite->getStock()->addImage(dst_image); if (undo->isEnabled()) - undo->undo_add_image(sprite->getStock(), index); + undo->pushUndoer(new undoers::AddImage( + undo->getObjects(), sprite->getStock(), index)); - /* creating a copy of the cell */ + // Creating a copy of the cell dst_cel = new Cel(frpos, index); dst_cel->setPosition(src_cel->getX(), src_cel->getY()); dst_cel->setOpacity(src_cel->getOpacity()); if (undo->isEnabled()) - undo->undo_add_cel(dst_layer, dst_cel); + undo->pushUndoer(new undoers::AddCel(undo->getObjects(), dst_layer, dst_cel)); static_cast(dst_layer)->addCel(dst_cel); } @@ -169,7 +177,8 @@ void MergeDownLayerCommand::onExecute(Context* context) dst_cel->setPosition(x1, y1); if (undo->isEnabled()) - undo->undo_replace_image(sprite->getStock(), dst_cel->getImage()); + undo->pushUndoer(new undoers::ReplaceImage(undo->getObjects(), + sprite->getStock(), dst_cel->getImage())); sprite->getStock()->replaceImage(dst_cel->getImage(), new_image); @@ -179,9 +188,9 @@ void MergeDownLayerCommand::onExecute(Context* context) } if (undo->isEnabled()) { - undo->undo_set_layer(sprite); - undo->undo_remove_layer(src_layer); - undo->undo_close(); + undo->pushUndoer(new undoers::SetCurrentLayer(undo->getObjects(), sprite)); + undo->pushUndoer(new undoers::RemoveLayer(undo->getObjects(), src_layer)); + undo->pushUndoer(new undoers::CloseGroup()); } sprite->setCurrentLayer(dst_layer); diff --git a/src/commands/cmd_palette_editor.cpp b/src/commands/cmd_palette_editor.cpp index 9b22ac694..0dd22cf57 100644 --- a/src/commands/cmd_palette_editor.cpp +++ b/src/commands/cmd_palette_editor.cpp @@ -45,6 +45,7 @@ #include "skin/skin_slider_property.h" #include "ui_context.h" #include "undo/undo_history.h" +#include "undoers/set_palette_colors.h" #include "widgets/color_bar.h" #include "widgets/color_sliders.h" #include "widgets/editor/editor.h" @@ -665,7 +666,8 @@ void PaletteEntryEditor::updateCurrentSpritePalette(const char* operationName) if (undo->isEnabled()) { undo->setLabel(operationName); undo->setModification(undo::ModifyDocument); - undo->undo_set_palette_colors(sprite, currentSpritePalette, from, to); + undo->pushUndoer(new undoers::SetPaletteColors(undo->getObjects(), + sprite, currentSpritePalette, from, to)); } // Change the sprite palette diff --git a/src/commands/cmd_reselect_mask.cpp b/src/commands/cmd_reselect_mask.cpp index 29b167ec9..06c573a41 100644 --- a/src/commands/cmd_reselect_mask.cpp +++ b/src/commands/cmd_reselect_mask.cpp @@ -24,6 +24,7 @@ #include "raster/mask.h" #include "raster/sprite.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" ////////////////////////////////////////////////////////////////////// // reselect_mask @@ -65,7 +66,7 @@ void ReselectMaskCommand::onExecute(Context* context) if (undo->isEnabled()) { undo->setLabel("Mask Reselection"); undo->setModification(undo::DoesntModifyDocument); - undo->undo_set_mask(document); + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), document)); } // Make the mask visible again. diff --git a/src/commands/filters/filter_manager_impl.cpp b/src/commands/filters/filter_manager_impl.cpp index 647eda4c5..40e45716c 100644 --- a/src/commands/filters/filter_manager_impl.cpp +++ b/src/commands/filters/filter_manager_impl.cpp @@ -36,6 +36,9 @@ #include "raster/sprite.h" #include "raster/stock.h" #include "undo/undo_history.h" +#include "undoers/close_group.h" +#include "undoers/image_area.h" +#include "undoers/open_group.h" #include "widgets/editor/editor.h" #include @@ -209,7 +212,7 @@ void FilterManagerImpl::apply() if (undo->isEnabled()) { undo->setLabel(m_filter->getName()); undo->setModification(undo::ModifyDocument); - undo->undo_image(m_src, m_x, m_y, m_w, m_h); + undo->pushUndoer(new undoers::ImageArea(undo->getObjects(), m_src, m_x, m_y, m_w, m_h)); } // Copy "dst" to "src" @@ -236,7 +239,7 @@ void FilterManagerImpl::applyToTarget() // Open group of undo operations if (images.size() > 1) { if (undo->isEnabled()) - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); } m_progressBase = 0.0f; @@ -259,7 +262,7 @@ void FilterManagerImpl::applyToTarget() // Close group of undo operations if (images.size() > 1) { if (undo->isEnabled()) - undo->undo_close(); + undo->pushUndoer(new undoers::CloseGroup()); } } diff --git a/src/dialogs/maskcol.cpp b/src/dialogs/maskcol.cpp index ede13ea65..1feedbf65 100644 --- a/src/dialogs/maskcol.cpp +++ b/src/dialogs/maskcol.cpp @@ -38,6 +38,7 @@ #include "raster/mask.h" #include "raster/sprite.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" #include "util/misc.h" #include "widgets/color_bar.h" #include "widgets/color_button.h" @@ -143,7 +144,7 @@ void dialogs_mask_color(Document* document) if (undo->isEnabled()) { undo->setLabel("Mask by Color"); undo->setModification(undo::DoesntModifyDocument); - undo->undo_set_mask(document); + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), document)); } /* change the mask */ diff --git a/src/document.cpp b/src/document.cpp index d53f83ccf..22913bc10 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -33,6 +33,8 @@ #include "raster/sprite.h" #include "raster/stock.h" #include "undo/undo_history.h" +#include "undoers/add_image.h" +#include "undoers/add_layer.h" #include "util/boundary.h" using namespace undo; @@ -290,6 +292,8 @@ void Document::setMaskVisible(bool visible) void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, Layer* destLayer0) const { + UndoHistory* undo = destDoc->getUndoHistory(); + // Copy the layer name destLayer0->setName(sourceLayer0->getName()); @@ -312,12 +316,13 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La ASSERT(sourceImage != NULL); Image* newImage = image_new_copy(sourceImage); - newCel->setImage(destLayer->getSprite()->getStock()->addImage(newImage)); - if (destDoc->getUndoHistory()->isEnabled()) - destDoc->getUndoHistory()->undo_add_image(destLayer->getSprite()->getStock(), - newCel->getImage()); + if (undo->isEnabled()) { + undo->pushUndoer(new undoers::AddImage(undo->getObjects(), + destLayer->getSprite()->getStock(), + newCel->getImage())); + } destLayer->addCel(newCel); newCel.release(); @@ -349,8 +354,9 @@ void Document::copyLayerContent(const Layer* sourceLayer0, Document* destDoc, La ASSERT(destChild != NULL); // Add the new layer in the sprite. - if (destDoc->getUndoHistory()->isEnabled()) - destDoc->getUndoHistory()->undo_add_layer(destLayer, destChild); + if (undo->isEnabled()) + undo->pushUndoer(new undoers::AddLayer(undo->getObjects(), + destLayer, destChild)); destLayer->add_layer(destChild); destChild.release(); diff --git a/src/tools/inks.h b/src/tools/inks.h index 4a70c9a7b..1dc070858 100644 --- a/src/tools/inks.h +++ b/src/tools/inks.h @@ -23,6 +23,7 @@ #include "context.h" #include "document.h" #include "undo/undo_history.h" +#include "undoers/set_mask.h" // Ink used for tools which paint with primary/secondary @@ -259,8 +260,9 @@ public: m_modify_selection = state; if (state) { - if (loop->getDocument()->getUndoHistory()->isEnabled()) - loop->getDocument()->getUndoHistory()->undo_set_mask(loop->getDocument()); + undo::UndoHistory* undo = loop->getDocument()->getUndoHistory(); + if (undo->isEnabled()) + undo->pushUndoer(new undoers::SetMask(undo->getObjects(), loop->getDocument())); loop->getMask()->freeze(); loop->getMask()->reserve(0, 0, loop->getSprite()->getWidth(), loop->getSprite()->getHeight()); diff --git a/src/undo/CMakeLists.txt b/src/undo/CMakeLists.txt index ff4afc810..6bfa5a196 100644 --- a/src/undo/CMakeLists.txt +++ b/src/undo/CMakeLists.txt @@ -3,5 +3,4 @@ add_library(undo-lib undo_history.cpp - undo_history_backward.cpp undoers_stack.cpp) diff --git a/src/undo/undo_history.h b/src/undo/undo_history.h index 76c480355..4e89f1aec 100644 --- a/src/undo/undo_history.h +++ b/src/undo/undo_history.h @@ -12,18 +12,6 @@ #include -// TODO Remove this (it is here only for backward compatibility) -class Cel; -class Dirty; -class Document; -class GfxObj; -class Image; -class Layer; -class Mask; -class Palette; -class Sprite; -class Stock; - namespace undo { class ObjectsContainer; @@ -67,33 +55,6 @@ public: // UndoersCollector interface void pushUndoer(Undoer* undoer); - // Backward compatibility methods - void undo_open(); - void undo_close(); - void undo_image(Image *image, int x, int y, int w, int h); - void undo_flip(Image *image, int x1, int y1, int x2, int y2, bool horz); - void undo_dirty(Image* image, Dirty *dirty); - void undo_add_image(Stock *stock, int image_index); - void undo_remove_image(Stock *stock, int image_index); - void undo_replace_image(Stock *stock, int image_index); - void undo_set_layer_name(Layer *layer); - void undo_add_cel(Layer *layer, Cel *cel); - void undo_remove_cel(Layer *layer, Cel *cel); - void undo_add_layer(Layer *set, Layer *layer); - void undo_remove_layer(Layer *layer); - void undo_move_layer(Layer *layer); - void undo_set_layer(Sprite* sprite); - void undo_add_palette(Sprite* sprite, Palette* palette); - void undo_remove_palette(Sprite* sprite, Palette* palette); - void undo_set_palette_colors(Sprite* sprite, Palette* palette, int from, int to); - void undo_remap_palette(Sprite* sprite, int frame_from, int frame_to, const std::vector& mapping); - void undo_set_mask(Document* document); - void undo_set_imgtype(Sprite* sprite); - void undo_set_size(Sprite* sprite); - void undo_set_frame(Sprite* sprite); - void undo_set_frames(Sprite* sprite); - void undo_set_frlen(Sprite* sprite, int frame); - private: enum Direction { UndoDirection, RedoDirection }; diff --git a/src/undo/undo_history_backward.cpp b/src/undo/undo_history_backward.cpp deleted file mode 100644 index 9dc01d0c6..000000000 --- a/src/undo/undo_history_backward.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// ASEPRITE Undo Library -// Copyright (C) 2001-2011 David Capello -// -// This source file is ditributed under a BSD-like license, please -// read LICENSE.txt for more information. - -#include "config.h" - -#include "undo/undo_history.h" - -#include "raster/palette.h" -#include "undo/undoers_stack.h" -#include "undoers/add_cel.h" -#include "undoers/add_image.h" -#include "undoers/add_layer.h" -#include "undoers/add_palette.h" -#include "undoers/close_group.h" -#include "undoers/dirty_area.h" -#include "undoers/flip_image.h" -#include "undoers/image_area.h" -#include "undoers/move_layer.h" -#include "undoers/open_group.h" -#include "undoers/remap_palette.h" -#include "undoers/remove_cel.h" -#include "undoers/remove_image.h" -#include "undoers/remove_layer.h" -#include "undoers/remove_palette.h" -#include "undoers/replace_image.h" -#include "undoers/set_current_frame.h" -#include "undoers/set_current_layer.h" -#include "undoers/set_frame_duration.h" -#include "undoers/set_layer_name.h" -#include "undoers/set_mask.h" -#include "undoers/set_palette_colors.h" -#include "undoers/set_sprite_imgtype.h" -#include "undoers/set_sprite_size.h" -#include "undoers/set_total_frames.h" - -using namespace undo; - -void UndoHistory::undo_open() -{ - pushUndoer(new undoers::OpenGroup()); -} - -void UndoHistory::undo_close() -{ - pushUndoer(new undoers::CloseGroup()); -} - -void UndoHistory::undo_image(Image* image, int x, int y, int w, int h) -{ - pushUndoer(new undoers::ImageArea(getObjects(), image, x, y, w, h)); -} - -void UndoHistory::undo_flip(Image* image, int x1, int y1, int x2, int y2, bool horz) -{ - pushUndoer(new undoers::FlipImage(getObjects(), image, x1, y1, x2-x1+1, y2-y1+1, - (horz ? undoers::FlipImage::FlipHorizontal: - undoers::FlipImage::FlipVertical))); -} - -void UndoHistory::undo_dirty(Image* image, Dirty* dirty) -{ - pushUndoer(new undoers::DirtyArea(getObjects(), image, dirty)); -} - -void UndoHistory::undo_add_image(Stock* stock, int imageIndex) -{ - pushUndoer(new undoers::AddImage(getObjects(), stock, imageIndex)); -} - -void UndoHistory::undo_remove_image(Stock *stock, int imageIndex) -{ - pushUndoer(new undoers::RemoveImage(getObjects(), stock, imageIndex)); -} - -void UndoHistory::undo_replace_image(Stock *stock, int imageIndex) -{ - pushUndoer(new undoers::ReplaceImage(getObjects(), stock, imageIndex)); -} - -void UndoHistory::undo_add_cel(Layer* layer, Cel* cel) -{ - pushUndoer(new undoers::AddCel(getObjects(), layer, cel)); -} - -void UndoHistory::undo_remove_cel(Layer* layer, Cel* cel) -{ - pushUndoer(new undoers::RemoveCel(getObjects(), layer, cel)); -} - -void UndoHistory::undo_set_layer_name(Layer* layer) -{ - pushUndoer(new undoers::SetLayerName(getObjects(), layer)); -} - -void UndoHistory::undo_add_layer(Layer* folder, Layer* layer) -{ - pushUndoer(new undoers::AddLayer(getObjects(), folder, layer)); -} - -void UndoHistory::undo_remove_layer(Layer* layer) -{ - pushUndoer(new undoers::RemoveLayer(getObjects(), layer)); -} - -void UndoHistory::undo_move_layer(Layer* layer) -{ - pushUndoer(new undoers::MoveLayer(getObjects(), layer)); -} - -void UndoHistory::undo_set_layer(Sprite* sprite) -{ - pushUndoer(new undoers::SetCurrentLayer(getObjects(), sprite)); -} - -void UndoHistory::undo_add_palette(Sprite* sprite, Palette* palette) -{ - pushUndoer(new undoers::AddPalette(getObjects(), sprite, palette->getFrame())); -} - -void UndoHistory::undo_remove_palette(Sprite* sprite, Palette* palette) -{ - pushUndoer(new undoers::RemovePalette(getObjects(), sprite, palette->getFrame())); -} - -void UndoHistory::undo_set_palette_colors(Sprite* sprite, Palette* palette, int from, int to) -{ - pushUndoer(new undoers::SetPaletteColors(getObjects(), sprite, palette, from, to)); -} - -void UndoHistory::undo_remap_palette(Sprite* sprite, int frameFrom, int frameTo, const std::vector& mapping) -{ - pushUndoer(new undoers::RemapPalette(getObjects(), sprite, frameFrom, frameTo, mapping)); -} - -void UndoHistory::undo_set_mask(Document* document) -{ - pushUndoer(new undoers::SetMask(getObjects(), document)); -} - -void UndoHistory::undo_set_imgtype(Sprite* sprite) -{ - pushUndoer(new undoers::SetSpriteImgType(getObjects(), sprite)); -} - -void UndoHistory::undo_set_size(Sprite* sprite) -{ - pushUndoer(new undoers::SetSpriteSize(getObjects(), sprite)); -} - -void UndoHistory::undo_set_frame(Sprite* sprite) -{ - pushUndoer(new undoers::SetCurrentFrame(getObjects(), sprite)); -} - -void UndoHistory::undo_set_frames(Sprite* sprite) -{ - pushUndoer(new undoers::SetTotalFrames(getObjects(), sprite)); -} - -void UndoHistory::undo_set_frlen(Sprite* sprite, int frame) -{ - pushUndoer(new undoers::SetFrameDuration(getObjects(), sprite, frame)); -} diff --git a/src/undo_transaction.cpp b/src/undo_transaction.cpp index be7ccb46c..59e2cdaf7 100644 --- a/src/undo_transaction.cpp +++ b/src/undo_transaction.cpp @@ -33,11 +33,33 @@ #include "raster/sprite.h" #include "raster/stock.h" #include "undo/undo_history.h" +#include "undoers/add_cel.h" +#include "undoers/add_image.h" +#include "undoers/add_layer.h" +#include "undoers/close_group.h" +#include "undoers/dirty_area.h" +#include "undoers/flip_image.h" +#include "undoers/image_area.h" +#include "undoers/move_layer.h" +#include "undoers/open_group.h" +#include "undoers/remove_cel.h" +#include "undoers/remove_image.h" +#include "undoers/remove_layer.h" +#include "undoers/remove_palette.h" +#include "undoers/replace_image.h" #include "undoers/set_cel_frame.h" #include "undoers/set_cel_position.h" +#include "undoers/set_current_frame.h" +#include "undoers/set_current_layer.h" +#include "undoers/set_frame_duration.h" #include "undoers/set_layer_flags.h" +#include "undoers/set_layer_name.h" +#include "undoers/set_mask.h" #include "undoers/set_mask_position.h" +#include "undoers/set_sprite_imgtype.h" +#include "undoers/set_sprite_size.h" #include "undoers/set_stock_imgtype.h" +#include "undoers/set_total_frames.h" UndoTransaction::UndoTransaction(Document* document, const char* label, undo::Modification modification) { @@ -53,7 +75,7 @@ UndoTransaction::UndoTransaction(Document* document, const char* label, undo::Mo if (isEnabled()) { m_undoHistory->setLabel(label); m_undoHistory->setModification(modification); - m_undoHistory->undo_open(); + m_undoHistory->pushUndoer(new undoers::OpenGroup()); } } @@ -82,7 +104,7 @@ void UndoTransaction::closeUndoGroup() if (isEnabled()) { // Close the undo information. - m_undoHistory->undo_close(); + m_undoHistory->pushUndoer(new undoers::CloseGroup()); m_closed = true; } } @@ -122,7 +144,7 @@ void UndoTransaction::setNumberOfFrames(int frames) // Save in undo the current totalFrames property if (isEnabled()) - m_undoHistory->undo_set_frames(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetTotalFrames(m_undoHistory->getObjects(), m_sprite)); // Change the property m_sprite->setTotalFrames(frames); @@ -133,7 +155,7 @@ void UndoTransaction::setCurrentFrame(int frame) ASSERT(frame >= 0); if (isEnabled()) - m_undoHistory->undo_set_frame(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetCurrentFrame(m_undoHistory->getObjects(), m_sprite)); m_sprite->setCurrentFrame(frame); } @@ -147,7 +169,8 @@ void UndoTransaction::setCurrentFrame(int frame) void UndoTransaction::setCurrentLayer(Layer* layer) { if (isEnabled()) - m_undoHistory->undo_set_layer(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetCurrentLayer( + m_undoHistory->getObjects(), m_sprite)); m_sprite->setCurrentLayer(layer); } @@ -158,7 +181,7 @@ void UndoTransaction::setSpriteSize(int w, int h) ASSERT(h > 0); if (isEnabled()) - m_undoHistory->undo_set_size(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetSpriteSize(m_undoHistory->getObjects(), m_sprite)); m_sprite->setSize(w, h); } @@ -250,7 +273,7 @@ void UndoTransaction::setImgType(int new_imgtype, DitheringMethod dithering_meth // Change sprite's "imgtype" field. if (isEnabled()) - m_undoHistory->undo_set_imgtype(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetSpriteImgType(m_undoHistory->getObjects(), m_sprite)); m_sprite->setImgType(new_imgtype); @@ -264,7 +287,8 @@ void UndoTransaction::setImgType(int new_imgtype, DitheringMethod dithering_meth PalettesList palettes = m_sprite->getPalettes(); for (PalettesList::iterator it = palettes.begin(); it != palettes.end(); ++it) { Palette* palette = *it; - m_undoHistory->undo_remove_palette(m_sprite, palette); + m_undoHistory->pushUndoer(new undoers::RemovePalette( + m_undoHistory->getObjects(), m_sprite, palette->getFrame())); } } @@ -289,7 +313,8 @@ int UndoTransaction::addImageInStock(Image* image) int image_index = m_sprite->getStock()->addImage(image); if (isEnabled()) - m_undoHistory->undo_add_image(m_sprite->getStock(), image_index); + m_undoHistory->pushUndoer(new undoers::AddImage(m_undoHistory->getObjects(), + m_sprite->getStock(), image_index)); return image_index; } @@ -305,7 +330,8 @@ void UndoTransaction::removeImageFromStock(int image_index) ASSERT(image); if (isEnabled()) - m_undoHistory->undo_remove_image(m_sprite->getStock(), image_index); + m_undoHistory->pushUndoer(new undoers::RemoveImage(m_undoHistory->getObjects(), + m_sprite->getStock(), image_index)); m_sprite->getStock()->removeImage(image); image_free(image); @@ -319,7 +345,8 @@ void UndoTransaction::replaceStockImage(int image_index, Image* new_image) // replace the image in the stock if (isEnabled()) - m_undoHistory->undo_replace_image(m_sprite->getStock(), image_index); + m_undoHistory->pushUndoer(new undoers::ReplaceImage(m_undoHistory->getObjects(), + m_sprite->getStock(), image_index)); m_sprite->getStock()->replaceImage(image_index, new_image); @@ -337,7 +364,8 @@ Layer* UndoTransaction::newLayer() // add the layer in the sprite set if (isEnabled()) - m_undoHistory->undo_add_layer(m_sprite->getFolder(), layer); + m_undoHistory->pushUndoer(new undoers::AddLayer(m_undoHistory->getObjects(), + m_sprite->getFolder(), layer)); m_sprite->getFolder()->add_layer(layer); @@ -375,7 +403,8 @@ void UndoTransaction::removeLayer(Layer* layer) // remove the layer if (isEnabled()) - m_undoHistory->undo_remove_layer(layer); + m_undoHistory->pushUndoer(new undoers::RemoveLayer(m_undoHistory->getObjects(), + layer)); parent->remove_layer(layer); @@ -386,7 +415,7 @@ void UndoTransaction::removeLayer(Layer* layer) void UndoTransaction::moveLayerAfter(Layer* layer, Layer* after_this) { if (isEnabled()) - m_undoHistory->undo_move_layer(layer); + m_undoHistory->pushUndoer(new undoers::MoveLayer(m_undoHistory->getObjects(), layer)); layer->get_parent()->move_layer(layer, after_this); } @@ -475,7 +504,8 @@ void UndoTransaction::backgroundFromLayer(LayerImage* layer, int bgcolor) if (bg_image->w == cel_image->w && bg_image->h == cel_image->h) { if (isEnabled()) - m_undoHistory->undo_image(cel_image, 0, 0, cel_image->w, cel_image->h); + m_undoHistory->pushUndoer(new undoers::ImageArea(m_undoHistory->getObjects(), + cel_image, 0, 0, cel_image->w, cel_image->h)); image_copy(cel_image, bg_image, 0, 0); } @@ -513,10 +543,8 @@ void UndoTransaction::layerFromBackground() ASSERT(m_sprite->getCurrentLayer()->is_background()); if (isEnabled()) { - m_undoHistory->pushUndoer(new undoers::SetLayerFlags(m_undoHistory->getObjects(), - m_sprite->getCurrentLayer())); - - m_undoHistory->undo_set_layer_name(m_sprite->getCurrentLayer()); + m_undoHistory->pushUndoer(new undoers::SetLayerFlags(m_undoHistory->getObjects(), m_sprite->getCurrentLayer())); + m_undoHistory->pushUndoer(new undoers::SetLayerName(m_undoHistory->getObjects(), m_sprite->getCurrentLayer())); } m_sprite->getCurrentLayer()->set_background(false); @@ -543,12 +571,14 @@ void UndoTransaction::flattenLayers(int bgcolor) background = new LayerImage(m_sprite); if (isEnabled()) - m_undoHistory->undo_add_layer(m_sprite->getFolder(), background); + m_undoHistory->pushUndoer(new undoers::AddLayer(m_undoHistory->getObjects(), + m_sprite->getFolder(), background)); m_sprite->getFolder()->add_layer(background); if (isEnabled()) - m_undoHistory->undo_move_layer(background); + m_undoHistory->pushUndoer(new undoers::MoveLayer(m_undoHistory->getObjects(), + background)); background->configureAsBackground(); } @@ -568,7 +598,8 @@ void UndoTransaction::flattenLayers(int bgcolor) if (isEnabled()) { Dirty* dirty = new Dirty(cel_image, image); dirty->saveImagePixels(cel_image); - m_undoHistory->undo_dirty(cel_image, dirty); + m_undoHistory->pushUndoer(new undoers::DirtyArea( + m_undoHistory->getObjects(), cel_image, dirty)); delete dirty; } } @@ -592,7 +623,8 @@ void UndoTransaction::flattenLayers(int bgcolor) /* select the background */ if (m_sprite->getCurrentLayer() != background) { if (isEnabled()) - m_undoHistory->undo_set_layer(m_sprite); + m_undoHistory->pushUndoer(new undoers::SetCurrentLayer( + m_undoHistory->getObjects(), m_sprite)); m_sprite->setCurrentLayer(background); } @@ -608,7 +640,8 @@ void UndoTransaction::flattenLayers(int bgcolor) // Remove the layer if (isEnabled()) - m_undoHistory->undo_remove_layer(old_layer); + m_undoHistory->pushUndoer(new undoers::RemoveLayer(m_undoHistory->getObjects(), + old_layer)); m_sprite->getFolder()->remove_layer(old_layer); @@ -622,8 +655,8 @@ void UndoTransaction::configureLayerAsBackground(LayerImage* layer) { if (isEnabled()) { m_undoHistory->pushUndoer(new undoers::SetLayerFlags(m_undoHistory->getObjects(), layer)); - m_undoHistory->undo_set_layer_name(layer); - m_undoHistory->undo_move_layer(layer); + m_undoHistory->pushUndoer(new undoers::SetLayerName(m_undoHistory->getObjects(), layer)); + m_undoHistory->pushUndoer(new undoers::MoveLayer(m_undoHistory->getObjects(), layer)); } layer->configureAsBackground(); @@ -757,7 +790,8 @@ void UndoTransaction::addCel(LayerImage* layer, Cel* cel) ASSERT(cel); if (isEnabled()) - m_undoHistory->undo_add_cel(layer, cel); + m_undoHistory->pushUndoer(new undoers::AddCel(m_undoHistory->getObjects(), + layer, cel)); layer->addCel(cel); } @@ -784,7 +818,8 @@ void UndoTransaction::removeCel(LayerImage* layer, Cel* cel) removeImageFromStock(cel->getImage()); if (isEnabled()) - m_undoHistory->undo_remove_cel(layer, cel); + m_undoHistory->pushUndoer(new undoers::RemoveCel(m_undoHistory->getObjects(), + layer, cel)); // remove the cel from the layer layer->removeCel(cel); @@ -817,7 +852,8 @@ void UndoTransaction::setCelPosition(Cel* cel, int x, int y) void UndoTransaction::setFrameDuration(int frame, int msecs) { if (isEnabled()) - m_undoHistory->undo_set_frlen(m_sprite, frame); + m_undoHistory->pushUndoer(new undoers::SetFrameDuration( + m_undoHistory->getObjects(), m_sprite, frame)); m_sprite->setFrameDuration(frame, msecs); } @@ -826,7 +862,8 @@ void UndoTransaction::setConstantFrameRate(int msecs) { if (isEnabled()) { for (int fr=0; frgetTotalFrames(); ++fr) - m_undoHistory->undo_set_frlen(m_sprite, fr); + m_undoHistory->pushUndoer(new undoers::SetFrameDuration( + m_undoHistory->getObjects(), m_sprite, fr)); } m_sprite->setDurationForAllFrames(msecs); @@ -966,7 +1003,8 @@ void UndoTransaction::clearMask(int bgcolor) // if the layer is the background then we clear the image if (m_sprite->getCurrentLayer()->is_background()) { if (isEnabled()) - m_undoHistory->undo_image(image, 0, 0, image->w, image->h); + m_undoHistory->pushUndoer(new undoers::ImageArea(m_undoHistory->getObjects(), + image, 0, 0, image->w, image->h)); // clear all image_clear(image, bgcolor); @@ -991,7 +1029,8 @@ void UndoTransaction::clearMask(int bgcolor) return; if (isEnabled()) - m_undoHistory->undo_image(image, x1, y1, x2-x1+1, y2-y1+1); + m_undoHistory->pushUndoer(new undoers::ImageArea(m_undoHistory->getObjects(), + image, x1, y1, x2-x1+1, y2-y1+1)); // clear the masked zones for (v=0; vh; v++) { @@ -1012,18 +1051,18 @@ void UndoTransaction::clearMask(int bgcolor) } void UndoTransaction::flipImage(Image* image, int x1, int y1, int x2, int y2, - bool flip_horizontal, bool flip_vertical) + bool flip_horizontal, bool flip_vertical) { - // insert the undo operation + // Insert the undo operation. if (isEnabled()) { - if (flip_horizontal) - m_undoHistory->undo_flip(image, x1, y1, x2, y2, true); - - if (flip_vertical) - m_undoHistory->undo_flip(image, x1, y1, x2, y2, false); + m_undoHistory->pushUndoer + (new undoers::FlipImage + (m_undoHistory->getObjects(), image, x1, y1, x2-x1+1, y2-y1+1, + (flip_horizontal ? undoers::FlipImage::FlipHorizontal: 0) | + (flip_vertical ? undoers::FlipImage::FlipVertical: 0))); } - // flip the portion of the bitmap + // Flip the portion of the bitmap. Image* area = image_crop(image, x1, y1, x2-x1+1, y2-y1+1, 0); int x, y; @@ -1062,7 +1101,8 @@ void UndoTransaction::copyToCurrentMask(Mask* mask) ASSERT(mask); if (isEnabled()) - m_undoHistory->undo_set_mask(m_document); + m_undoHistory->pushUndoer(new undoers::SetMask(m_undoHistory->getObjects(), + m_document)); mask_copy(m_document->getMask(), mask); } @@ -1081,7 +1121,8 @@ void UndoTransaction::setMaskPosition(int x, int y) void UndoTransaction::deselectMask() { if (isEnabled()) - m_undoHistory->undo_set_mask(m_document); + m_undoHistory->pushUndoer(new undoers::SetMask(m_undoHistory->getObjects(), + m_document)); m_document->setMaskVisible(false); } diff --git a/src/undoers/flip_image.cpp b/src/undoers/flip_image.cpp index f3405d8b1..db3d26843 100644 --- a/src/undoers/flip_image.cpp +++ b/src/undoers/flip_image.cpp @@ -29,11 +29,11 @@ using namespace undo; using namespace undoers; -FlipImage::FlipImage(ObjectsContainer* objects, Image* image, int x, int y, int w, int h, FlipType flipType) +FlipImage::FlipImage(ObjectsContainer* objects, Image* image, int x, int y, int w, int h, int flipFlags) : m_imageId(objects->addObject(image)) , m_imgtype(image->imgtype) , m_x(x), m_y(y), m_w(w), m_h(h) - , m_flipType(flipType) + , m_flipFlags(flipFlags) { ASSERT(w >= 1 && h >= 1); ASSERT(x >= 0 && y >= 0 && x+w <= image->w && y+h <= image->h); @@ -51,7 +51,7 @@ void FlipImage::revert(ObjectsContainer* objects, UndoersCollector* redoers) if (image->imgtype != m_imgtype) throw UndoException("Image type does not match"); - redoers->pushUndoer(new FlipImage(objects, image, m_x, m_y, m_w, m_h, m_flipType)); + redoers->pushUndoer(new FlipImage(objects, image, m_x, m_y, m_w, m_h, m_flipFlags)); UniquePtr area(image_crop(image, m_x, m_y, m_w, m_h, 0)); int x, y; @@ -61,7 +61,7 @@ void FlipImage::revert(ObjectsContainer* objects, UndoersCollector* redoers) for (y=0; yisEnabled()) { undo->setLabel("Move Cel"); undo->setModification(undo::ModifyDocument); - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); - undo->undo_set_layer(sprite); - undo->undo_set_frame(sprite); + undo->pushUndoer(new undoers::SetCurrentLayer(undo->getObjects(), sprite)); + undo->pushUndoer(new undoers::SetCurrentFrame(undo->getObjects(), sprite)); } sprite->setCurrentLayer(dst_layer); @@ -101,7 +110,7 @@ void move_cel(DocumentWriter& document) /* move the cel in different layers */ else { if (undo->isEnabled()) - undo->undo_remove_cel(src_layer, src_cel); + undo->pushUndoer(new undoers::RemoveCel(undo->getObjects(), src_layer, src_cel)); static_cast(src_layer)->removeCel(src_cel); src_cel->setFrame(dst_frame); @@ -119,7 +128,8 @@ void move_cel(DocumentWriter& document) sprite->getHeight(), 0); if (undo->isEnabled()) { - undo->undo_replace_image(sprite->getStock(), src_cel->getImage()); + undo->pushUndoer(new undoers::ReplaceImage(undo->getObjects(), + sprite->getStock(), src_cel->getImage())); undo->pushUndoer(new undoers::SetCelPosition(undo->getObjects(), src_cel)); undo->pushUndoer(new undoers::SetCelOpacity(undo->getObjects(), src_cel)); } @@ -135,14 +145,14 @@ void move_cel(DocumentWriter& document) } if (undo->isEnabled()) - undo->undo_add_cel(dst_layer, src_cel); + undo->pushUndoer(new undoers::AddCel(undo->getObjects(), dst_layer, src_cel)); static_cast(dst_layer)->addCel(src_cel); } } if (undo->isEnabled()) - undo->undo_close(); + undo->pushUndoer(new undoers::CloseGroup()); set_frame_to_handle(NULL, 0, NULL, 0); } @@ -164,10 +174,10 @@ void copy_cel(DocumentWriter& document) if (undo->isEnabled()) { undo->setLabel("Move Cel"); undo->setModification(undo::ModifyDocument); - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); - undo->undo_set_layer(sprite); - undo->undo_set_frame(sprite); + undo->pushUndoer(new undoers::SetCurrentLayer(undo->getObjects(), sprite)); + undo->pushUndoer(new undoers::SetCurrentFrame(undo->getObjects(), sprite)); } sprite->setCurrentLayer(dst_layer); @@ -215,7 +225,8 @@ void copy_cel(DocumentWriter& document) /* add the image in the stock */ image_index = sprite->getStock()->addImage(dst_image); if (undo->isEnabled()) - undo->undo_add_image(sprite->getStock(), image_index); + undo->pushUndoer(new undoers::AddImage(undo->getObjects(), + sprite->getStock(), image_index)); /* create the new cel */ dst_cel = new Cel(dst_frame, image_index); @@ -223,13 +234,13 @@ void copy_cel(DocumentWriter& document) dst_cel->setOpacity(dst_cel_opacity); if (undo->isEnabled()) - undo->undo_add_cel(dst_layer, dst_cel); + undo->pushUndoer(new undoers::AddCel(undo->getObjects(), dst_layer, dst_cel)); static_cast(dst_layer)->addCel(dst_cel); } if (undo->isEnabled()) - undo->undo_close(); + undo->pushUndoer(new undoers::CloseGroup()); set_frame_to_handle(NULL, 0, NULL, 0); } @@ -254,23 +265,24 @@ static void remove_cel(Sprite* sprite, undo::UndoHistory* undo, LayerImage *laye } if (undo->isEnabled()) - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); if (!used) { - /* if the image is only used by this cel, we can remove the - image from the stock */ + // If the image is only used by this cel, we can remove the + // image from the stock. image = sprite->getStock()->getImage(cel->getImage()); if (undo->isEnabled()) - undo->undo_remove_image(sprite->getStock(), cel->getImage()); + undo->pushUndoer(new undoers::RemoveImage(undo->getObjects(), + sprite->getStock(), cel->getImage())); sprite->getStock()->removeImage(image); image_free(image); } if (undo->isEnabled()) { - undo->undo_remove_cel(layer, cel); - undo->undo_close(); + undo->pushUndoer(new undoers::RemoveCel(undo->getObjects(), layer, cel)); + undo->pushUndoer(new undoers::CloseGroup()); } // Remove the cel diff --git a/src/util/clipboard.cpp b/src/util/clipboard.cpp index abc7f4026..10f17c814 100644 --- a/src/util/clipboard.cpp +++ b/src/util/clipboard.cpp @@ -40,6 +40,8 @@ #include "ui_context.h" #include "undo/undo_history.h" #include "undo_transaction.h" +#include "undoers/add_image.h" +#include "undoers/image_area.h" #include "util/clipboard.h" #include "util/misc.h" #include "widgets/color_bar.h" @@ -236,7 +238,8 @@ void clipboard::paste(DocumentWriter& document) // Add the new image in the stock int dst_image_index = sprite->getStock()->addImage(dst_image); if (undo->isEnabled()) - undo->undo_add_image(sprite->getStock(), dst_image_index); + undo->pushUndoer(new undoers::AddImage(undo->getObjects(), + sprite->getStock(), dst_image_index)); // Create the new cel in the current frame with the recently // created image @@ -293,11 +296,12 @@ void clipboard::paste(DocumentWriter& document) h = v2-v1+1; if (w >= 1 && h >= 1) { - /* undo region */ + // Add information to hold the modified region in the image. if (undo->isEnabled()) - undo->undo_image(dst_image, u1, v1, w, h); + undo->pushUndoer(new undoers::ImageArea(undo->getObjects(), + dst_image, u1, v1, w, h)); - /* draw the transformed image */ + // Draw the transformed image. image_parallelogram(dst_image, src_image, xout[0], yout[0], xout[1], yout[1], xout[2], yout[2], xout[3], yout[3]); diff --git a/src/widgets/editor/editor.cpp b/src/widgets/editor/editor.cpp index a6064f36a..76e05fdad 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/widgets/editor/editor.cpp @@ -20,8 +20,7 @@ #include "config.h" -#include -#include +#include "widgets/editor/editor.h" #include "app.h" #include "app/color.h" @@ -41,15 +40,23 @@ #include "tools/tool.h" #include "ui_context.h" #include "undo/undo_history.h" +#include "undoers/add_cel.h" +#include "undoers/add_image.h" +#include "undoers/close_group.h" +#include "undoers/dirty_area.h" +#include "undoers/open_group.h" +#include "undoers/replace_image.h" #include "undoers/set_cel_position.h" #include "util/boundary.h" #include "util/misc.h" #include "util/render.h" #include "widgets/color_bar.h" -#include "widgets/editor/editor.h" #include "widgets/editor/pixels_movement.h" #include "widgets/statebar.h" +#include +#include + #define has_shifts(msg,shift) \ (((msg)->any.shifts & (shift)) == (shift)) @@ -1935,10 +1942,12 @@ public: // We create the undo information (for the new cel_image // in the stock and the new cel in the layer)... - undo->undo_open(); - undo->undo_add_image(m_sprite->getStock(), m_cel->getImage()); - undo->undo_add_cel(m_sprite->getCurrentLayer(), m_cel); - undo->undo_close(); + undo->pushUndoer(new undoers::OpenGroup()); + undo->pushUndoer(new undoers::AddImage(undo->getObjects(), + m_sprite->getStock(), m_cel->getImage())); + undo->pushUndoer(new undoers::AddCel(undo->getObjects(), + m_sprite->getCurrentLayer(), m_cel)); + undo->pushUndoer(new undoers::CloseGroup()); // And finally we add the cel again in the layer. static_cast(m_sprite->getCurrentLayer())->addCel(m_cel); @@ -1952,7 +1961,8 @@ public: dirty->saveImagePixels(m_cel_image); if (dirty != NULL) - undo->undo_dirty(m_cel_image, dirty); + undo->pushUndoer(new undoers::DirtyArea(undo->getObjects(), + m_cel_image, dirty)); delete dirty; } @@ -1965,7 +1975,7 @@ public: // replace the entire image. else { if (undo->isEnabled()) { - undo->undo_open(); + undo->pushUndoer(new undoers::OpenGroup()); if (m_cel->getX() != m_old_cel_x || m_cel->getY() != m_old_cel_y) { @@ -1978,8 +1988,9 @@ public: m_cel->setPosition(x, y); } - undo->undo_replace_image(m_sprite->getStock(), m_cel->getImage()); - undo->undo_close(); + undo->pushUndoer(new undoers::ReplaceImage(undo->getObjects(), + m_sprite->getStock(), m_cel->getImage())); + undo->pushUndoer(new undoers::CloseGroup()); } // Replace the image in the stock.