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/input_chain.h"
14
15namespace app {
16
17class ClearCommand : public Command {
18public:
19 ClearCommand();
20
21protected:
22 bool onEnabled(Context* ctx) override;
23 void onExecute(Context* ctx) override;
24};
25
26ClearCommand::ClearCommand()
27 : Command(CommandId::Clear(), CmdUIOnlyFlag)
28{
29}
30
31bool ClearCommand::onEnabled(Context* ctx)
32{
33 return App::instance()->inputChain().canClear(ctx);
34}
35
36void ClearCommand::onExecute(Context* ctx)
37{
38 App::instance()->inputChain().clear(ctx);
39}
40
41Command* CommandFactory::createClearCommand()
42{
43 return new ClearCommand;
44}
45
46} // namespace app
47