Keep/restore the timeline position for each sprite/DocView (fix #3676)

In this way the store (in memory) the exact timeline position for each
DocView. Useful when editing multiple sprites and the timeline jumps
from one side to another.
This commit is contained in:
David Capello 2023-01-17 17:17:57 -03:00
parent f536327fc1
commit 6080af5346
2 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2020 Igara Studio S.A.
// Copyright (C) 2019-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -55,6 +55,10 @@ namespace app {
bool isPreview() { return m_type == Preview; }
// Preferred timeline scroll
const gfx::Point& timelineScroll() { return m_timelineScroll; }
void setTimelineScroll(const gfx::Point& pt) { m_timelineScroll = pt; }
// TabView implementation
std::string getTabText() override;
TabIcon getTabIcon() override;
@ -106,6 +110,7 @@ namespace app {
ui::View* m_view;
DocViewPreviewDelegate* m_previewDelegate;
Editor* m_editor;
gfx::Point m_timelineScroll;
};
} // namespace app

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2018-2022 Igara Studio S.A.
// Copyright (C) 2018-2023 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -390,7 +390,7 @@ void Timeline::updateUsingEditor(Editor* editor)
setFocusStop(true);
regenerateRows();
setViewScroll(viewScroll());
setViewScroll(view->timelineScroll());
showCurrentCel();
}
@ -417,6 +417,9 @@ void Timeline::detachDocument()
m_dropRange.clearRange();
if (m_editor) {
if (DocView* view = m_editor->getDocView())
view->setTimelineScroll(viewScroll());
m_editor->remove_observer(this);
m_editor = nullptr;
}