Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1161:a7faab54e8f8
Fix broken of running animation
- Running animation is stop automatically after a certain time.
- It is 300ms according MBScene._updateUI().
- It is caused by notification of changing DOM tree. The
notification handlers would call MBScene.updateUI() to update
framelines and buttons.
- MBScene.updateUI() would call MBScene.show() after 300ms,
MBScene.show() calls MBScene.parseScene() in turn.
- MBScene.parseScene() would remove duplicate group that is using
by code of running animation, MBScene.doRunNext(). It make
running animation stop.
- fixed by setting MBScene.lockui when a running animation is started
or stoped.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 28 Dec 2010 13:35:34 +0800 |
parents | 1a699dc00fa3 |
children | c23593881507 |
comparison
equal
deleted
inserted
replaced
1160:1a699dc00fa3 | 1161:a7faab54e8f8 |
---|---|
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: |
871 """ | 873 """ |
872 Execute the current animation till the last frame. | 874 Execute the current animation till the last frame. |
873 """ | 875 """ |
874 if self.btnRun.get_label() == "Run": | 876 if self.btnRun.get_label() == "Run": |
875 self.btnRun.set_label("Stop") | 877 self.btnRun.set_label("Stop") |
878 self.lockui = True | |
876 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) | 879 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) |
877 else: | 880 else: |
878 self.btnRun.set_label("Run") | 881 self.btnRun.set_label("Run") |
879 glib.source_remove(self.last_update) | 882 glib.source_remove(self.last_update) |
883 self.lockui = False | |
884 pass | |
880 | 885 |
881 def doRunNext(self): | 886 def doRunNext(self): |
882 if self.current >= self.maxframe: | 887 if self.current >= self.maxframe: |
883 self.current = 0 | 888 self.current = 0 |
884 print self.current,self.maxframe | 889 try: |
885 self.setCurrentScene(self.current+1) | 890 self.setCurrentScene(self.current+1) |
891 except: | |
892 traceback.print_exc() | |
893 raise | |
886 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) | 894 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext) |
887 | 895 |
888 | 896 |
889 def addButtons(self,hbox): | 897 def addButtons(self,hbox): |
890 #btn = gtk.Button('Edit') | 898 #btn = gtk.Button('Edit') |