From kde-kimageshop Sat Feb 18 18:12:46 2017 From: Dmitry Kazakov Date: Sat, 18 Feb 2017 18:12:46 +0000 To: kde-kimageshop Subject: [krita/kazakov/svg-loading] libs/flake/tools: FEATURE: Highlight the active path segment while dragg Message-Id: X-MARC-Message: https://marc.info/?l=kde-kimageshop&m=148744158626980 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 KoView= Converter &converter) delete m_activeHandle; m_activeHandle =3D 0; } + } else if (m_activeSegment && m_activeSegment->isValid()) { + + KoPathShape *shape =3D 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 =3D shape->pathPointIndex(m_activeSegme= nt->segmentStart); + KoPathSegment segment =3D shape->segmentByIndex(index).toCubic= (); + + KisHandlePainterHelper helper =3D + KoShape::createHandlePainterHelper(&painter, shape, conver= ter, 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 =3D new KoPathSegmentChangeStrategy(this= , event->point, data, m_activeSegment->positionOnSegment); event->accept(); - delete m_activeSegment; - m_activeSegment =3D 0; } else { = KoShapeManager *shapeManager =3D 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 =3D 0; + if (m_activeSegment) { + KoPathPointIndex index =3D m_activeSegment->path->pathPointIndex(m= _activeSegment->segmentStart); + KoPathSegment segment =3D m_activeSegment->path->segmentByIndex(in= dex); + repaint(segment.boundingRect()); + + delete m_activeSegment; + m_activeSegment =3D 0; + } = Q_FOREACH (KoPathShape *shape, m_pointSelection.selectedShapes()) { QRectF roi =3D 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 =3D hoveredSegment; + repaintSegment(m_activeSegment); } else { uint selectedPointCount =3D m_pointSelection.size(); if (selectedPointCount =3D=3D 0) @@ -681,6 +713,15 @@ void KoPathTool::mouseMoveEvent(KoPointerEvent *event) } } = +void KoPathTool::repaintSegment(PathSegment *pathSegment) +{ + if (!pathSegment || !pathSegment->isValid()) return; + + KoPathPointIndex index =3D pathSegment->path->pathPointIndex(pathSegme= nt->segmentStart); + KoPathSegment segment =3D 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 shapes); KUndo2Command* createPointToCurveCommand(const QList = &points); + void repaintSegment(PathSegment *pathSegment); = protected: KoPathToolSelection m_pointSelection; ///< the point selection