Mercurial > MadButterfly
comparison pyink/frameline.py @ 958:7631dbbbb2be
Fix bug for no any key frame in a frameline
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Wed, 17 Nov 2010 15:18:30 +0800 |
parents | 75bc6d9f4e0a |
children | dbb5462c471f |
comparison
equal
deleted
inserted
replaced
957:8e3e46c26137 | 958:7631dbbbb2be |
---|---|
231 gc.set_rgb_fg_color(border_color) | 231 gc.set_rgb_fg_color(border_color) |
232 gc.set_line_attributes(1, gtk.gdk.LINE_SOLID, | 232 gc.set_line_attributes(1, gtk.gdk.LINE_SOLID, |
233 gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER) | 233 gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER) |
234 win.draw_line(gc, next_f_x, 0, next_f_x, w_h) | 234 win.draw_line(gc, next_f_x, 0, next_f_x, w_h) |
235 pass | 235 pass |
236 | |
237 ## \brief Draw a bottom line from start to the point before stop frame. | |
238 # | |
239 def _draw_bottom_line(self, start, stop): | |
240 win = self.window | |
241 w_x, w_y, w_w, w_h, depth = win.get_geometry() | |
242 gc = self._gc | |
243 | |
244 border_rgb = color_to_rgb(self._normal_border) | |
245 border_color = gtk.gdk.Color(*border_rgb) | |
246 gc.set_rgb_fg_color(border_color) | |
247 start_x = start * self._frame_width | |
248 stop_x = stop * self._frame_width | |
249 win.draw_line(gc, start_x, w_h - 1, stop_x, w_h - 1) | |
250 pass | |
236 | 251 |
237 def _draw_all_frames(self): | 252 def _draw_all_frames(self): |
238 win = self.window | 253 win = self.window |
239 w_x, w_y, w_w, w_h, depth = win.get_geometry() | 254 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
240 gc = self._gc | 255 gc = self._gc |
272 self._draw_normal_frame(i) | 287 self._draw_normal_frame(i) |
273 i = i + 1 | 288 i = i + 1 |
274 pass | 289 pass |
275 pass | 290 pass |
276 | 291 |
277 border_rgb = color_to_rgb(self._normal_border) | 292 self._draw_bottom_line(0, num_frames) |
278 border_color = gtk.gdk.Color(*border_rgb) | |
279 gc.set_rgb_fg_color(border_color) | |
280 stop_x = num_frames * self._frame_width | |
281 win.draw_line(gc, 0, w_h - 1, stop_x, w_h - 1) | |
282 pass | 293 pass |
283 | 294 |
284 def _draw_keyframe(self, frame_idx): | 295 def _draw_keyframe(self, frame_idx): |
285 win = self.window | 296 win = self.window |
286 w_x, w_y, w_w, w_h, depth = win.get_geometry() | 297 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
342 | 353 |
343 ## \brief Redraw a frame specified by an index. | 354 ## \brief Redraw a frame specified by an index. |
344 # | 355 # |
345 def _redraw_frame(self, frame_idx): | 356 def _redraw_frame(self, frame_idx): |
346 keys = [key.idx for key in self._keys] | 357 keys = [key.idx for key in self._keys] |
347 try: | 358 if len(keys): |
348 pos = keys.index(frame_idx) | 359 try: |
349 except ValueError: | 360 pos = keys.index(frame_idx) |
350 keys.append(frame_idx) | 361 except ValueError: |
351 keys.sort() | 362 keys.append(frame_idx) |
352 pos = keys.index(frame_idx) - 1 | 363 keys.sort() |
353 pass | 364 pos = keys.index(frame_idx) - 1 |
354 key = self._keys[pos] | 365 pass |
355 | 366 if pos < 0: |
356 if key.right_tween or (key.left_tween and key.idx == frame_idx): | 367 pos = 0 |
368 pass | |
369 key = self._keys[pos] | |
370 else: | |
371 key = None | |
372 pass | |
373 | |
374 if key and (key.right_tween or \ | |
375 (key.left_tween and key.idx == frame_idx)): | |
357 first_key = last_key = key | 376 first_key = last_key = key |
358 first_pos = last_pos = pos | 377 first_pos = last_pos = pos |
359 while first_pos > 0 and first_key.left_tween: | 378 while first_pos > 0 and first_key.left_tween: |
360 first_pos = first_pos - 1 | 379 first_pos = first_pos - 1 |
361 first_key = self._keys[first_pos] | 380 first_key = self._keys[first_pos] |
365 last_pos = last_pos + 1 | 384 last_pos = last_pos + 1 |
366 last_key = self._keys[last_pos] | 385 last_key = self._keys[last_pos] |
367 pass | 386 pass |
368 | 387 |
369 self._draw_tween(first_key, last_key) | 388 self._draw_tween(first_key, last_key) |
389 self._draw_bottom_line(first_key.idx, last_key.idx + 1) | |
370 | 390 |
371 for i in range(first_pos, last_pos + 1): | 391 for i in range(first_pos, last_pos + 1): |
372 key = self._keys[i] | 392 key = self._keys[i] |
373 self._draw_keyframe(key.idx) | 393 self._draw_keyframe(key.idx) |
374 pass | 394 pass |
375 pass | 395 pass |
376 else: | 396 else: |
377 self._draw_normal_frame(frame_idx) | 397 self._draw_normal_frame(frame_idx) |
378 if key.idx == frame_idx: | 398 self._draw_bottom_line(frame_idx, frame_idx + 1) |
399 if key and (key.idx == frame_idx): | |
379 self._draw_keyframe(frame_idx) | 400 self._draw_keyframe(frame_idx) |
380 pass | 401 pass |
381 pass | 402 pass |
382 pass | 403 pass |
383 | 404 |