Fix several issues dropping pixels in MovingPixelState (fix #1241)

This commit is contained in:
David Capello 2016-09-07 10:40:32 -03:00
parent 5a55a9e276
commit 76fefe64f2

View File

@ -198,11 +198,28 @@ void MovingPixelsState::onActiveToolChange(Editor* editor, tools::Tool* tool)
// If the user changed the tool when he/she is moving pixels, // If the user changed the tool when he/she is moving pixels,
// we have to drop the pixels only if the new tool is not selection... // we have to drop the pixels only if the new tool is not selection...
if (m_pixelsMovement && if (m_pixelsMovement) {
(!tool->getInk(0)->isSelection() || // We don't want to drop pixels in case the user change the tool
!tool->getInk(1)->isSelection())) { // for scrolling/zooming/picking colors.
// We have to drop pixels if ((!tool->getInk(0)->isSelection() ||
dropPixels(); !tool->getInk(1)->isSelection()) &&
(!tool->getInk(0)->isScrollMovement() ||
!tool->getInk(1)->isScrollMovement()) &&
(!tool->getInk(0)->isZoom() ||
!tool->getInk(1)->isZoom()) &&
(!tool->getInk(0)->isEyedropper() ||
!tool->getInk(1)->isEyedropper())) {
// We have to drop pixels
dropPixels();
}
// If we've temporarily gone to a non-selection tool and now we're
// back, we've just to update the context bar to show the "moving
// pixels" controls (e.g. OK/Cancel movement buttons).
else if (tool->getInk(0)->isSelection() ||
tool->getInk(1)->isSelection()) {
ContextBar* contextBar = App::instance()->contextBar();
contextBar->updateForMovingPixels();
}
} }
} }
@ -477,8 +494,13 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev)
return; return;
} }
} }
// Don't drop pixels if the user zooms/scrolls/picks a color
// using commands.
else if ((command->id() == CommandId::Zoom) || else if ((command->id() == CommandId::Zoom) ||
(command->id() == CommandId::Scroll)) { (command->id() == CommandId::Scroll) ||
(command->id() == CommandId::Eyedropper) ||
// DiscardBrush is used by Eyedropper command
(command->id() == CommandId::DiscardBrush)) {
// Do not drop pixels // Do not drop pixels
return; return;
} }