1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-2015 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/modules/editors.h" |
14 | #include "app/ui/editor/editor.h" |
15 | #include "ui/base.h" |
16 | #include "app/context.h" |
17 | |
18 | namespace app { |
19 | |
20 | class SwapCheckerboardColorsCommand : public Command { |
21 | public: |
22 | SwapCheckerboardColorsCommand(); |
23 | |
24 | protected: |
25 | bool onEnabled(Context* context) override; |
26 | void onExecute(Context* context) override; |
27 | }; |
28 | |
29 | SwapCheckerboardColorsCommand::SwapCheckerboardColorsCommand() |
30 | : Command(CommandId::SwapCheckerboardColors(), CmdUIOnlyFlag) |
31 | { |
32 | } |
33 | |
34 | bool SwapCheckerboardColorsCommand::onEnabled(Context* context) |
35 | { |
36 | return true; |
37 | } |
38 | |
39 | void SwapCheckerboardColorsCommand::onExecute(Context* context) |
40 | { |
41 | DocumentPreferences& docPref = Preferences::instance().document(context->activeDocument()); |
42 | app::Color c1 = docPref.bg.color1(); |
43 | app::Color c2 = docPref.bg.color2(); |
44 | |
45 | docPref.bg.color1(c2); |
46 | docPref.bg.color2(c1); |
47 | } |
48 | Command* CommandFactory::createSwapCheckerboardColorsCommand() |
49 | { |
50 | return new SwapCheckerboardColorsCommand; |
51 | } |
52 | |
53 | } // namespace app |
54 |