changeset 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
files pyink/MBScene.py
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/MBScene.py	Mon Jan 10 11:45:12 2011 +0800
+++ b/pyink/MBScene.py	Mon Jan 10 11:45:12 2011 +0800
@@ -867,6 +867,8 @@
 
     ## \brief Get data associated with the given key frame.
     #
+    # The given frame index must be exactly a key frame.
+    #
     def get_keyframe_data(self, layer_idx, frame_idx):
 	frameline = self._framelines[layer_idx]
 	data = frameline.get_frame_data(frame_idx)
@@ -1096,6 +1098,8 @@
 
     ## \brief Return associated group node for a key frame.
     #
+    # The given frame index must be exactly a key frame.
+    #
     def get_keyframe_group(self, layer_idx, frame_idx):
 	scene_node = self._fl_mgr.get_keyframe_data(frame_idx)
 	scene_group_id = scene_node.getAttribute('ref')
@@ -1169,7 +1173,7 @@
 # implemented by this class.  It use API provided by MBScene_dom to reflect
 # actions to the DOM-tree.
 #
-class MBScene(MBScene_dom, MBScene_framelines):
+class MBScene(object):
     _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
 			      TweenObject.TWEEN_TYPE_SCALE)
     _tween_type_names = ('normal', 'scale')
@@ -1231,8 +1235,11 @@
 	"""
 	try:
 	    self._dom.add_key(layer_idx, frame_idx)
-	except ValueError:
-	    # existed key frame
+	except ValueError:	# existed key frame
+	    pass
+	else:			# new key frame
+	    scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx)
+	    self._enterGroup(scene_group)
 	    pass
 	pass
 
@@ -1247,6 +1254,9 @@
 	    self._dom.get_left_key(layer_idx, frame_idx)
 	tween_len = frame_idx - start
 	self._dom.tween(layer_idx, start, tween_len, tween_type)
+	
+	scene_group = self._dom.get_keyframe_group(layer_idx, start)
+	self._enterGroup(scene_gorup)
 	pass
     
     def setCurrentScene(self, idx):
@@ -1309,7 +1319,7 @@
 	    pass
 	pass
     
-    def enterGroup(self, scene_group):
+    def _enterGroup(self, scene_group):
 	self.desktop.setCurrentLayer(scene_group.spitem)
 	pass
     
@@ -1328,7 +1338,7 @@
 	    return
 
 	scene_group = self._dom.get_keyframe_group(layer_idx, start)
-	self.enterGroup(scene_group)
+	self._enterGroup(scene_group)
 	self.setTweenType(tween_type)
 	pass