Changeset 314
- Timestamp:
- 01/14/09 23:15:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
packages/defcon/branches/ufo2/Lib/defcon/objects/glyph.py
r310 r314 4 4 from defcon.tools.notifications import NotificationCenter 5 5 6 7 6 _representationFactories = {} 8 7 … … 17 16 18 17 """ 19 XXX lib, note,controlPointBounds18 XXX controlPointBounds 20 19 21 20 This object represents a glyph and it contains contour, component, anchor … … 51 50 _notificationName = "Glyph.Changed" 52 51 53 def __init__(self, contourClass=None, componentClass=None, anchorClass=None ):52 def __init__(self, contourClass=None, componentClass=None, anchorClass=None, libClass=None): 54 53 super(Glyph, self).__init__() 54 55 55 self._parent = None 56 56 self._dirty = False … … 58 58 self._unicodes = [] 59 59 self._width = 0 60 self.note = None 61 self.lib = {} 60 self._note = None 62 61 self._dispatcher = None 63 62 … … 65 64 self._components = [] 66 65 self._anchors = [] 66 67 self._lib = None 67 68 68 69 self._boundsCache = None … … 79 80 from anchor import Anchor 80 81 anchorClass = Anchor 81 82 self.contourClass = contourClass 83 self.componentClass = componentClass 84 self.anchorClass = anchorClass 82 if libClass is None: 83 from lib import Lib 84 libClass = Lib 85 86 self._contourClass = contourClass 87 self._componentClass = componentClass 88 self._anchorClass = anchorClass 89 90 self._lib = libClass() 91 self._lib.setParent(self) 85 92 86 93 def _set_dispatcher(self, dispatcher): … … 93 100 for anchor in self._anchors: 94 101 self._setParentDataInAnchor(anchor) 102 self._lib.dispatcher = dispatcher 103 self._lib.addObserver(observer=self, methodName="_libContentChanged", notification="Lib.Changed") 95 104 self.addObserver(observer=self, methodName="destroyAllRepresentations", notification="Glyph.Changed") 96 105 … … 103 112 # Attributes 104 113 # ---------- 114 115 def _get_contourClass(self): 116 return self._contourClass 117 118 contourClass = property(_get_contourClass, doc="The class used for contours.") 119 120 def _get_componentClass(self): 121 return self._componentClass 122 123 componentClass = property(_get_componentClass, doc="The class used for components.") 124 125 def _get_anchorClass(self): 126 return self._anchorClass 127 128 anchorClass = property(_get_anchorClass, doc="The class used for anchors.") 105 129 106 130 def _set_name(self, value): … … 209 233 210 234 anchors = property(_get_anchors, doc="An ordered list of :class:`Anchor` objects stored in the glyph.") 235 236 def _get_note(self): 237 return self._note 238 239 def _set_note(self, value): 240 assert isinstance(value, basestring) 241 self._note = value 242 self.dirty = True 243 244 note = property(_get_note, _set_note, doc="An arbitrary note for the glyph. Setting this will post a *Glyph.Changed* notification.") 245 246 def _get_lib(self): 247 return self._lib 248 249 def _set_lib(self, value): 250 self._lib.clear() 251 self._lib.update(value) 252 self.dirty = True 253 254 lib = property(_get_lib, _set_lib, doc="The glyph's :class:`Lib` object. Setting this will clear any existing lib data and post a *Glyph.Changed* notification if data was replaced.") 211 255 212 256 # ----------- … … 678 722 self.dirty = True 679 723 724 def _libContentChanged(self, notification): 725 self.dirty = True 726 680 727 681 728 # -----
Note: See TracChangeset
for help on using the changeset viewer.
