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
20namespace app {
21
22class DiscardBrushCommand : public Command {
23public:
24 DiscardBrushCommand();
25
26protected:
27 bool onEnabled(Context* context) override;
28 void onExecute(Context* context) override;
29};
30
31DiscardBrushCommand::DiscardBrushCommand()
32 : Command(CommandId::DiscardBrush(), CmdUIOnlyFlag)
33{
34}
35
36bool DiscardBrushCommand::onEnabled(Context* context)
37{
38 ContextBar* ctxBar = App::instance()->contextBar();
39 return (ctxBar->activeBrush()->type() == kImageBrushType);
40}
41
42void DiscardBrushCommand::onExecute(Context* context)
43{
44 ContextBar* ctxBar = App::instance()->contextBar();
45 ctxBar->discardActiveBrush();
46}
47
48Command* CommandFactory::createDiscardBrushCommand()
49{
50 return new DiscardBrushCommand();
51}
52
53} // namespace app
54