diff options
| author | Adrien Tétar | 2015-10-12 19:39:58 +0200 | 
|---|---|---|
| committer | Adrien Tétar | 2015-10-12 19:39:58 +0200 | 
| commit | 19aab2d0ad7c546cad6bc31bf4f1ea4b211918bd (patch) | |
| tree | fff13493dd9a278529f4373cd22bf3d0c5a53441 /Lib/defconQt/glyphView.py | |
| parent | 36ab3fbd5dddae518ca7a6f2a81116a6182b5ea5 (diff) | |
| download | trufont-19aab2d0ad7c546cad6bc31bf4f1ea4b211918bd.tar.bz2 | |
glyphView: allow offCurves deletion
Diffstat (limited to 'Lib/defconQt/glyphView.py')
| -rw-r--r-- | Lib/defconQt/glyphView.py | 21 | 
1 files changed, 19 insertions, 2 deletions
| diff --git a/Lib/defconQt/glyphView.py b/Lib/defconQt/glyphView.py index 0c80ddd..9a2b91c 100644 --- a/Lib/defconQt/glyphView.py +++ b/Lib/defconQt/glyphView.py @@ -312,6 +312,9 @@ class OffCurvePointItem(QGraphicsEllipseItem):          self.setBrush(QBrush(offCurvePointColor))          self._needsUngrab = False +    def delete(self): +        self.parentItem()._CPDeleted() +      def itemChange(self, change, value):          if change == QGraphicsItem.ItemPositionChange:              if self.scene()._integerPlane: @@ -444,6 +447,20 @@ class OnCurvePointItem(QGraphicsPathItem):              if pt.segmentType is not None: index += 1          return index % len(self._contour.segments) +    def _CPDeleted(self): +        pointIndex = self.getPointIndex() +        children = self.childItems() +        selected = 1 +        if not (children[1].isVisible() or children[1].isSelected()): +            selected = 3 + +        firstSibling = self._contour[pointIndex+selected-2] +        secondSibling = self._contour[pointIndex+(selected-2)*2] +        if firstSibling.segmentType is None and secondSibling.segmentType is None: +            # we have two offCurves, wipe them +            self._contour.removePoint(firstSibling) +            self._contour.removePoint(secondSibling) +      def _CPMoved(self, newValue):          pointIndex = self.getPointIndex()          children = self.childItems() @@ -851,7 +868,7 @@ class GlyphScene(QGraphicsScene):              for item in self.selectedItems():                  if isinstance(item, OnCurvePointItem):                      item.delete(not event.modifiers() & Qt.ShiftModifier) -                elif isinstance(item, (AnchorItem, ComponentItem)): +                elif isinstance(item, (AnchorItem, ComponentItem, OffCurvePointItem)):                      item.delete()                  elif isinstance(item, PixmapItem):                      self.removeItem(item) @@ -1390,7 +1407,7 @@ class GlyphView(QGraphicsView):          if not scene._blocked:              # TODO: also rewind anchors and components              for item in scene.items(): -                if isinstance(item, OnCurvePointItem) or isinstance(item, ComponentItem) or isinstance(item, AnchorItem): +                if isinstance(item, (OnCurvePointItem, ComponentItem, AnchorItem)):                      scene.removeItem(item)                  elif isinstance(item, VGuidelinesTextItem):                      item.setPos(self._glyph.width, item.y()) | 
