Mercurial > MadButterfly
comparison pyink/frameline.py @ 971:a4c0aff915ad
Fix the rm_keyframe to search the keyframe.
Implement tween_type_none which will duplicate all frames between two keyframe
author | wycc |
---|---|
date | Fri, 19 Nov 2010 23:54:24 +0800 |
parents | a1ebbe11354d |
children | 8a7e5914a84b |
comparison
equal
deleted
inserted
replaced
970:a1ebbe11354d | 971:a4c0aff915ad |
---|---|
119 # Colors for normal frames | 119 # Colors for normal frames |
120 _normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc] | 120 _normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc] |
121 _normal_border = 0xaaaaaa # border color of normal frames. | 121 _normal_border = 0xaaaaaa # border color of normal frames. |
122 _active_border = 0xff3030 # border color of an active frame | 122 _active_border = 0xff3030 # border color of an active frame |
123 _hover_border_color = 0xa0a0a0 # border when the pointer over a frame | 123 _hover_border_color = 0xa0a0a0 # border when the pointer over a frame |
124 # tween types | |
125 _tween_type_none=0 | |
126 _tween_type_shape=3 | |
127 | |
124 | 128 |
125 FRAME_BUT_PRESS = 'frame-button-press' | 129 FRAME_BUT_PRESS = 'frame-button-press' |
126 | 130 |
127 def __new__(clz, *args): | 131 def __new__(clz, *args): |
128 if not frameline._type: | 132 if not frameline._type: |
341 | 345 |
342 gc = self._gc | 346 gc = self._gc |
343 gc.set_rgb_fg_color(color) | 347 gc.set_rgb_fg_color(color) |
344 | 348 |
345 for key in self._keys: | 349 for key in self._keys: |
350 if key.left_tween is True and lastkey.right_tween_type == frameline._tween_type_none: | |
351 continue | |
352 | |
346 mark_sz = self._key_mark_sz | 353 mark_sz = self._key_mark_sz |
347 mark_x = int((key.idx + 0.5) * self._frame_width - mark_sz / 2) | 354 mark_x = int((key.idx + 0.5) * self._frame_width - mark_sz / 2) |
348 mark_y = w_h * 2 / 3 - mark_sz / 2 | 355 mark_y = w_h * 2 / 3 - mark_sz / 2 |
349 | 356 |
350 win.draw_rectangle(gc, True, mark_x, mark_y, mark_sz, mark_sz) | 357 win.draw_rectangle(gc, True, mark_x, mark_y, mark_sz, mark_sz) |
358 lastkey = key | |
351 pass | 359 pass |
352 pass | 360 pass |
353 | 361 |
354 def _draw_active(self): | 362 def _draw_active(self): |
355 if not self._drawing: | 363 if not self._drawing: |
430 self._draw_tween(first_key, last_key) | 438 self._draw_tween(first_key, last_key) |
431 self._draw_bottom_line(first_key.idx, last_key.idx + 1) | 439 self._draw_bottom_line(first_key.idx, last_key.idx + 1) |
432 | 440 |
433 for i in range(first_pos, last_pos + 1): | 441 for i in range(first_pos, last_pos + 1): |
434 key = self._keys[i] | 442 key = self._keys[i] |
435 self._draw_keyframe(key.idx) | 443 print "frame %d type=%d" % (key.idx,key.right_tween_type) |
444 if key.left_tween is False or lastkey.right_tween_type != frameline._tween_type_none: | |
445 self._draw_keyframe(key.idx) | |
446 lasykey = key | |
436 pass | 447 pass |
437 pass | 448 pass |
438 else: # not in tween | 449 else: # not in tween |
439 self._draw_normal_frame(frame_idx) | 450 self._draw_normal_frame(frame_idx) |
440 self._draw_bottom_line(frame_idx, frame_idx + 1) | 451 self._draw_bottom_line(frame_idx, frame_idx + 1) |
514 | 525 |
515 self._draw_keyframe(idx) | 526 self._draw_keyframe(idx) |
516 pass | 527 pass |
517 | 528 |
518 def rm_keyframe(self, idx): | 529 def rm_keyframe(self, idx): |
530 found=False | |
531 for i in range(0,len(self._keys)): | |
532 if self._keys[i].idx == idx: | |
533 idx = i | |
534 found = True | |
535 break | |
536 if not found: return | |
519 key = self._keys[idx] | 537 key = self._keys[idx] |
520 del self._keys[idx] | 538 del self._keys[idx] |
521 | 539 |
522 if key.right_tween ^ key.left_tween: | 540 if key.right_tween ^ key.left_tween: |
523 # | 541 # |
524 # tween in one side | 542 # tween in one side |
525 # | 543 # |
526 if key.right_tween: | 544 if key.right_tween: |
527 right_key = self._keys[idx] | 545 right_key = self._keys[idx] |
528 right_key.left_tween = False | 546 right_key.left_tween = False |
529 rdraw_range = (right_key.idx, idx + 1) | 547 redraw_range = (right_key.idx, idx + 1) |
530 else: | 548 else: |
531 left_key = self._keys[idx - 1] | 549 left_key = self._keys[idx - 1] |
532 left_key.right_key = False | 550 left_key.right_key = False |
533 redraw_range = (idx, left_key.idx + 1) | 551 redraw_range = (idx, left_key.idx + 1) |
534 pass | 552 pass |
535 | 553 print redraw_range |
536 for i in range(*redraw_range): | 554 for i in range(*redraw_range): |
537 self._redraw_frame(i) | 555 self._redraw_frame(i) |
538 pass | 556 pass |
539 else: | 557 else: |
540 self._redraw_frame(idx) | 558 self._redraw_frame(idx) |
615 fr.set_size_request(300, 20) | 633 fr.set_size_request(300, 20) |
616 | 634 |
617 fl = frameline(40) | 635 fl = frameline(40) |
618 fl.set_size_request(300, 20) | 636 fl.set_size_request(300, 20) |
619 fl.add_keyframe(3) | 637 fl.add_keyframe(3) |
638 fl.add_keyframe(15) | |
639 fl.tween(3) | |
620 fl.add_keyframe(9) | 640 fl.add_keyframe(9) |
621 fl.add_keyframe(15) | |
622 fl.add_keyframe(20) | 641 fl.add_keyframe(20) |
623 fl.tween(3) | 642 fl.tween(9) |
624 fl.tween(15, 1) | 643 fl.active_frame(1) |
625 fl.active_frame(15) | 644 fl.rm_keyframe(15) |
626 print 'num of frames: %d' % (len(fl)) | 645 print 'num of frames: %d' % (len(fl)) |
627 | 646 |
628 def press_sig(fl, frame, but): | 647 def press_sig(fl, frame, but): |
629 print 'press_sig button %d for frame %d' % (but, frame) | 648 print 'press_sig button %d for frame %d' % (but, frame) |
630 pass | 649 pass |