Add option to play/preview with subtags & repetitions

This commit is contained in:
David Capello 2022-10-20 14:41:24 -03:00
parent 4f96d37b1f
commit 9601c02812
10 changed files with 51 additions and 18 deletions

View File

@ -180,6 +180,7 @@
<option id="straight_line_preview" type="bool" default="true" /> <option id="straight_line_preview" type="bool" default="true" />
<option id="play_once" type="bool" default="false" /> <option id="play_once" type="bool" default="false" />
<option id="play_all" type="bool" default="false" /> <option id="play_all" type="bool" default="false" />
<option id="play_subtags" type="bool" default="false" />
<!-- TODO this would be nice to be "true" but we have to fix <!-- TODO this would be nice to be "true" but we have to fix
some performance issue rendering huge sprites with small some performance issue rendering huge sprites with small
zoom levels --> zoom levels -->
@ -211,6 +212,7 @@
<section id="preview" text="Preview"> <section id="preview" text="Preview">
<option id="play_once" type="bool" default="false" /> <option id="play_once" type="bool" default="false" />
<option id="play_all" type="bool" default="false" /> <option id="play_all" type="bool" default="false" />
<option id="play_subtags" type="bool" default="false" />
</section> </section>
<section id="theme" text="Theme"> <section id="theme" text="Theme">
<option id="selected" type="std::string" default="&quot;default&quot;" /> <option id="selected" type="std::string" default="&quot;default&quot;" />

View File

@ -1775,6 +1775,7 @@ title = Preview
speed_x = Speed x{} speed_x = Speed x{}
play_once = Play Once play_once = Play Once
play_all_no_tags = Play All Frames (Ignore Tags) play_all_no_tags = Play All Frames (Ignore Tags)
play_subtags_and_repeats = Play Subtags & Repetitions
rewind_on_stop = Rewind on Stop rewind_on_stop = Rewind on Stop
[recover_files] [recover_files]

View File

@ -1,4 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2022 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
@ -62,7 +63,8 @@ void PlayAnimationCommand::onExecute(Context* context)
current_editor->stop(); current_editor->stop();
else else
current_editor->play(Preferences::instance().editor.playOnce(), current_editor->play(Preferences::instance().editor.playOnce(),
Preferences::instance().editor.playAll()); Preferences::instance().editor.playAll(),
Preferences::instance().editor.playSubtags());
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

View File

@ -2754,7 +2754,8 @@ void Editor::startZoomingState(ui::MouseMessage* msg)
} }
void Editor::play(const bool playOnce, void Editor::play(const bool playOnce,
const bool playAll) const bool playAll,
const bool playSubtags)
{ {
ASSERT(m_state); ASSERT(m_state);
if (!m_state) if (!m_state)
@ -2764,7 +2765,9 @@ void Editor::play(const bool playOnce,
stop(); stop();
m_isPlaying = true; m_isPlaying = true;
setState(EditorStatePtr(new PlayState(playOnce, playAll))); setState(EditorStatePtr(new PlayState(playOnce,
playAll,
playSubtags)));
} }
void Editor::stop() void Editor::stop()
@ -2792,6 +2795,7 @@ bool Editor::isPlaying() const
void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce, void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
Option<bool>& playAll, Option<bool>& playAll,
Option<bool>& playSubtags,
const bool withStopBehaviorOptions) const bool withStopBehaviorOptions)
{ {
const double options[] = { 0.25, 0.5, 1.0, 1.5, 2.0, 3.0 }; const double options[] = { 0.25, 0.5, 1.0, 1.5, 2.0, 3.0 };
@ -2828,6 +2832,17 @@ void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
menu.addChild(item); menu.addChild(item);
} }
// Play subtags & repeats
{
MenuItem* item = new MenuItem(Strings::preview_play_subtags_and_repeats());
item->Click.connect(
[&playSubtags]() {
playSubtags(!playSubtags());
});
item->setSelected(playSubtags());
menu.addChild(item);
}
if (withStopBehaviorOptions) { if (withStopBehaviorOptions) {
MenuItem* item = new MenuItem(Strings::preview_rewind_on_stop()); MenuItem* item = new MenuItem(Strings::preview_rewind_on_stop());
item->Click.connect( item->Click.connect(
@ -2846,7 +2861,8 @@ void Editor::showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
// Re-play // Re-play
stop(); stop();
play(playOnce(), play(playOnce(),
playAll()); playAll(),
playSubtags());
} }
} }

View File

