aseprite/src/app/commands/cmd_flatten_layers.cpp

59 lines
1.3 KiB
C++
Raw Normal View History

2015-02-12 23:16:25 +08:00
// Aseprite
2017-05-19 22:10:56 +08:00
// Copyright (C) 2001-2017 David Capello
2015-02-12 23:16:25 +08:00
//
2016-08-27 04:02:58 +08:00
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
2017-05-19 22:10:56 +08:00
#include "app/cmd/flatten_layers.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
2017-05-19 22:10:56 +08:00
#include "app/ui/color_bar.h"
#include "doc/sprite.h"
namespace app {
class FlattenLayersCommand : public Command {
public:
FlattenLayersCommand();
Command* clone() const override { return new FlattenLayersCommand(*this); }
protected:
bool onEnabled(Context* context) override;
void onExecute(Context* context) override;
};
FlattenLayersCommand::FlattenLayersCommand()
: Command("FlattenLayers", CmdUIOnlyFlag)
{
}
bool FlattenLayersCommand::onEnabled(Context* context)
{
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable);
}
void FlattenLayersCommand::onExecute(Context* context)
{
ContextWriter writer(context);
Sprite* sprite = writer.sprite();
{
Transaction transaction(writer.context(), "Flatten Layers");
2017-05-19 22:10:56 +08:00
transaction.execute(new cmd::FlattenLayers(sprite));
transaction.commit();
}
update_screen_for_document(writer.document());
}
Command* CommandFactory::createFlattenLayersCommand()
{
return new FlattenLayersCommand;
}
} // namespace app