| 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 ClearCommand : public Command { |
| 18 | public: |
| 19 | ClearCommand(); |
| 20 | |
| 21 | protected: |
| 22 | bool onEnabled(Context* ctx) override; |
| 23 | void onExecute(Context* ctx) override; |
| 24 | }; |
| 25 | |
| 26 | ClearCommand::ClearCommand() |
| 27 | : Command(CommandId::Clear(), CmdUIOnlyFlag) |
| 28 | { |
| 29 | } |
| 30 | |
| 31 | bool ClearCommand::onEnabled(Context* ctx) |
| 32 | { |
| 33 | return App::instance()->inputChain().canClear(ctx); |
| 34 | } |
| 35 | |
| 36 | void ClearCommand::onExecute(Context* ctx) |
| 37 | { |
| 38 | App::instance()->inputChain().clear(ctx); |
| 39 | } |
| 40 | |
| 41 | Command* CommandFactory::createClearCommand() |
| 42 | { |
| 43 | return new ClearCommand; |
| 44 | } |
| 45 | |
| 46 | } // namespace app |
| 47 |