Mercurial > MadButterfly
annotate pyink/frameline.py @ 1187:9d715956823a
Update the maxframeline
author | wycc |
---|---|
date | Tue, 04 Jan 2011 01:13:23 +0800 |
parents | bfd7d466a022 |
children | 1d476b35dc79 |
rev | line source |
---|---|
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
1 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; fill-column: 79 -*- |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
2 # vim: sw=4:ts=8:sts=4:textwidth=79 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
3 import pygtk |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
4 pygtk.require("2.0") |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
5 import gtk |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
6 import gtk.gdk |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
7 import pango |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
8 import gobject |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
9 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
10 def color_to_rgb(v): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
11 return (((v >> 16) & 0xff) * 65535 / 0xff, |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
12 ((v >> 8) & 0xff) * 65535 / 0xff, |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
13 (v & 0xff) * 65535 / 0xff) |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
14 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
15 class keyframe(object): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
16 def __init__(self, frame_idx): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
17 self.idx = frame_idx |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
18 self.left_tween = False |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
19 self.right_tween = False |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
20 self.right_tween_type = 0 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
21 self.ref = '' |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
22 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
23 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
24 |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
25 class frameruler(gtk.DrawingArea): |
952
88bf64efcc1d
rename _type_id to _type, it is GGbject type actually
Thinker K.F. Li <thinker@codemud.net>
parents:
951
diff
changeset
|
26 _type = 0 |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
27 _frame_width = 10 # Width for each frame is 10 pixels |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
28 _mark_color = 0x808080 # color of mark lines |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
29 _number_color = 0x000000 # color of frame number |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
30 _number_sz = 8 # font size of frame number |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
31 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
32 def __new__(clz, *args): |
952
88bf64efcc1d
rename _type_id to _type, it is GGbject type actually
Thinker K.F. Li <thinker@codemud.net>
parents:
951
diff
changeset
|
33 if not frameruler._type: |
88bf64efcc1d
rename _type_id to _type, it is GGbject type actually
Thinker K.F. Li <thinker@codemud.net>
parents:
951
diff
changeset
|
34 frameruler._type = gobject.type_register(frameruler) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
35 pass |
952
88bf64efcc1d
rename _type_id to _type, it is GGbject type actually
Thinker K.F. Li <thinker@codemud.net>
parents:
951
diff
changeset
|
36 fr = gobject.new(frameruler._type) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
37 return fr |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
38 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
39 def __init__(self, num_frames=20): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
40 self.connect('expose_event', self._fr_expose) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
41 self._num_frames = num_frames |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
42 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
43 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
44 def _fr_expose(self, widget, event): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
45 self.update() |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
46 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
47 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
48 def queue_draw(self): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
49 print 'queue_draw' |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
50 self.update() |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
51 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
52 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
53 def queue_draw_area(self, x, y, w, h): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
54 print 'queue_draw_area' |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
55 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
56 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
57 def update(self): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
58 win = self.window |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
59 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
60 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
61 gc = gtk.gdk.GC(win) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
62 |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
63 # |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
64 # Set color of mark lines |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
65 # |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
66 color_rgb = color_to_rgb(self._mark_color) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
67 color = gtk.gdk.Color(*color_rgb) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
68 gc.set_rgb_fg_color(color) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
69 |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
70 # |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
71 # Mark mark lines |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
72 # |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
73 mark_h = w_h / 10 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
74 for i in range(self._num_frames): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
75 mark_x = (i + 1) * self._frame_width |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
76 win.draw_line(gc, mark_x, 0, mark_x, mark_h) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
77 win.draw_line(gc, mark_x, w_h - mark_h - 1, mark_x, w_h - 1) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
78 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
79 |
950
1bb0780f1036
Add more border line to frameline and frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
949
diff
changeset
|
80 win.draw_line(gc, 0, w_h - 1, w_w, w_h -1) |
1bb0780f1036
Add more border line to frameline and frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
949
diff
changeset
|
81 |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
82 # |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
83 # Set color of frame number |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
84 # |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
85 color_rgb = color_to_rgb(self._number_color) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
86 color = gtk.gdk.Color(*color_rgb) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
87 gc.set_rgb_fg_color(color) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
88 |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
89 font_desc = pango.FontDescription() |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
90 font_desc.set_size(self._number_sz * pango.SCALE) |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
91 |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
92 number_y = (w_h - self._number_sz) / 2 |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
93 |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
94 # |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
95 # Draw frame number |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
96 # |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
97 layout = self.create_pango_layout('1') |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
98 layout.set_font_description(font_desc) |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
99 win.draw_layout(gc, 0, number_y, layout) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
100 for i in range(4, self._num_frames, 5): |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
101 mark_x = i * self._frame_width |
949
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
102 layout.set_text(str(i + 1)) |
c9bf47cc621f
Set font size for frame number in frameruler
Thinker K.F. Li <thinker@codemud.net>
parents:
948
diff
changeset
|
103 win.draw_layout(gc, mark_x, number_y, layout) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
104 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
105 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
106 pass |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
107 |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
108 ## \brief Drawing on the screen for a frameline. |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
109 # |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
110 # This class contain all functions that drawing thing on the screen for a |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
111 # frameline. It is used by descendants to drawing a frameline. This class is |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
112 # only responsible to draw screen, the logical part is the responsible of |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
113 # deriving classes. |
953
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
114 # |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
115 # This class should only include functions about drawing, no any control, logic |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
116 # function, and state should be implemented here. This class should change/or |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
117 # read states of instances. It is stateless. |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
118 # |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
119 class frameline_draw(gtk.DrawingArea): |
952
88bf64efcc1d
rename _type_id to _type, it is GGbject type actually
Thinker K.F. Li <thinker@codemud.net>
parents:
951
diff
changeset
|
120 _type = 0 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
121 _frame_width = 10 # Width for each frame is 10 pixels |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
122 _select_color = 0xee2222 # color of border of selected frame |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
123 _key_mark_color = 0x000000 # color of marks for key frames. |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
124 _key_mark_sz = 4 # width and height of a key frame mark |
945
8db3dd03508f
Draw line to connect continious tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
944
diff
changeset
|
125 _tween_color = 0x808080 # color of tween line |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
126 # bg colors of tween frames |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
127 _tween_bgcolors = [0x80ff80, 0xff8080, 0xffff80] |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
128 # Colors for normal frames |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
129 _normal_bgcolors = [0xffffff, 0xffffff, 0xffffff, 0xffffff, 0xcccccc] |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
130 _normal_border = 0xaaaaaa # border color of normal frames. |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
131 _active_border = 0xff3030 # border color of an active frame |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
132 _hover_border_color = 0xa0a0a0 # border when the pointer over a frame |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
133 |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
134 def __new__(clz, *args): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
135 if not clz._type: |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
136 clz._type = gobject.type_register(clz) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
137 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
138 fl_obj = gobject.new(clz._type) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
139 return fl_obj |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
140 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
141 def _draw_tween(self, first_idx, last_idx, tween_type): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
142 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
143 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
144 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
145 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
146 # Get background color of a tween |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
147 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
148 bg_idx = tween_type |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
149 bg_color_v = self._tween_bgcolors[bg_idx] |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
150 bg_color_rgb = color_to_rgb(bg_color_v) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
151 bg_color = gtk.gdk.Color(*bg_color_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
152 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
153 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
154 gc.set_rgb_fg_color(bg_color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
155 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
156 draw_x = first_idx * self._frame_width + 1 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
157 draw_w = (last_idx - first_idx + 1) * self._frame_width - 1 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
158 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
159 win.draw_rectangle(gc, True, draw_x, 0, draw_w, w_h) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
160 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
161 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
162 # Set color of tween line |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
163 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
164 line_v = self._tween_color |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
165 line_rgb = color_to_rgb(line_v) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
166 line_color = gtk.gdk.Color(*line_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
167 gc.set_rgb_fg_color(line_color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
168 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
169 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
170 # Draw tween line |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
171 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
172 line_x1 = int((first_idx + 0.5) * self._frame_width) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
173 line_x2 = line_x1 + (last_idx - first_idx) * self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
174 line_y = int(w_h * 2 / 3) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
175 win.draw_line(gc, line_x1, line_y, line_x2, line_y) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
176 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
177 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
178 def _draw_normal_frame(self, idx): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
179 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
180 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
181 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
182 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
183 bg_idx = idx % len(self._normal_bgcolors) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
184 rgb = color_to_rgb(self._normal_bgcolors[bg_idx]) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
185 color = gtk.gdk.Color(*rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
186 gc.set_rgb_fg_color(color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
187 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
188 f_x = self._frame_width * idx |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
189 win.draw_rectangle(gc, True, f_x + 1, 0, self._frame_width - 1, w_h) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
190 next_f_x = f_x + self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
191 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
192 border_rgb = color_to_rgb(self._normal_border) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
193 border_color = gtk.gdk.Color(*border_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
194 gc.set_rgb_fg_color(border_color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
195 gc.set_line_attributes(1, gtk.gdk.LINE_SOLID, |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
196 gtk.gdk.CAP_BUTT, gtk.gdk.JOIN_MITER) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
197 win.draw_line(gc, next_f_x, 0, next_f_x, w_h) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
198 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
199 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
200 ## \brief Draw a bottom line from start to the point before stop frame. |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
201 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
202 def _draw_bottom_line(self, start_idx, stop_idx): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
203 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
204 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
205 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
206 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
207 border_rgb = color_to_rgb(self._normal_border) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
208 border_color = gtk.gdk.Color(*border_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
209 gc.set_rgb_fg_color(border_color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
210 start_x = start_idx * self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
211 stop_x = stop_idx * self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
212 win.draw_line(gc, start_x, w_h - 1, stop_x, w_h - 1) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
213 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
214 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
215 def _draw_active(self, idx): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
216 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
217 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
218 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
219 color_v = self._active_border |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
220 color_rgb = color_to_rgb(color_v) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
221 color = gtk.gdk.Color(*color_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
222 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
223 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
224 gc.set_rgb_fg_color(color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
225 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
226 line_x1 = idx * self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
227 line_x2 = line_x1 + self._frame_width |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
228 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
229 win.draw_line(gc, line_x1, 0, line_x1, w_h) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
230 win.draw_line(gc, line_x2, 0, line_x2, w_h) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
231 win.draw_line(gc, line_x1, w_h - 1, line_x2, w_h - 1) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
232 win.draw_line(gc, line_x1, 0, line_x2, 0) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
233 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
234 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
235 def _draw_keyframe_(self, frame_idx): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
236 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
237 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
238 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
239 color_v = self._key_mark_color |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
240 color_rgb = color_to_rgb(color_v) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
241 color = gtk.gdk.Color(*color_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
242 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
243 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
244 gc.set_rgb_fg_color(color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
245 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
246 mark_sz = self._key_mark_sz |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
247 mark_x = int((frame_idx + 0.5) * self._frame_width - mark_sz / 2) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
248 mark_y = w_h * 2 / 3 - mark_sz / 2 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
249 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
250 win.draw_rectangle(gc, True, mark_x, mark_y, mark_sz, mark_sz) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
251 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
252 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
253 ## \brief Show a mark for the pointer for a frame. |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
254 # |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
255 def _draw_hover(self, frame_idx): |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
256 win = self.window |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
257 w_x, w_y, w_w, w_h, depth = win.get_geometry() |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
258 gc = self._gc |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
259 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
260 color_rgb = color_to_rgb(self._hover_border_color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
261 color = gtk.gdk.Color(*color_rgb) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
262 gc.set_rgb_fg_color(color) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
263 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
264 line_x1 = frame_idx * self._frame_width + 1 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
265 line_x2 = line_x1 + self._frame_width - 2 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
266 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
267 win.draw_line(gc, line_x1, 1, line_x1, w_h - 2) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
268 win.draw_line(gc, line_x2, 1, line_x2, w_h - 2) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
269 win.draw_line(gc, line_x1, 1, line_x2, 1) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
270 win.draw_line(gc, line_x1, w_h - 2, line_x2, w_h - 2) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
271 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
272 pass |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
273 |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
274 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
275 ## \brief Drawing frameline according state of a frameline. |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
276 # |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
277 # Thsi class calls methods of class frameline_draw to drawing frameline. But, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
278 # this class is state awared. It according states of an instance to determines |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
279 # calling methods and arguments. This class decorates methods of |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
280 # frameline_draw class according states of an instance. |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
281 # |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
282 # This classs reading state of a frameline, but it does not change and control |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
283 # states. The deriving classes are responsible to change and control states. |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
284 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
285 class frameline_draw_state(frameline_draw): |
971 | 286 # tween types |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
287 TWEEN_TYPE_NONE = 0 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
288 TWEEN_TYPE_MOVE = 1 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
289 TWEEN_TYPE_SHAPE = 2 |
953
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
290 |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
291 def __init__(self, num_frames): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
292 frameline_draw.__init__(self) |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
293 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
294 self._num_frames = num_frames |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
295 self._keys = [] |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
296 self._active_frame = -1 |
968
a715301b5879
Start drawing after an expose event
Thinker K.F. Li <thinker@codemud.net>
parents:
967
diff
changeset
|
297 self._drawing = False |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
298 pass |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
299 |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
300 def _draw_keyframe(self, frame_idx): |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
301 # Only keyframes that is not right-side of NONE type tween should be |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
302 # draw. |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
303 pos = self._find_keyframe(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
304 key = self._keys[pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
305 if key.left_tween and not key.right_tween: |
1154
1c9ef65c74b2
Stop showing for second key frame of a tween
Thinker K.F. Li <thinker@codemud.net>
parents:
1153
diff
changeset
|
306 return |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
307 |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
308 self._draw_keyframe_(frame_idx) |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
309 pass |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
310 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
311 def _draw_keyframes(self): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
312 for key in self._keys: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
313 self._draw_keyframe(key.idx) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
314 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
315 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
316 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
317 ## \brief Redraw a frame specified by an index. |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
318 # |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
319 def _draw_frame(self, frame_idx): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
320 if not self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
321 return |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
322 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
323 pos = self._find_keyframe_floor(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
324 try: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
325 key = self._keys[pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
326 except IndexError: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
327 key = None |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
328 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
329 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
330 if key and (key.right_tween or |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
331 (key.left_tween and key.idx == frame_idx)): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
332 # |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
333 # in tween |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
334 # |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
335 first_pos, last_pos = self._find_tween_range(pos) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
336 first_key = self._keys[first_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
337 last_key = self._keys[last_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
338 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
339 self._draw_tween_of_key(first_pos) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
340 else: # not in tween |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
341 self._draw_normal_frame(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
342 self._draw_bottom_line(frame_idx, frame_idx + 1) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
343 if key and (key.idx == frame_idx): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
344 self._draw_keyframe(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
345 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
346 pass |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
347 pass |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
348 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
349 def _draw_all_frames(self): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
350 if not self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
351 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
352 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
353 i = 0 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
354 key_pos = 0 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
355 try: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
356 key = self._keys[key_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
357 except IndexError: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
358 key = keyframe(self._num_frames) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
359 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
360 num_frames = self._num_frames |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
361 while i < num_frames: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
362 if key.idx == i and key.right_tween: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
363 # |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
364 # Skip tween keys |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
365 # |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
366 first_tween_pos, last_tween_pos = \ |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
367 self._find_tween_range(key_pos) |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
368 first_tween_key = self._keys[first_tween_pos] |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
369 last_tween_key = self._keys[last_tween_pos] |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
370 self._draw_tween(first_tween_key.idx, last_tween_key.idx, |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
371 first_tween_key.right_tween_type) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
372 last_tween_key = self._keys[last_tween_pos] |
1158
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
373 key_pos = last_tween_pos + 1 |
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
374 try: |
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
375 key = self._keys[key_pos] |
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
376 except: |
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
377 key = keyframe(self._num_frames) |
1d1f2a1e43f6
Fix the issue of drawing consquence tween frames
Thinker K.F. Li <thinker@codemud.net>
parents:
1154
diff
changeset
|
378 pass |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
379 i = last_tween_key.idx + 1 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
380 else: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
381 self._draw_normal_frame(i) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
382 if key.idx == i: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
383 key_pos = key_pos+1 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
384 try: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
385 key = self._keys[key_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
386 except: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
387 key = keyframe(self._num_frames) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
388 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
389 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
390 i = i + 1 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
391 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
392 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
393 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
394 self._draw_bottom_line(0, num_frames) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
395 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
396 self._draw_keyframes() |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
397 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
398 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
399 def _draw_tween_of_key(self, key_pos): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
400 if not self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
401 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
402 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
403 first_pos, last_pos = self._find_tween_range(key_pos) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
404 first_key = self._keys[first_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
405 last_key = self._keys[last_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
406 |
1152
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
407 self._draw_tween(first_key.idx, last_key.idx, |
d333baa702a9
Refactory drawing function of frameline to frameline_draw
Thinker K.F. Li <thinker@codemud.net>
parents:
1150
diff
changeset
|
408 first_key.right_tween_type) |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
409 self._draw_bottom_line(first_key.idx, last_key.idx + 1) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
410 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
411 for i in range(first_pos, last_pos + 1): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
412 key = self._keys[i] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
413 self._draw_keyframe(key.idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
414 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
415 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
416 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
417 def _draw_active_frame(self): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
418 if not self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
419 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
420 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
421 if self._active_frame == -1: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
422 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
423 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
424 self._draw_active(self._active_frame) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
425 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
426 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
427 def _draw_hover_frame(self, frame_idx): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
428 if not self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
429 return |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
430 self._draw_hover(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
431 pass |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
432 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
433 ## \brief Start future drawing actions |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
434 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
435 def start_drawing(self): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
436 if not hasattr(self, '_gc'): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
437 win = self.window |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
438 self._gc = gtk.gdk.GC(win) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
439 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
440 # register for button press event |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
441 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
442 emask = win.get_events() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
443 emask = emask | gtk.gdk.BUTTON_PRESS_MASK | \ |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
444 gtk.gdk.POINTER_MOTION_MASK |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
445 win.set_events(emask) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
446 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
447 self._drawing = True |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
448 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
449 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
450 ## \brief Stop any future drawing actions |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
451 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
452 # When doing massive udpate, to stop drawing the screen make |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
453 # application more effecient. The screen is updated by calling |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
454 # update() method after massive update and calliing start_drawing(). |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
455 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
456 def stop_drawing(self): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
457 self._drawing = False |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
458 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
459 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
460 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
461 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
462 ## Show frame status of a layer |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
463 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
464 # \section frameline_sigs Signals |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
465 # - 'frame-button-pree' for user press on a frame. |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
466 # - callback(widget, frame_idx, button) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
467 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
468 # All methos that change state of the frameline, must call methods to update |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
469 # the screen. |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
470 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
471 class frameline(frameline_draw_state): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
472 _sig_frame_but_press = None |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
473 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
474 FRAME_BUT_PRESS = 'frame-button-press' |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
475 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
476 def __new__(clz, *args): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
477 fl_obj = frameline_draw_state.__new__(clz, *args) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
478 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
479 if not clz._sig_frame_but_press: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
480 but_press = gobject.signal_new(frameline.FRAME_BUT_PRESS, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
481 frameline._type, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
482 gobject.SIGNAL_RUN_FIRST, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
483 gobject.TYPE_NONE, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
484 (gobject.TYPE_INT, |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
485 gobject.TYPE_INT)) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
486 clz._sig_frame_but_press = but_press |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
487 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
488 return fl_obj |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
489 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
490 def __init__(self, num_frames=20): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
491 frameline_draw_state.__init__(self, num_frames) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
492 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
493 self.connect('button-press-event', self._press_hdl) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
494 self.connect('expose-event', self._fl_expose) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
495 self.connect('motion-notify-event', self._motion_hdl) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
496 self._last_hover = -1 # frame index of last hover |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
497 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
498 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
499 def __len__(self): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
500 return self._num_frames |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
501 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
502 def _find_keyframe(self, idx): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
503 key_indic = [key.idx for key in self._keys] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
504 key_pos = key_indic.index(idx) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
505 return key_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
506 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
507 def _find_keyframe_floor(self, frame_idx): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
508 pos = 0 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
509 keys = [key.idx for key in self._keys] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
510 keys.append(frame_idx) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
511 keys.sort() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
512 keys.reverse() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
513 pos = (len(keys) - 1) - keys.index(frame_idx) - 1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
514 return pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
515 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
516 ## \brief Find the range a continous tween. |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
517 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
518 def _find_tween_range(self, key_pos): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
519 key = self._keys[key_pos] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
520 if not (key.left_tween or key.right_tween): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
521 raise ValueError, 'the keyframe is not in a tween' |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
522 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
523 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
524 # Initialize tween type and first_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
525 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
526 if key.right_tween: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
527 tween_type = key.right_tween_type |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
528 first_pos = key_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
529 else: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
530 # key.left_tween is True since the key is in a tween. |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
531 first_pos = key_pos -1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
532 key = self._keys[first_pos] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
533 tween_type = key.right_tween_type |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
534 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
535 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
536 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
537 # Find first_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
538 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
539 while first_pos and key.left_tween: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
540 right_pos = first_pos - 1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
541 right_key = self._keys[right_pos] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
542 if right_key.right_tween_type != tween_type: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
543 break |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
544 first_pos = right_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
545 key = right_key |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
546 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
547 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
548 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
549 # Find last_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
550 # |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
551 max_pos = len(self._keys) - 1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
552 last_pos = key_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
553 key = self._keys[last_pos] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
554 while last_pos < max_pos and self._keys[last_pos].right_tween: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
555 if key.right_tween_type != tween_type: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
556 break |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
557 last_pos = last_pos + 1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
558 key = self._keys[last_pos] |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
559 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
560 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
561 return first_pos, last_pos |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
562 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
563 def _press_hdl(self, widget, event): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
564 frame = event.x / self._frame_width |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
565 but = event.button |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
566 self.emit(frameline.FRAME_BUT_PRESS, frame, but) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
567 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
568 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
569 def hide_hover(self): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
570 if self._active_frame != self._last_hover: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
571 self._draw_normal_frame(self._last_hover) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
572 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
573 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
574 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
575 def _motion_hdl(self, widget, event): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
576 frame_idx = int(event.x / self._frame_width) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
577 if self._last_hover != -1: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
578 self._draw_frame(self._last_hover) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
579 if self._last_hover == self._active_frame: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
580 self._draw_active_frame() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
581 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
582 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
583 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
584 if frame_idx < self._num_frames and frame_idx >= 0: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
585 self._draw_hover_frame(frame_idx) |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
586 if self._last_hover == self._active_frame: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
587 self._draw_active_frame() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
588 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
589 self._last_hover = frame_idx |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
590 else: |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
591 self._last_hover = -1 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
592 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
593 pass |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
594 |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
595 def _fl_expose(self, widget, event): |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
596 win = self.window |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
597 self.start_drawing() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
598 self.update() |
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
599 pass |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
600 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
601 def set_tween_type(self, frame_idx, tween_type): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
602 pos = self._find_keyframe(frame_idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
603 key = self._keys[pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
604 assert key.right_tween |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
605 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
606 key.right_tween_type = tween_type |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
607 self._draw_tween_of_key(pos) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
608 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
609 self._draw_active_frame() |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
610 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
611 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
612 def update(self): |
954
75bc6d9f4e0a
Show hover mark when the pointer over a frame
Thinker K.F. Li <thinker@codemud.net>
parents:
953
diff
changeset
|
613 self._draw_all_frames() |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
614 self._draw_active_frame() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
615 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
616 |
947 | 617 ## Add a key frame |
618 # | |
619 # A key frame is the frame that user specify actions. For | |
620 # example, move a object or add new objects at the frame. | |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
621 def add_keyframe(self, idx, ref=None): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
622 try: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
623 pos = self._find_keyframe(idx) # it is not already a keyframe. |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
624 except ValueError: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
625 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
626 else: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
627 raise ValueError, 'the frame is already a key frame' |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
628 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
629 key_indic = [key.idx for key in self._keys] |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
630 key_indic.append(idx) |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
631 key_indic.sort() |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
632 insert_pos = key_indic.index(idx) |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
633 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
634 key = keyframe(idx) |
972
8a7e5914a84b
Add addScenes to generate scene definition according to the current framelines.
wycc
parents:
971
diff
changeset
|
635 key.ref = ref |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
636 if insert_pos > 0 and self._keys[insert_pos - 1].right_tween: |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
637 if self._keys[insert_pos-1].idx == idx-1: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
638 self._keys[insert_pos-1].right_tween = False |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
639 self._keys[insert_pos:insert_pos] = [key] |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
640 return |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
641 else: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
642 key2 = keyframe(idx-1) |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
643 key2.ref = self._keys[insert_pos-1].ref |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
644 key2.left_tween = True |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
645 self._keys[insert_pos:insert_pos] = [key2,key] |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
646 key.left_tween = False |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
647 key.right_tween = True |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
648 key.right_tween_type = self._keys[insert_pos - 1].right_tween_type |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
649 pass |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
650 else: |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
651 self._keys[insert_pos:insert_pos] = [key] |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
652 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
653 if self._drawing: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
654 self._draw_keyframe(idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
655 pass |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
656 pass |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
657 |
1164
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
658 ## Set the frame @idx as the right of a tween |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
659 def set_right_tween(self,idx): |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
660 pos = self._find_keyframe(idx) |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
661 self._keys[pos].right_tween = TRue |
2cb5047d8f2b
Add support to insert key frame in the middle of the tween.
wycc
parents:
1163
diff
changeset
|
662 |
1174 | 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 | |
1180
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
711 |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
712 def rm_keyframe(self, idx): |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
713 key_pos = self._find_keyframe(idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
714 key = self._keys[key_pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
715 del self._keys[key_pos] |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
716 |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
717 if key.right_tween ^ key.left_tween: |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
718 # |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
719 # tween in one side |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
720 # |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
721 if key.right_tween: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
722 right_key = self._keys[key_pos] |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
723 right_key.left_tween = False |
971 | 724 redraw_range = (right_key.idx, idx + 1) |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
725 else: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
726 left_key = self._keys[key_pos - 1] |
1154
1c9ef65c74b2
Stop showing for second key frame of a tween
Thinker K.F. Li <thinker@codemud.net>
parents:
1153
diff
changeset
|
727 left_key.right_tween = False |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
728 redraw_range = (idx, left_key.idx + 1) |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
729 pass |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
730 self._draw_frame(i) |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
731 pass |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
732 else: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
733 self._draw_frame(idx) |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
734 pass |
967
5c013e3cadd0
Provide the facility to stop drawing for massive content update.
Thinker K.F. Li <thinker@codemud.net>
parents:
966
diff
changeset
|
735 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
736 self._draw_active_frame() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
737 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
738 |
946
f82ac6740a32
change wording in doc
Thinker K.F. Li <thinker@codemud.net>
parents:
945
diff
changeset
|
739 ## Tween the key frame specified by an index and the key frame at right. |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
740 # |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
741 # \see http://www.entheosweb.com/Flash/shape_tween.asp |
1153
5abf419d66e5
Refactory methods of state awared drawing to frameline_draw_state
Thinker K.F. Li <thinker@codemud.net>
parents:
1152
diff
changeset
|
742 def tween(self, idx, tween_type=frameline_draw_state.TWEEN_TYPE_NONE): |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
743 pos = self._find_keyframe(idx) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
744 key = self._keys[pos] |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
745 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
746 try: |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
747 right_key = self._keys[pos + 1] |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
748 except IndexError: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
749 raise ValueError, 'no right key frame' |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
750 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
751 key.right_tween = True |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
752 right_key.left_tween = True |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
753 key.right_tween_type = tween_type |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
754 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
755 self._draw_tween_of_key(pos) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
756 self._draw_active_frame() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
757 pass |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
758 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
759 def get_tween_type(self, idx): |
1120
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
977
diff
changeset
|
760 for i in range(0,len(self._keys)): |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
977
diff
changeset
|
761 key = self._keys[i] |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
977
diff
changeset
|
762 if key.left_tween is True: continue |
214e1f628d63
Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents:
977
diff
changeset
|
763 if key.idx == idx: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
764 return key.right_tween_type |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
765 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
766 pass |
1187 | 767 ## Get the maximum frame number in a layer(frameline) |
768 # Return the frame number | |
769 def max_frame(self): | |
770 if len(self._keys) == 0: return 0 | |
771 return self._keys[len(self._keys)-1].idx | |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
772 |
1180
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
773 ## \bref Return range of blocks of conesequence frames (tweens). |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
774 # |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
775 # Return range and type of tweens and key frames that is not start or stop |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
776 # of a tween. |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
777 def get_frame_blocks(self): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
778 blocks = [] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
779 for pos, key in enumerate(self._keys): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
780 if key.right_tween: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
781 next_key = self._keys[pos + 1] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
782 block = (key.idx, next_key.idx, key.right_tween_type) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
783 elif not key.left_tween: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
784 block = (key.idx, key.idx, 0) |
1161
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1158
diff
changeset
|
785 else: |
a7faab54e8f8
Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents:
1158
diff
changeset
|
786 continue |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
787 blocks.append(block) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
788 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
789 return blocks |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
790 |
1180
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
791 ## \brief Return the range of a block of consequence frames (tween). |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
792 # |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
793 # - If the index frame is in a tween, it returns the range of the tween. |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
794 # |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
795 # - If the indexed frame is a key frame with no right_tween, returns the |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
796 # range that start and stop are both equivalent to idx. |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
797 # |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
798 # - Otherwise, raise an exception. |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
799 # |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
800 # \param idx is the index number of a frame. |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
801 # \return A tuple of (start, stop, tween_type) |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
802 # |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
803 def get_frame_block(self, idx): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
804 pos = self._find_keyframe_floor(idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
805 if pos != -1: |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
806 key = self._keys[pos] |
1180
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
807 if key.right_tween: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
808 next_key = self._keys[pos + 1] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
809 return key.idx, next_key.idx, key.right_tween_type |
1180
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
810 elif key.idx == idx: |
bfd7d466a022
Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents:
1174
diff
changeset
|
811 return key.idx, key.idx, 0 |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
812 pass |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
813 raise ValueError, \ |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
814 'the frame specified by idx is not in any tween or a key frame' |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
815 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
816 def get_frame_data(self, idx): |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
817 pos = self._find_keyframe(idx) |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
818 key = self._keys[pos] |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
819 return key.ref |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
820 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
821 ## Set active frame |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
822 # |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
823 # The active frame is the frame that is working on. |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
824 # |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
825 def active_frame(self, idx): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
826 if idx < 0 or idx >= self._num_frames: |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
827 raise IndexError, 'value of index (%d) is out of range' % (idx) |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
828 |
967
5c013e3cadd0
Provide the facility to stop drawing for massive content update.
Thinker K.F. Li <thinker@codemud.net>
parents:
966
diff
changeset
|
829 if self._active_frame != -1: |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
830 self._draw_frame(self._active_frame) |
967
5c013e3cadd0
Provide the facility to stop drawing for massive content update.
Thinker K.F. Li <thinker@codemud.net>
parents:
966
diff
changeset
|
831 pass |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
832 self._active_frame = idx |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
833 self._draw_active_frame() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
834 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
835 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
836 def deactive(self): |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
837 self._draw_frame(self._active_frame) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
838 self._active_frame = -1 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
839 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
840 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
841 def set_num_frames(self, num): |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
842 self._num_frames = num |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
843 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
844 |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
845 def reset(self): |
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
846 self._keys = [] |
1150
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
847 self._active_frame = -1 |
6586cd10c92f
Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents:
1131
diff
changeset
|
848 self._draw_all_frames() |
966
ca993c473379
Function of removing key frames
Thinker K.F. Li <thinker@codemud.net>
parents:
965
diff
changeset
|
849 pass |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
850 pass |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
851 |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
852 if __name__ == '__main__': |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
853 window = gtk.Window(gtk.WINDOW_TOPLEVEL) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
854 fr = frameruler(40) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
855 fr.set_size_request(300, 20) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
856 |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
857 fl = frameline(40) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
858 fl.set_size_request(300, 20) |
977 | 859 fl.add_keyframe(15) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
860 fl.add_keyframe(3) |
971 | 861 fl.tween(3) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
862 fl.add_keyframe(9) |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
863 fl.add_keyframe(20) |
971 | 864 fl.tween(9) |
865 fl.active_frame(1) | |
866 fl.rm_keyframe(15) | |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
867 print 'num of frames: %d' % (len(fl)) |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
868 |
953
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
869 def press_sig(fl, frame, but): |
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
870 print 'press_sig button %d for frame %d' % (but, frame) |
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
871 pass |
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
872 fl.connect(frameline.FRAME_BUT_PRESS, press_sig) |
2346d3238e03
frame-button-press event of frameline
Thinker K.F. Li <thinker@codemud.net>
parents:
952
diff
changeset
|
873 |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
874 box = gtk.VBox() |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
875 |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
876 box.pack_start(fr, False) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
877 box.pack_start(fl, False) |
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
878 window.add(box) |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
879 |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
880 fr.show() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
881 fl.show() |
948
518c61784355
Add frameruler to show ruler for framelines
Thinker K.F. Li <thinker@codemud.net>
parents:
947
diff
changeset
|
882 box.show() |
944
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
883 window.show() |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
884 gtk.main() |
b0edd13779ee
Implement a frameline widget
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
885 pass |