mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 04:59:24 +00:00
Add "Cancel" option to cel_movement_popup (popup when you move cels in the Timeline)
This commit is contained in:
parent
7a15f1c909
commit
f60d1c5c4f
@ -18,7 +18,9 @@
|
||||
<key command="AdvancedMode" shortcut="F11" />
|
||||
<key command="DeveloperConsole" shortcut="F12" />
|
||||
<key command="Exit" shortcut="Alt+F4" />
|
||||
<key command="Cancel" shortcut="Esc" />
|
||||
<key command="Cancel" shortcut="Esc">
|
||||
<param name="type" value="all" />
|
||||
</key>
|
||||
<!-- Edit -->
|
||||
<key command="Undo" shortcut="Ctrl+Z" /> <key command="Undo" shortcut="Ctrl+U" />
|
||||
<key command="Redo" shortcut="Ctrl+Y" />
|
||||
@ -454,6 +456,10 @@
|
||||
<menu id="cel_movement_popup">
|
||||
<item command="MoveCel" text="&Move" />
|
||||
<item command="CopyCel" text="&Copy" />
|
||||
<separator />
|
||||
<item command="Cancel" text="Cancel">
|
||||
<param name="type" value="noop" />
|
||||
</item>
|
||||
</menu>
|
||||
</menus>
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "app/commands/command.h"
|
||||
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/context.h"
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
@ -30,26 +31,52 @@ namespace app {
|
||||
|
||||
class CancelCommand : public Command {
|
||||
public:
|
||||
enum Type {
|
||||
NoOp,
|
||||
All,
|
||||
};
|
||||
|
||||
CancelCommand();
|
||||
Command* clone() const OVERRIDE { return new CancelCommand(*this); }
|
||||
|
||||
protected:
|
||||
void onLoadParams(Params* params);
|
||||
void onExecute(Context* context);
|
||||
|
||||
private:
|
||||
Type m_type;
|
||||
};
|
||||
|
||||
CancelCommand::CancelCommand()
|
||||
: Command("Cancel",
|
||||
"Cancel",
|
||||
CmdUIOnlyFlag)
|
||||
, m_type(NoOp)
|
||||
{
|
||||
}
|
||||
|
||||
void CancelCommand::onLoadParams(Params* params)
|
||||
{
|
||||
std::string type = params->get("type");
|
||||
if (type == "noop") m_type = NoOp;
|
||||
else if (type == "all") m_type = All;
|
||||
}
|
||||
|
||||
void CancelCommand::onExecute(Context* context)
|
||||
{
|
||||
if (context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||
ContextFlags::HasVisibleMask)) {
|
||||
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::DeselectMask);
|
||||
context->executeCommand(cmd);
|
||||
switch (m_type) {
|
||||
|
||||
case NoOp:
|
||||
// Do nothing.
|
||||
break;
|
||||
|
||||
case All:
|
||||
if (context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||
ContextFlags::HasVisibleMask)) {
|
||||
Command* cmd = CommandsModule::instance()->getCommandByName(CommandId::DeselectMask);
|
||||
context->executeCommand(cmd);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user