Mercurial > MadButterfly
changeset 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 |
files | pyink/MBScene.py pyink/domview.py pyink/domview_ui.py |
diffstat | 3 files changed, 48 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pyink/MBScene.py Sun Apr 10 20:30:06 2011 +0800 +++ b/pyink/MBScene.py Mon Apr 11 00:05:25 2011 +0800 @@ -232,6 +232,7 @@ def do_CellClick(self, layer_idx, frame_idx): self._director.show_scene(frame_idx) self.selectSceneObject(layer_idx, frame_idx) + self._domviewui.remember_current_frame(layer_idx, frame_idx) pass def doInsertKeyScene(self,w):
--- a/pyink/domview.py Sun Apr 10 20:30:06 2011 +0800 +++ b/pyink/domview.py Mon Apr 11 00:05:25 2011 +0800 @@ -664,6 +664,40 @@ parent_group.appendChild(use_node) return use_node + + def remember_current_frame(self, layer_idx, frame_idx): + if not isinstance(layer_idx, int): + raise TypeError, 'layer index should be a integer' + if not isinstance(frame_idx, int): + raise TypeError, 'frame index should be a integer' + + timeline_name = self.get_current_timeline() + timeline = self._cur_comp.get_timeline(timeline_name) + timeline_scenes = timeline.scenes_node + timeline_scenes.setAttribute('cur_layer', str(layer_idx)) + timeline_scenes.setAttribute('cur_frame', str(frame_idx)) + pass + + def get_current_frame(self): + timeline_name = self.get_current_timeline() + timeline = self._cur_comp.get_timeline(timeline_name) + timeline_scenes = timeline.scenes_node + try: + cur_layer = timeline_scenes.getAttribute('cur_layer') + except KeyError: + cur_layer_idx = 0 + else: + cur_layer_idx = int(cur_layer) + pass + try: + cur_frame = timeline_scenes.getAttribute('cur_frame') + except KeyError: + cur_frame_idx = 0 + else: + cur_frame_idx = int(cur_frame) + pass + + return cur_layer_idx, cur_frame_idx pass
--- a/pyink/domview_ui.py Sun Apr 10 20:30:06 2011 +0800 +++ b/pyink/domview_ui.py Mon Apr 11 00:05:25 2011 +0800 @@ -424,6 +424,9 @@ self._dom.switch_component(name) self._framelines_refresh() # from domview_ui self._comp_dock.refresh_timelines() + + cur_layer_idx, cur_frame_idx = self._dom.get_current_frame() + self._fl_stack.active_frame(cur_layer_idx, cur_frame_idx) pass def all_comp_names(self): @@ -450,6 +453,9 @@ def switch_timeline(self, name): self._dom.switch_timeline(name) self._framelines_refresh() # from domview_ui + + cur_layer_idx, cur_frame_idx = self._dom.get_current_frame() + self._fl_stack.active_frame(cur_layer_idx, cur_frame_idx) pass def all_timeline_names(self): @@ -876,6 +882,13 @@ max_frame = self._dom.get_max_frame() return max_frame + def remember_current_frame(self, layer_idx, frame_idx): + self._dom.remember_current_frame(layer_idx, frame_idx) + pass + + def get_current_frame(self): + return self._dom.get_current_frame() + ## \brief add the current position to the undo buffer. # # The msg will be displayed in the UI to indicate the undo set.