Mercurial > MadButterfly
diff 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 |
line wrap: on
line diff
--- a/pyink/MBScene.py Wed Jan 05 22:58:03 2011 +0800 +++ b/pyink/MBScene.py Thu Jan 06 09:24:54 2011 +0800 @@ -541,6 +541,18 @@ self._last_mouse_over_frameline = None self._last_active_frameline = None pass + + def search_frameline_by_id(self, id): + """ + Search the frameline whose layer is id + """ + + for f in self._framelines: + idx = f.search_by_id(id) + if idx != -1: + return (f,idx) + pass + return (None,-1) def _change_hover_frameline(self, widget, event): """ @@ -692,8 +704,34 @@ except: self.nameEditor.set_text('') pass + + # The selection is a PYSPObject. Convert it to be PYNode + self.change_active_frame(self.last_select.repr.parent()) pass + def change_active_frame(self,obj): + """ + Change the active frame to the current selected object. This will + tell users where the current object is. + """ + + while obj: + id = obj.getAttribute('id') + try: + # Search for the frameline which use @obj as one of its scene + # group. + (frameline,frame) = self.search_frameline_by_id(id) + if frameline == None: + print "Error: internal structure error %s not found" % id + else: + self._change_active_frame(frameline, 0,0) + self.onCellClick(frameline,frame,0) + return + except: + traceback.print_exc() + obj = obj.parent() + + def insertKeyScene(self, line, frame): """ Insert a new key scene into the stage. If the nth is always a