changeset 1455:8ea0d32a1864

Prevent user from escaping from scene or dup group. - It monitor changes of layer. - Go back to previous scene or dup group when user escape from the scene or dup group.
author Thinker K.F. Li <thinker@codemud.net>
date Thu, 14 Apr 2011 15:24:37 +0800
parents e22df2f3bffe
children 894a4bf35fe6
files pyink/MBScene.py
diffstat 1 files changed, 39 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/MBScene.py	Wed Apr 13 19:57:58 2011 +0800
+++ b/pyink/MBScene.py	Thu Apr 14 15:24:37 2011 +0800
@@ -147,6 +147,8 @@
 	    start, stop, tween_type = \
 		self._domviewui.get_key(layer_idx, frame_idx)
 	except:
+	    dup_group = self._domviewui.get_layer_dup_group(layer_idx)
+	    self._enterGroup(dup_group)
 	    return
 
 	scene_group = self._domviewui.get_key_group(layer_idx, start)
@@ -402,6 +404,8 @@
 	self.last_update = None
 	
 	self._drop_undo()
+
+	self.desktop.connectCurrentLayerChanged(self.handle_change_layer)
 	
 	return False
 
@@ -421,6 +425,41 @@
 	self._domviewui.link_to_component(comp_name, node_parent_group)
 	pass
 
+    ## \brief Handle event that user change layers.
+    #
+    # This method is always being called for chaning layer event.
+    # So, we should do some check at beginning for re-entry condition.
+    #
+    def handle_change_layer(self, node):
+	layer = self.desktop.currentLayer()
+	node = layer.repr
+
+	#
+	# Only scene group and dup group are allowed.
+	#
+	try:
+	    scene_group_attr = node.getAttribute('scene_group')
+	except KeyError:
+	    pass
+	else:
+	    if scene_group_attr == 'true':
+		return
+	    pass
+
+	try:
+	    label = node.getAttribute('inkscape:label')
+	except KeyError:
+	    pass
+	else:
+	    if label == 'dup':
+		return
+	    pass
+	# It is not a scene or dup group.
+
+	layer_idx, frame_idx = self._domviewui.get_current_frame()
+	self.selectSceneObject(layer_idx, frame_idx)
+	pass
+
     ## \brief Add menu item to context menu.
     #
     # This method is called by pyink.pyink_context_menu() to notify the