comparison pyink/frameline.py @ 1120:214e1f628d63

Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
author wycc
date Tue, 07 Dec 2010 07:52:47 +0800
parents 5cefabccfb76
children b65ac686a7c5
comparison
equal deleted inserted replaced
1104:9d52dda8d49f 1120:214e1f628d63
114 _frame_width = 10 # Width for each frame is 10 pixels 114 _frame_width = 10 # Width for each frame is 10 pixels
115 _select_color = 0xee2222 # color of border of selected frame 115 _select_color = 0xee2222 # color of border of selected frame
116 _key_mark_color = 0x000000 # color of marks for key frames. 116 _key_mark_color = 0x000000 # color of marks for key frames.
117 _key_mark_sz = 4 # width and height of a key frame mark 117 _key_mark_sz = 4 # width and height of a key frame mark
118 _tween_color = 0x808080 # color of tween line 118 _tween_color = 0x808080 # color of tween line
119 _tween_bgcolors = [0x80ff80, 0xff8080] # bg colors of tween frames 119 _tween_bgcolors = [0x80ff80, 0xff8080,0xffff80] # bg colors of tween frames
120 # Colors for normal frames 120 # Colors for normal frames
121 _normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc] 121 _normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc]
122 _normal_border = 0xaaaaaa # border color of normal frames. 122 _normal_border = 0xaaaaaa # border color of normal frames.
123 _active_border = 0xff3030 # border color of an active frame 123 _active_border = 0xff3030 # border color of an active frame
124 _hover_border_color = 0xa0a0a0 # border when the pointer over a frame 124 _hover_border_color = 0xa0a0a0 # border when the pointer over a frame
125 # tween types 125 # tween types
126 _tween_type_none=0 126 _tween_type_none=0
127 _tween_type_shape=3 127 _tween_type_move=1
128 _tween_type_shape=2
128 129
129 130
130 FRAME_BUT_PRESS = 'frame-button-press' 131 FRAME_BUT_PRESS = 'frame-button-press'
131 132
132 def __new__(clz, *args): 133 def __new__(clz, *args):
462 if key and (key.idx == frame_idx): 463 if key and (key.idx == frame_idx):
463 self._draw_keyframe(frame_idx) 464 self._draw_keyframe(frame_idx)
464 pass 465 pass
465 pass 466 pass
466 pass 467 pass
468 def set_tween_type(self,frame_idx,typ):
469 found=False
470 for i in range(0,len(self._keys)):
471 if self._keys[i].idx == frame_idx:
472 idx = i
473 found = True
474 break
475 if not found: return
476 key = self._keys[idx]
477 if typ == 'normal':
478 type = self._tween_type_none
479 elif typ == 'relocate':
480 type = self._tween_type_move
481 elif typ == 'scale':
482 type = self._tween_type_shape
483 if key.left_tween is False and key.right_tween is True:
484 key.right_tween_type = type
485
467 486
468 ## \brief Show a mark for the pointer for a frame. 487 ## \brief Show a mark for the pointer for a frame.
469 # 488 #
470 def _draw_hover(self, frame_idx): 489 def _draw_hover(self, frame_idx):
471 if not self._drawing: 490 if not self._drawing:
571 pass 590 pass
572 591
573 ## Tween the key frame specified by an index and the key frame at right. 592 ## Tween the key frame specified by an index and the key frame at right.
574 # 593 #
575 # \see http://www.entheosweb.com/Flash/shape_tween.asp 594 # \see http://www.entheosweb.com/Flash/shape_tween.asp
576 def tween(self, idx, _type=0): 595 def tween(self, idx, _type='normal'):
577 key_indic = [key.idx for key in self._keys] 596 key_indic = [key.idx for key in self._keys]
578 pos = key_indic.index(idx) 597 pos = key_indic.index(idx)
579 key = self._keys[pos] 598 key = self._keys[pos]
580 599
581 try: 600 try:
583 except IndexError: 602 except IndexError:
584 raise ValueError, 'No right key frame' 603 raise ValueError, 'No right key frame'
585 604
586 key.right_tween = True 605 key.right_tween = True
587 right_key.left_tween = True 606 right_key.left_tween = True
588 key.right_tween_type = _type 607 if _type == 'normal':
589 pass 608 key.right_tween_type = self._tween_type_none
609 elif _type == 'relocate':
610 key.right_tween_type = self._tween_type_move
611 elif _type == 'scale':
612 key.right_tween_type = self._tween_type_shape
613 pass
614 def get_tween_type(self,idx):
615 for i in range(0,len(self._keys)):
616 key = self._keys[i]
617 if key.left_tween is True: continue
618 if key.idx == idx:
619 if key.right_tween_type == self._tween_type_none:
620 return 'normal'
621 elif key.right_tween_type == self._tween_type_move:
622 return 'relocate'
623 elif key.right_tween_type == self._tween_type_shape:
624 return 'scale'
625
590 626
591 ## Set active frame 627 ## Set active frame
592 # 628 #
593 # The active frame is the frame that is working on. 629 # The active frame is the frame that is working on.
594 # 630 #
624 ss = rdoc.createElement("ns0:scene") 660 ss = rdoc.createElement("ns0:scene")
625 node.appendChild(ss) 661 node.appendChild(ss)
626 ss.setAttribute("start", str(key.idx+1),True) 662 ss.setAttribute("start", str(key.idx+1),True)
627 ss.setAttribute("ref",key.ref.attribute("id"),True) 663 ss.setAttribute("ref",key.ref.attribute("id"),True)
628 ss.setAttribute("end", str(self._keys[i+1].idx+1),True) 664 ss.setAttribute("end", str(self._keys[i+1].idx+1),True)
665 if self._keys[i].right_tween_type == self._tween_type_none:
666 ss.setAttribute("type", "normal", True)
667 elif self._keys[i].right_tween_type == self._tween_type_move:
668 ss.setAttribute("type", "relocate", True)
669 elif self._keys[i].right_tween_type == self._tween_type_scale:
670 ss.setAttribute("type", "scale", True)
629 else: 671 else:
630 ss = rdoc.createElement("ns0:scene") 672 ss = rdoc.createElement("ns0:scene")
631 node.appendChild(ss) 673 node.appendChild(ss)
632 ss.setAttribute("start", str(key.idx+1),True) 674 ss.setAttribute("start", str(key.idx+1),True)
633 ss.setAttribute("ref",key.ref.attribute("id"),True) 675 ss.setAttribute("ref",key.ref.attribute("id"),True)
676 ss.setAttribute("type", "normal", True)
634 677
635 678
636 ## \brief Start future drawing actions 679 ## \brief Start future drawing actions
637 # 680 #
638 def start_drawing(self): 681 def start_drawing(self):