diff 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
line wrap: on
line diff
--- a/pyink/domview_ui.py	Wed Jan 12 12:25:45 2011 +0800
+++ b/pyink/domview_ui.py	Wed Jan 12 15:01:14 2011 +0800
@@ -75,7 +75,6 @@
     def _add_frameline(self, layer_idx):
 	if layer_idx > len(self._framelines):
 	    raise ValueError, 'layer number should be a consequence'
-
 	vbox = self._frameline_vbox
 	
 	line = frameline(self._num_frames_of_line)
@@ -111,6 +110,7 @@
 	
 	hbox = line.parent
 	vbox.remove(hbox)
+	hbox.remove(line)
 	del self._framelines[layer_idx]
 	
 	for idx in range(layer_idx, len(self._framelines)):
@@ -118,7 +118,23 @@
 	    pass
 	pass
 
+    def _remove_all_framelines(self):
+        num = len(self._framelines)
+	
+        for idx in range(0,num):
+	    line = self._framelines[idx]
+	    hbox = line.parent
+	    self._frameline_vbox.remove(hbox)
+	self._framelines=[]
+	self._last_mouse_over_frameline = None
+	self._last_active_frameline = None
+	self._active_frame_callback = None
+
+	pass
+
     def _init_framelines(self):
+        if self._framelines!= None: 
+	    return
 	self._framelines = []
 	
 	box = gtk.ScrolledWindow()
@@ -411,6 +427,13 @@
         self._root = root
 	pass
 
+    ## \brief Reload the document.
+    #
+    def reset(self):
+        self._fl_stack._remove_all_framelines()
+        self.handle_doc_root(self._doc, self._root)
+	pass
+
     ## \brief Mark given frame as a key frame.
     #
     def mark_key(self, layer_idx, key_idx):
@@ -645,6 +668,13 @@
 	max_frame = self._dom.get_max_frame()
 	return max_frame
 
+    ## \brief add the current position to the undo buffer.
+    #
+    #  The msg will be displayed in the UI to indicate the undo set.
+    def mark_undo(self, msg):
+    	self._dom.mark_undo(msg)
+    	pass
+
     @property
     def doc(self):
         return self._doc