mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-26 09:19:27 +00:00
Remember last frame/layer visited for each document (fix #486)
This commit is contained in:
parent
09bfa3e61b
commit
1af22f1ab7
@ -114,6 +114,10 @@
|
||||
</tool>
|
||||
|
||||
<document>
|
||||
<section id="site">
|
||||
<option id="frame" type="doc::frame_t" default="doc::frame_t(0)" />
|
||||
<option id="layer" type="doc::LayerIndex" />
|
||||
</section>
|
||||
<section id="tiled">
|
||||
<option id="mode" type="filters::TiledMode" default="filters::TiledMode::NONE" migrate="Tools.Tiled" />
|
||||
</section>
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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<void>(&Editor::invalidate, this));
|
||||
m_gridConn = docPref.grid.AfterChange.connect(Bind<void>(&Editor::invalidate, this));
|
||||
m_pixelGridConn = docPref.pixelGrid.AfterChange.connect(Bind<void>(&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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user