2015-02-12 23:16:25 +08:00
|
|
|
// 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.
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-09-19 07:57:02 +08:00
|
|
|
#include "config.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#endif
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/app.h"
|
2015-01-19 09:05:33 +08:00
|
|
|
#include "app/cmd/deselect_mask.h"
|
|
|
|
#include "app/cmd/clear_mask.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/console.h"
|
|
|
|
#include "app/context_access.h"
|
|
|
|
#include "app/document.h"
|
|
|
|
#include "app/document_api.h"
|
|
|
|
#include "app/document_location.h"
|
2014-08-08 21:33:45 +08:00
|
|
|
#include "app/document_range.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/modules/editors.h"
|
|
|
|
#include "app/modules/gfx.h"
|
|
|
|
#include "app/modules/gui.h"
|
|
|
|
#include "app/modules/palettes.h"
|
|
|
|
#include "app/settings/settings.h"
|
2015-01-19 09:05:33 +08:00
|
|
|
#include "app/transaction.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/color_bar.h"
|
|
|
|
#include "app/ui/editor/editor.h"
|
2014-08-08 21:33:45 +08:00
|
|
|
#include "app/ui/main_window.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui/skin/skin_parts.h"
|
|
|
|
#include "app/ui/skin/skin_theme.h"
|
2014-08-08 21:33:45 +08:00
|
|
|
#include "app/ui/timeline.h"
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/ui_context.h"
|
|
|
|
#include "app/util/clipboard.h"
|
|
|
|
#include "app/util/misc.h"
|
2014-10-21 09:21:31 +08:00
|
|
|
#include "doc/doc.h"
|
2014-12-28 22:06:11 +08:00
|
|
|
#include "render/quantization.h"
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2015-02-12 23:46:56 +08:00
|
|
|
#ifdef _WIN32
|
2014-08-22 12:32:13 +08:00
|
|
|
#include <windows.h>
|
2011-03-24 22:50:00 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
#include "app/util/clipboard_win32.h"
|
2009-03-08 03:14:40 +08:00
|
|
|
#endif
|
|
|
|
|
2014-08-08 21:52:21 +08:00
|
|
|
#include <stdexcept>
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
namespace app {
|
|
|
|
|
2015-02-12 23:16:25 +08:00
|
|
|
namespace {
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
class ClipboardRange {
|
|
|
|
public:
|
|
|
|
ClipboardRange() : m_doc(NULL) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool valid() {
|
|
|
|
return m_doc != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void invalidate() {
|
|
|
|
m_doc = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void setRange(Document* doc, const DocumentRange& range) {
|
|
|
|
m_doc = doc;
|
|
|
|
m_range = range;
|
|
|
|
}
|
|
|
|
|
|
|
|
Document* document() const { return m_doc; }
|
|
|
|
DocumentRange range() const { return m_range; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
Document* m_doc;
|
|
|
|
DocumentRange m_range;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-10-21 09:21:31 +08:00
|
|
|
using namespace doc;
|
2013-08-06 08:20:19 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
static void set_clipboard_image(Image* image, Palette* palette, bool set_system_clipboard);
|
2013-03-12 07:29:45 +08:00
|
|
|
static bool copy_from_document(const DocumentLocation& location);
|
2009-03-08 03:14:40 +08:00
|
|
|
|
|
|
|
static bool first_time = true;
|
|
|
|
|
|
|
|
static Palette* clipboard_palette = NULL;
|
|
|
|
static Image* clipboard_image = NULL;
|
2014-08-08 21:33:45 +08:00
|
|
|
static ClipboardRange clipboard_range;
|
2014-11-24 11:09:22 +08:00
|
|
|
static gfx::Point clipboard_pos(0, 0);
|
2009-03-08 03:14:40 +08:00
|
|
|
|
2010-03-01 10:36:05 +08:00
|
|
|
static void on_exit_delete_clipboard()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2010-03-01 10:36:05 +08:00
|
|
|
delete clipboard_palette;
|
|
|
|
delete clipboard_image;
|
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
static void set_clipboard_image(Image* image, Palette* palette, bool set_system_clipboard)
|
2009-03-08 03:14:40 +08:00
|
|
|
{
|
|
|
|
if (first_time) {
|
|
|
|
first_time = false;
|
2010-03-01 10:36:05 +08:00
|
|
|
App::instance()->Exit.connect(&on_exit_delete_clipboard);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
2009-03-08 03:14:40 +08:00
|
|
|
|
|
|
|
delete clipboard_palette;
|
|
|
|
delete clipboard_image;
|
|
|
|
|
|
|
|
clipboard_palette = palette;
|
|
|
|
clipboard_image = image;
|
|
|
|
|
|
|
|
// copy to the Windows clipboard
|
2015-02-12 23:46:56 +08:00
|
|
|
#ifdef _WIN32
|
2009-03-08 03:14:40 +08:00
|
|
|
if (set_system_clipboard)
|
|
|
|
set_win32_clipboard_bitmap(image, palette);
|
|
|
|
#endif
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
clipboard_range.invalidate();
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
static bool copy_from_document(const DocumentLocation& location)
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2013-03-12 07:29:45 +08:00
|
|
|
const Document* document = location.document();
|
|
|
|
|
2011-03-23 11:06:43 +08:00
|
|
|
ASSERT(document != NULL);
|
|
|
|
ASSERT(document->isMaskVisible());
|
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
Image* image = NewImageFromMask(location);
|
2009-03-08 03:14:40 +08:00
|
|
|
if (!image)
|
|
|
|
return false;
|
|
|
|
|
2014-11-24 11:09:22 +08:00
|
|
|
clipboard_pos = document->mask()->bounds().getOrigin();
|
2012-01-06 10:21:51 +08:00
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
const Palette* pal = document->sprite()->palette(location.frame());
|
2014-08-08 21:33:45 +08:00
|
|
|
set_clipboard_image(image, pal ? new Palette(*pal): NULL, true);
|
2009-03-08 03:14:40 +08:00
|
|
|
return true;
|
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
clipboard::ClipboardFormat clipboard::get_current_format()
|
2009-03-08 03:14:40 +08:00
|
|
|
{
|
2015-02-12 23:46:56 +08:00
|
|
|
#ifdef _WIN32
|
2009-03-08 03:14:40 +08:00
|
|
|
if (win32_clipboard_contains_bitmap())
|
2014-08-08 21:33:45 +08:00
|
|
|
return ClipboardImage;
|
2009-03-08 03:14:40 +08:00
|
|
|
#endif
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
if (clipboard_image != NULL)
|
|
|
|
return ClipboardImage;
|
|
|
|
else if (clipboard_range.valid())
|
|
|
|
return ClipboardDocumentRange;
|
|
|
|
else
|
|
|
|
return ClipboardNone;
|
|
|
|
}
|
|
|
|
|
|
|
|
void clipboard::get_document_range_info(Document** document, DocumentRange* range)
|
|
|
|
{
|
|
|
|
if (clipboard_range.valid()) {
|
|
|
|
*document = clipboard_range.document();
|
|
|
|
*range = clipboard_range.range();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
*document = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void clipboard::clear_content()
|
|
|
|
{
|
|
|
|
set_clipboard_image(NULL, NULL, true);
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
void clipboard::cut(ContextWriter& writer)
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2013-03-12 07:29:45 +08:00
|
|
|
ASSERT(writer.document() != NULL);
|
|
|
|
ASSERT(writer.sprite() != NULL);
|
|
|
|
ASSERT(writer.layer() != NULL);
|
2011-03-23 08:11:25 +08:00
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
if (!copy_from_document(*writer.location())) {
|
2009-06-11 23:11:11 +08:00
|
|
|
Console console;
|
|
|
|
console.printf("Can't copying an image portion from the current layer\n");
|
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
else {
|
2008-10-11 23:59:13 +08:00
|
|
|
{
|
2015-01-19 09:05:33 +08:00
|
|
|
Transaction transaction(writer.context(), "Cut");
|
|
|
|
transaction.execute(new cmd::ClearMask(writer.cel()));
|
|
|
|
transaction.execute(new cmd::DeselectMask(writer.document()));
|
|
|
|
transaction.commit();
|
2008-10-11 23:59:13 +08:00
|
|
|
}
|
2013-03-12 07:29:45 +08:00
|
|
|
writer.document()->generateMaskBoundaries();
|
|
|
|
update_screen_for_document(writer.document());
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
void clipboard::copy(const ContextReader& reader)
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2013-03-12 07:29:45 +08:00
|
|
|
ASSERT(reader.document() != NULL);
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2013-03-12 07:29:45 +08:00
|
|
|
if (!copy_from_document(*reader.location())) {
|
2009-06-11 23:11:11 +08:00
|
|
|
Console console;
|
2010-09-19 10:54:56 +08:00
|
|
|
console.printf("Can't copying an image portion from the current layer\n");
|
2014-08-08 21:33:45 +08:00
|
|
|
return;
|
2009-06-11 23:11:11 +08:00
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
void clipboard::copy_range(const ContextReader& reader, const DocumentRange& range)
|
|
|
|
{
|
|
|
|
ASSERT(reader.document() != NULL);
|
|
|
|
|
|
|
|
ContextWriter writer(reader);
|
|
|
|
|
|
|
|
set_clipboard_image(NULL, NULL, true);
|
|
|
|
clipboard_range.setRange(writer.document(), range);
|
|
|
|
|
|
|
|
// TODO Replace this with a signal, because here the timeline
|
2015-03-17 06:53:20 +08:00
|
|
|
// depends on the clipboard and the clipboard on the timeline.
|
2014-08-08 21:33:45 +08:00
|
|
|
App::instance()->getMainWindow()
|
|
|
|
->getTimeline()->activateClipboardRange();
|
|
|
|
}
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
void clipboard::copy_image(Image* image, Palette* pal, const gfx::Point& point)
|
2009-03-08 03:14:40 +08:00
|
|
|
{
|
2014-08-08 21:33:45 +08:00
|
|
|
set_clipboard_image(Image::createCopy(image),
|
|
|
|
pal ? new Palette(*pal): NULL, true);
|
2012-02-12 08:06:31 +08:00
|
|
|
|
2014-11-24 11:09:22 +08:00
|
|
|
clipboard_pos = point;
|
2009-03-08 03:14:40 +08:00
|
|
|
}
|
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
void clipboard::paste()
|
2007-09-19 07:57:02 +08:00
|
|
|
{
|
2012-01-06 10:21:51 +08:00
|
|
|
Editor* editor = current_editor;
|
2013-01-21 05:40:37 +08:00
|
|
|
if (editor == NULL)
|
|
|
|
return;
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
Document* dstDoc = editor->document();
|
|
|
|
Sprite* dstSpr = dstDoc->sprite();
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
switch (get_current_format()) {
|
|
|
|
|
|
|
|
case clipboard::ClipboardImage: {
|
2015-02-12 23:46:56 +08:00
|
|
|
#ifdef _WIN32
|
2014-08-08 21:33:45 +08:00
|
|
|
// Get the image from the clipboard.
|
|
|
|
{
|
|
|
|
Image* win32_image = NULL;
|
|
|
|
Palette* win32_palette = NULL;
|
|
|
|
get_win32_clipboard_bitmap(win32_image, win32_palette);
|
|
|
|
if (win32_image != NULL)
|
|
|
|
set_clipboard_image(win32_image, win32_palette, false);
|
|
|
|
}
|
2009-03-08 03:14:40 +08:00
|
|
|
#endif
|
2011-03-23 08:11:25 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
if (clipboard_image == NULL)
|
|
|
|
return;
|
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
Palette* dst_palette = dstSpr->palette(editor->frame());
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
// Source image (clipboard or a converted copy to the destination 'imgtype')
|
|
|
|
Image* src_image;
|
2014-08-18 11:21:03 +08:00
|
|
|
if (clipboard_image->pixelFormat() == dstSpr->pixelFormat() &&
|
2014-08-08 21:33:45 +08:00
|
|
|
// Indexed images can be copied directly only if both images
|
|
|
|
// have the same palette.
|
|
|
|
(clipboard_image->pixelFormat() != IMAGE_INDEXED ||
|
|
|
|
clipboard_palette->countDiff(dst_palette, NULL, NULL) == 0)) {
|
|
|
|
src_image = clipboard_image;
|
|
|
|
}
|
|
|
|
else {
|
2014-12-29 07:39:11 +08:00
|
|
|
RgbMap* dst_rgbmap = dstSpr->rgbMap(editor->frame());
|
2014-08-08 21:33:45 +08:00
|
|
|
|
2014-12-28 22:06:11 +08:00
|
|
|
src_image = render::convert_pixel_format(
|
2014-08-18 11:21:03 +08:00
|
|
|
clipboard_image, NULL, dstSpr->pixelFormat(),
|
2014-12-28 22:06:11 +08:00
|
|
|
DitheringMethod::NONE, dst_rgbmap, clipboard_palette,
|
2014-08-08 21:33:45 +08:00
|
|
|
false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Change to MovingPixelsState
|
2014-11-24 11:09:22 +08:00
|
|
|
editor->pasteImage(src_image, clipboard_pos);
|
2014-08-08 21:33:45 +08:00
|
|
|
|
|
|
|
if (src_image != clipboard_image)
|
|
|
|
delete src_image;
|
|
|
|
break;
|
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
case clipboard::ClipboardDocumentRange: {
|
2014-08-18 11:21:03 +08:00
|
|
|
DocumentRange srcRange = clipboard_range.range();
|
|
|
|
Document* srcDoc = clipboard_range.document();
|
|
|
|
Sprite* srcSpr = srcDoc->sprite();
|
|
|
|
std::vector<Layer*> srcLayers;
|
|
|
|
std::vector<Layer*> dstLayers;
|
|
|
|
srcSpr->getLayersList(srcLayers);
|
|
|
|
dstSpr->getLayersList(dstLayers);
|
|
|
|
|
|
|
|
switch (srcRange.type()) {
|
|
|
|
|
|
|
|
case DocumentRange::kCels: {
|
2014-09-01 01:24:29 +08:00
|
|
|
// Do nothing case: pasting in the same document.
|
|
|
|
if (srcDoc == dstDoc)
|
|
|
|
return;
|
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
Transaction transaction(UIContext::instance(), "Paste Cels");
|
|
|
|
DocumentApi api = dstDoc->getApi(transaction);
|
2014-08-18 11:21:03 +08:00
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t dstFrame = editor->frame();
|
|
|
|
for (frame_t frame = srcRange.frameBegin(); frame <= srcRange.frameEnd(); ++frame) {
|
2014-08-18 11:21:03 +08:00
|
|
|
if (dstFrame == dstSpr->totalFrames())
|
|
|
|
api.addFrame(dstSpr, dstFrame);
|
|
|
|
|
|
|
|
for (LayerIndex
|
|
|
|
i = srcRange.layerEnd(),
|
|
|
|
j = dstSpr->layerToIndex(editor->layer());
|
|
|
|
i >= srcRange.layerBegin() &&
|
|
|
|
i >= LayerIndex(0) &&
|
|
|
|
j >= LayerIndex(0); --i, --j) {
|
2014-12-29 08:04:08 +08:00
|
|
|
Cel* cel = srcLayers[i]->cel(frame);
|
2014-08-18 11:21:03 +08:00
|
|
|
|
|
|
|
if (cel && cel->image()) {
|
|
|
|
api.copyCel(
|
|
|
|
static_cast<LayerImage*>(srcLayers[i]), frame,
|
2014-09-17 20:53:25 +08:00
|
|
|
static_cast<LayerImage*>(dstLayers[j]), dstFrame);
|
2014-08-18 11:21:03 +08:00
|
|
|
}
|
|
|
|
else {
|
2014-12-29 08:04:08 +08:00
|
|
|
Cel* dstCel = dstLayers[j]->cel(dstFrame);
|
2014-08-18 11:21:03 +08:00
|
|
|
if (dstCel)
|
2014-09-17 20:53:25 +08:00
|
|
|
api.clearCel(dstCel);
|
2014-08-18 11:21:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
++dstFrame;
|
2014-08-18 11:21:03 +08:00
|
|
|
}
|
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
transaction.commit();
|
2014-08-18 11:21:03 +08:00
|
|
|
editor->invalidate();
|
|
|
|
break;
|
|
|
|
}
|
2014-03-30 08:31:27 +08:00
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
case DocumentRange::kFrames: {
|
2015-01-19 09:05:33 +08:00
|
|
|
Transaction transaction(UIContext::instance(), "Paste Frames");
|
|
|
|
DocumentApi api = dstDoc->getApi(transaction);
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t dstFrame = frame_t(editor->frame() + 1);
|
2014-08-18 11:21:03 +08:00
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
for (frame_t frame = srcRange.frameBegin(); frame <= srcRange.frameEnd(); ++frame) {
|
2014-08-18 11:21:03 +08:00
|
|
|
api.addFrame(dstSpr, dstFrame);
|
|
|
|
|
|
|
|
for (LayerIndex
|
|
|
|
i = LayerIndex(srcLayers.size()-1),
|
|
|
|
j = LayerIndex(dstLayers.size()-1);
|
|
|
|
i >= LayerIndex(0) &&
|
|
|
|
j >= LayerIndex(0); --i, --j) {
|
2014-12-29 08:04:08 +08:00
|
|
|
Cel* cel = static_cast<LayerImage*>(srcLayers[i])->cel(frame);
|
2014-08-18 11:21:03 +08:00
|
|
|
if (cel && cel->image()) {
|
|
|
|
api.copyCel(
|
|
|
|
static_cast<LayerImage*>(srcLayers[i]), frame,
|
2014-09-17 20:53:25 +08:00
|
|
|
static_cast<LayerImage*>(dstLayers[j]), dstFrame);
|
2014-08-18 11:21:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 07:39:11 +08:00
|
|
|
++dstFrame;
|
2014-08-18 11:21:03 +08:00
|
|
|
}
|
2014-03-30 08:31:27 +08:00
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
transaction.commit();
|
2014-08-18 11:21:03 +08:00
|
|
|
editor->invalidate();
|
|
|
|
break;
|
|
|
|
}
|
2015-02-12 23:16:25 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
case DocumentRange::kLayers: {
|
2014-08-18 11:21:03 +08:00
|
|
|
if (srcDoc->colorMode() != dstDoc->colorMode())
|
2014-08-08 21:33:45 +08:00
|
|
|
throw std::runtime_error("You cannot copy layers of document with different color modes");
|
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
Transaction transaction(UIContext::instance(), "Paste Layers");
|
|
|
|
DocumentApi api = dstDoc->getApi(transaction);
|
2014-08-08 21:33:45 +08:00
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
// Expand frames of dstDoc if it's needed.
|
2014-12-29 07:39:11 +08:00
|
|
|
frame_t maxFrame(0);
|
2014-08-18 11:21:03 +08:00
|
|
|
for (LayerIndex i = srcRange.layerBegin();
|
|
|
|
i <= srcRange.layerEnd() &&
|
|
|
|
i < LayerIndex(srcLayers.size()); ++i) {
|
|
|
|
Cel* lastCel = static_cast<LayerImage*>(srcLayers[i])->getLastCel();
|
2014-08-20 19:29:21 +08:00
|
|
|
if (lastCel && maxFrame < lastCel->frame())
|
2014-08-12 18:57:40 +08:00
|
|
|
maxFrame = lastCel->frame();
|
|
|
|
}
|
2015-03-17 20:29:24 +08:00
|
|
|
while (dstSpr->totalFrames() < maxFrame+1)
|
|
|
|
api.addEmptyFrame(dstSpr, dstSpr->totalFrames());
|
2014-08-12 18:57:40 +08:00
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
for (LayerIndex i = srcRange.layerBegin(); i <= srcRange.layerEnd(); ++i) {
|
2015-03-17 21:06:37 +08:00
|
|
|
Layer* afterThis;
|
|
|
|
if (srcLayers[i]->isBackground() &&
|
|
|
|
!dstDoc->sprite()->backgroundLayer()) {
|
|
|
|
afterThis = nullptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
afterThis = dstSpr->folder()->getLastLayer();
|
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
LayerImage* newLayer = new LayerImage(dstSpr);
|
2015-03-17 21:06:37 +08:00
|
|
|
api.addLayer(dstSpr->folder(), newLayer, afterThis);
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2014-08-18 11:21:03 +08:00
|
|
|
srcDoc->copyLayerContent(
|
|
|
|
srcLayers[i], dstDoc, newLayer);
|
2014-08-08 21:33:45 +08:00
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
|
2015-01-19 09:05:33 +08:00
|
|
|
transaction.commit();
|
2014-08-08 21:33:45 +08:00
|
|
|
editor->invalidate();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-08-18 11:21:03 +08:00
|
|
|
|
2014-08-08 21:33:45 +08:00
|
|
|
}
|
2007-09-19 07:57:02 +08:00
|
|
|
}
|
2012-02-12 04:06:35 +08:00
|
|
|
|
2013-08-06 08:20:19 +08:00
|
|
|
bool clipboard::get_image_size(gfx::Size& size)
|
2012-02-12 04:06:35 +08:00
|
|
|
{
|
2015-02-12 23:46:56 +08:00
|
|
|
#ifdef _WIN32
|
2012-02-12 04:06:35 +08:00
|
|
|
// Get the image from the clipboard.
|
|
|
|
return get_win32_clipboard_bitmap_size(size);
|
|
|
|
#else
|
|
|
|
if (clipboard_image != NULL) {
|
2014-07-30 12:28:15 +08:00
|
|
|
size.w = clipboard_image->width();
|
|
|
|
size.h = clipboard_image->height();
|
2012-02-12 04:06:35 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
2013-08-06 08:20:19 +08:00
|
|
|
|
|
|
|
} // namespace app
|