comparison pyink/MBScene.py @ 1234:0f597a2073eb

Enter the group after insert/extend a key frame
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 11:45:12 +0800
parents 7f17a7e70d82
children 84e7b1c1892b
comparison
equal deleted inserted replaced
1233:7f17a7e70d82 1234:0f597a2073eb
865 frameline.add_keyframe(frame_idx) 865 frameline.add_keyframe(frame_idx)
866 pass 866 pass
867 867
868 ## \brief Get data associated with the given key frame. 868 ## \brief Get data associated with the given key frame.
869 # 869 #
870 # The given frame index must be exactly a key frame.
871 #
870 def get_keyframe_data(self, layer_idx, frame_idx): 872 def get_keyframe_data(self, layer_idx, frame_idx):
871 frameline = self._framelines[layer_idx] 873 frameline = self._framelines[layer_idx]
872 data = frameline.get_frame_data(frame_idx) 874 data = frameline.get_frame_data(frame_idx)
873 return data 875 return data
874 876
1094 def get_layer_num(self): 1096 def get_layer_num(self):
1095 return self._dom.get_layer_num() 1097 return self._dom.get_layer_num()
1096 1098
1097 ## \brief Return associated group node for a key frame. 1099 ## \brief Return associated group node for a key frame.
1098 # 1100 #
1101 # The given frame index must be exactly a key frame.
1102 #
1099 def get_keyframe_group(self, layer_idx, frame_idx): 1103 def get_keyframe_group(self, layer_idx, frame_idx):
1100 scene_node = self._fl_mgr.get_keyframe_data(frame_idx) 1104 scene_node = self._fl_mgr.get_keyframe_data(frame_idx)
1101 scene_group_id = scene_node.getAttribute('ref') 1105 scene_group_id = scene_node.getAttribute('ref')
1102 scene_group_node = self._dom.get_node(scene_group_id) 1106 scene_group_node = self._dom.get_node(scene_group_id)
1103 return scene_group_node 1107 return scene_group_node
1167 # 1171 #
1168 # This class connect behavior of GUI to the DOM-tree. All about GUI is 1172 # This class connect behavior of GUI to the DOM-tree. All about GUI is
1169 # implemented by this class. It use API provided by MBScene_dom to reflect 1173 # implemented by this class. It use API provided by MBScene_dom to reflect
1170 # actions to the DOM-tree. 1174 # actions to the DOM-tree.
1171 # 1175 #
1172 class MBScene(MBScene_dom, MBScene_framelines): 1176 class MBScene(object):
1173 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL, 1177 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
1174 TweenObject.TWEEN_TYPE_SCALE) 1178 TweenObject.TWEEN_TYPE_SCALE)
1175 _tween_type_names = ('normal', 'scale') 1179 _tween_type_names = ('normal', 'scale')
1176 1180
1177 _num_frames_of_line = 100 1181 _num_frames_of_line = 100
1229 new scene. 1233 new scene.
1230 1234
1231 """ 1235 """
1232 try: 1236 try:
1233 self._dom.add_key(layer_idx, frame_idx) 1237 self._dom.add_key(layer_idx, frame_idx)
1234 except ValueError: 1238 except ValueError: # existed key frame
1235 # existed key frame 1239 pass
1240 else: # new key frame
1241 scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx)
1242 self._enterGroup(scene_group)
1236 pass 1243 pass
1237 pass 1244 pass
1238 1245
1239 def removeKeyScene(self, layer_idx, frame_idx): 1246 def removeKeyScene(self, layer_idx, frame_idx):
1240 self._dom.rm_key_n_tween(layer_idx, frame_idx) 1247 self._dom.rm_key_n_tween(layer_idx, frame_idx)
1245 layer_idx, frame_idx = self._dom.get_active_layer_frame() 1252 layer_idx, frame_idx = self._dom.get_active_layer_frame()
1246 start, end, tween_type = \ 1253 start, end, tween_type = \
1247 self._dom.get_left_key(layer_idx, frame_idx) 1254 self._dom.get_left_key(layer_idx, frame_idx)
1248 tween_len = frame_idx - start 1255 tween_len = frame_idx - start
1249 self._dom.tween(layer_idx, start, tween_len, tween_type) 1256 self._dom.tween(layer_idx, start, tween_len, tween_type)
1257
1258 scene_group = self._dom.get_keyframe_group(layer_idx, start)
1259 self._enterGroup(scene_gorup)
1250 pass 1260 pass
1251 1261
1252 def setCurrentScene(self, idx): 1262 def setCurrentScene(self, idx):
1253 """ 1263 """
1254 Update the scene group according to the curretn scene 1264 Update the scene group according to the curretn scene
1307 pass 1317 pass
1308 pass 1318 pass
1309 pass 1319 pass
1310 pass 1320 pass
1311 1321
1312 def enterGroup(self, scene_group): 1322 def _enterGroup(self, scene_group):
1313 self.desktop.setCurrentLayer(scene_group.spitem) 1323 self.desktop.setCurrentLayer(scene_group.spitem)
1314 pass 1324 pass
1315 1325
1316 def setTweenType(self, tween_type): 1326 def setTweenType(self, tween_type):
1317 tween_type_name = self._tween_type_names[tween_type] 1327 tween_type_name = self._tween_type_names[tween_type]
1326 start, stop, tween_type = self._dom.get_key(frame_idx) 1336 start, stop, tween_type = self._dom.get_key(frame_idx)
1327 except: 1337 except:
1328 return 1338 return
1329 1339
1330 scene_group = self._dom.get_keyframe_group(layer_idx, start) 1340 scene_group = self._dom.get_keyframe_group(layer_idx, start)
1331 self.enterGroup(scene_group) 1341 self._enterGroup(scene_group)
1332 self.setTweenType(tween_type) 1342 self.setTweenType(tween_type)
1333 pass 1343 pass
1334 1344
1335 ## \brief Remove the layer that lost the layer group. 1345 ## \brief Remove the layer that lost the layer group.
1336 # 1346 #