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#include <cstdio>
16
17namespace app {
18
19// using namespace ui;
20
21class DuplicateViewCommand : public Command {
22public:
23 DuplicateViewCommand();
24
25protected:
26 bool onEnabled(Context* context) override;
27 void onExecute(Context* context) override;
28};
29
30DuplicateViewCommand::DuplicateViewCommand()
31 : Command(CommandId::DuplicateView(), CmdUIOnlyFlag)
32{
33}
34
35bool DuplicateViewCommand::onEnabled(Context* context)
36{
37 Workspace* workspace = App::instance()->workspace();
38 WorkspaceView* view = workspace->activeView();
39 return (view != nullptr);
40}
41
42void DuplicateViewCommand::onExecute(Context* context)
43{
44 App::instance()->workspace()->duplicateActiveView();
45}
46
47Command* CommandFactory::createDuplicateViewCommand()
48{
49 return new DuplicateViewCommand;
50}
51
52} // namespace app
53