Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1166:d73ef03c96de
Refactory code of MBScene.updateUI() from MBScene.show()
- It is too busy to reborn full GUI components of pyink everytime the
content being updated.
- It is fixed by moveing code about updating of frameline to
MBScene._updateUI() and avoid calling MBScene.show() to reduce time
for updating frameline.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 29 Dec 2010 21:16:27 +0800 |
parents | 2cb5047d8f2b |
children | 16ea7b81eda8 |
comparison
equal
deleted
inserted
replaced
1165:9f2b5a1a0d84 | 1166:d73ef03c96de |
---|---|
712 pass | 712 pass |
713 pass | 713 pass |
714 pass | 714 pass |
715 | 715 |
716 def _create_framelines(self): | 716 def _create_framelines(self): |
717 self.scrollwin = gtk.ScrolledWindow() | 717 if not hasattr(self, 'scrollwin'): |
718 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | 718 self.scrollwin = gtk.ScrolledWindow() |
719 self.scrollwin.set_size_request(-1,150) | 719 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC, |
720 gtk.POLICY_AUTOMATIC) | |
721 self.scrollwin.set_size_request(-1,150) | |
722 vbox = gtk.VBox() | |
723 vbox.show() | |
724 self.scrollwin.add_with_viewport(vbox) | |
725 self.scrollwin_vbox = vbox | |
726 else: | |
727 self.scrollwin.remove(self.scrollwin_vbox) | |
728 vbox = gtk.VBox() | |
729 vbox.show() | |
730 self.scrollwin.add_with_viewport(vbox) | |
731 self.scrollwin_vbox = vbox | |
732 pass | |
720 | 733 |
721 nframes = 100 | 734 nframes = 100 |
722 | |
723 vbox = gtk.VBox() | |
724 vbox.show() | |
725 self.scrollwin.add_with_viewport(vbox) | |
726 | 735 |
727 ruler = frameruler(nframes) | 736 ruler = frameruler(nframes) |
728 ruler.set_size_request(nframes * 10, 20) | 737 ruler.set_size_request(nframes * 10, 20) |
729 ruler.show() | 738 ruler.show() |
730 hbox = gtk.HBox() | 739 hbox = gtk.HBox() |
805 self.last_line.rm_keyframe(self.last_frame) | 814 self.last_line.rm_keyframe(self.last_frame) |
806 return | 815 return |
807 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id")) | 816 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id")) |
808 key.ref = node | 817 key.ref = node |
809 self.update() | 818 self.update() |
810 self.show() | 819 self.updateUI() |
811 self.doEditScene(None) | 820 self.doEditScene(None) |
812 return | 821 return |
813 last_key = key | 822 last_key = key |
814 i = i + 1 | 823 i = i + 1 |
815 pass | 824 pass |
1007 pass | 1016 pass |
1008 pass | 1017 pass |
1009 | 1018 |
1010 def updateUI(self,node=None,arg=None): | 1019 def updateUI(self,node=None,arg=None): |
1011 if self.lockui: return | 1020 if self.lockui: return |
1012 self.lockui = True | 1021 |
1013 self._updateUI() | |
1014 self.lockui = False | |
1015 pass | |
1016 | |
1017 def _updateUI(self,node=None,arg=None): | |
1018 if self.last_update!= None: | 1022 if self.last_update!= None: |
1019 glib.source_remove(self.last_update) | 1023 glib.source_remove(self.last_update) |
1020 self.last_update = glib.timeout_add(300,self.show) | 1024 self.last_update = glib.timeout_add(300,self._updateUI) |
1025 | |
1026 pass | |
1027 | |
1028 def _updateUI(self,node=None,arg=None): | |
1029 self.parseScene() | |
1030 self._create_framelines() | |
1031 self._update_framelines() | |
1021 pass | 1032 pass |
1022 | 1033 |
1023 def show(self): | 1034 def show(self): |
1024 self.OK = True | 1035 self.OK = True |
1025 if not self.root: | 1036 if not self.root: |
1026 self.root = self.desktop.doc().root().repr | 1037 self.root = self.desktop.doc().root().repr |
1027 pass | 1038 pass |
1028 | 1039 |
1029 self.document = self.desktop.doc().rdoc | 1040 self.document = self.desktop.doc().rdoc |
1030 self.tween = TweenObject(self.document, self.root) | 1041 self.tween = TweenObject(self.document, self.root) |
1031 self.parseScene() | 1042 self._updateUI() |
1032 self._create_framelines() | |
1033 self._update_framelines() | |
1034 if self.top == None: | 1043 if self.top == None: |
1035 self.top = gtk.VBox(False,0) | 1044 self.top = gtk.VBox(False,0) |
1036 self.desktop.getToplevel().child.child.pack_end(self.top,expand=False) | 1045 self.desktop.getToplevel().child.child.pack_end(self.top,expand=False) |
1037 else: | 1046 else: |
1038 self.top.remove(self.startWindow) | 1047 self.top.remove(self.startWindow) |