comparison pyink/MBScene.py @ 1163:c23593881507

Merge. Fix a bug to select the tween without key frame after it.
author wycc
date Tue, 28 Dec 2010 22:26:11 +0800
parents a7faab54e8f8
children 2cb5047d8f2b
comparison
equal deleted inserted replaced
1162:64c54ef39480 1163:c23593881507
84 def notifyContentChanged(self,node,old_content,new_content): 84 def notifyContentChanged(self,node,old_content,new_content):
85 print 'cont' 85 print 'cont'
86 if self.type == 'DOMSubtreeModified': 86 if self.type == 'DOMSubtreeModified':
87 self.func(node) 87 self.func(node)
88 def notifyAttributeChanged(self,node, name, old_value, new_value): 88 def notifyAttributeChanged(self,node, name, old_value, new_value):
89 print 'attr',node,name,old_value,new_value 89 # print 'attr',node,name,old_value,new_value
90 if self.type == 'DOMAttrModified': 90 if self.type == 'DOMAttrModified':
91 self.func(node,name) 91 self.func(node,name)
92 92
93 def addEventListener(obj, type, func,arg): 93 def addEventListener(obj, type, func,arg):
94 obs = ObjectWatcher(obj,type,func,arg) 94 obs = ObjectWatcher(obj,type,func,arg)
334 print scene.getCenter() 334 print scene.getCenter()
335 if scene.name() == 'svg:g': 335 if scene.name() == 'svg:g':
336 try: 336 try:
337 label = scene.getAttribute('inkscape:label') 337 label = scene.getAttribute('inkscape:label')
338 if label == 'dup': 338 if label == 'dup':
339 # XXX: This would stop animation.
340 # This function is called by updateUI()
339 node.removeChild(scene) 341 node.removeChild(scene)
340 except: 342 except:
341 pass 343 pass
342 344
343 try: 345 try:
601 tween_obj_tween_type = \ 603 tween_obj_tween_type = \
602 self._tween_obj_tween_types[tween_type_idx] 604 self._tween_obj_tween_types[tween_type_idx]
603 605
604 next_idx, next_stop_idx, next_tween_type = \ 606 next_idx, next_stop_idx, next_tween_type = \
605 layer.get_frame_block(stop_idx + 1) 607 layer.get_frame_block(stop_idx + 1)
606 next_scene_group = layer.get_frame_data(next_idx) 608 if next_idx == -1:
609 next_scene_group = scene_group
610 else:
611 next_scene_group = layer.get_frame_data(next_idx)
607 612
608 nframes = next_idx - start_idx + 1 613 nframes = stop_idx - start_idx + 1
609 percent = float(idx - start_idx) / nframes 614 percent = float(idx - start_idx) / nframes
610 self.tween.updateTweenContent(layer.duplicateGroup, 615 self.tween.updateTweenContent(layer.duplicateGroup,
611 tween_obj_tween_type, 616 tween_obj_tween_type,
612 scene_group, 617 scene_group,
613 next_scene_group, 618 next_scene_group,
871 """ 876 """
872 Execute the current animation till the last frame. 877 Execute the current animation till the last frame.
873 """ 878 """
874 if self.btnRun.get_label() == "Run": 879 if self.btnRun.get_label() == "Run":
875 self.btnRun.set_label("Stop") 880 self.btnRun.set_label("Stop")
881 self.lockui = True
876 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) 882 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
877 else: 883 else:
878 self.btnRun.set_label("Run") 884 self.btnRun.set_label("Run")
879 glib.source_remove(self.last_update) 885 glib.source_remove(self.last_update)
886 self.lockui = False
887 pass
880 888
881 def doRunNext(self): 889 def doRunNext(self):
882 if self.current >= self.maxframe: 890 if self.current >= self.maxframe:
883 self.current = 0 891 self.current = 0
884 print self.current,self.maxframe 892 try:
885 self.setCurrentScene(self.current+1) 893 self.setCurrentScene(self.current+1)
894 except:
895 traceback.print_exc()
896 raise
886 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) 897 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
887 898
888 899
889 def addButtons(self,hbox): 900 def addButtons(self,hbox):
890 #btn = gtk.Button('Edit') 901 #btn = gtk.Button('Edit')
915 return 926 return
916 927
917 if self.last_line == None: 928 if self.last_line == None:
918 return 929 return
919 frameline = self.last_line 930 frameline = self.last_line
931 idx = self.last_frame
920 i = 0 932 i = 0
921 found = -1 933 found = -1
922 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks(): 934 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
923 if start_idx < stop_idx: 935 if start_idx <= idx and stop_idx >= idx:
924 n = self.tweenTypeSelector.get_active() 936 n = self.tweenTypeSelector.get_active()
925 new_tween_type = MBScene._frameline_tween_types[n] 937 new_tween_type = MBScene._frameline_tween_types[n]
926 self.last_line.set_tween_type(start_idx, new_tween_type) 938 self.last_line.set_tween_type(start_idx, new_tween_type)
927 self.update() 939 self.update()
928 break 940 break