diff --git a/data/pref.xml b/data/pref.xml
index f86c74d60..aa7fa6213 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -43,6 +43,7 @@
+
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index 12d7a0aa9..b25a0ef6e 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -8,6 +8,7 @@
+
@@ -26,7 +27,6 @@
-
@@ -60,6 +60,13 @@
+
+
+
+
+
+
+
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index 520f4a158..fc7db52c3 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -65,6 +65,9 @@ public:
if (m_preferences.general.autoshowTimeline())
autotimeline()->setSelected(true);
+ if (m_preferences.general.rewindOnStop())
+ rewindOnStop()->setSelected(true);
+
if (m_preferences.general.expandMenubarOnMouseover())
expandMenubarOnMouseover()->setSelected(true);
@@ -155,6 +158,7 @@ public:
void saveConfig() {
m_preferences.general.autoshowTimeline(autotimeline()->isSelected());
+ m_preferences.general.rewindOnStop(rewindOnStop()->isSelected());
bool expandOnMouseover = expandMenubarOnMouseover()->isSelected();
m_preferences.general.expandMenubarOnMouseover(expandOnMouseover);
diff --git a/src/app/ui/ani_controls.cpp b/src/app/ui/ani_controls.cpp
index d53a1b4d9..e59f75e74 100644
--- a/src/app/ui/ani_controls.cpp
+++ b/src/app/ui/ani_controls.cpp
@@ -109,7 +109,7 @@ void AniControls::onRightClick(Item* item)
ButtonSet::onRightClick(item);
if (item == getItem(ACTION_PLAY) && current_editor)
- current_editor->showAnimationSpeedMultiplierPopup();
+ current_editor->showAnimationSpeedMultiplierPopup(true);
}
} // namespace app
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index b35b7982e..2264ddba7 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -1599,18 +1599,31 @@ bool Editor::isPlaying() const
return (dynamic_cast(m_state.get()) != nullptr);
}
-void Editor::showAnimationSpeedMultiplierPopup()
+void Editor::showAnimationSpeedMultiplierPopup(bool withStopBehaviorOptions)
{
double options[] = { 0.25, 0.5, 1.0, 1.5, 2.0, 3.0 };
Menu menu;
for (double option : options) {
- MenuItem* item = new MenuItem("x" + base::convert_to(option));
+ MenuItem* item = new MenuItem("Speed x" + base::convert_to(option));
item->Click.connect(Bind(&Editor::setAnimationSpeedMultiplier, this, option));
item->setSelected(m_aniSpeed == option);
menu.addChild(item);
}
+ if (withStopBehaviorOptions) {
+ menu.addChild(new Separator("", JI_HORIZONTAL));
+ MenuItem* item = new MenuItem("Rewind on Stop");
+ item->Click.connect(
+ []() {
+ // Switch the "rewind_on_stop" option
+ Preferences::instance().general.rewindOnStop(
+ !Preferences::instance().general.rewindOnStop());
+ });
+ item->setSelected(Preferences::instance().general.rewindOnStop());
+ menu.addChild(item);
+ }
+
menu.showPopup(ui::get_mouse_position());
}
diff --git a/src/app/ui/editor/editor.h b/src/app/ui/editor/editor.h
index 0cf37d377..6df7d8e80 100644
--- a/src/app/ui/editor/editor.h
+++ b/src/app/ui/editor/editor.h
@@ -197,7 +197,7 @@ namespace app {
bool isPlaying() const;
// Shows a popup menu to change the editor animation speed.
- void showAnimationSpeedMultiplierPopup();
+ void showAnimationSpeedMultiplierPopup(bool withStopBehaviorOptions);
double getAnimationSpeedMultiplier() const;
void setAnimationSpeedMultiplier(double speed);
diff --git a/src/app/ui/editor/play_state.cpp b/src/app/ui/editor/play_state.cpp
index 1648b0d12..cf2700c6d 100644
--- a/src/app/ui/editor/play_state.cpp
+++ b/src/app/ui/editor/play_state.cpp
@@ -14,6 +14,7 @@
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/loop_tag.h"
+#include "app/pref/preferences.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/scrolling_state.h"
#include "app/ui_context.h"
@@ -64,7 +65,8 @@ void PlayState::onEnterState(Editor* editor)
EditorState::LeaveAction PlayState::onLeaveState(Editor* editor, EditorState* newState)
{
if (!m_toScroll) {
- m_editor->setFrame(m_refFrame);
+ if (Preferences::instance().general.rewindOnStop())
+ m_editor->setFrame(m_refFrame);
// We don't stop the timer if we are going to the ScrollingState
// (we keep playing the animation).
diff --git a/src/app/ui/preview_editor.cpp b/src/app/ui/preview_editor.cpp
index d49344a33..d552aab48 100644
--- a/src/app/ui/preview_editor.cpp
+++ b/src/app/ui/preview_editor.cpp
@@ -290,7 +290,7 @@ void PreviewEditorWindow::onPopupSpeed()
if (!miniEditor || !miniEditor->document())
return;
- miniEditor->showAnimationSpeedMultiplierPopup();
+ miniEditor->showAnimationSpeedMultiplierPopup(false);
m_aniSpeed = miniEditor->getAnimationSpeedMultiplier();
}