comparison pyink/MBScene.py @ 1182:8b0e5e8a6b0c

Rename MBScene.update() to update_scenes_of_dom()
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 31 Dec 2010 12:31:02 +0800
parents f14dbcf19e2b
children e8446e138427
comparison
equal deleted inserted replaced
1181:f14dbcf19e2b 1182:8b0e5e8a6b0c
271 self.ID[gid]=1 271 self.ID[gid]=1
272 ns.setAttribute("id",gid) 272 ns.setAttribute("id",gid)
273 ns.setAttribute("inkscape:groupmode","layer") 273 ns.setAttribute("inkscape:groupmode","layer")
274 line.node.appendChild(ns) 274 line.node.appendChild(ns)
275 line.add_keyframe(frame, ns) 275 line.add_keyframe(frame, ns)
276 self.update() 276 self.update_scenes_of_dom()
277 pass 277 pass
278 pass 278 pass
279 279
280 class MBScene(MBScene_dom): 280 class MBScene(MBScene_dom):
281 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE, 281 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE,
329 vbox.pack_start(self.button) 329 vbox.pack_start(self.button)
330 self.button.connect("clicked", self.onQuit) 330 self.button.connect("clicked", self.onQuit)
331 self.window.add(vbox) 331 self.window.add(vbox)
332 pass 332 pass
333 333
334 def update(self): 334 def update_scenes_of_dom(self):
335 doc = self.root 335 doc = self.root
336 rdoc = self.document 336 rdoc = self.document
337 for node in doc.childList(): 337 for node in doc.childList():
338 if node.name() == 'svg:metadata': 338 if node.name() == 'svg:metadata':
339 for t in node.childList(): 339 for t in node.childList():
340 if t.name() == "ns0:scenes": 340 if t.name() == "ns0:scenes":
341 node.removeChild(t) 341 node.removeChild(t)
342 ns = rdoc.createElement("ns0:scenes") 342 scenes = rdoc.createElement("ns0:scenes")
343 node.appendChild(ns) 343 node.appendChild(scenes)
344 for layer in range(0,len(self._framelines)): 344 for layer in range(0, len(self._framelines)):
345 lobj = self._framelines[layer] 345 lobj = self._framelines[layer]
346 self.addScenes(lobj, ns) 346 self.add_scene_on_dom(lobj, scenes)
347 pass 347 pass
348 pass 348 pass
349 pass 349 pass
350 pass 350 pass
351 pass 351 pass
487 self.last_line.rm_keyframe(layer._keys[i+1].idx) 487 self.last_line.rm_keyframe(layer._keys[i+1].idx)
488 self.last_line.rm_keyframe(nth) 488 self.last_line.rm_keyframe(nth)
489 else: 489 else:
490 self.last_line.rm_keyframe(nth) 490 self.last_line.rm_keyframe(nth)
491 491
492 self.update() 492 self.update_scenes_of_dom()
493 self.last_line._draw_all_frames() 493 self.last_line._draw_all_frames()
494 self.last_line.update() 494 self.last_line.update()
495 return 495 return
496 i = i + 1 496 i = i + 1
497 pass 497 pass
509 return 509 return
510 try: 510 try:
511 if nth <= layer._keys[i+2].idx: 511 if nth <= layer._keys[i+2].idx:
512 layer._keys[i+1].idx = nth 512 layer._keys[i+1].idx = nth
513 layer.draw_all_frames() 513 layer.draw_all_frames()
514 self.update() 514 self.update_scenes_of_dom()
515 self.setCurrentScene(nth) 515 self.setCurrentScene(nth)
516 self.last_line.update() 516 self.last_line.update()
517 return 517 return
518 else: 518 else:
519 # We may in the next scene 519 # We may in the next scene
522 except: 522 except:
523 # This is the last keyframe, extend the keyframe by 523 # This is the last keyframe, extend the keyframe by
524 # relocate the location of the keyframe 524 # relocate the location of the keyframe
525 layer._keys[i+1].idx = nth 525 layer._keys[i+1].idx = nth
526 layer._draw_all_frames() 526 layer._draw_all_frames()
527 self.update() 527 self.update_scenes_of_dom()
528 self.last_line.update() 528 self.last_line.update()
529 self.setCurrentScene(nth) 529 self.setCurrentScene(nth)
530 return 530 return
531 else: 531 else:
532 # We are in the front of all keyframes 532 # We are in the front of all keyframes
543 # available here. Create a new tween here 543 # available here. Create a new tween here
544 idx = layer._keys[i].idx 544 idx = layer._keys[i].idx
545 layer.add_keyframe(nth,layer._keys[i].ref) 545 layer.add_keyframe(nth,layer._keys[i].ref)
546 layer.tween(idx) 546 layer.tween(idx)
547 layer._draw_all_frames() 547 layer._draw_all_frames()
548 self.update() 548 self.update_scenes_of_dom()
549 self.setCurrentScene(nth) 549 self.setCurrentScene(nth)
550 self.last_line.update() 550 self.last_line.update()
551 return 551 return
552 else: 552 else:
553 # We may in the next scene 553 # We may in the next scene
558 # This is the last scene, create a new one 558 # This is the last scene, create a new one
559 idx = layer._keys[i].idx 559 idx = layer._keys[i].idx
560 layer.add_keyframe(nth,layer._keys[i].ref) 560 layer.add_keyframe(nth,layer._keys[i].ref)
561 layer.tween(idx) 561 layer.tween(idx)
562 layer._draw_all_frames() 562 layer._draw_all_frames()
563 self.update() 563 self.update_scenes_of_dom()
564 self.setCurrentScene(nth) 564 self.setCurrentScene(nth)
565 self.last_line.update() 565 self.last_line.update()
566 return 566 return
567 pass 567 pass
568 pass 568 pass
809 # This is the first frame, we can not duplicate it 809 # This is the first frame, we can not duplicate it
810 self.last_line.rm_keyframe(self.last_frame) 810 self.last_line.rm_keyframe(self.last_frame)
811 return 811 return
812 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id")) 812 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id"))
813 key.ref = node 813 key.ref = node
814 self.update() 814 self.update_scenes_of_dom()
815 self.updateUI() 815 self.updateUI()
816 self.doEditScene(None) 816 self.doEditScene(None)
817 return 817 return
818 last_key = key 818 last_key = key
819 i = i + 1 819 i = i + 1
926 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) 926 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
927 927
928 def doInsertScene(self,w): 928 def doInsertScene(self,w):
929 self.lockui=True 929 self.lockui=True
930 self.last_line.insert_frame(self.last_frame) 930 self.last_line.insert_frame(self.last_frame)
931 self.update() 931 self.update_scenes_of_dom()
932 self.lockui=False 932 self.lockui=False
933 933
934 def doRemoveScene(self,w): 934 def doRemoveScene(self,w):
935 self.lockui=True 935 self.lockui=True
936 self.last_line.remove_frame(self.last_frame) 936 self.last_line.remove_frame(self.last_frame)
937 self.update() 937 self.update_scenes_of_dom()
938 self.lockui=False 938 self.lockui=False
939 939
940 def addButtons(self,hbox): 940 def addButtons(self,hbox):
941 btn = gtk.Button('Insert Key') 941 btn = gtk.Button('Insert Key')
942 btn.connect('clicked',self.doInsertKeyScene) 942 btn.connect('clicked',self.doInsertKeyScene)
988 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks(): 988 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
989 if start_idx <= idx and stop_idx >= idx: 989 if start_idx <= idx and stop_idx >= idx:
990 n = self.tweenTypeSelector.get_active() 990 n = self.tweenTypeSelector.get_active()
991 new_tween_type = MBScene._frameline_tween_types[n] 991 new_tween_type = MBScene._frameline_tween_types[n]
992 self.last_line.set_tween_type(start_idx, new_tween_type) 992 self.last_line.set_tween_type(start_idx, new_tween_type)
993 self.update() 993 self.update_scenes_of_dom()
994 break 994 break
995 pass 995 pass
996 pass 996 pass
997 997
998 def addTweenTypeSelector(self,hbox): 998 def addTweenTypeSelector(self,hbox):
1018 def onOK(self,event): 1018 def onOK(self,event):
1019 self.OK = True 1019 self.OK = True
1020 gtk.main_quit() 1020 gtk.main_quit()
1021 pass 1021 pass
1022 1022
1023 def addScenes(self, frameline, scenes_node): 1023 def add_scene_on_dom(self, frameline, scenes_node):
1024 doc = self.document 1024 doc = self.document
1025 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks(): 1025 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
1026 ref = frameline.get_frame_data(start_idx) 1026 ref = frameline.get_frame_data(start_idx)
1027 tween_type_idx = self._frameline_tween_types.index(tween_type) 1027 tween_type_idx = self._frameline_tween_types.index(tween_type)
1028 tween_type_name = self._tween_type_names[tween_type_idx] 1028 tween_type_name = self._tween_type_names[tween_type_idx]