mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 21:19:10 +00:00
Don't overwrite clipboard content on Edit > Insert Text (fix #839)
This commit is contained in:
parent
9225420eba
commit
91af58dbb0
@ -14,16 +14,18 @@
|
||||
#include "app/console.h"
|
||||
#include "app/context.h"
|
||||
#include "app/file_selector.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/ui/drop_down_button.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/font_popup.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/util/freetype_utils.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/path.h"
|
||||
#include "base/string.h"
|
||||
#include "base/unique_ptr.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/image_ref.h"
|
||||
|
||||
#include "paste_text.xml.h"
|
||||
|
||||
@ -138,6 +140,10 @@ private:
|
||||
|
||||
void PasteTextCommand::onExecute(Context* ctx)
|
||||
{
|
||||
Editor* editor = current_editor;
|
||||
if (editor == NULL)
|
||||
return;
|
||||
|
||||
Preferences& pref = Preferences::instance();
|
||||
PasteTextWindow window(pref.textTool.fontFace(),
|
||||
pref.textTool.fontSize(),
|
||||
@ -165,10 +171,9 @@ void PasteTextCommand::onExecute(Context* ctx)
|
||||
appColor.getBlue(),
|
||||
appColor.getAlpha());
|
||||
|
||||
doc::Image* image = render_text(faceName, size, text, color);
|
||||
doc::ImageRef image(render_text(faceName, size, text, color));
|
||||
if (image) {
|
||||
clipboard::copy_image(image, nullptr, nullptr);
|
||||
clipboard::paste();
|
||||
editor->pasteImage(image.get());
|
||||
}
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
|
@ -1494,7 +1494,20 @@ void Editor::setZoomAndCenterInMouse(const Zoom& zoom,
|
||||
void Editor::pasteImage(const Image* image, const Mask* mask)
|
||||
{
|
||||
ASSERT(image);
|
||||
ASSERT(mask);
|
||||
|
||||
base::UniquePtr<Mask> temp_mask;
|
||||
if (!mask) {
|
||||
gfx::Rect visibleBounds = getVisibleSpriteBounds();
|
||||
gfx::Rect imageBounds = image->bounds();
|
||||
|
||||
temp_mask.reset(new Mask);
|
||||
temp_mask->replace(
|
||||
gfx::Rect(visibleBounds.x + visibleBounds.w/2 - imageBounds.w/2,
|
||||
visibleBounds.y + visibleBounds.h/2 - imageBounds.h/2,
|
||||
imageBounds.w, imageBounds.h));
|
||||
|
||||
mask = temp_mask.get();
|
||||
}
|
||||
|
||||
// Change to a selection tool: it's necessary for PixelsMovement
|
||||
// which will use the extra cel for transformation preview, and is
|
||||
|
@ -185,7 +185,7 @@ namespace app {
|
||||
void setZoomAndCenterInMouse(const render::Zoom& zoom,
|
||||
const gfx::Point& mousePos, ZoomBehavior zoomBehavior);
|
||||
|
||||
void pasteImage(const Image* image, const Mask* mask);
|
||||
void pasteImage(const Image* image, const Mask* mask = nullptr);
|
||||
|
||||
void startSelectionTransformation(const gfx::Point& move, double angle);
|
||||
|
||||
|
@ -262,17 +262,6 @@ void clipboard::paste()
|
||||
if (!clipboard_image)
|
||||
return;
|
||||
|
||||
if (!clipboard_mask) {
|
||||
gfx::Rect visibleBounds = editor->getVisibleSpriteBounds();
|
||||
gfx::Rect imageBounds = clipboard_image->bounds();
|
||||
|
||||
clipboard_mask.reset(new Mask);
|
||||
clipboard_mask->replace(
|
||||
gfx::Rect(visibleBounds.x + visibleBounds.w/2 - imageBounds.w/2,
|
||||
visibleBounds.y + visibleBounds.h/2 - imageBounds.h/2,
|
||||
imageBounds.w, imageBounds.h));
|
||||
}
|
||||
|
||||
Palette* dst_palette = dstSpr->palette(editor->frame());
|
||||
|
||||
// Source image (clipboard or a converted copy to the destination 'imgtype')
|
||||
|
Loading…
Reference in New Issue
Block a user