Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1097:52d8bf5d12b4
Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
author | wycc |
---|---|
date | Sat, 04 Dec 2010 07:43:51 +0800 |
parents | afa42d5836cc |
children | 5ba2cab1d505 |
comparison
equal
deleted
inserted
replaced
1070:afa42d5836cc | 1097:52d8bf5d12b4 |
---|---|
547 | 547 |
548 self.last_cell = cell | 548 self.last_cell = cell |
549 color = cell.get_colormap().alloc_color("green") | 549 color = cell.get_colormap().alloc_color("green") |
550 cell.modify_bg(gtk.STATE_NORMAL, color) | 550 cell.modify_bg(gtk.STATE_NORMAL, color) |
551 pass | 551 pass |
552 | 552 def duplicateKeyScene(self): |
553 self.last_line.add_keyframe(self.last_frame) | |
554 # Search for the current scene | |
555 i = 0 | |
556 while i < len(self.last_line._keys): | |
557 key = self.last_line._keys[i] | |
558 if key.idx == self.last_frame: | |
559 if i == 0: | |
560 # This is the first frame, we can not duplicate it | |
561 self.last_line.rm_keyframe(self.last_frame) | |
562 return | |
563 node = self.duplicateSceneGroup(last_key.ref.attribute("id")) | |
564 key.ref = node | |
565 self.update() | |
566 self.show() | |
567 self.doEditScene(None) | |
568 return | |
569 last_key = key | |
570 i = i + 1 | |
571 def duplicateSceneGroup(self,gid): | |
572 # Search for the duplicated group | |
573 doc = self.desktop.doc().root() | |
574 rdoc = self.desktop.doc().rdoc | |
575 orig = None | |
576 for node in doc.childList(): | |
577 if node.repr.name() == 'svg:g': | |
578 for t in node.childList(): | |
579 if t.repr.name() == "svg:g": | |
580 if t.repr.attribute("id") == gid: | |
581 orig = t.repr | |
582 break | |
583 if orig == None: | |
584 return None | |
585 ns = orig.duplicate(rdoc) | |
586 gid = self.last_line.node.label()+self.newID() | |
587 self.ID[gid]=1 | |
588 ns.setAttribute("id",gid,True) | |
589 ns.setAttribute("inkscape:groupmode","layer",True) | |
590 self.last_line.node.repr.appendChild(ns) | |
591 return ns | |
553 | 592 |
554 def doEditScene(self,w): | 593 def doEditScene(self,w): |
555 self.setCurrentScene(self.last_frame+1) | 594 self.setCurrentScene(self.last_frame+1) |
556 self.selectSceneObject(self.last_line,self.last_frame+1) | 595 self.selectSceneObject(self.last_line,self.last_frame+1) |
557 pass | 596 pass |
558 | 597 |
559 def doInsertKeyScene(self,w): | 598 def doInsertKeyScene(self,w): |
560 self.insertKeyScene() | 599 self.insertKeyScene() |
561 # self.grid.show_all() | 600 # self.grid.show_all() |
562 return | 601 return |
602 def doDuplicateKeyScene(self,w): | |
603 self.duplicateKeyScene() | |
563 | 604 |
564 def doRemoveScene(self,w): | 605 def doRemoveScene(self,w): |
565 self.removeKeyScene() | 606 self.removeKeyScene() |
566 return | 607 return |
567 | 608 |
581 btn=gtk.Button('Remove Key') | 622 btn=gtk.Button('Remove Key') |
582 btn.connect('clicked', self.doRemoveScene) | 623 btn.connect('clicked', self.doRemoveScene) |
583 hbox.pack_start(btn,expand=False,fill=False) | 624 hbox.pack_start(btn,expand=False,fill=False) |
584 btn=gtk.Button('Extend scene') | 625 btn=gtk.Button('Extend scene') |
585 btn.connect('clicked', self.doExtendScene) | 626 btn.connect('clicked', self.doExtendScene) |
627 hbox.pack_start(btn,expand=False,fill=False) | |
628 btn=gtk.Button('Duplicate Key') | |
629 btn.connect('clicked', self.doDuplicateKeyScene) | |
586 hbox.pack_start(btn,expand=False,fill=False) | 630 hbox.pack_start(btn,expand=False,fill=False) |
587 pass | 631 pass |
588 | 632 |
589 def onQuit(self, event): | 633 def onQuit(self, event): |
590 self.OK = False | 634 self.OK = False |