Mercurial > MadButterfly
changeset 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 a05c8deb6523 |
files | pyink/MBScene.py pyink/frameline.py |
diffstat | 2 files changed, 51 insertions(+), 0 deletions(-) [+] |
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
--- a/pyink/frameline.py Wed Jan 05 22:58:03 2011 +0800 +++ b/pyink/frameline.py Thu Jan 06 09:24:54 2011 +0800 @@ -6,6 +6,7 @@ import gtk.gdk import pango import gobject +import traceback def color_to_rgb(v): return (((v >> 16) & 0xff) * 65535 / 0xff, @@ -864,6 +865,18 @@ pos = self._find_keyframe(idx) key = self._keys[pos] return key.ref + + def search_by_id(self,ID): + for k in self._keys: + try: + if k.ref == None: continue + if k.ref.getAttribute("ref") == ID: + return k.idx + except: + traceback.print_exc() + pass + pass + return -1 def set_frame_data(self, idx, value): pos = self._find_keyframe(idx)