| 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_access.h" | 
| 14 | #include "app/modules/editors.h" | 
| 15 | #include "app/ui/editor/editor.h" | 
| 16 | |
| 17 | namespace app { | 
| 18 | |
| 19 | class FitScreenCommand : public Command { | 
| 20 | public: | 
| 21 | FitScreenCommand(); | 
| 22 | |
| 23 | protected: | 
| 24 | bool onEnabled(Context* context) override; | 
| 25 | void onExecute(Context* context) override; | 
| 26 | }; | 
| 27 | |
| 28 | FitScreenCommand::FitScreenCommand() | 
| 29 | : Command(CommandId::FitScreen(), CmdUIOnlyFlag) | 
| 30 | { | 
| 31 | } | 
| 32 | |
| 33 | bool FitScreenCommand::onEnabled(Context* context) | 
| 34 | { | 
| 35 | return (current_editor != nullptr); | 
| 36 | } | 
| 37 | |
| 38 | void FitScreenCommand::onExecute(Context* context) | 
| 39 | { | 
| 40 | current_editor->setScrollAndZoomToFitScreen(); | 
| 41 | } | 
| 42 | |
| 43 | Command* CommandFactory::createFitScreenCommand() | 
| 44 | { | 
| 45 | return new FitScreenCommand; | 
| 46 | } | 
| 47 | |
| 48 | } //namespace app | 
| 49 | 
