Merge branch 'swap-bg-colors' (fix #1812)

This commit is contained in:
David Capello 2020-06-04 16:57:56 -03:00
commit e4b224a0bd
4 changed files with 56 additions and 0 deletions

View File

@ -439,6 +439,7 @@ SpriteProperties = Sprite Properties
SpriteSize = Sprite Size
Stroke = Stroke Selection Borders with Foreground Color
SwitchColors = Switch Colors
SwapCheckerboardColors = Swap Checkerboard Background Colors
SwitchNonactiveLayersOpacity = Switch Nonactive Layers Opacity
SymmetryMode = Symmetry Mode
TiledMode = Tiled Mode

View File

@ -283,6 +283,7 @@ if(ENABLE_UI)
commands/cmd_show.cpp
commands/cmd_slice_properties.cpp
commands/cmd_sprite_properties.cpp
commands/cmd_swap_checkerboard_colors.cpp
commands/cmd_switch_colors.cpp
commands/cmd_symmetry_mode.cpp
commands/cmd_tiled_mode.cpp

View File

@ -0,0 +1,53 @@
// Aseprite
// Copyright (C) 2001-2015 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "app/app.h"
#include "app/commands/command.h"
#include "app/modules/editors.h"
#include "app/ui/editor/editor.h"
#include "ui/base.h"
#include "app/context.h"
namespace app {
class SwapCheckerboardColorsCommand : public Command {
public:
SwapCheckerboardColorsCommand();
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
};
SwapCheckerboardColorsCommand::SwapCheckerboardColorsCommand()
: Command(CommandId::SwapCheckerboardColors(), CmdUIOnlyFlag)
{
}
bool SwapCheckerboardColorsCommand::onEnabled(Context* context)
{
return true;
}
void SwapCheckerboardColorsCommand::onExecute(Context* context)
{
DocumentPreferences& docPref = Preferences::instance().document(context->activeDocument());
app::Color c1 = docPref.bg.color1();
app::Color c2 = docPref.bg.color2();
docPref.bg.color1(c2);
docPref.bg.color2(c1);
}
Command* CommandFactory::createSwapCheckerboardColorsCommand()
{
return new SwapCheckerboardColorsCommand;
}
} // namespace app

View File

@ -151,6 +151,7 @@ FOR_EACH_COMMAND(SliceProperties)
FOR_EACH_COMMAND(SnapToGrid)
FOR_EACH_COMMAND(SpriteProperties)
FOR_EACH_COMMAND(Stroke)
FOR_EACH_COMMAND(SwapCheckerboardColors)
FOR_EACH_COMMAND(SwitchColors)
FOR_EACH_COMMAND(SymmetryMode)
FOR_EACH_COMMAND(TiledMode)