@ -274,13 +274,15 @@ namespace app {
// Animation control // Animation control
void play(const bool playOnce, void play(const bool playOnce,
const bool playAll); const bool playAll,
const bool playSubtags);
void stop(); void stop();
bool isPlaying() const; bool isPlaying() const;
// Shows a popup menu to change the editor animation speed. // Shows a popup menu to change the editor animation speed.
void showAnimationSpeedMultiplierPopup(Option<bool>& playOnce, void showAnimationSpeedMultiplierPopup(Option<bool>& playOnce,
Option<bool>& playAll, Option<bool>& playAll,
Option<bool>& playSubtags,
const bool withStopBehaviorOptions); const bool withStopBehaviorOptions);
double getAnimationSpeedMultiplier() const; double getAnimationSpeedMultiplier() const;
void setAnimationSpeedMultiplier(double speed); void setAnimationSpeedMultiplier(double speed);

View File

@ -31,10 +31,12 @@ namespace app {
using namespace ui; using namespace ui;
PlayState::PlayState(const bool playOnce, PlayState::PlayState(const bool playOnce,
const bool playAll) const bool playAll,
const bool playSubtags)
: m_editor(nullptr) : m_editor(nullptr)
, m_playOnce(playOnce) , m_playOnce(playOnce)
, m_playAll(playAll) , m_playAll(playAll)
, m_playSubtags(playSubtags)
, m_toScroll(false) , m_toScroll(false)
, m_playTimer(10) , m_playTimer(10)
, m_nextFrameTime(-1) , m_nextFrameTime(-1)
@ -83,13 +85,14 @@ void PlayState::onEnterState(Editor* editor)
m_editor->setFrame(frame); m_editor->setFrame(frame);
} }
m_playback = doc::Playback(m_editor->sprite(), m_playback = doc::Playback(
TagsList(), // TODO add support to follow subtags m_editor->sprite(),
m_editor->frame(), m_playSubtags ? m_editor->sprite()->tags().getInternalList() : TagsList(),
m_playOnce ? doc::Playback::PlayOnce: m_editor->frame(),
m_playAll ? doc::Playback::PlayWithoutTagsInLoop: m_playOnce ? doc::Playback::PlayOnce :
doc::Playback::PlayInLoop, m_playAll ? doc::Playback::PlayWithoutTagsInLoop :
m_tag); doc::Playback::PlayInLoop,
m_tag);
m_toScroll = false; m_toScroll = false;
m_nextFrameTime = getNextFrameTime(); m_nextFrameTime = getNextFrameTime();

View File

@ -27,7 +27,8 @@ namespace app {
class PlayState : public StateWithWheelBehavior { class PlayState : public StateWithWheelBehavior {
public: public:
PlayState(const bool playOnce, PlayState(const bool playOnce,
const bool playAll); const bool playAll,
const bool playSubtags);
doc::Tag* playingTag() const; doc::Tag* playingTag() const;
@ -54,6 +55,7 @@ namespace app {
doc::Playback m_playback; doc::Playback m_playback;
bool m_playOnce; bool m_playOnce;
bool m_playAll; bool m_playAll;
bool m_playSubtags;
bool m_toScroll; bool m_toScroll;
ui::Timer m_playTimer; ui::Timer m_playTimer;

View File

@ -317,7 +317,8 @@ void PreviewEditorWindow::onPlayClicked()
if (m_playButton->isPlaying()) { if (m_playButton->isPlaying()) {
m_refFrame = miniEditor->frame(); m_refFrame = miniEditor->frame();
miniEditor->play(Preferences::instance().preview.playOnce(), miniEditor->play(Preferences::instance().preview.playOnce(),
Preferences::instance().preview.playAll()); Preferences::instance().preview.playAll(),
Preferences::instance().preview.playSubtags());
} }
else { else {
miniEditor->stop(); miniEditor->stop();
@ -337,6 +338,7 @@ void PreviewEditorWindow::onPopupSpeed()
miniEditor->showAnimationSpeedMultiplierPopup( miniEditor->showAnimationSpeedMultiplierPopup(
pref.preview.playOnce, pref.preview.playOnce,
pref.preview.playAll, pref.preview.playAll,
pref.preview.playSubtags,
false); false);
m_aniSpeed = miniEditor->getAnimationSpeedMultiplier(); m_aniSpeed = miniEditor->getAnimationSpeedMultiplier();
} }
@ -513,7 +515,8 @@ void PreviewEditorWindow::adjustPlayingTag()
miniEditor->setFrame(m_refFrame = editor->frame()); miniEditor->setFrame(m_refFrame = editor->frame());
miniEditor->play(Preferences::instance().preview.playOnce(), miniEditor->play(Preferences::instance().preview.playOnce(),
Preferences::instance().preview.playAll()); Preferences::instance().preview.playAll(),
Preferences::instance().preview.playSubtags());
} }
} // namespace app } // namespace app

View File

@ -95,7 +95,8 @@ void AniControls::onRightClick(Item* item)
if (item == getItem(ACTION_PLAY) && current_editor) if (item == getItem(ACTION_PLAY) && current_editor)
current_editor->showAnimationSpeedMultiplierPopup( current_editor->showAnimationSpeedMultiplierPopup(
Preferences::instance().editor.playOnce, Preferences::instance().editor.playOnce,
Preferences::instance().editor.playAll, true); Preferences::instance().editor.playAll,
Preferences::instance().editor.playSubtags, true);
} }
const char* AniControls::getCommandId(int index) const const char* AniControls::getCommandId(int index) const

View File

@ -513,7 +513,8 @@ void Timeline::setFrame(frame_t frame, bool byUser)
if (isPlaying) if (isPlaying)
m_editor->play(false, m_editor->play(false,
Preferences::instance().editor.playAll()); Preferences::instance().editor.playAll(),
Preferences::instance().editor.playSubtags());
} }
} }