Mercurial > MadButterfly
comparison pyink/domview_ui.py @ 1265:ca301f6abef7
Support undo for insert key frame/rm keyframe. We will refresh all layers and scenes since it is not feasible to collect these changes and update the layers and scenes. We may scan two level only in the future to improve the performance.
author | wycc |
---|---|
date | Wed, 12 Jan 2011 15:01:14 +0800 |
parents | 2f861eea1214 |
children | 0daf68f3c1f9 |
comparison
equal
deleted
inserted
replaced
1264:ff410dcdea02 | 1265:ca301f6abef7 |
---|---|
73 ## \brief Add a frameline into the frameline box for the given layer. | 73 ## \brief Add a frameline into the frameline box for the given layer. |
74 # | 74 # |
75 def _add_frameline(self, layer_idx): | 75 def _add_frameline(self, layer_idx): |
76 if layer_idx > len(self._framelines): | 76 if layer_idx > len(self._framelines): |
77 raise ValueError, 'layer number should be a consequence' | 77 raise ValueError, 'layer number should be a consequence' |
78 | |
79 vbox = self._frameline_vbox | 78 vbox = self._frameline_vbox |
80 | 79 |
81 line = frameline(self._num_frames_of_line) | 80 line = frameline(self._num_frames_of_line) |
82 line.set_size_request(self._num_frames_of_line * 10, 20) | 81 line.set_size_request(self._num_frames_of_line * 10, 20) |
83 | 82 |
109 vbox = self._frameline_vbox | 108 vbox = self._frameline_vbox |
110 line = self._framelines[layer_idx] | 109 line = self._framelines[layer_idx] |
111 | 110 |
112 hbox = line.parent | 111 hbox = line.parent |
113 vbox.remove(hbox) | 112 vbox.remove(hbox) |
113 hbox.remove(line) | |
114 del self._framelines[layer_idx] | 114 del self._framelines[layer_idx] |
115 | 115 |
116 for idx in range(layer_idx, len(self._framelines)): | 116 for idx in range(layer_idx, len(self._framelines)): |
117 self._framelines[idx].layer_idx = idx | 117 self._framelines[idx].layer_idx = idx |
118 pass | 118 pass |
119 pass | 119 pass |
120 | 120 |
121 def _remove_all_framelines(self): | |
122 num = len(self._framelines) | |
123 | |
124 for idx in range(0,num): | |
125 line = self._framelines[idx] | |
126 hbox = line.parent | |
127 self._frameline_vbox.remove(hbox) | |
128 self._framelines=[] | |
129 self._last_mouse_over_frameline = None | |
130 self._last_active_frameline = None | |
131 self._active_frame_callback = None | |
132 | |
133 pass | |
134 | |
121 def _init_framelines(self): | 135 def _init_framelines(self): |
136 if self._framelines!= None: | |
137 return | |
122 self._framelines = [] | 138 self._framelines = [] |
123 | 139 |
124 box = gtk.ScrolledWindow() | 140 box = gtk.ScrolledWindow() |
125 self._frameline_box = box | 141 self._frameline_box = box |
126 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) | 142 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) |
407 self._add_frameline_for_every_layer() | 423 self._add_frameline_for_every_layer() |
408 self._fl_stack._show_framelines() | 424 self._fl_stack._show_framelines() |
409 | 425 |
410 self._doc = doc | 426 self._doc = doc |
411 self._root = root | 427 self._root = root |
428 pass | |
429 | |
430 ## \brief Reload the document. | |
431 # | |
432 def reset(self): | |
433 self._fl_stack._remove_all_framelines() | |
434 self.handle_doc_root(self._doc, self._root) | |
412 pass | 435 pass |
413 | 436 |
414 ## \brief Mark given frame as a key frame. | 437 ## \brief Mark given frame as a key frame. |
415 # | 438 # |
416 def mark_key(self, layer_idx, key_idx): | 439 def mark_key(self, layer_idx, key_idx): |
642 return dup_group | 665 return dup_group |
643 | 666 |
644 def get_max_frame(self): | 667 def get_max_frame(self): |
645 max_frame = self._dom.get_max_frame() | 668 max_frame = self._dom.get_max_frame() |
646 return max_frame | 669 return max_frame |
670 | |
671 ## \brief add the current position to the undo buffer. | |
672 # | |
673 # The msg will be displayed in the UI to indicate the undo set. | |
674 def mark_undo(self, msg): | |
675 self._dom.mark_undo(msg) | |
676 pass | |
647 | 677 |
648 @property | 678 @property |
649 def doc(self): | 679 def doc(self): |
650 return self._doc | 680 return self._doc |
651 | 681 |