Save/restore focused tag band when we switch between editors

This commit is contained in:
David Capello 2017-04-14 10:02:02 -03:00
parent 2aeae2aaa7
commit dc9b1d826d
3 changed files with 29 additions and 5 deletions

View File

@ -175,6 +175,7 @@ Editor::Editor(Document* document, EditorFlags flags)
, m_aniSpeed(1.0)
, m_isPlaying(false)
, m_showGuidesThisCel(nullptr)
, m_tagFocusBand(-1)
{
m_proj.setPixelRatio(m_sprite->pixelRatio());
@ -1804,6 +1805,16 @@ void Editor::onSpritePixelRatioChanged(doc::DocumentEvent& ev)
invalidate();
}
void Editor::onAddFrameTag(DocumentEvent& ev)
{
m_tagFocusBand = -1;
}
void Editor::onRemoveFrameTag(DocumentEvent& ev)
{
m_tagFocusBand = -1;
}
void Editor::setCursor(const gfx::Point& mouseScreenPos)
{
bool used = false;

View File

@ -254,6 +254,9 @@ namespace app {
// IColorSource
app::Color getColorByPosition(const gfx::Point& pos) override;
void setTagFocusBand(int value) { m_tagFocusBand = value; }
int tagFocusBand() const { return m_tagFocusBand; }
protected:
bool onProcessMessage(ui::Message* msg) override;
void onSizeHint(ui::SizeHintEvent& ev) override;
@ -267,6 +270,8 @@ namespace app {
// DocumentObserver impl
void onExposeSpritePixels(doc::DocumentEvent& ev) override;
void onSpritePixelRatioChanged(doc::DocumentEvent& ev) override;
void onAddFrameTag(DocumentEvent& ev) override;
void onRemoveFrameTag(DocumentEvent& ev) override;
// ActiveToolObserver impl
void onActiveToolChange(tools::Tool* tool) override;
@ -378,6 +383,10 @@ namespace app {
// pressed (move key).
Cel* m_showGuidesThisCel;
// Focused tag band. Used by the Timeline to save/restore the
// focused tag band for each sprite/editor.
int m_tagFocusBand;
static doc::ImageBufferPtr m_renderBuffer;
// The render engine must be shared between all editors so when a

View File

@ -276,8 +276,12 @@ void Timeline::updateUsingEditor(Editor* editor)
m_aniControls.updateUsingEditor(editor);
if (editor != m_editor)
if (editor != m_editor) {
// Save active m_tagFocusBand into the old focused editor
if (m_editor)
m_editor->setTagFocusBand(m_tagFocusBand);
m_tagFocusBand = -1;
}
detachDocument();
@ -289,12 +293,12 @@ void Timeline::updateUsingEditor(Editor* editor)
// We always update the editor. In this way the timeline keeps in
// sync with the active editor.
m_editor = editor;
if (m_editor)
m_editor->add_observer(this);
else
if (!m_editor)
return; // No editor specified.
m_editor->add_observer(this);
m_tagFocusBand = m_editor->tagFocusBand();
Site site;
DocumentView* view = m_editor->getDocumentView();
view->getSite(&site);