diff --git a/src/widgets/editor.h b/src/widgets/editor.h index 4c0300101..58452aefd 100644 --- a/src/widgets/editor.h +++ b/src/widgets/editor.h @@ -195,6 +195,7 @@ public: protected: bool onProcessMessage(JMessage msg); + void onCurrentToolChange(); private: void drawGrid(const Rect& gridBounds, color_t color); diff --git a/src/widgets/editor/editor.cpp b/src/widgets/editor/editor.cpp index de7abdb62..e7fcb84b5 100644 --- a/src/widgets/editor/editor.cpp +++ b/src/widgets/editor/editor.cpp @@ -104,6 +104,8 @@ Editor::Editor() m_pixelsMovement = NULL; jwidget_focusrest(this, true); + + App::instance()->CurrentToolChange.connect(&Editor::onCurrentToolChange, this); } Editor::~Editor() @@ -1508,6 +1510,22 @@ bool Editor::onProcessMessage(JMessage msg) return Widget::onProcessMessage(msg); } +// When the current tool is changed +void Editor::onCurrentToolChange() +{ + UIContext* context = UIContext::instance(); + Tool* current_tool = context->getSettings()->getCurrentTool(); + + // 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... + if (m_pixelsMovement && + (!current_tool->getInk(0)->isSelection() || + !current_tool->getInk(1)->isSelection())) { + // We have to drop pixels + dropPixels(); + } +} + /** * Returns size for the editor viewport */