Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1200:213f03dbfc41
Fix issue of removing a scene
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 03 Jan 2011 13:51:31 +0800 |
parents | 25e1579ed3d1 |
children | 582d3410e546 |
comparison
equal
deleted
inserted
replaced
1199:25e1579ed3d1 | 1200:213f03dbfc41 |
---|---|
634 vbox.pack_start(self.button) | 634 vbox.pack_start(self.button) |
635 self.button.connect("clicked", self.onQuit) | 635 self.button.connect("clicked", self.onQuit) |
636 self.window.add(vbox) | 636 self.window.add(vbox) |
637 pass | 637 pass |
638 | 638 |
639 def removeKeyScene(self): | 639 def removeKeyScene(self, frameline, frame_idx): |
640 nth = self.last_frame | 640 start, end, scene_type = frameline.get_frame_block(frame_idx) |
641 y = self.last_line | 641 scene_node = frameline.get_frame_data(start) |
642 rdoc = self.document | 642 |
643 i = 0 | 643 frameline.rm_keyframe(start) |
644 layer = self.last_line | 644 if start != end: |
645 while i < len(layer._keys): | 645 frameline.rm_keyframe(end) |
646 s = layer._keys[i] | 646 pass |
647 print "nth:%d idx %d" % (nth,s.idx) | 647 |
648 if nth > s.idx: | 648 scene_group_id = scene_node.getAttribute('ref') |
649 if i == len(layer._keys)-1: | 649 scene_group = self.get_node(scene_group_id) |
650 return | 650 scene_group.parent().removeChild(scene_group) |
651 if nth == s.idx: | 651 scene_node.parent().removeChild(scene_node) |
652 if s.left_tween: | 652 |
653 # This is left tween, we move the keyframe one frame ahead | 653 try: |
654 if s.idx == layer._keys[i-1].idx: | 654 frameline.duplicateGroup.setAttribute('style', 'display: none') |
655 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref) | 655 except AttributeError: |
656 self.last_line.rm_keyframe(nth) | |
657 self.last_line.rm_keyframe(nth-1) | |
658 else: | |
659 s.idx = s.idx-1 | |
660 else: | |
661 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref) | |
662 if s.right_tween: | |
663 self.last_line.rm_keyframe(layer._keys[i+1].idx) | |
664 self.last_line.rm_keyframe(nth) | |
665 else: | |
666 self.last_line.rm_keyframe(nth) | |
667 | |
668 self.update_scenes_of_dom() | |
669 self.last_line._draw_all_frames() | |
670 self.last_line.update() | |
671 return | |
672 i = i + 1 | |
673 pass | 656 pass |
674 pass | 657 pass |
675 | 658 |
676 def extendScene(self): | 659 def extendScene(self): |
677 frame_idx = self.last_frame | 660 frame_idx = self.last_frame |
1022 self.duplicateKeyScene() | 1005 self.duplicateKeyScene() |
1023 self._lockui = False | 1006 self._lockui = False |
1024 | 1007 |
1025 def doRemoveScene(self,w): | 1008 def doRemoveScene(self,w): |
1026 self._lockui = True | 1009 self._lockui = True |
1027 self.removeKeyScene() | 1010 self.removeKeyScene(self.last_line, self.last_frame) |
1028 self._lockui = False | 1011 self._lockui = False |
1029 return | 1012 return |
1030 | 1013 |
1031 | 1014 |
1032 def doExtendScene(self,w): | 1015 def doExtendScene(self,w): |
1076 def doInsertScene(self,w): | 1059 def doInsertScene(self,w): |
1077 self._lockui=True | 1060 self._lockui=True |
1078 self.last_line.insert_frame(self.last_frame) | 1061 self.last_line.insert_frame(self.last_frame) |
1079 self.update_scenes_of_dom() | 1062 self.update_scenes_of_dom() |
1080 self._lockui=False | 1063 self._lockui=False |
1081 | 1064 pass |
1082 def doRemoveScene(self,w): | 1065 |
1083 self._lockui=True | |
1084 self.last_line.remove_frame(self.last_frame) | |
1085 self.update_scenes_of_dom() | |
1086 self._lockui=False | |
1087 | |
1088 def addButtons(self,hbox): | 1066 def addButtons(self,hbox): |
1089 btn = gtk.Button('Insert Key') | 1067 btn = gtk.Button('Insert Key') |
1090 btn.connect('clicked',self.doInsertKeyScene) | 1068 btn.connect('clicked',self.doInsertKeyScene) |
1091 hbox.pack_start(btn,expand=False,fill=False) | 1069 hbox.pack_start(btn,expand=False,fill=False) |
1092 | 1070 |