Mercurial > MadButterfly
changeset 1223:ec964cf4c993
merge
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Thu, 06 Jan 2011 09:39:47 +0800 |
parents | 03daff2d939c (current diff) 33aa2d63e240 (diff) |
children | 5d731460b32c |
files | pyink/MBScene.py |
diffstat | 2 files changed, 53 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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):
--- 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)