1// Aseprite
2// Copyright (C) 2020-2021 Igara Studio S.A.
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 "ui/ui.h"
12
13#include "app/app.h"
14#include "app/commands/command.h"
15#include "app/commands/commands.h"
16#include "app/context.h"
17#include "os/system.h"
18#include "os/window.h"
19
20namespace app {
21
22class FullscreenModeCommand : public Command {
23public:
24 FullscreenModeCommand();
25
26protected:
27 void onExecute(Context* context) override;
28};
29
30FullscreenModeCommand::FullscreenModeCommand()
31 : Command(CommandId::FullscreenMode(), CmdUIOnlyFlag)
32{
33}
34
35// Shows the sprite using the complete screen.
36void FullscreenModeCommand::onExecute(Context* ctx)
37{
38 if (!ctx->isUIAvailable())
39 return;
40
41 ui::Manager* manager = ui::Manager::getDefault();
42 ASSERT(manager);
43 if (!manager)
44 return;
45
46 os::Window* window = manager->display()->nativeWindow();
47 ASSERT(window);
48 if (!window)
49 return;
50
51 window->setFullscreen(
52 !window->isFullscreen());
53}
54
55Command* CommandFactory::createFullscreenModeCommand()
56{
57 return new FullscreenModeCommand;
58}
59
60} // namespace app
61