comparison pyink/MBScene.py @ 1240:84bcd398cccc

Fix bug of removing keyframe
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 11:45:13 +0800
parents 447cd3359cf2
children e64f5bd2270c
comparison
equal deleted inserted replaced
1239:447cd3359cf2 1240:84bcd398cccc
862 pass 862 pass
863 frameline.add_keyframe(right_frame_idx) 863 frameline.add_keyframe(right_frame_idx)
864 frameline.tween(start, fl_tween_type) 864 frameline.tween(start, fl_tween_type)
865 pass 865 pass
866 866
867 ## \brief Remove key frame.
868 #
869 # Once a key frame was removed, the associated tween was also removed
870 # totally.
871 #
867 def rm_keyframe(self, layer_idx, frame_idx): 872 def rm_keyframe(self, layer_idx, frame_idx):
868 frameline = self._framelines[layer_idx] 873 frameline = self._framelines[layer_idx]
869 start, end, fl_tween_type = frameline.get_frame_block(frame_idx) 874 start, end, fl_tween_type = frameline.get_frame_block(frame_idx)
870 if start != frame_idx: 875 if start != frame_idx:
871 raise ValueError, 'no such key (%d, %d)' % (layer_idx, frame_idx) 876 raise ValueError, 'no such key (%d, %d)' % (layer_idx, frame_idx)
1073 1078
1074 def rm_key_n_tween(self, layer_idx, key_frame_idx): 1079 def rm_key_n_tween(self, layer_idx, key_frame_idx):
1075 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, key_frame_idx) 1080 scene_node = self._fl_mgr.get_keyframe_data(layer_idx, key_frame_idx)
1076 self._dom.rm_scene_node_n_group(scene_node) 1081 self._dom.rm_scene_node_n_group(scene_node)
1077 1082
1078 self._fl_mgr.rm_key_n_tween(layer_idx, key_frame_idx) 1083 self._fl_mgr.rm_keyframe(layer_idx, key_frame_idx)
1079 pass 1084 pass
1080 1085
1081 def add_frames(self, layer_idx, frame_idx, num): 1086 def add_frames(self, layer_idx, frame_idx, num):
1082 self._fl_mgr.add_frames(layer_idx, frame_idx, num) 1087 self._fl_mgr.add_frames(layer_idx, frame_idx, num)
1083 self._dom.add_frames(layer_idx, frame_idx, num) 1088 self._dom.add_frames(layer_idx, frame_idx, num)
1277 1282
1278 """ 1283 """
1279 try: 1284 try:
1280 self._dom.add_key(layer_idx, frame_idx) 1285 self._dom.add_key(layer_idx, frame_idx)
1281 except ValueError: # existed key frame 1286 except ValueError: # existed key frame
1282 pass
1283 else: # new key frame
1284 scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx)
1285 self._enterGroup(scene_group)
1286 pass 1287 pass
1287 pass 1288 pass
1288 1289
1289 def removeKeyScene(self, layer_idx, frame_idx): 1290 def removeKeyScene(self, layer_idx, frame_idx):
1290 self._dom.rm_key_n_tween(layer_idx, frame_idx) 1291 self._dom.rm_key_n_tween(layer_idx, frame_idx)
1367 def _enterGroup(self, scene_group): 1368 def _enterGroup(self, scene_group):
1368 self.desktop.setCurrentLayer(scene_group.spitem) 1369 self.desktop.setCurrentLayer(scene_group.spitem)
1369 pass 1370 pass
1370 1371
1371 def setTweenType(self, tween_type): 1372 def setTweenType(self, tween_type):
1372 tween_type_name = self._tween_type_names[tween_type]
1373
1374 self._disable_tween_type_selector = True 1373 self._disable_tween_type_selector = True
1375 self.tweenTypeSelector.set_active(tween_type_name) 1374 self.tweenTypeSelector.set_active(tween_type)
1376 self._disable_tween_type_selector = False 1375 self._disable_tween_type_selector = False
1377 pass 1376 pass
1378 1377
1379 def selectSceneObject(self, layer_idx, frame_idx): 1378 def selectSceneObject(self, layer_idx, frame_idx):
1380 try: 1379 try:
1381 start, stop, tween_type = self._dom.get_key(frame_idx) 1380 start, stop, tween_type = self._dom.get_key(layer_idx, frame_idx)
1382 except: 1381 except:
1383 return 1382 return
1384 1383
1385 scene_group = self._dom.get_keyframe_group(layer_idx, start) 1384 scene_group = self._dom.get_keyframe_group(layer_idx, start)
1386 self._enterGroup(scene_group) 1385 self._enterGroup(scene_group)
1625 if not self._root: 1624 if not self._root:
1626 self._root = self.desktop.doc().root().repr 1625 self._root = self.desktop.doc().root().repr
1627 pass 1626 pass
1628 1627
1629 self.document = self.desktop.doc().rdoc 1628 self.document = self.desktop.doc().rdoc
1629
1630 self.tween = TweenObject(self.document, self._root) 1630 self.tween = TweenObject(self.document, self._root)
1631 self._dom.handle_doc_root(self.document, self._root) 1631 self._dom.handle_doc_root(self.document, self._root)
1632 self._dom.register_active_frame_callback(self.onCellClick) 1632 self._dom.register_active_frame_callback(self.onCellClick)
1633 1633
1634 if self.top == None: 1634 if self.top == None: