1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-2017 David Capello |
3 | // |
4 | // This program is distributed under the terms of |
5 | // the End-User License Agreement for Aseprite. |
6 | |
7 | #ifdef HAVE_CONFIG_H |
8 | #include "config.h" |
9 | #endif |
10 | |
11 | #include "app/app.h" |
12 | #include "app/commands/command.h" |
13 | #include "app/ui/input_chain.h" |
14 | |
15 | namespace app { |
16 | |
17 | class CutCommand : public Command { |
18 | public: |
19 | CutCommand(); |
20 | |
21 | protected: |
22 | bool onEnabled(Context* ctx) override; |
23 | void onExecute(Context* ctx) override; |
24 | }; |
25 | |
26 | CutCommand::CutCommand() |
27 | : Command(CommandId::Cut(), CmdUIOnlyFlag) |
28 | { |
29 | } |
30 | |
31 | bool CutCommand::onEnabled(Context* ctx) |
32 | { |
33 | return App::instance()->inputChain().canCut(ctx); |
34 | } |
35 | |
36 | void CutCommand::onExecute(Context* ctx) |
37 | { |
38 | App::instance()->inputChain().cut(ctx); |
39 | } |
40 | |
41 | Command* CommandFactory::createCutCommand() |
42 | { |
43 | return new CutCommand; |
44 | } |
45 | |
46 | } // namespace app |
47 |