From 76afcfedac506c9603ef9642b9ae98d30023c6ea Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 1 Jun 2014 18:10:26 -0300 Subject: [PATCH] Change current palette after undo/redo --- src/app/commands/cmd_undo.cpp | 2 ++ src/app/context_access.h | 4 ++++ src/app/document_location.cpp | 5 +++++ src/app/document_location.h | 1 + 4 files changed, 12 insertions(+) diff --git a/src/app/commands/cmd_undo.cpp b/src/app/commands/cmd_undo.cpp index 687223b86..55fcaf461 100644 --- a/src/app/commands/cmd_undo.cpp +++ b/src/app/commands/cmd_undo.cpp @@ -27,6 +27,7 @@ #include "app/ini_file.h" #include "app/modules/editors.h" #include "app/modules/gui.h" +#include "app/modules/palettes.h" #include "app/ui/editor/editor.h" #include "app/ui/status_bar.h" #include "base/thread.h" @@ -117,6 +118,7 @@ void UndoCommand::onExecute(Context* context) document->destroyExtraCel(); // Regenerate extras update_screen_for_document(document); + set_current_palette(writer.palette(), false); } Command* CommandFactory::createUndoCommand() diff --git a/src/app/context_access.h b/src/app/context_access.h index a773a4747..fd0d9977e 100644 --- a/src/app/context_access.h +++ b/src/app/context_access.h @@ -51,6 +51,10 @@ namespace app { return m_location.image(x, y, opacity); } + Palette* palette() const { + return m_location.palette(); + } + protected: ContextAccess(const Context* context) : m_context(context) diff --git a/src/app/document_location.cpp b/src/app/document_location.cpp index 0cfb2beaf..f920e0ead 100644 --- a/src/app/document_location.cpp +++ b/src/app/document_location.cpp @@ -84,4 +84,9 @@ Image* DocumentLocation::image(int* x, int* y, int* opacity) const return image; } +Palette* DocumentLocation::palette() const +{ + return (m_sprite ? m_sprite->getPalette(m_frame): NULL); +} + } // namespace app diff --git a/src/app/document_location.h b/src/app/document_location.h index 1feae9e92..10ed1567a 100644 --- a/src/app/document_location.h +++ b/src/app/document_location.h @@ -67,6 +67,7 @@ namespace app { void layerIndex(LayerIndex layerIndex); Palette* palette(); Image* image(int* x = NULL, int* y = NULL, int* opacity = NULL) const; + Palette* palette() const; private: Document* m_document;