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/context.h"
14 #include "app/doc.h"
15 #include "app/pref/preferences.h"
16 
17 namespace app {
18 
19 using namespace gfx;
20 
21 class ShowOnionSkinCommand : public Command {
22 public:
ShowOnionSkinCommand()23   ShowOnionSkinCommand()
24     : Command(CommandId::ShowOnionSkin(), CmdUIOnlyFlag)
25   {
26   }
27 
clone() const28   Command* clone() const override { return new ShowOnionSkinCommand(*this); }
29 
30 protected:
onChecked(Context * context)31   bool onChecked(Context* context) override {
32     DocumentPreferences& docPref = Preferences::instance().document(context->activeDocument());
33     return docPref.onionskin.active();
34   }
35 
onExecute(Context * context)36   void onExecute(Context* context) override {
37     DocumentPreferences& docPref = Preferences::instance().document(context->activeDocument());
38     docPref.onionskin.active(!docPref.onionskin.active());
39   }
40 };
41 
createShowOnionSkinCommand()42 Command* CommandFactory::createShowOnionSkinCommand()
43 {
44   return new ShowOnionSkinCommand;
45 }
46 
47 } // namespace app
48