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