# HG changeset patch # User Thinker K.F. Li # Date 1302765877 -28800 # Node ID 8ea0d32a1864e842395cd133512b10def1e93bc9 # Parent e22df2f3bffedb54cf71ee2633812587780e7722 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. diff -r e22df2f3bffe -r 8ea0d32a1864 pyink/MBScene.py --- 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