comparison pyink/MBScene.py @ 1179:b65df4f0d30a

Change signature of MBScene.insertKeyScene()
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 31 Dec 2010 11:10:14 +0800
parents 416e41952b76
children bfd7d466a022
comparison
equal deleted inserted replaced
1178:416e41952b76 1179:b65df4f0d30a
409 return l 409 return l
410 pass 410 pass
411 return None 411 return None
412 412
413 413
414 def insertKeyScene(self): 414 def insertKeyScene(self, line, frame):
415 """ 415 """
416 Insert a new key scene into the stage. If the nth is always a 416 Insert a new key scene into the stage. If the nth is always a
417 key scene, we will return without changing anything. If the 417 key scene, we will return without changing anything. If the
418 nth is a filled scene, we will break the original scene into 418 nth is a filled scene, we will break the original scene into
419 two parts. If the nth is out of any scene, we will append a 419 two parts. If the nth is out of any scene, we will append a
420 new scene. 420 new scene.
421 421
422 """ 422 """
423 x = self.last_frame
424 y = self.last_line
425 rdoc = self.document 423 rdoc = self.document
426 ns = rdoc.createElement("svg:g") 424 ns = rdoc.createElement("svg:g")
427 found = False 425 found = False
428 for node in self.last_line.node.childList(): 426 for node in line.node.childList():
429 try: 427 try:
430 label = node.getAttribute("inkscape:label") 428 label = node.getAttribute("inkscape:label")
431 except: 429 except:
432 continue 430 continue
433 if label == "dup": 431 if label == "dup":
449 txt.setAttribute("width","100") 447 txt.setAttribute("width","100")
450 txt.setAttribute("height","100") 448 txt.setAttribute("height","100")
451 txt.setAttribute("style","fill:#ff00") 449 txt.setAttribute("style","fill:#ff00")
452 ns.appendChild(txt) 450 ns.appendChild(txt)
453 451
454 gid = self.last_line.node.getAttribute('inkscape:label')+self.newID() 452 gid = line.node.getAttribute('inkscape:label')+self.newID()
455 self.ID[gid]=1 453 self.ID[gid]=1
456 ns.setAttribute("id",gid) 454 ns.setAttribute("id",gid)
457 ns.setAttribute("inkscape:groupmode","layer") 455 ns.setAttribute("inkscape:groupmode","layer")
458 self.last_line.node.appendChild(ns) 456 line.node.appendChild(ns)
459 self.last_line.add_keyframe(x,ns) 457 line.add_keyframe(frame, ns)
460 self.update() 458 self.update()
461 pass 459 pass
462 460
463 def removeKeyScene(self): 461 def removeKeyScene(self):
464 nth = self.last_frame 462 nth = self.last_frame
685 btn.add(img) 683 btn.add(img)
686 btn.connect("button_press_event", self.cellSelect) 684 btn.connect("button_press_event", self.cellSelect)
687 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray")) 685 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray"))
688 return btn 686 return btn
689 687
690 def onCellClick(self,line,frame,but): 688 def onCellClick(self, line, frame, but):
691 self.last_line = line 689 self.last_line = line
692 self.last_frame = frame 690 self.last_frame = frame
693 self.last_line.active_frame(frame) 691 self.last_line.active_frame(frame)
694 self.lockui = True 692 self.lockui = True
695 self.doEditScene(frame) 693 self.doEditScene(None)
696 self.lockui = False 694 self.lockui = False
697 pass 695 pass
698 696
699 def _remove_active_frame(self,widget,event): 697 def _remove_active_frame(self,widget,event):
700 """ 698 """
854 self.last_line.node.appendChild(ns) 852 self.last_line.node.appendChild(ns)
855 return ns 853 return ns
856 854
857 def doEditScene(self, w): 855 def doEditScene(self, w):
858 self.setCurrentScene(self.last_frame+1) 856 self.setCurrentScene(self.last_frame+1)
859 self.selectSceneObject(self.last_line,self.last_frame) 857 self.selectSceneObject(self.last_line, self.last_frame)
860 pass 858 pass
861 859
862 def doInsertKeyScene(self,w): 860 def doInsertKeyScene(self,w):
863 self.lockui=True 861 self.lockui=True
864 self.insertKeyScene() 862 self.insertKeyScene(self.last_line, self.last_frame)
865 self.selectSceneObject(self.last_line, self.last_frame) 863 self.selectSceneObject(self.last_line, self.last_frame)
866 self.lockui=False 864 self.lockui=False
867 # self.grid.show_all() 865 # self.grid.show_all()
868 return 866 return
869 867
934 self.last_line.remove_frame(self.last_frame) 932 self.last_line.remove_frame(self.last_frame)
935 self.update() 933 self.update()
936 self.lockui=False 934 self.lockui=False
937 935
938 def addButtons(self,hbox): 936 def addButtons(self,hbox):
939 #btn = gtk.Button('Edit')
940 #btn.connect('clicked', self.doEditScene)
941 #hbox.pack_start(btn,expand=False,fill=False)
942
943 btn = gtk.Button('Insert Key') 937 btn = gtk.Button('Insert Key')
944 btn.connect('clicked',self.doInsertKeyScene) 938 btn.connect('clicked',self.doInsertKeyScene)
945 hbox.pack_start(btn,expand=False,fill=False) 939 hbox.pack_start(btn,expand=False,fill=False)
946 940
947 btn=gtk.Button('Remove Key') 941 btn=gtk.Button('Remove Key')