mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-03 05:29:13 +00:00
Add Shift+Enter (PlayPreviewAnimation command) to play/stop animation in preview window (fix #1774)
This commit is contained in:
parent
3e0ebd34c9
commit
ac65b1291d
@ -97,6 +97,7 @@
|
||||
<key command="GotoLastFrame" shortcut="End" />
|
||||
<key command="GotoFrame" shortcut="Alt+G" />
|
||||
<key command="PlayAnimation" shortcut="Enter" />
|
||||
<key command="PlayPreviewAnimation" shortcut="Shift+Enter" />
|
||||
<!-- Cels -->
|
||||
<key command="ClearCel" />
|
||||
<key command="UnlinkCel" />
|
||||
|
@ -331,6 +331,7 @@ Paste = Paste
|
||||
PasteText = Insert Text
|
||||
PixelPerfectMode = Switch Pixel Perfect Mode
|
||||
PlayAnimation = Play Animation
|
||||
PlayPreviewAnimation = Play Preview Animation
|
||||
Redo = Redo
|
||||
Refresh = Refresh
|
||||
RemoveFrame = Remove Frame
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -8,17 +8,22 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "app/ui/preview_editor.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
class PlayAnimationCommand : public Command {
|
||||
public:
|
||||
PlayAnimationCommand();
|
||||
@ -61,9 +66,47 @@ void PlayAnimationCommand::onExecute(Context* context)
|
||||
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()
|
||||
{
|
||||
return new PlayAnimationCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::createPlayPreviewAnimationCommand()
|
||||
{
|
||||
return new PlayPreviewAnimationCommand;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -105,6 +105,7 @@ FOR_EACH_COMMAND(Paste)
|
||||
FOR_EACH_COMMAND(PasteText)
|
||||
FOR_EACH_COMMAND(PixelPerfectMode)
|
||||
FOR_EACH_COMMAND(PlayAnimation)
|
||||
FOR_EACH_COMMAND(PlayPreviewAnimation)
|
||||
FOR_EACH_COMMAND(Refresh)
|
||||
FOR_EACH_COMMAND(RemoveFrame)
|
||||
FOR_EACH_COMMAND(RemoveFrameTag)
|
||||
|
@ -206,6 +206,13 @@ void PreviewEditorWindow::setPreviewEnabled(bool state)
|
||||
updateUsingEditor(current_editor);
|
||||
}
|
||||
|
||||
void PreviewEditorWindow::pressPlayButton()
|
||||
{
|
||||
m_playButton->setSelected(
|
||||
!m_playButton->isSelected());
|
||||
onPlayClicked();
|
||||
}
|
||||
|
||||
bool PreviewEditorWindow::onProcessMessage(ui::Message* msg)
|
||||
{
|
||||
switch (msg->type()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
// the End-User License Agreement for Aseprite.
|
||||
@ -27,9 +27,9 @@ namespace app {
|
||||
|
||||
bool isPreviewEnabled() const { return m_isEnabled; }
|
||||
void setPreviewEnabled(bool state);
|
||||
void pressPlayButton();
|
||||
|
||||
void updateUsingEditor(Editor* editor);
|
||||
|
||||
Editor* relatedEditor() const { return m_relatedEditor; }
|
||||
|
||||
// EditorObserver impl
|
||||
|
Loading…
Reference in New Issue
Block a user