Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1237:b5cceb2b87bb
Sucessful extend and duplicate
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 10 Jan 2011 11:45:13 +0800 |
parents | 2eeac97853eb |
children | 2febe4a301fa |
comparison
equal
deleted
inserted
replaced
1236:2eeac97853eb | 1237:b5cceb2b87bb |
---|---|
802 ## \brief Get layer and frame index of current active frame. | 802 ## \brief Get layer and frame index of current active frame. |
803 # | 803 # |
804 # \return (-1, -1) for no active, (layer_idx, frame_idx) for current | 804 # \return (-1, -1) for no active, (layer_idx, frame_idx) for current |
805 # active. | 805 # active. |
806 def get_active_layer_frame(self): | 806 def get_active_layer_frame(self): |
807 if self._active_frameline: | 807 if self._last_active_frameline: |
808 layer_idx = self._active_frameline.layer_idx | 808 layer_idx = self._last_active_frameline.layer_idx |
809 frame_idx = self._active_frameline.get_active_frame() | 809 frame_idx = self._last_active_frameline.get_active_frame() |
810 if frame_idx != -1: | 810 if frame_idx != -1: |
811 return layer_idx, frame_idx | 811 return layer_idx, frame_idx |
812 pass | 812 pass |
813 return -1, -1 | 813 return -1, -1 |
814 | 814 |
1023 def add_key(self, layer_idx, key_idx): | 1023 def add_key(self, layer_idx, key_idx): |
1024 scene_group = self._dom.add_scene_group(layer_idx) | 1024 scene_group = self._dom.add_scene_group(layer_idx) |
1025 scene_group_id = scene_group.getAttribute('id') | 1025 scene_group_id = scene_group.getAttribute('id') |
1026 | 1026 |
1027 scene_node = self._dom.add_scene_node(key_idx, key_idx) | 1027 scene_node = self._dom.add_scene_node(key_idx, key_idx) |
1028 scene_node.chg_scene_node(scene_node, ref=scene_group_id) | 1028 self._dom.chg_scene_node(scene_node, ref=scene_group_id) |
1029 | 1029 |
1030 self._fl_mgr.add_keyframe(layer_idx, key_idx) | 1030 self._fl_mgr.add_keyframe(layer_idx, key_idx) |
1031 self._fl_mgr.set_keyframe_data(layer_idx, key_idx, scene_node) | 1031 self._fl_mgr.set_keyframe_data(layer_idx, key_idx, scene_node) |
1032 pass | 1032 pass |
1033 | 1033 |
1230 pybInkscape.inkscape.connect('change_selection', self.on_selection) | 1230 pybInkscape.inkscape.connect('change_selection', self.on_selection) |
1231 self.last_select = None | 1231 self.last_select = None |
1232 self._lockui = False | 1232 self._lockui = False |
1233 self.tween = None | 1233 self.tween = None |
1234 self.document = None | 1234 self.document = None |
1235 self.root = root | 1235 self._root = root |
1236 self.framerate = 12 | 1236 self.framerate = 12 |
1237 self._disable_tween_type_selector = False | 1237 self._disable_tween_type_selector = False |
1238 self.current = 0 | 1238 self.current = 0 |
1239 | 1239 |
1240 self._dom = MBDOM_UI() | 1240 self._dom = MBDOM_UI() |
1295 self._dom.get_left_key(layer_idx, frame_idx) | 1295 self._dom.get_left_key(layer_idx, frame_idx) |
1296 tween_len = frame_idx - start + 1 | 1296 tween_len = frame_idx - start + 1 |
1297 self._dom.tween(layer_idx, start, tween_len, tween_type) | 1297 self._dom.tween(layer_idx, start, tween_len, tween_type) |
1298 | 1298 |
1299 scene_group = self._dom.get_keyframe_group(layer_idx, start) | 1299 scene_group = self._dom.get_keyframe_group(layer_idx, start) |
1300 self._enterGroup(scene_gorup) | 1300 self._enterGroup(scene_group) |
1301 pass | 1301 pass |
1302 | 1302 |
1303 def setCurrentScene(self, idx): | 1303 def setCurrentScene(self, idx): |
1304 """ | 1304 """ |
1305 Update the scene group according to the curretn scene | 1305 Update the scene group according to the curretn scene |
1399 | 1399 |
1400 self._dom.add_key(layer_idx, frame_idx) | 1400 self._dom.add_key(layer_idx, frame_idx) |
1401 | 1401 |
1402 scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx) | 1402 scene_group = self._dom.get_keyframe_group(layer_idx, frame_idx) |
1403 left_scene_group = \ | 1403 left_scene_group = \ |
1404 self._dom.get_keyframe_group(layer_idx, left_frame_idx) | 1404 self._dom.get_keyframe_group(layer_idx, left_start) |
1405 | 1405 |
1406 left_scene_group_id = left_scene_group.getAttribute('id') | 1406 dup_group = self._duplicate_group(left_scene_group, scene_group) |
1407 dup_group = self._duplicate_group(left_scene_group_id, scene_group) | |
1408 | 1407 |
1409 self.setCurrentScene(frame_idx) | 1408 self.setCurrentScene(frame_idx) |
1410 pass | 1409 pass |
1411 | 1410 |
1412 ## \brief Duplicate children of a group. | 1411 ## \brief Duplicate children of a group. |
1414 # Duplicate children of a group, and append them to another group. | 1413 # Duplicate children of a group, and append them to another group. |
1415 # | 1414 # |
1416 def _duplicate_group(self, src_group, dst_group): | 1415 def _duplicate_group(self, src_group, dst_group): |
1417 # Search for the duplicated group | 1416 # Search for the duplicated group |
1418 root = self._root | 1417 root = self._root |
1419 doc = self._doc | 1418 doc = self.document |
1420 | 1419 |
1421 dup_group = orig.duplicate(doc) | 1420 dup_group = src_group.duplicate(doc) |
1422 for child in dup_group.childList(): | 1421 for child in dup_group.childList(): |
1422 dup_group.removeChild(child) # prvent from crash | |
1423 dst_group.appendChild(child) | 1423 dst_group.appendChild(child) |
1424 pass | 1424 pass |
1425 | 1425 |
1426 old_nodes = _DOM_iterator(src_group) | 1426 old_nodes = _DOM_iterator(src_group) |
1427 new_nodes = _DOM_iterator(dst_group) | 1427 new_nodes = _DOM_iterator(dst_group) |
1618 self.addTweenTypeSelector(hbox) | 1618 self.addTweenTypeSelector(hbox) |
1619 pass | 1619 pass |
1620 | 1620 |
1621 def show(self): | 1621 def show(self): |
1622 self.OK = True | 1622 self.OK = True |
1623 if not self.root: | 1623 if not self._root: |
1624 self.root = self.desktop.doc().root().repr | 1624 self._root = self.desktop.doc().root().repr |
1625 pass | 1625 pass |
1626 | 1626 |
1627 self.document = self.desktop.doc().rdoc | 1627 self.document = self.desktop.doc().rdoc |
1628 self.tween = TweenObject(self.document, self.root) | 1628 self.tween = TweenObject(self.document, self._root) |
1629 self._dom.handle_doc_root(self.document, self.root) | 1629 self._dom.handle_doc_root(self.document, self._root) |
1630 self._dom.register_active_frame_callback(self.onCellClick) | 1630 self._dom.register_active_frame_callback(self.onCellClick) |
1631 | 1631 |
1632 if self.top == None: | 1632 if self.top == None: |
1633 self.top = gtk.VBox(False, 0) | 1633 self.top = gtk.VBox(False, 0) |
1634 toplevel = self.desktop.getToplevel() | 1634 toplevel = self.desktop.getToplevel() |