1 | // Aseprite |
---|---|
2 | // Copyright (C) 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/pref/preferences.h" |
14 | #include "app/tools/tool.h" |
15 | |
16 | namespace app { |
17 | |
18 | class ContiguousFillCommand : public Command { |
19 | public: |
20 | ContiguousFillCommand(); |
21 | |
22 | protected: |
23 | bool onChecked(Context* context) override; |
24 | void onExecute(Context* context) override; |
25 | }; |
26 | |
27 | ContiguousFillCommand::ContiguousFillCommand() |
28 | : Command(CommandId::ContiguousFill(), CmdUIOnlyFlag) |
29 | { |
30 | } |
31 | |
32 | bool ContiguousFillCommand::onChecked(Context* ctx) |
33 | { |
34 | tools::Tool* tool = App::instance()->activeTool(); |
35 | if (!tool) |
36 | return false; |
37 | |
38 | auto& toolPref = Preferences::instance().tool(tool); |
39 | return toolPref.contiguous(); |
40 | } |
41 | |
42 | void ContiguousFillCommand::onExecute(Context* ctx) |
43 | { |
44 | tools::Tool* tool = App::instance()->activeTool(); |
45 | if (!tool) |
46 | return; |
47 | |
48 | auto& toolPref = Preferences::instance().tool(tool); |
49 | toolPref.contiguous(!toolPref.contiguous()); |
50 | } |
51 | |
52 | Command* CommandFactory::createContiguousFillCommand() |
53 | { |
54 | return new ContiguousFillCommand; |
55 | } |
56 | |
57 | } // namespace app |
58 |