1 | // Aseprite |
---|---|
2 | // Copyright (c) 2019-2020 Igara Studio S.A. |
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/color_bar.h" |
14 | |
15 | namespace app { |
16 | |
17 | using namespace gfx; |
18 | |
19 | class ToggleTilesModeCommand : public Command { |
20 | public: |
21 | ToggleTilesModeCommand() |
22 | : Command(CommandId::ToggleTilesMode(), CmdUIOnlyFlag) { |
23 | } |
24 | |
25 | protected: |
26 | bool onChecked(Context* context) override { |
27 | auto colorBar = ColorBar::instance(); |
28 | return (colorBar->tilemapMode() == TilemapMode::Tiles); |
29 | } |
30 | |
31 | void onExecute(Context* context) override { |
32 | auto colorBar = ColorBar::instance(); |
33 | colorBar->setTilemapMode( |
34 | colorBar->tilemapMode() == TilemapMode::Pixels ? |
35 | TilemapMode::Tiles: |
36 | TilemapMode::Pixels); |
37 | } |
38 | }; |
39 | |
40 | Command* CommandFactory::createToggleTilesModeCommand() |
41 | { |
42 | return new ToggleTilesModeCommand; |
43 | } |
44 | |
45 | } // namespace app |
46 |