changeset 1215:8e372ae69010

Fix the issue of showing active mark for a frame in a tween - Does not show active frame if user set an active frame in a tween and move the to other frame. - Frameline only redraw active mark of the current active frame is same as one of new hover and last hover frame. - It is fixed by detecting if the crruent active frame is in the same frame as one of new hover and last hover frame.
author Thinker K.F. Li <thinker@codemud.net>
date Wed, 05 Jan 2011 18:53:54 +0800
parents e55499f7505a
children 61f1b3d424cf
files pyink/frameline.py
diffstat 1 files changed, 31 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pyink/frameline.py	Wed Jan 05 17:56:14 2011 +0800
+++ b/pyink/frameline.py	Wed Jan 05 18:53:54 2011 +0800
@@ -428,23 +428,46 @@
     def _draw_hover_frame(self, frame_idx):
 	if not self._drawing:
 	    return
+
+	last_hover = self._last_hover
 	
-        if self._last_hover != -1:
-            self._draw_frame(self._last_hover)
-	    if self._last_hover == self._active_frame:
-		self._draw_active_frame()
-		pass
+        if last_hover != -1:
+            self._draw_frame(last_hover)
             pass
 	
         if frame_idx < self._num_frames and frame_idx >= 0:
             self._draw_hover(frame_idx)
-	    if self._last_hover == self._active_frame:
-		self._draw_active_frame()
-		pass
 	    self._last_hover = frame_idx
 	else:
 	    self._last_hover = -1
 	    pass
+
+	#
+	# Redraw active frame if active frame in a tween that is same as the
+	# one that the give frame or last hover frame is in.
+	#
+	if self._active_frame in (frame_idx, last_hover):
+	    self._draw_active_frame()
+	    return
+
+	for idx in (frame_idx, last_hover):
+	    key_pos = self._find_keyframe_floor(idx)
+	    if key_pos != -1:
+		key = self._keys[key_pos]
+		if key.right_tween or \
+			(key.left_tween and key.idx == idx):
+		    # The given frame is in a tween
+		    first_pos, last_pos = self._find_tween_range(key_pos)
+		    start = self._keys[first_pos].idx
+		    end = self._keys[last_pos].idx
+		    if self._active_frame >= start and \
+			    self._active_frame <= end:
+			# The active frame is in the tween
+			self._draw_active_frame()
+			break
+		    pass
+		pass
+	    pass
         pass
 
     ## \brief Start future drawing actions