comparison pyink/MBScene.py @ 1228:027187a21117

Add undo support. This is not working yet. We need to modify the MBScene_dom to handle the undo events correctly.
author wycc
date Sat, 08 Jan 2011 15:46:09 +0800
parents 5d731460b32c
children cc55f3de9c0b
comparison
equal deleted inserted replaced
1227:983442b2698c 1228:027187a21117
114 pass 114 pass
115 115
116 def _on_insert_node(self, node, child): 116 def _on_insert_node(self, node, child):
117 try: 117 try:
118 child_id = child.getAttribute('id') 118 child_id = child.getAttribute('id')
119 print "On insert node %s" % child_id
119 except: 120 except:
120 pass 121 pass
121 else: 122 else:
122 if child_id not in self._id2node: 123 if child_id not in self._id2node:
123 self._id2node[child_id] = child 124 self._id2node[child_id] = child
797 798
798 try: 799 try:
799 frameline.duplicateGroup.setAttribute('style', 'display: none') 800 frameline.duplicateGroup.setAttribute('style', 'display: none')
800 except AttributeError: 801 except AttributeError:
801 pass 802 pass
803 self.done("remove key")
802 pass 804 pass
803 805
804 def extendScene(self): 806 def extendScene(self):
805 frame_idx = self.last_frame 807 frame_idx = self.last_frame
806 frameline = self.last_line 808 frameline = self.last_line
815 817
816 scene_node = frameline.get_frame_data(start) 818 scene_node = frameline.get_frame_data(start)
817 self.chg_scene_node(scene_node, end=frame_idx) 819 self.chg_scene_node(scene_node, end=frame_idx)
818 frameline.add_keyframe(frame_idx) 820 frameline.add_keyframe(frame_idx)
819 frameline.tween(start, scene_type) 821 frameline.tween(start, scene_type)
822 self.done("extend scene")
820 pass 823 pass
821 824
822 def setCurrentScene(self, idx): 825 def setCurrentScene(self, idx):
823 """ 826 """
824 Update the scene group according to the curretn scene 827 Update the scene group according to the curretn scene
1134 return scene_group 1137 return scene_group
1135 1138
1136 def changeObjectLabel(self,w): 1139 def changeObjectLabel(self,w):
1137 o = self.desktop.selection.list()[0] 1140 o = self.desktop.selection.list()[0]
1138 o.setAttribute("inkscape:label", self.nameEditor.get_text()) 1141 o.setAttribute("inkscape:label", self.nameEditor.get_text())
1142 self.done("modify name")
1139 pass 1143 pass
1140 1144
1141 def addNameEditor(self,hbox): 1145 def addNameEditor(self,hbox):
1142 self.nameEditor = gtk.Entry(max=40) 1146 self.nameEditor = gtk.Entry(max=40)
1143 hbox.pack_start(self.nameEditor,expand=False,fill=False) 1147 hbox.pack_start(self.nameEditor,expand=False,fill=False)
1179 self._lockui=True 1183 self._lockui=True
1180 self.insertKeyScene(self.last_line, self.last_frame) 1184 self.insertKeyScene(self.last_line, self.last_frame)
1181 self.selectSceneObject(self.last_line, self.last_frame) 1185 self.selectSceneObject(self.last_line, self.last_frame)
1182 self._lockui=False 1186 self._lockui=False
1183 # self.grid.show_all() 1187 # self.grid.show_all()
1188 self.done("new key")
1184 return 1189 return
1185 1190
1186 def doDuplicateKeyScene(self,w): 1191 def doDuplicateKeyScene(self,w):
1187 self._lockui = True 1192 self._lockui = True
1188 self.duplicateKeyScene() 1193 self.duplicateKeyScene()
1189 self._lockui = False 1194 self._lockui = False
1195 self.done("dup key")
1196 return
1190 1197
1191 def doRemoveScene(self,w): 1198 def doRemoveScene(self,w):
1192 self._lockui = True 1199 self._lockui = True
1193 self.removeKeyScene(self.last_line, self.last_frame) 1200 self.removeKeyScene(self.last_line, self.last_frame)
1194 self._lockui = False 1201 self._lockui = False
1202 self.done("remove key")
1195 return 1203 return
1196 1204
1197 1205
1198 def doExtendScene(self,w): 1206 def doExtendScene(self,w):
1199 self._lockui = True 1207 self._lockui = True
1200 self.extendScene() 1208 self.extendScene()
1201 self._lockui = False 1209 self._lockui = False
1210 self.done("extend key")
1202 pass 1211 pass
1203 1212
1204 def doRun(self,arg): 1213 def doRun(self,arg):
1205 """ 1214 """
1206 Execute the current animation till the last frame. 1215 Execute the current animation till the last frame.
1363 1372
1364 frameline.tween(start, tween_type) 1373 frameline.tween(start, tween_type)
1365 1374
1366 scene_node = frameline.get_frame_data(start) 1375 scene_node = frameline.get_frame_data(start)
1367 self.chg_scene_node(scene_node, tween_type=type_name) 1376 self.chg_scene_node(scene_node, tween_type=type_name)
1377 self.done("None","change tween type")
1368 pass 1378 pass
1369 1379
1370 def addTweenTypeSelector(self, hbox): 1380 def addTweenTypeSelector(self, hbox):
1371 tweenbox = gtk.HBox() 1381 tweenbox = gtk.HBox()
1372 label = gtk.Label('Tween Type') 1382 label = gtk.Label('Tween Type')
1390 def onOK(self, event): 1400 def onOK(self, event):
1391 self.OK = True 1401 self.OK = True
1392 gtk.main_quit() 1402 gtk.main_quit()
1393 pass 1403 pass
1394 1404
1405 def done(self, desc):
1406 spdoc = self.desktop.doc()
1407 spdoc.done("None",desc)
1408 pass
1409
1395 def show(self): 1410 def show(self):
1396 self.OK = True 1411 self.OK = True
1397 if not self.root: 1412 if not self.root:
1398 self.root = self.desktop.doc().root().repr 1413 self.root = self.desktop.doc().root().repr
1399 pass 1414 pass