Backport FullscreenMode command (#464)

Original from ae02600a63
This commit is contained in:
David Capello 2020-06-24 21:34:55 -03:00
parent 8c0215dd06
commit 8f838ba36d
5 changed files with 67 additions and 1 deletions

View File

@ -128,6 +128,7 @@
<key command="Refresh" shortcut="F5" /> <key command="Refresh" shortcut="F5" />
<key command="TogglePreview" shortcut="F7" /> <key command="TogglePreview" shortcut="F7" />
<key command="FullscreenPreview" shortcut="F8" /> <key command="FullscreenPreview" shortcut="F8" />
<key command="FullscreenMode" shortcut="F11" mac="Cmd+Ctrl+F" />
<key command="ShowGrid" shortcut="Ctrl+'" mac="Cmd+'" /> <key command="ShowGrid" shortcut="Ctrl+'" mac="Cmd+'" />
<key command="ShowPixelGrid" shortcut="Ctrl+Shift+'" mac="Cmd+Shift+'" /> <key command="ShowPixelGrid" shortcut="Ctrl+Shift+'" mac="Cmd+Shift+'" />
<key command="SnapToGrid" shortcut="Shift+S" /> <key command="SnapToGrid" shortcut="Shift+S" />
@ -929,7 +930,8 @@
<param name="switch" value="true" /> <param name="switch" value="true" />
</item> </item>
<item command="TogglePreview" text="@.view_preview" /> <item command="TogglePreview" text="@.view_preview" />
<item command="AdvancedMode" text="@.view_full_screen_mode" /> <item command="AdvancedMode" text="@.view_advanced_mode" />
<item command="FullscreenMode" text="@.view_full_screen_mode" />
<item command="FullscreenPreview" text="@.view_full_screen_preview" /> <item command="FullscreenPreview" text="@.view_full_screen_preview" />
<item command="Home" text="@.view_home" group="view_controls" /> <item command="Home" text="@.view_home" group="view_controls" />
<separator /> <separator />

View File

@ -275,6 +275,7 @@ Flip_Selection = Selection
Flip_Vertically = Vertically Flip_Vertically = Vertically
FrameProperties = Frame Properties FrameProperties = Frame Properties
FrameTagProperties = Tag Properties FrameTagProperties = Tag Properties
FullscreenMode = Toggle Fullscreen Mode
FullscreenPreview = Fullscreen Preview FullscreenPreview = Fullscreen Preview
GotoFirstFrame = Go to First Frame GotoFirstFrame = Go to First Frame
GotoFirstFrameInTag = Go to First Frame In Tag GotoFirstFrameInTag = Go to First Frame In Tag
@ -946,6 +947,7 @@ view_set_loop_section = Set &Loop Section
view_show_onion_skin = Show &Onion Skin view_show_onion_skin = Show &Onion Skin
view_timeline = &Timeline view_timeline = &Timeline
view_preview = Previe&w view_preview = Previe&w
view_advanced_mode = &Advanced Mode
view_full_screen_mode = &Full Screen Mode view_full_screen_mode = &Full Screen Mode
view_full_screen_preview = F&ull Screen Preview view_full_screen_preview = F&ull Screen Preview
view_home = &Home view_home = &Home

View File

@ -225,6 +225,7 @@ if(ENABLE_UI)
commands/cmd_fit_screen.cpp commands/cmd_fit_screen.cpp
commands/cmd_frame_properties.cpp commands/cmd_frame_properties.cpp
commands/cmd_frame_tag_properties.cpp commands/cmd_frame_tag_properties.cpp
commands/cmd_fullscreen_mode.cpp
commands/cmd_fullscreen_preview.cpp commands/cmd_fullscreen_preview.cpp
commands/cmd_goto_frame.cpp commands/cmd_goto_frame.cpp
commands/cmd_goto_layer.cpp commands/cmd_goto_layer.cpp

View File

@ -0,0 +1,60 @@
// Aseprite
// Copyright (C) 2020-2021 Igara Studio S.A.
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "ui/ui.h"
#include "app/app.h"
#include "app/commands/command.h"
#include "app/commands/commands.h"
#include "app/context.h"
#include "os/system.h"
#include "os/window.h"
namespace app {
class FullscreenModeCommand : public Command {
public:
FullscreenModeCommand();
protected:
void onExecute(Context* context) override;
};
FullscreenModeCommand::FullscreenModeCommand()
: Command(CommandId::FullscreenMode(), CmdUIOnlyFlag)
{
}
// Shows the sprite using the complete screen.
void FullscreenModeCommand::onExecute(Context* ctx)
{
if (!ctx->isUIAvailable())
return;
ui::Manager* manager = ui::Manager::getDefault();
ASSERT(manager);
if (!manager)
return;
os::Window* window = manager->display();
ASSERT(window);
if (!window)
return;
window->setFullscreen(
!window->isFullscreen());
}
Command* CommandFactory::createFullscreenModeCommand()
{
return new FullscreenModeCommand;
}
} // namespace app

View File

@ -71,6 +71,7 @@ FOR_EACH_COMMAND(Fill)
FOR_EACH_COMMAND(FitScreen) FOR_EACH_COMMAND(FitScreen)
FOR_EACH_COMMAND(FrameProperties) FOR_EACH_COMMAND(FrameProperties)
FOR_EACH_COMMAND(FrameTagProperties) FOR_EACH_COMMAND(FrameTagProperties)
FOR_EACH_COMMAND(FullscreenMode)
FOR_EACH_COMMAND(FullscreenPreview) FOR_EACH_COMMAND(FullscreenPreview)
FOR_EACH_COMMAND(GotoFirstFrame) FOR_EACH_COMMAND(GotoFirstFrame)
FOR_EACH_COMMAND(GotoFirstFrameInTag) FOR_EACH_COMMAND(GotoFirstFrameInTag)