diff --git a/data/pref.xml b/data/pref.xml index 4bfccfa70..9ceab9652 100644 --- a/data/pref.xml +++ b/data/pref.xml @@ -114,6 +114,10 @@ +
+
diff --git a/src/app/pref/preferences.h b/src/app/pref/preferences.h index ffe2108f0..2a2eda41d 100644 --- a/src/app/pref/preferences.h +++ b/src/app/pref/preferences.h @@ -19,6 +19,7 @@ #include "doc/brush_pattern.h" #include "doc/documents_observer.h" #include "doc/frame.h" +#include "doc/layer_index.h" #include "filters/tiled_mode.h" #include "gfx/rect.h" diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 81bb790f0..9bbef3701 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -181,6 +181,14 @@ Editor::Editor(Document* document, EditorFlags flags) DocumentPreferences& docPref = Preferences::instance().document(m_document); + // Restore last site in preferences + frame_t preferredFrame = docPref.site.frame(); + Layer* preferredLayer = m_sprite->indexToLayer(docPref.site.layer()); + if (preferredFrame >= 0 && preferredFrame <= m_sprite->lastFrame()) + setFrame(preferredFrame); + if (preferredLayer) + setLayer(preferredLayer); + m_tiledConn = docPref.tiled.AfterChange.connect(Bind(&Editor::invalidate, this)); m_gridConn = docPref.grid.AfterChange.connect(Bind(&Editor::invalidate, this)); m_pixelGridConn = docPref.pixelGrid.AfterChange.connect(Bind(&Editor::invalidate, this)); @@ -193,6 +201,13 @@ Editor::Editor(Document* document, EditorFlags flags) Editor::~Editor() { + if (m_document && m_sprite) { + DocumentPreferences& docPref = Preferences::instance() + .document(m_document); + docPref.site.frame(frame()); + docPref.site.layer(m_sprite->layerToIndex(layer())); + } + m_observers.notifyDestroyEditor(this); m_document->removeObserver(this);