comparison pyink/frameline.py @ 1174:96a7abce774a

Add functions to insert and remove frame.
author wycc
date Fri, 31 Dec 2010 00:49:58 +0800
parents 2cb5047d8f2b
children bfd7d466a022
comparison
equal deleted inserted replaced
1172:178b126edd2c 1174:96a7abce774a
658 ## Set the frame @idx as the right of a tween 658 ## Set the frame @idx as the right of a tween
659 def set_right_tween(self,idx): 659 def set_right_tween(self,idx):
660 pos = self._find_keyframe(idx) 660 pos = self._find_keyframe(idx)
661 self._keys[pos].right_tween = TRue 661 self._keys[pos].right_tween = TRue
662 662
663 def remove_frame(self, idx):
664 pos = self._find_keyframe_floor(idx)
665 if pos != -1:
666 key = self._keys[pos]
667 if key.idx == idx:
668 if key.left_tween:
669 self._keys[pos-1].right_tween = False
670 del self._keys[pos]
671 while pos < len(self._keys):
672 self._keys[pos].idx = self._keys[pos].idx - 1
673 pos = pos+1
674 self.update()
675 # Use remove key frame to remove the key frame
676 return
677 elif key.right_tween:
678 pos = pos + 1
679 while pos < len(self._keys):
680 self._keys[pos].idx = self._keys[pos].idx - 1
681 pos = pos + 1
682 if self._drawing:
683 self.update()
684 else:
685 return
686 pass
687 pass
688
689 def insert_frame(self,idx):
690 pos = self._find_keyframe_floor(idx)
691 if pos != -1:
692 key = self._keys[pos]
693 if key.idx == idx:
694 while pos < len(self._keys):
695 self._keys[pos].idx = self._keys[pos].idx + 1
696 pos = pos + 1
697 if self._drawing:
698 self.update()
699 return
700 elif key.right_tween:
701 pos = pos + 1
702 while pos < len(self._keys):
703 self._keys[pos].idx = self._keys[pos].idx + 1
704 pos = pos + 1
705 if self._drawing:
706 self.update()
707 else:
708 return
709 pass
710 pass
711 pass
663 def rm_keyframe(self, idx): 712 def rm_keyframe(self, idx):
664 key_pos = self._find_keyframe(idx) 713 key_pos = self._find_keyframe(idx)
665 key = self._keys[key_pos] 714 key = self._keys[key_pos]
666 del self._keys[key_pos] 715 del self._keys[key_pos]
667 716
676 else: 725 else:
677 left_key = self._keys[key_pos - 1] 726 left_key = self._keys[key_pos - 1]
678 left_key.right_tween = False 727 left_key.right_tween = False
679 redraw_range = (idx, left_key.idx + 1) 728 redraw_range = (idx, left_key.idx + 1)
680 pass 729 pass
681 for i in range(*redraw_range):
682 self._draw_frame(i) 730 self._draw_frame(i)
683 pass 731 pass
684 else: 732 else:
685 self._draw_frame(idx) 733 self._draw_frame(idx)
686 pass 734 pass