2015-02-12 23:16:25 +08:00
|
|
|
// Aseprite
|
2017-12-01 10:41:45 +08:00
|
|
|
// Copyright (C) 2001-42017 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.
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2012-01-06 06:45:03 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
#include "app/cmd/deselect_mask.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/commands/command.h"
|
|
|
|
|
#include "app/context_access.h"
|
|
|
|
|
#include "app/modules/gui.h"
|
2015-01-19 09:05:33 +08:00
|
|
|
#include "app/transaction.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/mask.h"
|
|
|
|
|
#include "doc/sprite.h"
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
2012-01-06 06:45:03 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
class DeselectMaskCommand : public Command {
|
2012-01-06 06:45:03 +08:00
|
|
|
public:
|
|
|
|
|
DeselectMaskCommand();
|
2014-08-15 10:07:47 +08:00
|
|
|
Command* clone() const override { return new DeselectMaskCommand(*this); }
|
2012-01-06 06:45:03 +08:00
|
|
|
|
|
|
|
|
protected:
|
2015-10-01 03:34:43 +08:00
|
|
|
bool onEnabled(Context* context) override;
|
|
|
|
|
void onExecute(Context* context) override;
|
2012-01-06 06:45:03 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
DeselectMaskCommand::DeselectMaskCommand()
|
2017-12-02 02:10:21 +08:00
|
|
|
: Command(CommandId::DeselectMask(), CmdRecordableFlag)
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DeselectMaskCommand::onEnabled(Context* context)
|
|
|
|
|
{
|
|
|
|
|
return context->checkFlags(ContextFlags::ActiveDocumentIsWritable |
|
|
|
|
|
ContextFlags::HasVisibleMask);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeselectMaskCommand::onExecute(Context* context)
|
|
|
|
|
{
|
2013-03-12 07:29:45 +08:00
|
|
|
ContextWriter writer(context);
|
|
|
|
|
Document* document(writer.document());
|
2012-01-06 06:45:03 +08:00
|
|
|
{
|
2015-01-19 09:05:33 +08:00
|
|
|
Transaction transaction(writer.context(), "Deselect", DoesntModifyDocument);
|
|
|
|
|
transaction.execute(new cmd::DeselectMask(document));
|
|
|
|
|
transaction.commit();
|
2012-01-06 06:45:03 +08:00
|
|
|
}
|
|
|
|
|
document->generateMaskBoundaries();
|
|
|
|
|
update_screen_for_document(document);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Command* CommandFactory::createDeselectMaskCommand()
|
|
|
|
|
{
|
|
|
|
|
return new DeselectMaskCommand;
|
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
|
} // namespace app
|