[aseprite] 32/134: Fix problems with multiple editors in MovingPixelsState (fix #419)
Tobias Hansen
thansen at moszumanska.debian.org
Sat Mar 14 17:09:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 9fb339639248fc15959ce5f558a06189a96ee99c
Author: David Capello <davidcapello at gmail.com>
Date: Sun Nov 2 16:15:52 2014 -0300
Fix problems with multiple editors in MovingPixelsState (fix #419)
---
src/app/ui/editor/moving_pixels_state.cpp | 39 +++++++++++++++++++++++++++++--
src/app/ui/editor/moving_pixels_state.h | 3 +++
src/app/ui/editor/standby_state.cpp | 2 ++
3 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp
index 6c6a45f..ee1b055 100644
--- a/src/app/ui/editor/moving_pixels_state.cpp
+++ b/src/app/ui/editor/moving_pixels_state.cpp
@@ -177,13 +177,23 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
{
ASSERT(m_pixelsMovement != NULL);
- Decorator* decorator = static_cast<Decorator*>(editor->decorator());
- Document* document = editor->document();
+ // Set this editor as the active one and setup the ContextBar for
+ // moving pixels. This is needed in case that the user is working
+ // with a couple of Editors, in one is moving pixels and the other
+ // one not.
+ UIContext* ctx = UIContext::instance();
+ ctx->setActiveView(editor->getDocumentView());
+
+ ContextBar* contextBar = App::instance()->getMainWindow()->getContextBar();
+ contextBar->updateForMovingPixels();
// Start scroll loop
if (checkForScroll(editor, msg))
return true;
+ Decorator* decorator = static_cast<Decorator*>(editor->decorator());
+ Document* document = editor->document();
+
// Transform selected pixels
if (document->isMaskVisible() &&
decorator->getTransformHandles(editor)) {
@@ -406,6 +416,10 @@ bool MovingPixelsState::onUpdateStatusBar(Editor* editor)
// Before executing any command, we drop the pixels (go back to standby).
void MovingPixelsState::onBeforeCommandExecution(Command* command)
{
+ // If the command is for other editor, we don't drop pixels.
+ if (!isActiveEditor())
+ return;
+
// We don't need to drop the pixels if a MoveMaskCommand of Content is executed.
if (MoveMaskCommand* moveMaskCmd = dynamic_cast<MoveMaskCommand*>(command)) {
if (moveMaskCmd->getTarget() == MoveMaskCommand::Content)
@@ -422,12 +436,18 @@ void MovingPixelsState::onBeforeCommandExecution(Command* command)
void MovingPixelsState::onBeforeFrameChanged(Editor* editor)
{
+ if (!isActiveDocument())
+ return;
+
if (m_pixelsMovement)
dropPixels(m_editor);
}
void MovingPixelsState::onBeforeLayerChanged(Editor* editor)
{
+ if (!isActiveDocument())
+ return;
+
if (m_pixelsMovement)
dropPixels(m_editor);
}
@@ -440,6 +460,9 @@ void MovingPixelsState::onSetMoveTransparentColor(app::Color newColor)
void MovingPixelsState::onDropPixels(ContextBarObserver::DropAction action)
{
+ if (!isActiveEditor())
+ return;
+
switch (action) {
case ContextBarObserver::DropPixels:
@@ -478,4 +501,16 @@ gfx::Transformation MovingPixelsState::getTransformation(Editor* editor)
return m_pixelsMovement->getTransformation();
}
+bool MovingPixelsState::isActiveDocument() const
+{
+ Document* doc = UIContext::instance()->activeDocument();
+ return (m_editor->document() == doc);
+}
+
+bool MovingPixelsState::isActiveEditor() const
+{
+ Editor* targetEditor = UIContext::instance()->activeEditor();
+ return (targetEditor == m_editor);
+}
+
} // namespace app
diff --git a/src/app/ui/editor/moving_pixels_state.h b/src/app/ui/editor/moving_pixels_state.h
index 6e2144b..bbaedcd 100644
--- a/src/app/ui/editor/moving_pixels_state.h
+++ b/src/app/ui/editor/moving_pixels_state.h
@@ -78,6 +78,9 @@ namespace app {
void setTransparentColor(const app::Color& color);
void dropPixels(Editor* editor);
+ bool isActiveDocument() const;
+ bool isActiveEditor() const;
+
// Helper member to move/translate selection and pixels.
PixelsMovementPtr m_pixelsMovement;
Editor* m_editor;
diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp
index f027b3f..60fdedd 100644
--- a/src/app/ui/editor/standby_state.cpp
+++ b/src/app/ui/editor/standby_state.cpp
@@ -556,6 +556,8 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
// Other editor is locking the document.
// TODO steal the PixelsMovement of the other editor and use it for this one.
+ StatusBar::instance()->showTip(1000, "The sprite is locked in other editor");
+ jmouse_set_cursor(kForbiddenCursor);
}
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list