From 71d24f1fb1751744cc7022755677097988cbfd6f Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Mar 28 2021 08:35:58 +0000 Subject: fix arc/multiarc start point offset and undo --- diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cpp index 52d0838..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; } }; //----------------------------------------------------------------------------- @@ -1024,13 +1032,17 @@ public: bool preLeftButtonDown() override { if (getViewer() && getViewer()->getGuidedStrokePickerMode()) return false; - - if (!getApplication()->getCurrentObject()->isSpline()) - // 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(); + 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; } @@ -2373,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 d62bffc..490418f 100644 --- a/toonz/sources/tnztools/typetool.cpp +++ b/toonz/sources/tnztools/typetool.cpp @@ -1205,8 +1205,7 @@ void TypeTool::mouseMove(const TPointD &pos, const TMouseEvent &) { bool TypeTool::preLeftButtonDown() { if (getViewer() && getViewer()->getGuidedStrokePickerMode()) return false; - if (m_validFonts && !m_active) - touchImage(); + if (m_validFonts && !m_active) touchImage(); return true; } @@ -1222,7 +1221,7 @@ void TypeTool::leftButtonDown(const TPointD &pos, const TMouseEvent &) { if (!m_validFonts) return; - TImageP img = getImage(true); + TImageP img = getImage(true); TVectorImageP vi = img; TToonzImageP ti = img; @@ -1615,7 +1614,7 @@ bool TypeTool::keyDown(QKeyEvent *event) { invalidate(); break; - /////////////////// end cursors + /////////////////// end cursors case Qt::Key_Escape: resetInputMethod();