[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-kimageshop
Subject:    [krita/kazakov/svg-loading] libs/flake/tools: FEATURE: Highlight the active path segment while dragg
From:       Dmitry Kazakov <null () kde ! org>
Date:       2017-02-18 18:12:46
Message-ID: E1cf9V0-00062n-PL () code ! kde ! org
[Download RAW message or body]

Git commit 508ec7a8a637206c52e6a0f1164d5075e3477495 by Dmitry Kazakov.
Committed on 18/02/2017 at 18:12.
Pushed by dkazakov into branch 'kazakov/svg-loading'.

FEATURE: Highlight the active path segment while dragging it

Now the user can easily see that he can also drag by the path
as well, not only by the control points. When you hover the
path segment, it is highlighted

CC:kimageshop@kde.org

M  +45   -4    libs/flake/tools/KoPathTool.cpp
M  +1    -0    libs/flake/tools/KoPathTool.h

https://commits.kde.org/krita/508ec7a8a637206c52e6a0f1164d5075e3477495

diff --git a/libs/flake/tools/KoPathTool.cpp b/libs/flake/tools/KoPathTool.cpp
index 8f8cab66513..0c5ea3152a2 100644
--- a/libs/flake/tools/KoPathTool.cpp
+++ b/libs/flake/tools/KoPathTool.cpp
@@ -485,8 +485,31 @@ void KoPathTool::paint(QPainter &painter, const KoViewConverter \
&converter)  delete m_activeHandle;
             m_activeHandle = 0;
         }
+    } else if (m_activeSegment && m_activeSegment->isValid()) {
+
+        KoPathShape *shape = m_activeSegment->path;
+
+        // if the stroke is invisible, then we already painted the outline of the \
shape! +        if (shape->stroke() && shape->stroke()->isVisible()) {
+            KoPathPointIndex index = \
shape->pathPointIndex(m_activeSegment->segmentStart); +            KoPathSegment \
segment = shape->segmentByIndex(index).toCubic(); +
+            KisHandlePainterHelper helper =
+                KoShape::createHandlePainterHelper(&painter, shape, converter, \
m_handleRadius); +            \
helper.setHandleStyle(KisHandleStyle::secondarySelection()); +
+            QPainterPath path;
+            path.moveTo(segment.first()->point());
+            path.cubicTo(segment.first()->controlPoint2(),
+                         segment.second()->controlPoint1(),
+                         segment.second()->point());
+
+            helper.drawPath(path);
+        }
     }
 
+
+
     if (m_currentStrategy) {
         painter.save();
         KoShape::applyConversion(painter, converter);
@@ -521,8 +544,6 @@ void KoPathTool::mousePressEvent(KoPointerEvent *event)
                 KoPathPointData data(m_activeSegment->path, index);
                 m_currentStrategy = new KoPathSegmentChangeStrategy(this, \
event->point, data, m_activeSegment->positionOnSegment);  event->accept();
-                delete m_activeSegment;
-                m_activeSegment = 0;
             } else {
 
                 KoShapeManager *shapeManager = canvas()->shapeManager();
@@ -561,11 +582,21 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
             m_activeHandle->repaint();
         }
 
+        if (m_activeSegment) {
+            repaintSegment(m_activeSegment);
+        }
+
         return;
     }
 
-    delete m_activeSegment;
-    m_activeSegment = 0;
+    if (m_activeSegment) {
+        KoPathPointIndex index = \
m_activeSegment->path->pathPointIndex(m_activeSegment->segmentStart); +        \
KoPathSegment segment = m_activeSegment->path->segmentByIndex(index); +        \
repaint(segment.boundingRect()); +
+        delete m_activeSegment;
+        m_activeSegment = 0;
+    }
 
     Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) {
         QRectF roi = handleGrabRect(shape->documentToShape(event->point));
@@ -670,6 +701,7 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
         useCursor(Qt::PointingHandCursor);
         emit statusTextChanged(i18n("Drag to change curve directly. Double click to \
insert new path point."));  m_activeSegment = hoveredSegment;
+        repaintSegment(m_activeSegment);
     } else {
         uint selectedPointCount = m_pointSelection.size();
         if (selectedPointCount == 0)
@@ -681,6 +713,15 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event)
     }
 }
 
+void KoPathTool::repaintSegment(PathSegment *pathSegment)
+{
+    if (!pathSegment || !pathSegment->isValid()) return;
+
+    KoPathPointIndex index = \
pathSegment->path->pathPointIndex(pathSegment->segmentStart); +    KoPathSegment \
segment = pathSegment->path->segmentByIndex(index); +    \
repaint(segment.boundingRect()); +}
+
 void KoPathTool::mouseReleaseEvent(KoPointerEvent *event)
 {
     Q_D(KoToolBase);
diff --git a/libs/flake/tools/KoPathTool.h b/libs/flake/tools/KoPathTool.h
index 70295724c75..15153332f2e 100644
--- a/libs/flake/tools/KoPathTool.h
+++ b/libs/flake/tools/KoPathTool.h
@@ -104,6 +104,7 @@ private:
     void clearActivePointSelectionReferences();
     void initializeWithShapes(const QList<KoShape*> shapes);
     KUndo2Command* createPointToCurveCommand(const QList<KoPathPointData> &points);
+    void repaintSegment(PathSegment *pathSegment);
 
 protected:
     KoPathToolSelection m_pointSelection; ///< the point selection


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic