Mercurial > MadButterfly
changeset 1288:fb44830c8a81
Change the duplicate key back to the old implementation. Now, we have clone key frame(extend) and copy key frame(duplicate).
author | wycc |
---|---|
date | Sat, 15 Jan 2011 21:06:55 +0800 |
parents | f6a28f473494 |
children | e816b0c2deec |
files | pyink/MBScene.py pyink/domview.py pyink/domview_ui.py |
diffstat | 3 files changed, 52 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/MBScene.py Sat Jan 15 20:52:24 2011 +0800 +++ b/pyink/MBScene.py Sat Jan 15 21:06:55 2011 +0800 @@ -128,7 +128,7 @@ # Create a key frame which link to the previous key frame scene_group = self._domviewui.get_key_group(layer_idx, start) self._domviewui.mark_key(layer_idx, frame_idx) - self._domviewui.copy_key_group(layer_idx, start, frame_idx) + self._domviewui.link_key_group(layer_idx, start, frame_idx) self._director.show_scene(frame_idx) self.selectSceneObject(layer_idx, frame_idx) pass
--- a/pyink/domview.py Sat Jan 15 20:52:24 2011 +0800 +++ b/pyink/domview.py Sat Jan 15 21:06:55 2011 +0800 @@ -732,6 +732,46 @@ def copy_group_children(self, src_group, dst_group): # Search for the duplicated group doc = self._doc + + dup_group = src_group.duplicate(doc) + + old_nodes = _DOM_iterator(src_group) + new_nodes = _DOM_iterator(dup_group) + new_gids = set() + for old_node in old_nodes: + old_node_id = old_node.getAttribute('id') + new_node = new_nodes.next() + new_node.setAttribute('ns0:duplicate-src', old_node_id) + + # + # Change ID here, or inkscape would insert the node with + # the same ID, and change it later to avoid duplication. + # But, our event handler would be called before changing + # ID. It would confuse our code. We change ID of nodes + # before inserting them into the DOM-tree. + # + gid = self.new_id() + while gid in new_gids: + gid = self.new_id() + pass + new_gids.add(gid) + new_node.setAttribute('id', gid) + pass + + for child in dup_group.childList(): + dup_group.removeChild(child) # prvent from crash + dst_group.appendChild(child) + pass + pass + pass + + ## \brief Link children of a group. + # + # Clone children of a group, and append them to another group. + # + def link_group_children(self, src_group, dst_group): + # Search for the duplicated group + doc = self._doc old_nodes = _DOM_iterator(src_group) new_gids = set() for old_node in old_nodes: @@ -757,4 +797,3 @@ pass pass pass -
--- a/pyink/domview_ui.py Sat Jan 15 20:52:24 2011 +0800 +++ b/pyink/domview_ui.py Sat Jan 15 21:06:55 2011 +0800 @@ -604,6 +604,17 @@ self._dom.copy_group_children(src_group, dst_group) pass + ## \brief Link content of a source key frame to a destinate. + # + # Link content of the scene group of a source key frame to the + # scene group of a destinate key frame. + # + def link_key_group(self, layer_idx, src_frame_idx, dst_frame_idx): + src_group = self.get_key_group(layer_idx, src_frame_idx) + dst_group = self.get_key_group(layer_idx, dst_frame_idx) + self._dom.link_group_children(src_group, dst_group) + pass + ## \brief Return widget showing frames and layers. # def get_frame_ui_widget(self):