Add Shift+Enter (PlayPreviewAnimation command) to play/stop animation in preview window (fix #1774)

This commit is contained in:
David Capello 2018-06-29 15:05:11 -03:00
parent 3e0ebd34c9
commit ac65b1291d
6 changed files with 56 additions and 3 deletions

View File

@ -97,6 +97,7 @@
<key command="GotoLastFrame" shortcut="End" /> <key command="GotoLastFrame" shortcut="End" />
<key command="GotoFrame" shortcut="Alt+G" /> <key command="GotoFrame" shortcut="Alt+G" />
<key command="PlayAnimation" shortcut="Enter" /> <key command="PlayAnimation" shortcut="Enter" />
<key command="PlayPreviewAnimation" shortcut="Shift+Enter" />
<!-- Cels --> <!-- Cels -->
<key command="ClearCel" /> <key command="ClearCel" />
<key command="UnlinkCel" /> <key command="UnlinkCel" />

View File

@ -331,6 +331,7 @@ Paste = Paste
PasteText = Insert Text PasteText = Insert Text
PixelPerfectMode = Switch Pixel Perfect Mode PixelPerfectMode = Switch Pixel Perfect Mode
PlayAnimation = Play Animation PlayAnimation = Play Animation
PlayPreviewAnimation = Play Preview Animation
Redo = Redo Redo = Redo
Refresh = Refresh Refresh = Refresh
RemoveFrame = Remove Frame RemoveFrame = Remove Frame

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -8,17 +8,22 @@
#include "config.h" #include "config.h"
#endif #endif
#include "app/app.h"
#include "app/commands/command.h" #include "app/commands/command.h"
#include "app/context.h" #include "app/context.h"
#include "app/context_access.h" #include "app/context_access.h"
#include "app/modules/editors.h" #include "app/modules/editors.h"
#include "app/pref/preferences.h" #include "app/pref/preferences.h"
#include "app/ui/editor/editor.h" #include "app/ui/editor/editor.h"
#include "app/ui/main_window.h"
#include "app/ui/preview_editor.h"
namespace app { namespace app {
using namespace ui; using namespace ui;
//////////////////////////////////////////////////////////////////////
class PlayAnimationCommand : public Command { class PlayAnimationCommand : public Command {
public: public:
PlayAnimationCommand(); PlayAnimationCommand();
@ -61,9 +66,47 @@ void PlayAnimationCommand::onExecute(Context* context)
Preferences::instance().editor.playAll()); Preferences::instance().editor.playAll());
} }
//////////////////////////////////////////////////////////////////////
class PlayPreviewAnimationCommand : public Command {
public:
PlayPreviewAnimationCommand();
Command* clone() const override { return new PlayPreviewAnimationCommand(*this); }
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
};
PlayPreviewAnimationCommand::PlayPreviewAnimationCommand()
: Command(CommandId::PlayPreviewAnimation(), CmdUIOnlyFlag)
{
}
bool PlayPreviewAnimationCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasActiveSprite);
}
void PlayPreviewAnimationCommand::onExecute(Context* context)
{
PreviewEditorWindow* preview = App::instance()->mainWindow()->getPreviewEditor();
if (!preview->isPreviewEnabled())
preview->setPreviewEnabled(true);
preview->pressPlayButton();
}
//////////////////////////////////////////////////////////////////////
Command* CommandFactory::createPlayAnimationCommand() Command* CommandFactory::createPlayAnimationCommand()
{ {
return new PlayAnimationCommand; return new PlayAnimationCommand;
} }
Command* CommandFactory::createPlayPreviewAnimationCommand()
{
return new PlayPreviewAnimationCommand;
}
} // namespace app } // namespace app

View File

@ -105,6 +105,7 @@ FOR_EACH_COMMAND(Paste)
FOR_EACH_COMMAND(PasteText) FOR_EACH_COMMAND(PasteText)
FOR_EACH_COMMAND(PixelPerfectMode) FOR_EACH_COMMAND(PixelPerfectMode)
FOR_EACH_COMMAND(PlayAnimation) FOR_EACH_COMMAND(PlayAnimation)
FOR_EACH_COMMAND(PlayPreviewAnimation)
FOR_EACH_COMMAND(Refresh) FOR_EACH_COMMAND(Refresh)
FOR_EACH_COMMAND(RemoveFrame) FOR_EACH_COMMAND(RemoveFrame)
FOR_EACH_COMMAND(RemoveFrameTag) FOR_EACH_COMMAND(RemoveFrameTag)

View File

@ -206,6 +206,13 @@ void PreviewEditorWindow::setPreviewEnabled(bool state)
updateUsingEditor(current_editor); updateUsingEditor(current_editor);
} }
void PreviewEditorWindow::pressPlayButton()
{
m_playButton->setSelected(
!m_playButton->isSelected());
onPlayClicked();
}
bool PreviewEditorWindow::onProcessMessage(ui::Message* msg) bool PreviewEditorWindow::onProcessMessage(ui::Message* msg)
{ {
switch (msg->type()) { switch (msg->type()) {

View File

@ -1,5 +1,5 @@
// Aseprite // Aseprite
// Copyright (C) 2001-2017 David Capello // Copyright (C) 2001-2018 David Capello
// //
// This program is distributed under the terms of // This program is distributed under the terms of
// the End-User License Agreement for Aseprite. // the End-User License Agreement for Aseprite.
@ -27,9 +27,9 @@ namespace app {
bool isPreviewEnabled() const { return m_isEnabled; } bool isPreviewEnabled() const { return m_isEnabled; }
void setPreviewEnabled(bool state); void setPreviewEnabled(bool state);
void pressPlayButton();
void updateUsingEditor(Editor* editor); void updateUsingEditor(Editor* editor);
Editor* relatedEditor() const { return m_relatedEditor; } Editor* relatedEditor() const { return m_relatedEditor; }
// EditorObserver impl // EditorObserver impl