Merge branch 'center-canvas-newcmd' of https://github.com/tony/aseprite into tony-center-canvas-newcmd

This commit is contained in:
David Capello 2015-12-08 15:44:44 -03:00
commit 20b59bf0c4
4 changed files with 52 additions and 0 deletions

View File

@ -218,6 +218,10 @@
<param name="action" value="in" />
</key>
<!-- Scroll to center -->
<key command="ScrollCenter" shortcut="C">
</key>
<!-- Scroll with arrows -->
<key command="Scroll" shortcut="Space+Left">
<param name="direction" value="left" />

View File

@ -243,6 +243,7 @@ add_library(app-lib
commands/cmd_save_mask.cpp
commands/cmd_save_palette.cpp
commands/cmd_scroll.cpp
commands/cmd_scroll_center.cpp
commands/cmd_set_color_selector.cpp
commands/cmd_set_ink_type.cpp
commands/cmd_set_loop_section.cpp

View File

@ -0,0 +1,46 @@
// 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 version 2 as
// published by the Free Software Foundation.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/editors.h"
#include "app/ui/editor/editor.h"
namespace app {
class ScrollCenterCommand : public Command {
public:
ScrollCenterCommand();
Command* clone() const override { return new ScrollCenterCommand(*this); }
protected:
void onExecute(Context* context) override;
};
ScrollCenterCommand::ScrollCenterCommand()
: Command("ScrollCenter",
"Scroll to center of canvas",
CmdUIOnlyFlag)
{
}
void ScrollCenterCommand::onExecute(Context* context)
{
current_editor->setDefaultScroll();
}
Command* CommandFactory::createScrollCenterCommand()
{
return new ScrollCenterCommand;
}
} //namespace app

View File

@ -106,6 +106,7 @@ FOR_EACH_COMMAND(SaveFileCopyAs)
FOR_EACH_COMMAND(SaveMask)
FOR_EACH_COMMAND(SavePalette)
FOR_EACH_COMMAND(Scroll)
FOR_EACH_COMMAND(ScrollCenter)
FOR_EACH_COMMAND(SelectionAsGrid)
FOR_EACH_COMMAND(SetColorSelector)
FOR_EACH_COMMAND(SetInkType)