mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add commands to navigate frames with same tag
This commit is contained in:
parent
6ab858b722
commit
2fa6f1995e
@ -85,8 +85,8 @@
|
||||
<key command="GotoFirstFrame" shortcut="Home" />
|
||||
<key command="GotoPreviousFrame" shortcut="Left" context="Normal" />
|
||||
<key command="GotoNextFrame" shortcut="Right" context="Normal" />
|
||||
<key command="GotoPreviousFrame" shortcut="," />
|
||||
<key command="GotoNextFrame" shortcut="." />
|
||||
<key command="GotoPreviousFrameWithSameTag" shortcut="," />
|
||||
<key command="GotoNextFrameWithSameTag" shortcut="." />
|
||||
<key command="GotoLastFrame" shortcut="End" />
|
||||
<key command="GotoFrame" shortcut="Alt+G" />
|
||||
<key command="PlayAnimation" shortcut="Enter" />
|
||||
|
@ -11,9 +11,11 @@
|
||||
|
||||
#include "app/commands/command.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/loop_tag.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "doc/frame_tag.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/window.h"
|
||||
|
||||
@ -22,6 +24,7 @@
|
||||
namespace app {
|
||||
|
||||
using namespace ui;
|
||||
using namespace doc;
|
||||
|
||||
class GotoCommand : public Command {
|
||||
protected:
|
||||
@ -88,6 +91,46 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
class GotoNextFrameWithSameTagCommand : public GotoCommand {
|
||||
public:
|
||||
GotoNextFrameWithSameTagCommand() : GotoCommand("GotoNextFrameWithSameTag",
|
||||
"Go to Next Frame with same tag") { }
|
||||
Command* clone() const override { return new GotoNextFrameWithSameTagCommand(*this); }
|
||||
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
Sprite* sprite = editor->sprite();
|
||||
frame_t currentFrame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(sprite, currentFrame);
|
||||
frame_t frameToGo = currentFrame + frame_t(1);
|
||||
|
||||
if (frameToGo > tag->toFrame())
|
||||
frameToGo = tag->fromFrame();
|
||||
|
||||
return frameToGo;
|
||||
}
|
||||
};
|
||||
|
||||
class GotoPreviousFrameWithSameTagCommand : public GotoCommand {
|
||||
public:
|
||||
GotoPreviousFrameWithSameTagCommand() : GotoCommand("GotoPreviousFrameWithSameTag",
|
||||
"Go to Previous Frame with same tag") { }
|
||||
Command* clone() const override { return new GotoPreviousFrameWithSameTagCommand(*this); }
|
||||
|
||||
protected:
|
||||
frame_t onGetFrame(Editor* editor) override {
|
||||
Sprite* sprite = editor->sprite();
|
||||
frame_t currentFrame = editor->frame();
|
||||
FrameTag* tag = get_animation_tag(sprite, currentFrame);
|
||||
frame_t frameToGo = currentFrame - frame_t(1);
|
||||
|
||||
if (frameToGo < tag->fromFrame())
|
||||
frameToGo = tag->toFrame();
|
||||
|
||||
return frameToGo;
|
||||
}
|
||||
};
|
||||
|
||||
class GotoLastFrameCommand : public GotoCommand {
|
||||
public:
|
||||
GotoLastFrameCommand() : GotoCommand("GotoLastFrame",
|
||||
@ -157,6 +200,16 @@ Command* CommandFactory::createGotoLastFrameCommand()
|
||||
return new GotoLastFrameCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::createGotoNextFrameWithSameTagCommand()
|
||||
{
|
||||
return new GotoNextFrameWithSameTagCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::createGotoPreviousFrameWithSameTagCommand()
|
||||
{
|
||||
return new GotoPreviousFrameWithSameTagCommand;
|
||||
}
|
||||
|
||||
Command* CommandFactory::createGotoFrameCommand()
|
||||
{
|
||||
return new GotoFrameCommand;
|
||||
|
@ -45,9 +45,11 @@ FOR_EACH_COMMAND(GotoFirstFrame)
|
||||
FOR_EACH_COMMAND(GotoFrame)
|
||||
FOR_EACH_COMMAND(GotoLastFrame)
|
||||
FOR_EACH_COMMAND(GotoNextFrame)
|
||||
FOR_EACH_COMMAND(GotoNextFrameWithSameTag)
|
||||
FOR_EACH_COMMAND(GotoNextLayer)
|
||||
FOR_EACH_COMMAND(GotoNextTab)
|
||||
FOR_EACH_COMMAND(GotoPreviousFrame)
|
||||
FOR_EACH_COMMAND(GotoPreviousFrameWithSameTag)
|
||||
FOR_EACH_COMMAND(GotoPreviousLayer)
|
||||
FOR_EACH_COMMAND(GotoPreviousTab)
|
||||
FOR_EACH_COMMAND(GridSettings)
|
||||
|
Loading…
x
Reference in New Issue
Block a user