Add option to change the "Stop" button behavior (fix #705)

This commit is contained in:
David Capello 2015-06-19 12:09:34 -03:00
parent b70be3ccd4
commit 401dd5362b
8 changed files with 34 additions and 7 deletions

View File

@ -43,6 +43,7 @@
<option id="screen_scale" type="int" default="2" />
<option id="visible_timeline" type="bool" default="false" />
<option id="autoshow_timeline" type="bool" default="true" migrate="Options.AutoShowTimeline" />
<option id="rewind_on_stop" type="bool" default="false" />
<option id="expand_menubar_on_mouseover" type="bool" default="false" migrate="Options.ExpandMenuBarOnMouseover" />
<option id="data_recovery" type="bool" default="true" />
<option id="data_recovery_period" type="int" default="2" />

View File

@ -8,6 +8,7 @@
<listbox id="section_listbox">
<listitem text="General" value="section_general" />
<listitem text="Editor" value="section_editor" />
<listitem text="Timeline" value="section_timeline" />
<listitem text="Grid &amp;&amp; Background" value="section_grid" />
<listitem text="Undo" value="section_undo" />
<listitem text="Experimental" value="section_experimental" />
@ -26,7 +27,6 @@
<listitem text="400%" value="4" />
</combobox>
</hbox>
<check text="Show timeline automatically" id="autotimeline" tooltip="Show the timeline automatically&#10;when a new frame or layer is added." />
<check text="Expand menu bar items on mouseover" id="expand_menubar_on_mouseover" tooltip="Check this option to get&#10;this old menus behavior." />
<hbox>
<check text="Automatically save recovery data every" id="enable_data_recovery" tooltip="With this option you can recover your documents&#10;if the program finalizes unexpectedly." />
@ -60,6 +60,13 @@
</hbox>
</vbox>
<!-- Editor -->
<vbox id="section_timeline">
<separator text="Timeline" horizontal="true" />
<check text="Show timeline automatically" id="autotimeline" tooltip="Show the timeline automatically&#10;when a new frame or layer is added." />
<check text="Rewind on Stop" id="rewind_on_stop" tooltip="The 'Stop' button should rewind the animation&#10;where it was started." />
</vbox>
<!-- Grid & background -->
<vbox id="section_grid">
<combobox id="grid_scope" />

View File

@ -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);

View File

@ -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

View File

@ -1599,18 +1599,31 @@ bool Editor::isPlaying() const
return (dynamic_cast<PlayState*>(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<std::string>(option));
MenuItem* item = new MenuItem("Speed x" + base::convert_to<std::string>(option));
item->Click.connect(Bind<void>(&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());
}

View File

@ -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);

View File

@ -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).

View File

@ -290,7 +290,7 @@ void PreviewEditorWindow::onPopupSpeed()
if (!miniEditor || !miniEditor->document())
return;
miniEditor->showAnimationSpeedMultiplierPopup();
miniEditor->showAnimationSpeedMultiplierPopup(false);
m_aniSpeed = miniEditor->getAnimationSpeedMultiplier();
}