mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-17 13:20:45 +00:00
Temporal fix for issue 299: Don't allow moving the selection from other editor than the current one
This commit is contained in:
parent
fc58c24da2
commit
fe552f60de
@ -1188,10 +1188,10 @@ void Editor::pasteImage(const Image* image, int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
PixelsMovement* pixelsMovement =
|
||||
PixelsMovementPtr pixelsMovement(
|
||||
new PixelsMovement(UIContext::instance(),
|
||||
document, sprite, layer,
|
||||
image, x, y, opacity, "Paste");
|
||||
document, sprite, layer,
|
||||
image, x, y, opacity, "Paste"));
|
||||
|
||||
// Select the pasted image so the user can move it and transform it.
|
||||
pixelsMovement->maskImage(image, x, y);
|
||||
|
@ -55,7 +55,7 @@ namespace app {
|
||||
|
||||
using namespace ui;
|
||||
|
||||
MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMovement* pixelsMovement, HandleType handle)
|
||||
MovingPixelsState::MovingPixelsState(Editor* editor, MouseMessage* msg, PixelsMovementPtr pixelsMovement, HandleType handle)
|
||||
: m_currentEditor(editor)
|
||||
, m_discarded(false)
|
||||
{
|
||||
@ -100,7 +100,7 @@ MovingPixelsState::~MovingPixelsState()
|
||||
UIContext::instance()->removeObserver(this);
|
||||
UIContext::instance()->settings()->selection()->removeObserver(this);
|
||||
|
||||
delete m_pixelsMovement;
|
||||
m_pixelsMovement.reset(NULL);
|
||||
|
||||
m_currentEditor->getManager()->removeMessageFilter(kKeyDownMessage, m_currentEditor);
|
||||
m_currentEditor->getManager()->removeMessageFilter(kKeyUpMessage, m_currentEditor);
|
||||
@ -122,8 +122,7 @@ EditorState::BeforeChangeAction MovingPixelsState::onBeforeChangeState(Editor* e
|
||||
|
||||
editor->getDocument()->resetTransformation();
|
||||
|
||||
delete m_pixelsMovement;
|
||||
m_pixelsMovement = NULL;
|
||||
m_pixelsMovement.reset(NULL);
|
||||
|
||||
editor->releaseMouse();
|
||||
|
||||
|
@ -21,9 +21,10 @@
|
||||
|
||||
#include "app/context_observer.h"
|
||||
#include "app/settings/settings_observers.h"
|
||||
#include "app/ui/editor/handle_type.h"
|
||||
#include "app/ui/editor/standby_state.h"
|
||||
#include "app/ui/context_bar.h"
|
||||
#include "app/ui/editor/handle_type.h"
|
||||
#include "app/ui/editor/pixels_movement.h"
|
||||
#include "app/ui/editor/standby_state.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "base/compiler_specific.h"
|
||||
|
||||
@ -33,14 +34,13 @@ namespace raster {
|
||||
|
||||
namespace app {
|
||||
class Editor;
|
||||
class PixelsMovement;
|
||||
|
||||
class MovingPixelsState
|
||||
: public StandbyState
|
||||
, ContextObserver
|
||||
, SelectionSettingsObserver {
|
||||
public:
|
||||
MovingPixelsState(Editor* editor, ui::MouseMessage* msg, PixelsMovement* pixelsMovement, HandleType handle);
|
||||
MovingPixelsState(Editor* editor, ui::MouseMessage* msg, PixelsMovementPtr pixelsMovement, HandleType handle);
|
||||
virtual ~MovingPixelsState();
|
||||
|
||||
// EditorState
|
||||
@ -69,7 +69,7 @@ namespace app {
|
||||
void dropPixels(Editor* editor);
|
||||
|
||||
// Helper member to move/translate selection and pixels.
|
||||
PixelsMovement* m_pixelsMovement;
|
||||
PixelsMovementPtr m_pixelsMovement;
|
||||
Editor* m_currentEditor;
|
||||
|
||||
// True if the image was discarded (e.g. when a "Cut" command was
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "app/ui/editor/handle_type.h"
|
||||
#include "app/undo_transaction.h"
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/shared_ptr.h"
|
||||
#include "gfx/size.h"
|
||||
#include "raster/algorithm/flip_type.h"
|
||||
|
||||
@ -129,6 +130,8 @@ namespace app {
|
||||
a = static_cast<PixelsMovement::MoveModifier>(a | b);
|
||||
return a;
|
||||
}
|
||||
|
||||
typedef SharedPtr<PixelsMovement> PixelsMovementPtr;
|
||||
|
||||
} // namespace app
|
||||
|
||||
|
@ -491,27 +491,34 @@ gfx::Transformation StandbyState::getTransformation(Editor* editor)
|
||||
|
||||
void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleType handle)
|
||||
{
|
||||
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
|
||||
Document* document = editor->getDocument();
|
||||
base::UniquePtr<Image> tmpImage(NewImageFromMask(editor->getDocumentLocation()));
|
||||
int x = document->getMask()->getBounds().x;
|
||||
int y = document->getMask()->getBounds().y;
|
||||
int opacity = 255;
|
||||
Sprite* sprite = editor->getSprite();
|
||||
Layer* layer = editor->getLayer();
|
||||
PixelsMovement* pixelsMovement =
|
||||
new PixelsMovement(UIContext::instance(),
|
||||
document, sprite, layer,
|
||||
tmpImage, x, y, opacity,
|
||||
"Transformation");
|
||||
try {
|
||||
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
|
||||
Document* document = editor->getDocument();
|
||||
base::UniquePtr<Image> tmpImage(NewImageFromMask(editor->getDocumentLocation()));
|
||||
int x = document->getMask()->getBounds().x;
|
||||
int y = document->getMask()->getBounds().y;
|
||||
int opacity = 255;
|
||||
Sprite* sprite = editor->getSprite();
|
||||
Layer* layer = editor->getLayer();
|
||||
PixelsMovementPtr pixelsMovement(
|
||||
new PixelsMovement(UIContext::instance(),
|
||||
document, sprite, layer,
|
||||
tmpImage, x, y, opacity,
|
||||
"Transformation"));
|
||||
|
||||
// If the Ctrl key is pressed start dragging a copy of the selection
|
||||
if (customization && customization->isCopySelectionKeyPressed())
|
||||
pixelsMovement->copyMask();
|
||||
else
|
||||
pixelsMovement->cutMask();
|
||||
// If the Ctrl key is pressed start dragging a copy of the selection
|
||||
if (customization && customization->isCopySelectionKeyPressed())
|
||||
pixelsMovement->copyMask();
|
||||
else
|
||||
pixelsMovement->cutMask();
|
||||
|
||||
editor->setState(EditorStatePtr(new MovingPixelsState(editor, msg, pixelsMovement, handle)));
|
||||
editor->setState(EditorStatePtr(new MovingPixelsState(editor, msg, pixelsMovement, handle)));
|
||||
}
|
||||
catch (const LockedDocumentException&) {
|
||||
// Other editor is locking the document.
|
||||
|
||||
// TODO steal the PixelsMovement of the other editor and use it for this one.
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
x
Reference in New Issue
Block a user