mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Add TiledMode command and "View > Tiled Mode" submenu
This commit is contained in:
parent
c159a3c4b5
commit
d796c88f6f
14
data/gui.xml
14
data/gui.xml
@ -642,6 +642,20 @@
|
||||
<item command="SnapToGrid" text="&Snap to Grid" />
|
||||
<item command="GridSettings" text="Gri&d Settings" />
|
||||
<item command="SelectionAsGrid" text="Select&ion as Grid" />
|
||||
<menu text="Tiled &Mode">
|
||||
<item command="TiledMode" text="&None">
|
||||
<param name="axis" value="none" />
|
||||
</item>
|
||||
<item command="TiledMode" text="Tiled in &Both Axis">
|
||||
<param name="axis" value="both" />
|
||||
</item>
|
||||
<item command="TiledMode" text="Tiled in &X Axis">
|
||||
<param name="axis" value="x" />
|
||||
</item>
|
||||
<item command="TiledMode" text="Tiled in &Y Axis">
|
||||
<param name="axis" value="y" />
|
||||
</item>
|
||||
</menu>
|
||||
<separator />
|
||||
<item command="SetLoopSection" text="Set &Loop Section" />
|
||||
<item command="ShowOnionSkin" text="Show &Onion Skin" />
|
||||
|
@ -228,6 +228,7 @@ add_library(app-lib
|
||||
commands/cmd_sprite_properties.cpp
|
||||
commands/cmd_sprite_size.cpp
|
||||
commands/cmd_switch_colors.cpp
|
||||
commands/cmd_tiled_mode.cpp
|
||||
commands/cmd_timeline.cpp
|
||||
commands/cmd_toggle_preview.cpp
|
||||
commands/cmd_undo.cpp
|
||||
|
76
src/app/commands/cmd_tiled_mode.cpp
Normal file
76
src/app/commands/cmd_tiled_mode.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
// 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/commands/params.h"
|
||||
#include "app/context.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "filters/tiled_mode.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
class TiledModeCommand : public Command {
|
||||
public:
|
||||
TiledModeCommand();
|
||||
Command* clone() const override { return new TiledModeCommand(*this); }
|
||||
|
||||
protected:
|
||||
void onLoadParams(const Params& params) override;
|
||||
bool onEnabled(Context* context) override;
|
||||
bool onChecked(Context* context) override;
|
||||
void onExecute(Context* context) override;
|
||||
|
||||
filters::TiledMode m_mode;
|
||||
};
|
||||
|
||||
TiledModeCommand::TiledModeCommand()
|
||||
: Command("TiledMode",
|
||||
"Tiled Mode",
|
||||
CmdUIOnlyFlag)
|
||||
, m_mode(filters::TiledMode::NONE)
|
||||
{
|
||||
}
|
||||
|
||||
void TiledModeCommand::onLoadParams(const Params& params)
|
||||
{
|
||||
m_mode = filters::TiledMode::NONE;
|
||||
|
||||
std::string mode = params.get("axis");
|
||||
if (mode == "both") m_mode = filters::TiledMode::BOTH;
|
||||
else if (mode == "x") m_mode = filters::TiledMode::X_AXIS;
|
||||
else if (mode == "y") m_mode = filters::TiledMode::Y_AXIS;
|
||||
}
|
||||
|
||||
bool TiledModeCommand::onEnabled(Context* ctx)
|
||||
{
|
||||
return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
||||
ContextFlags::HasActiveSprite);
|
||||
}
|
||||
|
||||
bool TiledModeCommand::onChecked(Context* ctx)
|
||||
{
|
||||
const Document* doc = ctx->activeDocument();
|
||||
return (Preferences::instance().document(doc).tiled.mode() == m_mode);
|
||||
}
|
||||
|
||||
void TiledModeCommand::onExecute(Context* ctx)
|
||||
{
|
||||
const Document* doc = ctx->activeDocument();
|
||||
Preferences::instance().document(doc).tiled.mode(m_mode);
|
||||
}
|
||||
|
||||
Command* CommandFactory::createTiledModeCommand()
|
||||
{
|
||||
return new TiledModeCommand;
|
||||
}
|
||||
|
||||
} // namespace app
|
@ -99,9 +99,9 @@ FOR_EACH_COMMAND(SaveFileCopyAs)
|
||||
FOR_EACH_COMMAND(SaveMask)
|
||||
FOR_EACH_COMMAND(SavePalette)
|
||||
FOR_EACH_COMMAND(Scroll)
|
||||
FOR_EACH_COMMAND(SelectionAsGrid)
|
||||
FOR_EACH_COMMAND(SetColorSelector)
|
||||
FOR_EACH_COMMAND(SetLoopSection)
|
||||
FOR_EACH_COMMAND(SelectionAsGrid)
|
||||
FOR_EACH_COMMAND(SetPalette)
|
||||
FOR_EACH_COMMAND(SetPaletteEntrySize)
|
||||
FOR_EACH_COMMAND(ShowGrid)
|
||||
@ -111,6 +111,7 @@ FOR_EACH_COMMAND(SnapToGrid)
|
||||
FOR_EACH_COMMAND(SpriteProperties)
|
||||
FOR_EACH_COMMAND(SpriteSize)
|
||||
FOR_EACH_COMMAND(SwitchColors)
|
||||
FOR_EACH_COMMAND(TiledMode)
|
||||
FOR_EACH_COMMAND(Timeline)
|
||||
FOR_EACH_COMMAND(TogglePreview)
|
||||
FOR_EACH_COMMAND(Undo)
|
||||
|
Loading…
x
Reference in New Issue
Block a user