Add TogglePreview command (rename "mini-editor" to "preview")

Renamed Preview to FullscreenPreview to avoid confusion.
As an extra "to do", we need to add command aliases, so Preview matches
FullscreenPreview (mainly to keep user defined keyboard shortcuts).
This commit is contained in:
David Capello 2015-02-10 09:07:04 -03:00
parent 52003da721
commit d1d49c5038
6 changed files with 99 additions and 16 deletions

View File

@ -90,7 +90,8 @@
<key command="MakeUniqueEditor" shortcut="Ctrl+1" mac="Cmd+1" />
<key command="SplitEditorVertically" shortcut="Ctrl+2" mac="Cmd+2" />
<key command="SplitEditorHorizontally" shortcut="Ctrl+3" mac="Cmd+3" />
<key command="Preview" shortcut="F8" />
<key command="TogglePreview" shortcut="F7" />
<key command="FullscreenPreview" shortcut="F8" />
<key command="ShowGrid" shortcut="Shift+G" />
<key command="ShowPixelGrid" shortcut="Alt+Shift+G" />
<key command="SnapToGrid" shortcut="Shift+S" />
@ -572,7 +573,8 @@
<item command="Timeline" text="&amp;Timeline">
<param name="switch" value="true" />
</item>
<item command="Preview" text="Previe&amp;w" />
<item command="TogglePreview" text="Previe&amp;w" />
<item command="FullscreenPreview" text="&amp;Fullscreen Preview" />
<separator />
<item command="Refresh" text="&amp;Refresh &amp;&amp; Reload Skin" />
</menu>

View File

@ -135,6 +135,7 @@ add_library(app-lib
commands/cmd_flatten_layers.cpp
commands/cmd_flip.cpp
commands/cmd_frame_properties.cpp
commands/cmd_fullscreen_preview.cpp
commands/cmd_goto_frame.cpp
commands/cmd_goto_layer.cpp
commands/cmd_goto_tab.cpp
@ -166,7 +167,6 @@ add_library(app-lib
commands/cmd_palette_editor.cpp
commands/cmd_paste.cpp
commands/cmd_play_animation.cpp
commands/cmd_preview.cpp
commands/cmd_refresh.cpp
commands/cmd_remove_frame.cpp
commands/cmd_remove_layer.cpp
@ -185,6 +185,7 @@ add_library(app-lib
commands/cmd_sprite_size.cpp
commands/cmd_switch_colors.cpp
commands/cmd_timeline.cpp
commands/cmd_toggle_preview.cpp
commands/cmd_undo.cpp
commands/cmd_unlink_cel.cpp
commands/cmd_zoom.cpp

View File

@ -1,5 +1,5 @@
/* Aseprite
* Copyright (C) 2001-2013 David Capello
* Copyright (C) 2001-2015 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -260,31 +260,31 @@ private:
filters::TiledMode m_tiled;
};
class PreviewCommand : public Command {
class FullscreenPreviewCommand : public Command {
public:
PreviewCommand();
Command* clone() const override { return new PreviewCommand(*this); }
FullscreenPreviewCommand();
Command* clone() const override { return new FullscreenPreviewCommand(*this); }
protected:
bool onEnabled(Context* context);
void onExecute(Context* context);
};
PreviewCommand::PreviewCommand()
: Command("Preview",
"Preview",
FullscreenPreviewCommand::FullscreenPreviewCommand()
: Command("FullscreenPreview",
"Fullscreen Preview",
CmdUIOnlyFlag)
{
}
bool PreviewCommand::onEnabled(Context* context)
bool FullscreenPreviewCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasActiveSprite);
}
// Shows the sprite using the complete screen.
void PreviewCommand::onExecute(Context* context)
void FullscreenPreviewCommand::onExecute(Context* context)
{
Editor* editor = current_editor;
@ -296,9 +296,9 @@ void PreviewCommand::onExecute(Context* context)
window.openWindowInForeground();
}
Command* CommandFactory::createPreviewCommand()
Command* CommandFactory::createFullscreenPreviewCommand()
{
return new PreviewCommand;
return new FullscreenPreviewCommand;
}
} // namespace app

View File

@ -0,0 +1,79 @@
/* Aseprite
* Copyright (C) 2001-2015 David Capello
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/context.h"
#include "app/ui/main_window.h"
#include "app/ui/mini_editor.h"
namespace app {
class TogglePreviewCommand : public Command {
public:
TogglePreviewCommand();
Command* clone() const override { return new TogglePreviewCommand(*this); }
protected:
bool onEnabled(Context* context) override;
bool onChecked(Context* context) override;
void onExecute(Context* context) override;
};
TogglePreviewCommand::TogglePreviewCommand()
: Command("TogglePreview",
"Toggle Preview",
CmdUIOnlyFlag)
{
}
bool TogglePreviewCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
ContextFlags::HasActiveSprite);
}
bool TogglePreviewCommand::onChecked(Context* context)
{
MainWindow* mainWin = App::instance()->getMainWindow();
if (!mainWin)
return false;
MiniEditorWindow* previewWin = mainWin->getMiniEditor();
return (previewWin && previewWin->isVisible());
}
void TogglePreviewCommand::onExecute(Context* context)
{
MiniEditorWindow* previewWin =
App::instance()->getMainWindow()->getMiniEditor();
bool state = previewWin->isMiniEditorEnabled();
previewWin->setMiniEditorEnabled(!state);
}
Command* CommandFactory::createTogglePreviewCommand()
{
return new TogglePreviewCommand;
}
} // namespace app

View File

@ -48,6 +48,7 @@ FOR_EACH_COMMAND(Eyedropper)
FOR_EACH_COMMAND(FlattenLayers)
FOR_EACH_COMMAND(Flip)
FOR_EACH_COMMAND(FrameProperties)
FOR_EACH_COMMAND(FullscreenPreview)
FOR_EACH_COMMAND(GotoFirstFrame)
FOR_EACH_COMMAND(GotoFrame)
FOR_EACH_COMMAND(GotoLastFrame)
@ -86,7 +87,6 @@ FOR_EACH_COMMAND(Options)
FOR_EACH_COMMAND(PaletteEditor)
FOR_EACH_COMMAND(Paste)
FOR_EACH_COMMAND(PlayAnimation)
FOR_EACH_COMMAND(Preview)
FOR_EACH_COMMAND(Redo)
FOR_EACH_COMMAND(Refresh)
FOR_EACH_COMMAND(RemoveFrame)
@ -114,6 +114,7 @@ FOR_EACH_COMMAND(SpriteProperties)
FOR_EACH_COMMAND(SpriteSize)
FOR_EACH_COMMAND(SwitchColors)
FOR_EACH_COMMAND(Timeline)
FOR_EACH_COMMAND(TogglePreview)
FOR_EACH_COMMAND(Undo)
FOR_EACH_COMMAND(UnlinkCel)
FOR_EACH_COMMAND(Zoom)

View File

@ -115,7 +115,7 @@ private:
};
MiniEditorWindow::MiniEditorWindow()
: Window(WithTitleBar, "Mini-Editor")
: Window(WithTitleBar, "Preview")
, m_docView(NULL)
, m_playButton(new MiniPlayButton())
, m_playTimer(10)