aboutsummaryrefslogtreecommitdiffstats
path: root/Lib/defconQt/glyphView.py
diff options
context:
space:
mode:
authorFelipe Corrêa da Silva Sanches2015-09-28 14:40:01 -0300
committerAdrien Tétar2015-09-29 11:47:58 +0200
commitce3690ad8d754c53900ccb9a30bd637737bd65e5 (patch)
tree235d571df931d0e2ae7022235154253b87b6928e /Lib/defconQt/glyphView.py
parent51a80dc8ce5cb7f41111b2cbc3b0fb53f1966016 (diff)
downloadtrufont-ce3690ad8d754c53900ccb9a30bd637737bd65e5.tar.bz2
work in progress: ComponentItem class
Diffstat (limited to 'Lib/defconQt/glyphView.py')
-rw-r--r--Lib/defconQt/glyphView.py15
1 files changed, 12 insertions, 3 deletions
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()