comparison pyink/frameline.py @ 1231:d28b1b840bfc

Integrate MBDOM_UI to MBScene
author Thinker K.F. Li <thinker@codemud.net>
date Mon, 10 Jan 2011 11:45:12 +0800
parents f0864d7177e3
children e64f5bd2270c
comparison
equal deleted inserted replaced
1230:f0864d7177e3 1231:d28b1b840bfc
678 if self._drawing: 678 if self._drawing:
679 self._draw_keyframe(idx) 679 self._draw_keyframe(idx)
680 pass 680 pass
681 pass 681 pass
682 682
683 def remove_frame(self, idx): 683 ## \brief Remove a frame from the frameline.
684 #
685 # The frames after specified one would move to head in one position. It
686 # means sub one from positions of all frame after given frame.
687 #
688 def rm_frame(self, idx):
684 pos = self._find_keyframe_floor(idx) 689 pos = self._find_keyframe_floor(idx)
685 if pos != -1: 690 if pos != -1:
686 key = self._keys[pos] 691 key = self._keys[pos]
687 if key.idx == idx: 692 if key.idx == idx:
688 if key.left_tween: 693 self.rm_keyframe(idx)
689 self._keys[pos-1].right_tween = False 694 pass
690 del self._keys[pos] 695
691 while pos < len(self._keys): 696 while pos < len(self._keys):
692 self._keys[pos].idx = self._keys[pos].idx - 1 697 self._keys[pos].idx = self._keys[pos].idx - 1
693 pos = pos+1 698 pos = pos+1
694 self.update() 699 pass
695 # Use remove key frame to remove the key frame 700 pass
696 return 701 pass
697 elif key.right_tween: 702
698 pos = pos + 1 703 ## \brief Inser a frame before given frame.
699 while pos < len(self._keys): 704 #
700 self._keys[pos].idx = self._keys[pos].idx - 1 705 # All frame at and after given frame position move to tail in one position.
701 pos = pos + 1 706 # It means to add one to positions of all key frames at/after given frame.
702 if self._drawing: 707 #
703 self.update() 708 def add_frame(self,idx):
704 else:
705 return
706 pass
707 pass
708
709 def insert_frame(self,idx):
710 pos = self._find_keyframe_floor(idx) 709 pos = self._find_keyframe_floor(idx)
711 if pos != -1: 710 if pos != -1:
712 key = self._keys[pos] 711 key = self._keys[pos]
713 if key.idx == idx: 712 if key.idx == idx:
714 while pos < len(self._keys):
715 self._keys[pos].idx = self._keys[pos].idx + 1
716 pos = pos + 1
717 if self._drawing:
718 self.update()
719 return
720 elif key.right_tween:
721 pos = pos + 1 713 pos = pos + 1
722 while pos < len(self._keys): 714 pass
723 self._keys[pos].idx = self._keys[pos].idx + 1 715 while pos < len(self._keys):
724 pos = pos + 1 716 key = self._keys[pos]
725 if self._drawing: 717 key.idx = key.idx + 1
726 self.update() 718 pos = pos + 1
727 else: 719 pass
728 return
729 pass 720 pass
730 pass 721 pass
731 722
732 def rm_keyframe(self, idx): 723 def rm_keyframe(self, idx):
733 key_pos = self._find_keyframe(idx) 724 key_pos = self._find_keyframe(idx)
775 key.right_tween_type = tween_type 766 key.right_tween_type = tween_type
776 767
777 self._draw_tween_of_key(pos) 768 self._draw_tween_of_key(pos)
778 self._draw_active_frame() 769 self._draw_active_frame()
779 pass 770 pass
771
772 ## \brief Remove right tween for given key frame.
773 #
774 def untween(self, idx):
775 pos = self._find_keyframe(idx)
776 key = self._keys[pos]
777 right_key = self._keys[pos + 1]
778
779 if not key.right_tween:
780 return
781
782 key.right_tween = False
783 key.right_tween_type = frameline_draw_state.TWEEN_TYPE_NONE
784 right_key.left_tween = False
785 pass
780 786
781 def get_tween_type(self, idx): 787 def get_tween_type(self, idx):
782 for i in range(0,len(self._keys)): 788 for i in range(0,len(self._keys)):
783 key = self._keys[i] 789 key = self._keys[i]
784 if key.left_tween is True: continue 790 if key.left_tween is True: continue
838 if key.left_tween: 844 if key.left_tween:
839 prev_key = self._keys[pos - 1] 845 prev_key = self._keys[pos - 1]
840 return prev_key.idx, key.idx, prev_key.right_tween_type 846 return prev_key.idx, key.idx, prev_key.right_tween_type
841 return key.idx, key.idx, 0 847 return key.idx, key.idx, 0
842 raise ValueError, \ 848 raise ValueError, \
843 'the frame specified by idx is not in any tween or a key frame' 849 'no any key frame at left side (%d)' % (idx)
844 850
845 ## \brief Return the range of a block of consequence frames (tween). 851 ## \brief Return the range of a block of consequence frames (tween).
846 # 852 #
847 # - If the index frame is in a tween, it returns the range of the tween. 853 # - If the index frame is in a tween, it returns the range of the tween.
848 # 854 #