Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1195:cb2c611d1656
Fix bug of duplicating a keyframe
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Sun, 02 Jan 2011 20:05:05 +0800 |
parents | 319414e4d87a |
children | 42f8cee2118b |
comparison
equal
deleted
inserted
replaced
1194:319414e4d87a | 1195:cb2c611d1656 |
---|---|
220 | 220 |
221 def _on_attr_modified(self, node, name, old_value, new_value): | 221 def _on_attr_modified(self, node, name, old_value, new_value): |
222 if name == 'id' and old_value != new_value: | 222 if name == 'id' and old_value != new_value: |
223 if old_value and (old_value not in self._id2node): | 223 if old_value and (old_value not in self._id2node): |
224 raise ValueError, \ | 224 raise ValueError, \ |
225 'old ID value of passed node is valid one (%s)' % \ | 225 'old ID value of passed node is invalid one (%s)' % \ |
226 (old_value) | 226 (old_value) |
227 if (new_value in self._id2node): | 227 if (new_value in self._id2node): |
228 raise ValueError, \ | 228 raise ValueError, \ |
229 'new ID value of passed node is valid one (%s)' % \ | 229 'new ID value of passed node is invalid one (%s)' % \ |
230 (new_value) | 230 (new_value) |
231 | 231 |
232 if old_value: | 232 if old_value: |
233 del self._id2node[old_value] | 233 del self._id2node[old_value] |
234 pass | 234 pass |
912 cell.modify_bg(gtk.STATE_NORMAL, color) | 912 cell.modify_bg(gtk.STATE_NORMAL, color) |
913 pass | 913 pass |
914 | 914 |
915 def duplicateKeyScene(self): | 915 def duplicateKeyScene(self): |
916 # Search for the current scene | 916 # Search for the current scene |
917 i = 0 | 917 frameline = self.last_line |
918 while i < len(self.last_line._keys): | 918 frame_idx = self.last_frame |
919 key = self.last_line._keys[i] | 919 |
920 if key.idx == self.last_frame: | 920 try: |
921 if i == 0: | 921 start, end, scene_type = frameline.get_frame_block_floor(frame_idx) |
922 # This is the first frame, we can not duplicate it | 922 except: |
923 return | 923 return |
924 self.last_line.add_keyframe(self.last_frame) | 924 if end >= frame_idx: |
925 last_scene_node = last_key.ref | 925 return |
926 last_scene_group_id = last_scene_node.getAttribute('ref') | 926 |
927 scene_group = self.duplicateSceneGroup(last_scene_group_id) | 927 prev_scene_node = frameline.get_frame_data(start) |
928 scene_node = self._add_scene_node(self.last_frame, | 928 prev_scene_group_id = prev_scene_node.getAttribute('ref') |
929 self.last_frame, | 929 |
930 ref=last_scene_group_id) | 930 scene_group = self.duplicateSceneGroup(prev_scene_group_id) |
931 key.ref = scene_node | 931 scene_group_id = scene_group.getAttribute('id') |
932 self.doEditScene(None) | 932 scene_node = self._add_scene_node(frame_idx, frame_idx, |
933 return | 933 ref=scene_group_id) |
934 last_key = key | 934 |
935 i = i + 1 | 935 frameline.add_keyframe(frame_idx, scene_node) |
936 pass | 936 |
937 self.setCurrentScene(frame_idx) | |
937 pass | 938 pass |
938 | 939 |
939 def duplicateSceneGroup(self,gid): | 940 def duplicateSceneGroup(self,gid): |
940 # Search for the duplicated group | 941 # Search for the duplicated group |
941 doc = self.root | 942 doc = self.root |
1066 | 1067 |
1067 btn=gtk.Button('Duplicate Key') | 1068 btn=gtk.Button('Duplicate Key') |
1068 btn.connect('clicked', self.doDuplicateKeyScene) | 1069 btn.connect('clicked', self.doDuplicateKeyScene) |
1069 hbox.pack_start(btn,expand=False,fill=False) | 1070 hbox.pack_start(btn,expand=False,fill=False) |
1070 | 1071 |
1071 btn=gtk.Button('Duplicate Key') | |
1072 btn.connect('clicked', self.doDuplicateKeyScene) | |
1073 hbox.pack_start(btn,expand=False,fill=False) | |
1074 | |
1075 btn=gtk.Button('Insert') | 1072 btn=gtk.Button('Insert') |
1076 btn.connect('clicked', self.doInsertScene) | 1073 btn.connect('clicked', self.doInsertScene) |
1077 hbox.pack_start(btn,expand=False,fill=False) | 1074 hbox.pack_start(btn,expand=False,fill=False) |
1078 | 1075 |
1079 btn=gtk.Button('Remove') | 1076 btn=gtk.Button('Remove') |