mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-14 18:40:55 +00:00
Fix playback of same tag when adding new frames (fix https://community.aseprite.org/t/6486)
This commit is contained in:
parent
0c0510b3b1
commit
2a48c688e2
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2015 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -11,7 +11,11 @@
|
|||||||
|
|
||||||
#include "app/cmd/set_tag_range.h"
|
#include "app/cmd/set_tag_range.h"
|
||||||
|
|
||||||
|
#include "app/doc.h"
|
||||||
|
#include "app/doc_event.h"
|
||||||
|
#include "doc/sprite.h"
|
||||||
#include "doc/tag.h"
|
#include "doc/tag.h"
|
||||||
|
#include "doc/tags.h"
|
||||||
|
|
||||||
namespace app {
|
namespace app {
|
||||||
namespace cmd {
|
namespace cmd {
|
||||||
@ -37,5 +41,16 @@ void SetTagRange::onUndo()
|
|||||||
tag()->incrementVersion();
|
tag()->incrementVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetTagRange::onFireNotifications()
|
||||||
|
{
|
||||||
|
Tag* tag = this->tag();
|
||||||
|
Sprite* sprite = tag->owner()->sprite();
|
||||||
|
Doc* doc = static_cast<Doc*>(sprite->document());
|
||||||
|
DocEvent ev(doc);
|
||||||
|
ev.sprite(sprite);
|
||||||
|
ev.tag(tag);
|
||||||
|
doc->notify_observers<DocEvent&>(&DocObserver::onTagChange, ev);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cmd
|
} // namespace cmd
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2019 Igara Studio S.A.
|
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2015 David Capello
|
// Copyright (C) 2001-2015 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -25,6 +25,7 @@ namespace cmd {
|
|||||||
protected:
|
protected:
|
||||||
void onExecute() override;
|
void onExecute() override;
|
||||||
void onUndo() override;
|
void onUndo() override;
|
||||||
|
void onFireNotifications() override;
|
||||||
size_t onMemSize() const override {
|
size_t onMemSize() const override {
|
||||||
return sizeof(*this);
|
return sizeof(*this);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
// Copyright (C) 2018-2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -73,6 +73,9 @@ namespace app {
|
|||||||
virtual void onSelectionChanged(DocEvent& ev) { }
|
virtual void onSelectionChanged(DocEvent& ev) { }
|
||||||
virtual void onSelectionBoundariesChanged(DocEvent& ev) { }
|
virtual void onSelectionBoundariesChanged(DocEvent& ev) { }
|
||||||
|
|
||||||
|
// Tags
|
||||||
|
virtual void onTagChange(DocEvent& ev) { }
|
||||||
|
|
||||||
// Slices
|
// Slices
|
||||||
virtual void onSliceNameChange(DocEvent& ev) { }
|
virtual void onSliceNameChange(DocEvent& ev) { }
|
||||||
|
|
||||||
|
@ -417,6 +417,12 @@ void DocView::onRemoveFrame(DocEvent& ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DocView::onTagChange(DocEvent& ev)
|
||||||
|
{
|
||||||
|
if (m_previewDelegate)
|
||||||
|
m_previewDelegate->onTagChangeEditor(m_editor, ev);
|
||||||
|
}
|
||||||
|
|
||||||
void DocView::onAddCel(DocEvent& ev)
|
void DocView::onAddCel(DocEvent& ev)
|
||||||
{
|
{
|
||||||
UIContext::instance()->notifyActiveSiteChanged();
|
UIContext::instance()->notifyActiveSiteChanged();
|
||||||
|
@ -30,6 +30,7 @@ namespace app {
|
|||||||
virtual void onScrollOtherEditor(Editor* editor) = 0;
|
virtual void onScrollOtherEditor(Editor* editor) = 0;
|
||||||
virtual void onDisposeOtherEditor(Editor* editor) = 0;
|
virtual void onDisposeOtherEditor(Editor* editor) = 0;
|
||||||
virtual void onPreviewOtherEditor(Editor* editor) = 0;
|
virtual void onPreviewOtherEditor(Editor* editor) = 0;
|
||||||
|
virtual void onTagChangeEditor(Editor* editor, DocEvent& ev) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DocView : public ui::Box,
|
class DocView : public ui::Box,
|
||||||
@ -75,6 +76,7 @@ namespace app {
|
|||||||
void onAddLayer(DocEvent& ev) override;
|
void onAddLayer(DocEvent& ev) override;
|
||||||
void onAddFrame(DocEvent& ev) override;
|
void onAddFrame(DocEvent& ev) override;
|
||||||
void onRemoveFrame(DocEvent& ev) override;
|
void onRemoveFrame(DocEvent& ev) override;
|
||||||
|
void onTagChange(DocEvent& ev) override;
|
||||||
void onAddCel(DocEvent& ev) override;
|
void onAddCel(DocEvent& ev) override;
|
||||||
void onRemoveCel(DocEvent& ev) override;
|
void onRemoveCel(DocEvent& ev) override;
|
||||||
void onTotalFramesChanged(DocEvent& ev) override;
|
void onTotalFramesChanged(DocEvent& ev) override;
|
||||||
|
@ -51,6 +51,11 @@ PlayState::PlayState(const bool playOnce,
|
|||||||
&PlayState::onBeforeCommandExecution, this);
|
&PlayState::onBeforeCommandExecution, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tag* PlayState::playingTag() const
|
||||||
|
{
|
||||||
|
return m_tag;
|
||||||
|
}
|
||||||
|
|
||||||
void PlayState::onEnterState(Editor* editor)
|
void PlayState::onEnterState(Editor* editor)
|
||||||
{
|
{
|
||||||
StateWithWheelBehavior::onEnterState(editor);
|
StateWithWheelBehavior::onEnterState(editor);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2017 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -27,6 +28,8 @@ namespace app {
|
|||||||
PlayState(const bool playOnce,
|
PlayState(const bool playOnce,
|
||||||
const bool playAll);
|
const bool playAll);
|
||||||
|
|
||||||
|
doc::Tag* playingTag() const;
|
||||||
|
|
||||||
void onEnterState(Editor* editor) override;
|
void onEnterState(Editor* editor) override;
|
||||||
LeaveAction onLeaveState(Editor* editor, EditorState* newState) override;
|
LeaveAction onLeaveState(Editor* editor, EditorState* newState) override;
|
||||||
bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
|
bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "app/app.h"
|
#include "app/app.h"
|
||||||
#include "app/doc.h"
|
#include "app/doc.h"
|
||||||
|
#include "app/doc_event.h"
|
||||||
#include "app/ini_file.h"
|
#include "app/ini_file.h"
|
||||||
#include "app/loop_tag.h"
|
#include "app/loop_tag.h"
|
||||||
#include "app/modules/editors.h"
|
#include "app/modules/editors.h"
|
||||||
@ -22,6 +23,7 @@
|
|||||||
#include "app/ui/editor/editor_customization_delegate.h"
|
#include "app/ui/editor/editor_customization_delegate.h"
|
||||||
#include "app/ui/editor/editor_view.h"
|
#include "app/ui/editor/editor_view.h"
|
||||||
#include "app/ui/editor/navigate_state.h"
|
#include "app/ui/editor/navigate_state.h"
|
||||||
|
#include "app/ui/editor/play_state.h"
|
||||||
#include "app/ui/skin/skin_theme.h"
|
#include "app/ui/skin/skin_theme.h"
|
||||||
#include "app/ui/status_bar.h"
|
#include "app/ui/status_bar.h"
|
||||||
#include "app/ui/toolbar.h"
|
#include "app/ui/toolbar.h"
|
||||||
@ -396,28 +398,7 @@ void PreviewEditorWindow::updateUsingEditor(Editor* editor)
|
|||||||
miniEditor->setFrame(editor->frame());
|
miniEditor->setFrame(editor->frame());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (miniEditor->isPlaying()) {
|
adjustPlayingTag();
|
||||||
doc::Tag* tag = editor
|
|
||||||
->getCustomizationDelegate()
|
|
||||||
->getTagProvider()
|
|
||||||
->getTagByFrame(editor->frame(), true);
|
|
||||||
|
|
||||||
doc::Tag* playingTag = editor
|
|
||||||
->getCustomizationDelegate()
|
|
||||||
->getTagProvider()
|
|
||||||
->getTagByFrame(m_refFrame, true);
|
|
||||||
|
|
||||||
if (tag == playingTag)
|
|
||||||
return;
|
|
||||||
|
|
||||||
miniEditor->stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!miniEditor->isPlaying())
|
|
||||||
miniEditor->setFrame(m_refFrame = editor->frame());
|
|
||||||
|
|
||||||
miniEditor->play(Preferences::instance().preview.playOnce(),
|
|
||||||
Preferences::instance().preview.playAll());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,6 +459,11 @@ void PreviewEditorWindow::onPreviewOtherEditor(Editor* editor)
|
|||||||
updateUsingEditor(editor);
|
updateUsingEditor(editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewEditorWindow::onTagChangeEditor(Editor* editor, DocEvent& ev)
|
||||||
|
{
|
||||||
|
adjustPlayingTag();
|
||||||
|
}
|
||||||
|
|
||||||
void PreviewEditorWindow::hideWindow()
|
void PreviewEditorWindow::hideWindow()
|
||||||
{
|
{
|
||||||
destroyDocView();
|
destroyDocView();
|
||||||
@ -495,4 +481,34 @@ void PreviewEditorWindow::destroyDocView()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PreviewEditorWindow::adjustPlayingTag()
|
||||||
|
{
|
||||||
|
Editor* editor = m_relatedEditor;
|
||||||
|
Editor* miniEditor = m_docView->editor();
|
||||||
|
|
||||||
|
ASSERT(editor);
|
||||||
|
ASSERT(miniEditor);
|
||||||
|
|
||||||
|
if (miniEditor->isPlaying()) {
|
||||||
|
doc::Tag* tag = editor
|
||||||
|
->getCustomizationDelegate()
|
||||||
|
->getTagProvider()
|
||||||
|
->getTagByFrame(editor->frame(), true);
|
||||||
|
|
||||||
|
auto playState = dynamic_cast<PlayState*>(miniEditor->getState().get());
|
||||||
|
doc::Tag* playingTag = (playState ? playState->playingTag(): nullptr);
|
||||||
|
|
||||||
|
if (tag == playingTag)
|
||||||
|
return;
|
||||||
|
|
||||||
|
miniEditor->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!miniEditor->isPlaying())
|
||||||
|
miniEditor->setFrame(m_refFrame = editor->frame());
|
||||||
|
|
||||||
|
miniEditor->play(Preferences::instance().preview.playOnce(),
|
||||||
|
Preferences::instance().preview.playAll());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace app
|
} // namespace app
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
|
// Copyright (C) 2020 Igara Studio S.A.
|
||||||
// Copyright (C) 2001-2018 David Capello
|
// Copyright (C) 2001-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -42,6 +43,7 @@ namespace app {
|
|||||||
void onScrollOtherEditor(Editor* editor) override;
|
void onScrollOtherEditor(Editor* editor) override;
|
||||||
void onDisposeOtherEditor(Editor* editor) override;
|
void onDisposeOtherEditor(Editor* editor) override;
|
||||||
void onPreviewOtherEditor(Editor* editor) override;
|
void onPreviewOtherEditor(Editor* editor) override;
|
||||||
|
void onTagChangeEditor(Editor* editor, DocEvent& ev) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onProcessMessage(ui::Message* msg) override;
|
bool onProcessMessage(ui::Message* msg) override;
|
||||||
@ -59,6 +61,7 @@ namespace app {
|
|||||||
void hideWindow();
|
void hideWindow();
|
||||||
void destroyDocView();
|
void destroyDocView();
|
||||||
void saveScrollPref();
|
void saveScrollPref();
|
||||||
|
void adjustPlayingTag();
|
||||||
|
|
||||||
bool m_isEnabled;
|
bool m_isEnabled;
|
||||||
DocView* m_docView;
|
DocView* m_docView;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user