Ejemplo n.º 1
0
 def __setattr__(self, key, value):
     try:
         layer = self._parent
     except AttributeError:
         pass
     else:
         if layer is not None and key[0] != "_":
             oldValue = getattr(self, key)
             if value != oldValue:
                 if key == "name":
                     layer.anchors[value] = self
                     return
                 obj_setattr(self, key, value)
                 if key == "selected":
                     if value:
                         layer._selection.add(self)
                     else:
                         layer._selection.remove(self)
                     layer._selectionBounds = None
                 else:
                     if self.selected:
                         layer._selectionBounds = None
                     glyph = layer._parent
                     glyph._lastModified = time()
             return
     obj_setattr(self, key, value)
Ejemplo n.º 2
0
 def __setattr__(self, key, value):
     try:
         path = self._parent
     except AttributeError:
         pass
     else:
         if path is not None and key[0] != "_":
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 layer = path._parent
                 if key == "selected":
                     if value:
                         layer._selection.add(self)
                     else:
                         layer._selection.remove(self)
                     layer._selectedPaths = layer._selectionBounds = None
                 else:
                     glyph = layer._parent
                     if key == "x" or key == "y":
                         if self.selected:
                             layer._selectedPaths = \
                                 layer._selectionBounds = None
                         path._bounds = path._graphicsPath = \
                             layer._bounds = \
                             layer._closedGraphicsPath = \
                             layer._openGraphicsPath = None
                     glyph._lastModified = time()
             return
     obj_setattr(self, key, value)
Ejemplo n.º 3
0
 def __setattr__(self, key, value):
     try:
         parent = self._parent
     except AttributeError:
         pass
     else:
         if hasattr(parent, "masterName") and key[0] != "_":
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 if key == "selected":
                     if value:
                         parent._selection.add(self)
                     else:
                         parent._selection.remove(self)
                     parent._selectionBounds = None
                 else:
                     # we don't really care about guidelines in the
                     # selection bounds, tbh
                     if (key == "x" or key == "y") and self.selected:
                         parent._selectionBounds = None
                     glyph = parent._parent
                     glyph._lastModified = time()
             return
     obj_setattr(self, key, value)
Ejemplo n.º 4
0
 def __setattr__(self, key, value):  # add some custom behavior
     try:
         path = self._parent  # can this happen?
     except AttributeError:
         pass
     else:
         if path is not None and key[0] != "_":  # not a private attribute
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 layer = path._parent
                 if key == "selected":  # tell the parent layer about our change of selected-ness
                     if value:
                         layer._selection.add(self)
                     else:
                         layer._selection.remove(self)
                     # (*) reset selection paths and bounds so that it will be recomputed
                     layer._selectedPaths = layer._selectionBounds = None
                 else:
                     glyph = layer._parent
                     if key == "x" or key == "y":
                         if self.selected:
                             layer._selectedPaths = \
                                 layer._selectionBounds = None # see (*) above
                         # reset several cached data, in order to trigger re-computation
                         path._bounds = path._graphicsPath = \
                             layer._bounds = \
                             layer._closedGraphicsPath = \
                             layer._openGraphicsPath = None
                     glyph._lastModified = time()
             return
     obj_setattr(self, key, value)
Ejemplo n.º 5
0
 def __setattr__(self, key, value):
     try:
         font = self._parent
     except AttributeError:
         pass
     else:
         if font is not None and key == "name":
             oldValue = getattr(self, key)
             if value != oldValue:
                 font.masters[value] = self
             return
     obj_setattr(self, key, value)
Ejemplo n.º 6
0
 def __setattr__(self, key, value):
     try:
         parent = self._parent
     except AttributeError:
         pass
     else:
         if parent is not None and key[0] != "_":
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 parent.transformation = self
             return
     obj_setattr(self, key, value)
Ejemplo n.º 7
0
 def __setattr__(self, key, value):
     try:
         font = self._parent
     except AttributeError:
         pass
     else:
         if font is not None and key[0] != "_":
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 font._layoutEngine = None
             return
     obj_setattr(self, key, value)
Ejemplo n.º 8
0
 def __setattr__(self, key, value):
     try:
         font = self._parent
     except AttributeError:
         pass
     else:
         if font is not None and key[0] != "_" \
                             and key != "selected":
             oldValue = getattr(self, key)
             if value != oldValue:
                 obj_setattr(self, key, value)
                 self._lastModified = time()
             return
     obj_setattr(self, key, value)