Mercurial > MadButterfly
changeset 1259:df474448364e
Add find_layer_from_group() for domview_ui
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 11 Jan 2011 17:39:06 +0800 |
parents | 2609b219703d |
children | bbd6bc0d079a |
files | pyink/domview.py pyink/domview_ui.py |
diffstat | 2 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/domview.py Tue Jan 11 17:24:56 2011 +0800 +++ b/pyink/domview.py Tue Jan 11 17:39:06 2011 +0800 @@ -524,6 +524,10 @@ def get_layer_num(self): return len(self._layers) + ## \brief Find layer index and scene info for a given scene node. + # + # \return (-1, None) for error. + # def find_layer_n_scene_of_node(self, node_id): for layer_idx, layer in enumerate(self._layers): for scene_node in layer.scenes: @@ -569,6 +573,17 @@ return dup_group + ## \brief Return associated layer index of given layer group. + # + # \return -1 for error. + # + def find_layer_of_group(self, group_id): + for layer_idx, layer in enumerate(self._layers): + if layer.group.getAttribute('id') == group_id: + return layer_idx + pass + return -1 + def insert_frames(self, layer_idx, frame_idx, num): layer = self._layers[layer_idx] for scene_node in layer.scenes:
--- a/pyink/domview_ui.py Tue Jan 11 17:24:56 2011 +0800 +++ b/pyink/domview_ui.py Tue Jan 11 17:39:06 2011 +0800 @@ -542,6 +542,9 @@ def find_key_from_group(self, scene_group_id): layer_idx, scene_node = \ self._dom.find_layer_n_scene_of_node(scene_group_id) + if layer_idx == -1: + raise ValueError, \ + 'can not find the key for group %s' % (scene_group_id) start, end, tween_name = self._dom._parse_one_scene(scene_node) tween_type = self._tween_type_names.index(tween_name) return layer_idx, (start, end, tween_type) @@ -589,6 +592,15 @@ def register_active_frame_callback(self, cb): self._fl_stack.register_active_frame_callback(cb) pass + + ## \brief Find the layer index associated with a given layer group. + # + def find_layer_from_group(self, group_id): + layer_idx = self._domview.find_layer_from_group(group_id) + if layer_idx == -1: + raise ValueError, \ + 'can not find the layer for group %s' % (group_id) + return layer_idx ## \brief Get duplicate group of a layer. #