From ce3690ad8d754c53900ccb9a30bd637737bd65e5 Mon Sep 17 00:00:00 2001 From: Felipe CorrĂȘa da Silva Sanches Date: Mon, 28 Sep 2015 14:40:01 -0300 Subject: work in progress: ComponentItem class --- Lib/defconQt/glyphView.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'Lib/defconQt/glyphView.py') diff --git a/Lib/defconQt/glyphView.py b/Lib/defconQt/glyphView.py index 88073ae..840b317 100644 --- a/Lib/defconQt/glyphView.py +++ b/Lib/defconQt/glyphView.py @@ -305,6 +305,13 @@ class OffCurvePointItem(QGraphicsEllipseItem): self.setRect(-offHalf/scale, -offHalf/scale, offWidth/scale, offHeight/scale) self.setPen(QPen(offCurvePointStrokeColor, offCurvePenWidth/scale)) +class ComponentItem(QGraphicsPathItem): + def __init__(self, path, component): + super(ComponentItem, self).__init__() + self._component = component + self.setFlag(QGraphicsItem.ItemIsMovable) + self.setFlag(QGraphicsItem.ItemIsSelectable) + class OnCurvePointItem(QGraphicsPathItem): def __init__(self, x, y, isSmooth, contour, point, scale=1, parent=None): super(OnCurvePointItem, self).__init__(parent) @@ -1284,9 +1291,11 @@ class GlyphView(QGraphicsView): scene._outlineItem.setZValue(-995) scene._glyphObject = self._glyph # components - paths = self._glyph.getRepresentation("defconQt.OnlyComponentsQPainterPath") - for path in paths: - scene.addPath(path, brush=QBrush(componentFillColor)) + components = self._glyph.getRepresentation("defconQt.OnlyComponentsQPainterPath") + scene._componentItems = [] + for path, component in components: + component_path = scene.addPath(path, brush=QBrush(componentFillColor)) + scene._componentItems.append(ComponentItem(component_path, component)) def addPoints(self): scene = self.scene() -- cgit v1.2.3