Mercurial > MadButterfly
comparison pyink/MBScene.py @ 1221:33aa2d63e240
When we select a new object, search the scene group which contain it and make it as the active frame.
author | wycc |
---|---|
date | Thu, 06 Jan 2011 09:24:54 +0800 |
parents | 9425733a677e |
children | ec964cf4c993 |
comparison
equal
deleted
inserted
replaced
1220:9425733a677e | 1221:33aa2d63e240 |
---|---|
539 super(MBScene_framelines, self).__init__(*args, **kws) | 539 super(MBScene_framelines, self).__init__(*args, **kws) |
540 | 540 |
541 self._last_mouse_over_frameline = None | 541 self._last_mouse_over_frameline = None |
542 self._last_active_frameline = None | 542 self._last_active_frameline = None |
543 pass | 543 pass |
544 | |
545 def search_frameline_by_id(self, id): | |
546 """ | |
547 Search the frameline whose layer is id | |
548 """ | |
549 | |
550 for f in self._framelines: | |
551 idx = f.search_by_id(id) | |
552 if idx != -1: | |
553 return (f,idx) | |
554 pass | |
555 return (None,-1) | |
544 | 556 |
545 def _change_hover_frameline(self, widget, event): | 557 def _change_hover_frameline(self, widget, event): |
546 """ | 558 """ |
547 Hide all hover frames. This is a hack. We should use the lost focus | 559 Hide all hover frames. This is a hack. We should use the lost focus |
548 event instead in the future to reduce the overhead. | 560 event instead in the future to reduce the overhead. |
690 try: | 702 try: |
691 self.nameEditor.set_text(o.getAttribute("inkscape:label")) | 703 self.nameEditor.set_text(o.getAttribute("inkscape:label")) |
692 except: | 704 except: |
693 self.nameEditor.set_text('') | 705 self.nameEditor.set_text('') |
694 pass | 706 pass |
695 pass | 707 |
708 # The selection is a PYSPObject. Convert it to be PYNode | |
709 self.change_active_frame(self.last_select.repr.parent()) | |
710 pass | |
711 | |
712 def change_active_frame(self,obj): | |
713 """ | |
714 Change the active frame to the current selected object. This will | |
715 tell users where the current object is. | |
716 """ | |
717 | |
718 while obj: | |
719 id = obj.getAttribute('id') | |
720 try: | |
721 # Search for the frameline which use @obj as one of its scene | |
722 # group. | |
723 (frameline,frame) = self.search_frameline_by_id(id) | |
724 if frameline == None: | |
725 print "Error: internal structure error %s not found" % id | |
726 else: | |
727 self._change_active_frame(frameline, 0,0) | |
728 self.onCellClick(frameline,frame,0) | |
729 return | |
730 except: | |
731 traceback.print_exc() | |
732 obj = obj.parent() | |
733 | |
696 | 734 |
697 def insertKeyScene(self, line, frame): | 735 def insertKeyScene(self, line, frame): |
698 """ | 736 """ |
699 Insert a new key scene into the stage. If the nth is always a | 737 Insert a new key scene into the stage. If the nth is always a |
700 key scene, we will return without changing anything. If the | 738 key scene, we will return without changing anything. If the |