aseprite/src/app/commands/cmd_goto_tab.cpp

83 lines
1.7 KiB
C++
Raw Normal View History

2015-02-12 23:16:25 +08:00
// Aseprite
// Copyright (C) 2001-2016 David Capello
2015-02-12 23:16:25 +08:00
//
2016-08-27 04:02:58 +08:00
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/commands/command.h"
#include "app/app.h"
#include "app/ui/workspace.h"
namespace app {
class GotoNextTabCommand : public Command {
public:
GotoNextTabCommand();
Command* clone() const override { return new GotoNextTabCommand(*this); }
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
};
GotoNextTabCommand::GotoNextTabCommand()
: Command("GotoNextTab",
"Go to Next Tab",
CmdUIOnlyFlag)
{
}
bool GotoNextTabCommand::onEnabled(Context* context)
{
return App::instance()->workspace()->canSelectOtherTab();
}
void GotoNextTabCommand::onExecute(Context* context)
{
App::instance()->workspace()->selectNextTab();
}
class GotoPreviousTabCommand : public Command {
public:
GotoPreviousTabCommand();
Command* clone() const override { return new GotoPreviousTabCommand(*this); }
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
};
GotoPreviousTabCommand::GotoPreviousTabCommand()
: Command("GotoPreviousTab",
"Go to Previous tab",
CmdRecordableFlag)
{
}
bool GotoPreviousTabCommand::onEnabled(Context* context)
{
return App::instance()->workspace()->canSelectOtherTab();
}
void GotoPreviousTabCommand::onExecute(Context* context)
{
App::instance()->workspace()->selectPreviousTab();
}
Command* CommandFactory::createGotoNextTabCommand()
{
return new GotoNextTabCommand;
}
Command* CommandFactory::createGotoPreviousTabCommand()
{
return new GotoPreviousTabCommand;
}
} // namespace app