Mercurial > MadButterfly
comparison pyink/domview.py @ 1431:60f2c9a24cdb
Keep the same active layer and frame when switching back a timeline.
- Add functions to remember frame and layer for timeline at domview.
- Recall active frame and layer when calling switch_component() and
switch_timeline().
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 11 Apr 2011 00:05:25 +0800 |
parents | bf405cb2d7cb |
children | 8e8c9ab3818f |
comparison
equal
deleted
inserted
replaced
1430:bf405cb2d7cb | 1431:60f2c9a24cdb |
---|---|
662 use_node.setAttribute('use_component', 'true') | 662 use_node.setAttribute('use_component', 'true') |
663 | 663 |
664 parent_group.appendChild(use_node) | 664 parent_group.appendChild(use_node) |
665 | 665 |
666 return use_node | 666 return use_node |
667 | |
668 def remember_current_frame(self, layer_idx, frame_idx): | |
669 if not isinstance(layer_idx, int): | |
670 raise TypeError, 'layer index should be a integer' | |
671 if not isinstance(frame_idx, int): | |
672 raise TypeError, 'frame index should be a integer' | |
673 | |
674 timeline_name = self.get_current_timeline() | |
675 timeline = self._cur_comp.get_timeline(timeline_name) | |
676 timeline_scenes = timeline.scenes_node | |
677 timeline_scenes.setAttribute('cur_layer', str(layer_idx)) | |
678 timeline_scenes.setAttribute('cur_frame', str(frame_idx)) | |
679 pass | |
680 | |
681 def get_current_frame(self): | |
682 timeline_name = self.get_current_timeline() | |
683 timeline = self._cur_comp.get_timeline(timeline_name) | |
684 timeline_scenes = timeline.scenes_node | |
685 try: | |
686 cur_layer = timeline_scenes.getAttribute('cur_layer') | |
687 except KeyError: | |
688 cur_layer_idx = 0 | |
689 else: | |
690 cur_layer_idx = int(cur_layer) | |
691 pass | |
692 try: | |
693 cur_frame = timeline_scenes.getAttribute('cur_frame') | |
694 except KeyError: | |
695 cur_frame_idx = 0 | |
696 else: | |
697 cur_frame_idx = int(cur_frame) | |
698 pass | |
699 | |
700 return cur_layer_idx, cur_frame_idx | |
667 pass | 701 pass |
668 | 702 |
669 | 703 |
670 ## \brief Parser for scenes nodes. | 704 ## \brief Parser for scenes nodes. |
671 # | 705 # |