mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 21:19:18 +00:00
Fix problem pasting from the clipboard when the active tool is a non-selection one.
The PixelsMovement uses the document's extra cel to show the transformation preview. On the other side, painting tools use the extra cel to show the drawing cursor preview. So MovingPixelsState is incompatible with painting tools, both use the extra cel for different purposes.
This commit is contained in:
parent
c6da98ea52
commit
9fbc9374e2
@ -45,6 +45,8 @@ using namespace tools;
|
||||
#include "tools/intertwiners.h"
|
||||
#include "tools/point_shapes.h"
|
||||
|
||||
const char* WellKnownTools::RectangularMarquee = "rectangular_marquee";
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
ToolBox::ToolBox()
|
||||
|
@ -29,6 +29,10 @@ class TiXmlElement;
|
||||
|
||||
namespace tools {
|
||||
|
||||
namespace WellKnownTools {
|
||||
extern const char* RectangularMarquee;
|
||||
};
|
||||
|
||||
typedef std::list<Tool*> ToolList;
|
||||
typedef ToolList::iterator ToolIterator;
|
||||
typedef ToolList::const_iterator ToolConstIterator;
|
||||
|
@ -38,6 +38,9 @@
|
||||
#include "raster/raster.h"
|
||||
#include "settings/settings.h"
|
||||
#include "skin/skin_theme.h"
|
||||
#include "tools/ink.h"
|
||||
#include "tools/tool.h"
|
||||
#include "tools/tool_box.h"
|
||||
#include "ui_context.h"
|
||||
#include "util/boundary.h"
|
||||
#include "util/misc.h"
|
||||
@ -49,6 +52,7 @@
|
||||
#include "widgets/editor/pixels_movement.h"
|
||||
#include "widgets/editor/standby_state.h"
|
||||
#include "widgets/statebar.h"
|
||||
#include "widgets/toolbar.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#include <stdio.h>
|
||||
@ -1157,6 +1161,18 @@ void Editor::setZoomAndCenterInMouse(int zoom, int mouse_x, int mouse_y)
|
||||
|
||||
void Editor::pasteImage(const Image* image, int x, int y)
|
||||
{
|
||||
// Change to a selection tool: it's necessary for PixelsMovement
|
||||
// which will use the extra cel for transformation preview, and is
|
||||
// not compatible with the drawing cursor preview which overwrite
|
||||
// the extra cel.
|
||||
tools::Tool* currentTool = getCurrentEditorTool();
|
||||
if (!currentTool->getInk(0)->isSelection()) {
|
||||
tools::Tool* defaultSelectionTool =
|
||||
App::instance()->getToolBox()->getToolById(tools::WellKnownTools::RectangularMarquee);
|
||||
|
||||
toolbar_select_tool(app_get_toolbar(), defaultSelectionTool);
|
||||
}
|
||||
|
||||
Document* document = getDocument();
|
||||
int opacity = 255;
|
||||
Sprite* sprite = getSprite();
|
||||
|
@ -43,6 +43,11 @@
|
||||
|
||||
MovingPixelsState::MovingPixelsState(Editor* editor, Message* msg, PixelsMovement* pixelsMovement, HandleType handle)
|
||||
{
|
||||
// MovingPixelsState needs a selection tool to avoid problems
|
||||
// sharing the extra cel between the drawing cursor preview and the
|
||||
// pixels movement/transformation preview.
|
||||
ASSERT(!editor->getCurrentEditorTool()->getInk(0)->isSelection());
|
||||
|
||||
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
|
||||
m_pixelsMovement = pixelsMovement;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user