1 | // Aseprite |
---|---|
2 | // Copyright (C) 2001-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/ui/workspace.h" |
14 | |
15 | namespace app { |
16 | |
17 | class GotoNextTabCommand : public Command { |
18 | public: |
19 | GotoNextTabCommand(); |
20 | |
21 | protected: |
22 | bool onEnabled(Context* context) override; |
23 | void onExecute(Context* context) override; |
24 | }; |
25 | |
26 | GotoNextTabCommand::GotoNextTabCommand() |
27 | : Command(CommandId::GotoNextTab(), CmdUIOnlyFlag) |
28 | { |
29 | } |
30 | |
31 | bool GotoNextTabCommand::onEnabled(Context* context) |
32 | { |
33 | return App::instance()->workspace()->canSelectOtherTab(); |
34 | } |
35 | |
36 | void GotoNextTabCommand::onExecute(Context* context) |
37 | { |
38 | App::instance()->workspace()->selectNextTab(); |
39 | } |
40 | |
41 | class GotoPreviousTabCommand : public Command { |
42 | public: |
43 | GotoPreviousTabCommand(); |
44 | |
45 | protected: |
46 | bool onEnabled(Context* context) override; |
47 | void onExecute(Context* context) override; |
48 | }; |
49 | |
50 | GotoPreviousTabCommand::GotoPreviousTabCommand() |
51 | : Command(CommandId::GotoPreviousTab(), CmdRecordableFlag) |
52 | { |
53 | } |
54 | |
55 | bool GotoPreviousTabCommand::onEnabled(Context* context) |
56 | { |
57 | return App::instance()->workspace()->canSelectOtherTab(); |
58 | } |
59 | |
60 | void GotoPreviousTabCommand::onExecute(Context* context) |
61 | { |
62 | App::instance()->workspace()->selectPreviousTab(); |
63 | } |
64 | |
65 | Command* CommandFactory::createGotoNextTabCommand() |
66 | { |
67 | return new GotoNextTabCommand; |
68 | } |
69 | |
70 | Command* CommandFactory::createGotoPreviousTabCommand() |
71 | { |
72 | return new GotoPreviousTabCommand; |
73 | } |
74 | |
75 | } // namespace app |
76 |