# HG changeset patch # User Thinker K.F. Li # Date 1294277987 -28800 # Node ID ec964cf4c99337a9878e1664cad3e402933f206b # Parent 03daff2d939c77ca65e21c9864fd94642a2e7055# Parent 33aa2d63e240fa8f6aeca91a1db2225b337f2165 merge diff -r 03daff2d939c -r ec964cf4c993 pyink/MBScene.py --- a/pyink/MBScene.py Thu Jan 06 09:37:24 2011 +0800 +++ b/pyink/MBScene.py Thu Jan 06 09:39:47 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,6 +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() + pass + obj = obj.parent() + pass pass def insertKeyScene(self, line, frame): diff -r 03daff2d939c -r ec964cf4c993 pyink/frameline.py --- a/pyink/frameline.py Thu Jan 06 09:37:24 2011 +0800 +++ b/pyink/frameline.py Thu Jan 06 09:39:47 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)