| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2020 Igara Studio S.A. |
| 3 | // Copyright (C) 2016-2017 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifdef HAVE_CONFIG_H |
| 9 | #include "config.h" |
| 10 | #endif |
| 11 | |
| 12 | #include "app/commands/command.h" |
| 13 | #include "app/context_access.h" |
| 14 | #include "app/util/clipboard.h" |
| 15 | |
| 16 | namespace app { |
| 17 | |
| 18 | class CopyMergedCommand : public Command { |
| 19 | public: |
| 20 | CopyMergedCommand(); |
| 21 | |
| 22 | protected: |
| 23 | bool onEnabled(Context* ctx) override; |
| 24 | void onExecute(Context* ctx) override; |
| 25 | }; |
| 26 | |
| 27 | CopyMergedCommand::CopyMergedCommand() |
| 28 | : Command(CommandId::CopyMerged(), CmdUIOnlyFlag) |
| 29 | { |
| 30 | } |
| 31 | |
| 32 | bool CopyMergedCommand::onEnabled(Context* ctx) |
| 33 | { |
| 34 | return ctx->checkFlags(ContextFlags::ActiveDocumentIsWritable | |
| 35 | ContextFlags::HasVisibleMask); |
| 36 | } |
| 37 | |
| 38 | void CopyMergedCommand::onExecute(Context* ctx) |
| 39 | { |
| 40 | ContextReader reader(ctx); |
| 41 | ctx->clipboard()->copyMerged(reader); |
| 42 | } |
| 43 | |
| 44 | Command* CommandFactory::createCopyMergedCommand() |
| 45 | { |
| 46 | return new CopyMergedCommand; |
| 47 | } |
| 48 | |
| 49 | } // namespace app |
| 50 |