Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1149:0ffef2df6201
Rename MBScene.dom to MBScene.root
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Fri, 24 Dec 2010 15:40:16 +0800 |
parents | 153a87b4edb7 |
children | 6586cd10c92f |
comparison
equal
deleted
inserted
replaced
1148:153a87b4edb7 | 1149:0ffef2df6201 |
---|---|
59 pass | 59 pass |
60 class DOM(pybInkscape.PYSPObject): | 60 class DOM(pybInkscape.PYSPObject): |
61 def __init__(self,obj=None): | 61 def __init__(self,obj=None): |
62 self.proxy = obj | 62 self.proxy = obj |
63 pass | 63 pass |
64 | |
64 def duplicate(self,doc): | 65 def duplicate(self,doc): |
65 return DOM(self.repr.duplicate(doc)) | 66 return DOM(self.repr.duplicate(doc)) |
66 | 67 |
67 class ObjectWatcher(pybInkscape.PYNodeObserver): | 68 class ObjectWatcher(pybInkscape.PYNodeObserver): |
68 def __init__(self,obj,type,func,arg): | 69 def __init__(self,obj,type,func,arg): |
138 def notifyAttributeChanged(self,node, name, old_value, new_value): | 139 def notifyAttributeChanged(self,node, name, old_value, new_value): |
139 self.ui.updateUI() | 140 self.ui.updateUI() |
140 pass | 141 pass |
141 | 142 |
142 class MBScene(): | 143 class MBScene(): |
143 def __init__(self,desktop,win): | 144 def __init__(self, desktop, win, root=None): |
144 self.desktop = desktop | 145 self.desktop = desktop |
145 self.window = win | 146 self.window = win |
146 self.layers = [] | 147 self.layers = [] |
147 self.layers.append(Layer(None)) | 148 self.layers.append(Layer(None)) |
148 self.scenemap = None | 149 self.scenemap = None |
151 pybInkscape.inkscape.connect('change_selection', self.show_selection) | 152 pybInkscape.inkscape.connect('change_selection', self.show_selection) |
152 self.last_select = None | 153 self.last_select = None |
153 self.lockui=False | 154 self.lockui=False |
154 self.tween=None | 155 self.tween=None |
155 self.document = None | 156 self.document = None |
156 self.dom = None | 157 self.root = root |
157 self.framerate=12 | 158 self.framerate=12 |
158 self.maxframe=0 | 159 self.maxframe=0 |
159 pass | 160 pass |
160 | 161 |
161 def show_selection(self,w,obj): | 162 def show_selection(self,w,obj): |
246 pass | 247 pass |
247 pass | 248 pass |
248 pass | 249 pass |
249 if self.scenemap==None: | 250 if self.scenemap==None: |
250 #self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") | 251 #self.desktop.doc().root().repr.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") |
251 self.dom.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") | 252 self.root.setAttribute("xmlns:ns0","http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd") |
252 scenes = self.document.createElement("ns0:scenes") | 253 scenes = self.document.createElement("ns0:scenes") |
253 node.appendChild(scenes) | 254 node.appendChild(scenes) |
254 pass | 255 pass |
255 pass | 256 pass |
256 | 257 |
257 def update(self): | 258 def update(self): |
258 doc = self.dom | 259 doc = self.root |
259 rdoc = self.document | 260 rdoc = self.document |
260 for node in doc.childList(): | 261 for node in doc.childList(): |
261 if node.name() == 'svg:metadata': | 262 if node.name() == 'svg:metadata': |
262 for t in node.childList(): | 263 for t in node.childList(): |
263 if t.name() == "ns0:scenes": | 264 if t.name() == "ns0:scenes": |
280 scene and then relocate them back to the appropriate scene | 281 scene and then relocate them back to the appropriate scene |
281 object. | 282 object. |
282 """ | 283 """ |
283 self.layers = [] | 284 self.layers = [] |
284 self.scenemap = None | 285 self.scenemap = None |
285 doc = self.dom | 286 doc = self.root |
286 | 287 |
287 #obs = pybInkscape.PYNodeObserver() | 288 #obs = pybInkscape.PYNodeObserver() |
288 #obs = LayerAddRemoveWatcher(self) | 289 #obs = LayerAddRemoveWatcher(self) |
289 #doc.addObserver(obs) | 290 #doc.addObserver(obs) |
290 addEventListener(doc,'DOMNodeInserted',self.updateUI,None) | 291 addEventListener(doc,'DOMNodeInserted',self.updateUI,None) |
344 self.dumpID() | 345 self.dumpID() |
345 pass | 346 pass |
346 | 347 |
347 def collectID(self): | 348 def collectID(self): |
348 self.ID = {} | 349 self.ID = {} |
349 root = self.dom | 350 root = self.root |
350 for n in root.childList(): | 351 for n in root.childList(): |
351 self.collectID_recursive(n) | 352 self.collectID_recursive(n) |
352 pass | 353 pass |
353 pass | 354 pass |
354 | 355 |
783 pass | 784 pass |
784 pass | 785 pass |
785 | 786 |
786 def duplicateSceneGroup(self,gid): | 787 def duplicateSceneGroup(self,gid): |
787 # Search for the duplicated group | 788 # Search for the duplicated group |
788 doc = self.dom | 789 doc = self.root |
789 rdoc = self.document | 790 rdoc = self.document |
790 orig = None | 791 orig = None |
791 for node in doc.childList(): | 792 for node in doc.childList(): |
792 if node.name() == 'svg:g': | 793 if node.name() == 'svg:g': |
793 for t in node.childList(): | 794 for t in node.childList(): |
967 self.last_update = glib.timeout_add(300,self.show) | 968 self.last_update = glib.timeout_add(300,self.show) |
968 pass | 969 pass |
969 | 970 |
970 def show(self): | 971 def show(self): |
971 self.OK = True | 972 self.OK = True |
972 self.dom = self.desktop.doc().root().repr | 973 if not self.root: |
974 self.root = self.desktop.doc().root().repr | |
975 pass | |
976 | |
973 self.document = self.desktop.doc().rdoc | 977 self.document = self.desktop.doc().rdoc |
974 self.tween = TweenObject(self.document,self.dom) | 978 self.tween = TweenObject(self.document, self.root) |
975 self.parseScene() | 979 self.parseScene() |
976 self._create_framelines() | 980 self._create_framelines() |
977 self._update_framelines() | 981 self._update_framelines() |
978 if self.top == None: | 982 if self.top == None: |
979 self.top = gtk.VBox(False,0) | 983 self.top = gtk.VBox(False,0) |