diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cpp index d7f3370..d0d2c35 100644 --- a/toonz/sources/tnztools/geometrictool.cpp +++ b/toonz/sources/tnztools/geometrictool.cpp @@ -561,6 +561,7 @@ public: bool getSmooth() { return m_param->m_smooth.getValue(); } virtual TStroke *makeStroke() const = 0; + virtual bool canTouchImageOnPreLeftClick() { return true; } }; //----------------------------------------------------------------------------- @@ -729,6 +730,9 @@ public: void onImageChanged() override; void setVertexes(const std::vector &vertex) { m_vertex = vertex; }; void setSpeedMoved(bool speedMoved) { m_speedMoved = speedMoved; }; + + // Only execute touchImage when clicking the first point of the polyline + bool canTouchImageOnPreLeftClick() override { return m_vertex.empty(); } }; //----------------------------------------------------------------------------- @@ -839,6 +843,7 @@ public: TStroke *makeStroke() const override; void draw() override; + void leftButtonDown(const TPointD &pos, const TMouseEvent &) override; void leftButtonUp(const TPointD &pos, const TMouseEvent &) override; void mouseMove(const TPointD &pos, const TMouseEvent &e) override; void leftButtonDoubleClick(const TPointD &, const TMouseEvent &e) override; @@ -869,6 +874,9 @@ public: void decreaseUndo() { --m_undoCount; } void increaseUndo() { ++m_undoCount; } + + // Only execute touchImage when clicking the first point of the multi arc + bool canTouchImageOnPreLeftClick() override { return m_clickNumber == 0; } }; //----------------------------------------------------------------------------- @@ -1022,19 +1030,27 @@ public: } } + bool preLeftButtonDown() override { + if (getViewer() && getViewer()->getGuidedStrokePickerMode()) return false; + if (getApplication()->getCurrentObject()->isSpline()) return true; + + // in the halfway through the drawing of Polyline / MultiArc primitive, OT + // should not call touchImage or the m_frameCreated / m_levelCreated flags + // will be reset. + if (m_primitive && !m_primitive->canTouchImageOnPreLeftClick()) return true; + // NEEDS to be done even if(m_active), due + // to the HORRIBLE m_frameCreated / m_levelCreated + // mechanism. touchImage() is the ONLY function + // resetting them to false... >_< + m_active = !!touchImage(); + return true; + } + void leftButtonDown(const TPointD &p, const TMouseEvent &e) override { if (getViewer() && getViewer()->getGuidedStrokePickerMode()) { getViewer()->doPickGuideStroke(p); return; } - - /* m_active = getApplication()->getCurrentObject()->isSpline() || - (bool) getImage(true);*/ - if (!getApplication()->getCurrentObject()->isSpline()) - m_active = touchImage(); // NEEDS to be done even if(m_active), due - if (!m_active) // to the HORRIBLE m_frameCreated / m_levelCreated - return; // mechanism. touchImage() is the ONLY function - // resetting them to false... >_< if (m_primitive) m_primitive->leftButtonDown(p, e); invalidate(); } @@ -2369,6 +2385,17 @@ TStroke *MultiArcPrimitive::makeStroke() const { //----------------------------------------------------------------------------- +void MultiArcPrimitive::leftButtonDown(const TPointD &pos, + const TMouseEvent &) { + if (m_clickNumber == 0) { + TPointD newPos = calculateSnap(pos); + newPos = checkGuideSnapping(pos); + m_startPoint = newPos; + } +} + +//----------------------------------------------------------------------------- + void MultiArcPrimitive::leftButtonUp(const TPointD &pos, const TMouseEvent &) { TTool::Application *app = TTool::getApplication(); if (!app) return; diff --git a/toonz/sources/tnztools/typetool.cpp b/toonz/sources/tnztools/typetool.cpp index d495d25..490418f 100644 --- a/toonz/sources/tnztools/typetool.cpp +++ b/toonz/sources/tnztools/typetool.cpp @@ -358,6 +358,7 @@ public: void setCursorIndexFromPoint(TPointD point); void mouseMove(const TPointD &pos, const TMouseEvent &) override; + bool preLeftButtonDown() override; void leftButtonDown(const TPointD &pos, const TMouseEvent &) override; void rightButtonDown(const TPointD &pos, const TMouseEvent &) override; bool keyDown(QKeyEvent *event) override; @@ -1201,6 +1202,15 @@ void TypeTool::mouseMove(const TPointD &pos, const TMouseEvent &) { //--------------------------------------------------------- +bool TypeTool::preLeftButtonDown() { + if (getViewer() && getViewer()->getGuidedStrokePickerMode()) return false; + + if (m_validFonts && !m_active) touchImage(); + return true; +} + +//--------------------------------------------------------- + void TypeTool::leftButtonDown(const TPointD &pos, const TMouseEvent &) { TSelection::setCurrent(0); @@ -1211,11 +1221,7 @@ void TypeTool::leftButtonDown(const TPointD &pos, const TMouseEvent &) { if (!m_validFonts) return; - TImageP img; - if (!m_active) - img = touchImage(); - else - img = getImage(true); + TImageP img = getImage(true); TVectorImageP vi = img; TToonzImageP ti = img; @@ -1608,7 +1614,7 @@ bool TypeTool::keyDown(QKeyEvent *event) { invalidate(); break; - /////////////////// end cursors + /////////////////// end cursors case Qt::Key_Escape: resetInputMethod();