| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2020 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2017 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifdef HAVE_CONFIG_H |
| 9 | #include "config.h" |
| 10 | #endif |
| 11 | |
| 12 | #include "app/app.h" |
| 13 | #include "app/commands/command.h" |
| 14 | #include "app/commands/commands.h" |
| 15 | #include "app/context_access.h" |
| 16 | #include "app/tools/tool_box.h" |
| 17 | #include "app/ui/context_bar.h" |
| 18 | #include "app/ui_context.h" |
| 19 | |
| 20 | namespace app { |
| 21 | |
| 22 | class DiscardBrushCommand : public Command { |
| 23 | public: |
| 24 | DiscardBrushCommand(); |
| 25 | |
| 26 | protected: |
| 27 | bool onEnabled(Context* context) override; |
| 28 | void onExecute(Context* context) override; |
| 29 | }; |
| 30 | |
| 31 | DiscardBrushCommand::DiscardBrushCommand() |
| 32 | : Command(CommandId::DiscardBrush(), CmdUIOnlyFlag) |
| 33 | { |
| 34 | } |
| 35 | |
| 36 | bool DiscardBrushCommand::onEnabled(Context* context) |
| 37 | { |
| 38 | ContextBar* ctxBar = App::instance()->contextBar(); |
| 39 | return (ctxBar->activeBrush()->type() == kImageBrushType); |
| 40 | } |
| 41 | |
| 42 | void DiscardBrushCommand::onExecute(Context* context) |
| 43 | { |
| 44 | ContextBar* ctxBar = App::instance()->contextBar(); |
| 45 | ctxBar->discardActiveBrush(); |
| 46 | } |
| 47 | |
| 48 | Command* CommandFactory::createDiscardBrushCommand() |
| 49 | { |
| 50 | return new DiscardBrushCommand(); |
| 51 | } |
| 52 | |
| 53 | } // namespace app |
| 54 |