Mercurial > MadButterfly
comparison pyink/frameline.py @ 977:5cefabccfb76
Generate the last key frame correct.
Fix the issue of draw.
author | wycc |
---|---|
date | Sat, 20 Nov 2010 15:46:03 +0800 |
parents | 8a7e5914a84b |
children | 214e1f628d63 |
comparison
equal
deleted
inserted
replaced
976:ab09c536a137 | 977:5cefabccfb76 |
---|---|
157 def _press_hdl(self, widget, event): | 157 def _press_hdl(self, widget, event): |
158 frame = event.x / self._frame_width | 158 frame = event.x / self._frame_width |
159 but = event.button | 159 but = event.button |
160 self.emit(frameline.FRAME_BUT_PRESS, frame, but) | 160 self.emit(frameline.FRAME_BUT_PRESS, frame, but) |
161 pass | 161 pass |
162 def hide_hover(self): | |
163 if self._active_frame != self._last_hover: | |
164 self._draw_normal_frame(self._last_hover) | |
162 | 165 |
163 def _motion_hdl(self, widget, event): | 166 def _motion_hdl(self, widget, event): |
164 frame = int(event.x / self._frame_width) | 167 frame = int(event.x / self._frame_width) |
168 | |
165 if frame < self._num_frames and frame >= 0: | 169 if frame < self._num_frames and frame >= 0: |
166 self._draw_hover(frame) | 170 self._draw_hover(frame) |
167 pass | 171 pass |
168 | 172 |
169 def _fl_expose(self, widget, event): | 173 def _fl_expose(self, widget, event): |
302 self._draw_tween(first_tween_key, last_tween_key) | 306 self._draw_tween(first_tween_key, last_tween_key) |
303 | 307 |
304 i = last_tween_key.idx + 1 | 308 i = last_tween_key.idx + 1 |
305 pass | 309 pass |
306 else: | 310 else: |
311 if key.idx == i: | |
312 key_i=key_i+1 | |
313 try: | |
314 key = self._keys[key_i] | |
315 except: | |
316 key = keyframe(self._num_frames) | |
307 self._draw_normal_frame(i) | 317 self._draw_normal_frame(i) |
308 i = i + 1 | 318 i = i + 1 |
309 pass | 319 pass |
310 pass | 320 pass |
311 | 321 |
490 if not self._drawing: | 500 if not self._drawing: |
491 return | 501 return |
492 | 502 |
493 win = self.window | 503 win = self.window |
494 x, y, w, h, depth = win.get_geometry() | 504 x, y, w, h, depth = win.get_geometry() |
495 | |
496 self._draw_all_frames() | 505 self._draw_all_frames() |
497 self._draw_keyframes() | 506 self._draw_keyframes() |
498 if self._active_frame != -1: | 507 if self._active_frame != -1: |
499 self._draw_active() | 508 self._draw_active() |
500 pass | 509 pass |
502 | 511 |
503 ## Add a key frame | 512 ## Add a key frame |
504 # | 513 # |
505 # A key frame is the frame that user specify actions. For | 514 # A key frame is the frame that user specify actions. For |
506 # example, move a object or add new objects at the frame. | 515 # example, move a object or add new objects at the frame. |
507 def add_keyframe(self, idx,ref): | 516 def add_keyframe(self, idx,ref=None): |
508 key_indic = [key.idx for key in self._keys] | 517 key_indic = [key.idx for key in self._keys] |
509 if idx in key_indic: | 518 if idx in key_indic: |
510 return | 519 return |
511 | 520 |
512 key_indic.append(idx) | 521 key_indic.append(idx) |
548 else: | 557 else: |
549 left_key = self._keys[idx - 1] | 558 left_key = self._keys[idx - 1] |
550 left_key.right_key = False | 559 left_key.right_key = False |
551 redraw_range = (idx, left_key.idx + 1) | 560 redraw_range = (idx, left_key.idx + 1) |
552 pass | 561 pass |
553 print redraw_range | |
554 for i in range(*redraw_range): | 562 for i in range(*redraw_range): |
555 self._redraw_frame(i) | 563 self._redraw_frame(i) |
556 pass | 564 pass |
557 else: | 565 else: |
558 self._redraw_frame(idx) | 566 self._redraw_frame(idx) |
609 pass | 617 pass |
610 | 618 |
611 def addScenes(self,rdoc,node): | 619 def addScenes(self,rdoc,node): |
612 for i in range(0,len(self._keys)): | 620 for i in range(0,len(self._keys)): |
613 key = self._keys[i] | 621 key = self._keys[i] |
614 if key.left_tween is True: return | 622 if key.left_tween is True: continue |
615 if key.right_tween is True: | 623 if key.right_tween is True: |
616 ss = rdoc.createElement("ns0:scene") | 624 ss = rdoc.createElement("ns0:scene") |
617 node.appendChild(ss) | 625 node.appendChild(ss) |
618 print "[%d:%d]" % (key.idx, self._keys[i+1].idx-1) | |
619 ss.setAttribute("start", str(key.idx+1),True) | 626 ss.setAttribute("start", str(key.idx+1),True) |
620 ss.setAttribute("ref",key.ref.attribute("id"),True) | 627 ss.setAttribute("ref",key.ref.attribute("id"),True) |
621 ss.setAttribute("end", str(self._keys[i+1].idx+1),True) | 628 ss.setAttribute("end", str(self._keys[i+1].idx+1),True) |
622 else: | 629 else: |
623 ss = rdoc.createElement("ns0:scene") | 630 ss = rdoc.createElement("ns0:scene") |
651 fr = frameruler(40) | 658 fr = frameruler(40) |
652 fr.set_size_request(300, 20) | 659 fr.set_size_request(300, 20) |
653 | 660 |
654 fl = frameline(40) | 661 fl = frameline(40) |
655 fl.set_size_request(300, 20) | 662 fl.set_size_request(300, 20) |
663 fl.add_keyframe(15) | |
656 fl.add_keyframe(3) | 664 fl.add_keyframe(3) |
657 fl.add_keyframe(15) | |
658 fl.tween(3) | 665 fl.tween(3) |
659 fl.add_keyframe(9) | 666 fl.add_keyframe(9) |
660 fl.add_keyframe(20) | 667 fl.add_keyframe(20) |
661 fl.tween(9) | 668 fl.tween(9) |
662 fl.active_frame(1) | 669 fl.active_frame(1) |