annotate window/widget.h @ 41:4c832144b3f2

OtakuNoRaifu is born! (Changed 'xclannad' to 'OtakuNoRaifu')
author thib
date Mon, 23 Mar 2009 18:17:57 +0000
parents 5ae5533b3a9a
children 15a18fbe6f21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
1 /*
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
2 * Copyright (c) 2004-2006 Kazunori "jagarl" Ueno
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
3 * All rights reserved.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
4 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
5 * Redistribution and use in source and binary forms, with or without
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
6 * modification, are permitted provided that the following conditions
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
7 * are met:
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
8 * 1. Redistributions of source code must retain the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
9 * notice, this list of conditions and the following disclaimer.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
10 * 2. Redistributions in binary form must reproduce the above copyright
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
11 * notice, this list of conditions and the following disclaimer in the
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
12 * documentation and/or other materials provided with the distribution.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
13 * 3. The name of the author may not be used to endorse or promote products
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
14 * derived from this software without specific prior written permission.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
15 *
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
26 */
5ae5533b3a9a * Added some license headers
thib
parents: 0
diff changeset
27
0
223b71206888 Initial import
thib
parents:
diff changeset
28 #ifndef __WIDGET_H__
223b71206888 Initial import
thib
parents:
diff changeset
29 #define __WIDGET_H__
223b71206888 Initial import
thib
parents:
diff changeset
30
223b71206888 Initial import
thib
parents:
diff changeset
31 #include<vector>
223b71206888 Initial import
thib
parents:
diff changeset
32 #include"font/font.h"
223b71206888 Initial import
thib
parents:
diff changeset
33 #include"font/text.h"
223b71206888 Initial import
thib
parents:
diff changeset
34 #include"event.h"
223b71206888 Initial import
thib
parents:
diff changeset
35 #include"picture.h"
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 #define TimeCursor WidTimeCursor
223b71206888 Initial import
thib
parents:
diff changeset
38 #define MouseCursor WidMouseCursor
223b71206888 Initial import
thib
parents:
diff changeset
39 #define Button WidButton
223b71206888 Initial import
thib
parents:
diff changeset
40 #define Scale WidScale
223b71206888 Initial import
thib
parents:
diff changeset
41 #define Label WidLabel
223b71206888 Initial import
thib
parents:
diff changeset
42 #define Dialog WidDialog
223b71206888 Initial import
thib
parents:
diff changeset
43 #define TextButton WidTextButton
223b71206888 Initial import
thib
parents:
diff changeset
44 #define Text WidText
223b71206888 Initial import
thib
parents:
diff changeset
45 #define AnmTime WidAnmTime
223b71206888 Initial import
thib
parents:
diff changeset
46 #define AnmMove WidAnmMove
223b71206888 Initial import
thib
parents:
diff changeset
47 #define AnmAlpha WidAnmAlpha
223b71206888 Initial import
thib
parents:
diff changeset
48 #define AnmPtnSolid WidAnmPtnSolid
223b71206888 Initial import
thib
parents:
diff changeset
49 #define AnmPtnAlpha WidAnmPtnAlpha
223b71206888 Initial import
thib
parents:
diff changeset
50
223b71206888 Initial import
thib
parents:
diff changeset
51 // namespace Widget {
223b71206888 Initial import
thib
parents:
diff changeset
52
223b71206888 Initial import
thib
parents:
diff changeset
53 struct TimeCursor : public Event::Time, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
54 int x,y,dx,dy, nptn;
223b71206888 Initial import
thib
parents:
diff changeset
55 int old_time, count, interval;
223b71206888 Initial import
thib
parents:
diff changeset
56 TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* fname, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r);
223b71206888 Initial import
thib
parents:
diff changeset
57 void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
58 };
223b71206888 Initial import
thib
parents:
diff changeset
59
223b71206888 Initial import
thib
parents:
diff changeset
60 struct MouseCursor : public Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
61 int x, y;
223b71206888 Initial import
thib
parents:
diff changeset
62 Event::Container& container;
223b71206888 Initial import
thib
parents:
diff changeset
63 MouseCursor(Event::Container& container, PicContainer* parent, const char* s, int x, int y, int w, int h);
223b71206888 Initial import
thib
parents:
diff changeset
64 MouseCursor(Event::Container& container, PicContainer* parent, Surface* s, int x, int y, int w, int h);
223b71206888 Initial import
thib
parents:
diff changeset
65 ~MouseCursor();
223b71206888 Initial import
thib
parents:
diff changeset
66 static bool Motionfunc(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
67 };
223b71206888 Initial import
thib
parents:
diff changeset
68
223b71206888 Initial import
thib
parents:
diff changeset
69 struct Button : public Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
70 int sx, sy, sdx, sdy, nptn;
223b71206888 Initial import
thib
parents:
diff changeset
71 bool is_in;
223b71206888 Initial import
thib
parents:
diff changeset
72 bool is_toggled;
223b71206888 Initial import
thib
parents:
diff changeset
73 bool is_toggle_switch;
223b71206888 Initial import
thib
parents:
diff changeset
74 Button(Event::Container& container, PicContainer* parent, const char* s, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r, int _z);
223b71206888 Initial import
thib
parents:
diff changeset
75 Button(Event::Container& container, PicContainer* parent, Surface* s, int sx, int sy, int sdx, int sdy, int nptn, const Rect& r, int _z);
223b71206888 Initial import
thib
parents:
diff changeset
76 ~Button();
223b71206888 Initial import
thib
parents:
diff changeset
77 void Press(void);
223b71206888 Initial import
thib
parents:
diff changeset
78 void Release(void);
223b71206888 Initial import
thib
parents:
diff changeset
79 void Drag(int x_from, int y_from, int x_to, int y_to);
223b71206888 Initial import
thib
parents:
diff changeset
80 void In(void);
223b71206888 Initial import
thib
parents:
diff changeset
81 void Out(void);
223b71206888 Initial import
thib
parents:
diff changeset
82 void Toggle(bool new_toggle);
223b71206888 Initial import
thib
parents:
diff changeset
83 typedef void (*PressFunc)(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
84 typedef void (*DragFunc)(int x_from, int y_from, int x_to, int y_to, void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
85 PressFunc press_func;
223b71206888 Initial import
thib
parents:
diff changeset
86 void* press_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
87 DragFunc drag_func;
223b71206888 Initial import
thib
parents:
diff changeset
88 void* drag_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
89
223b71206888 Initial import
thib
parents:
diff changeset
90 /* ·ΡΎ΅ */
223b71206888 Initial import
thib
parents:
diff changeset
91 void activate(void) { Event::Video::activate();}
223b71206888 Initial import
thib
parents:
diff changeset
92 void deactivate(void) { Event::Video::deactivate();}
223b71206888 Initial import
thib
parents:
diff changeset
93 void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);}
223b71206888 Initial import
thib
parents:
diff changeset
94 };
223b71206888 Initial import
thib
parents:
diff changeset
95 struct Scale : Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
96 private:
223b71206888 Initial import
thib
parents:
diff changeset
97 Button* arrow_down, *arrow_up;
223b71206888 Initial import
thib
parents:
diff changeset
98 Button* cursor;
223b71206888 Initial import
thib
parents:
diff changeset
99 PicContainer* panel;
223b71206888 Initial import
thib
parents:
diff changeset
100 Event::Container& container;
223b71206888 Initial import
thib
parents:
diff changeset
101 PicContainer* parent;
223b71206888 Initial import
thib
parents:
diff changeset
102 Color cursor_color;
223b71206888 Initial import
thib
parents:
diff changeset
103
223b71206888 Initial import
thib
parents:
diff changeset
104 int mouse_x, mouse_y;
223b71206888 Initial import
thib
parents:
diff changeset
105 enum {scale_max = 65536};
223b71206888 Initial import
thib
parents:
diff changeset
106 int min, max;
223b71206888 Initial import
thib
parents:
diff changeset
107 int value;
223b71206888 Initial import
thib
parents:
diff changeset
108 int value_add;
223b71206888 Initial import
thib
parents:
diff changeset
109 int value_dragstart;
223b71206888 Initial import
thib
parents:
diff changeset
110 int cursor_width;
223b71206888 Initial import
thib
parents:
diff changeset
111 bool is_vertical;
223b71206888 Initial import
thib
parents:
diff changeset
112
223b71206888 Initial import
thib
parents:
diff changeset
113 public:
223b71206888 Initial import
thib
parents:
diff changeset
114
223b71206888 Initial import
thib
parents:
diff changeset
115 Scale(Event::Container& container, PicContainer* parent, const Rect& r_orig, const Color& cursor_color, bool _is_vertical);
223b71206888 Initial import
thib
parents:
diff changeset
116 void InitCursor(int cursor_width_ratio); // 1024=max
223b71206888 Initial import
thib
parents:
diff changeset
117 void SetRange(int min, int max);
223b71206888 Initial import
thib
parents:
diff changeset
118 void SetValue(int value);
223b71206888 Initial import
thib
parents:
diff changeset
119 int GetValue(void) const;
223b71206888 Initial import
thib
parents:
diff changeset
120 typedef void (*ChangeFunc)(void* pointer, Scale* from);
223b71206888 Initial import
thib
parents:
diff changeset
121 ChangeFunc change_func;
223b71206888 Initial import
thib
parents:
diff changeset
122 void* change_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
123 private:
223b71206888 Initial import
thib
parents:
diff changeset
124 void Init(Rect r_orig);
223b71206888 Initial import
thib
parents:
diff changeset
125 int CalcValue(void);
223b71206888 Initial import
thib
parents:
diff changeset
126 void SetScaleValue(int value);
223b71206888 Initial import
thib
parents:
diff changeset
127
223b71206888 Initial import
thib
parents:
diff changeset
128 // callback
223b71206888 Initial import
thib
parents:
diff changeset
129 static void PressArrowDown(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
130 static void PressArrowUp(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
131 static void PressCursor(void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
132 static void DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from);
223b71206888 Initial import
thib
parents:
diff changeset
133
223b71206888 Initial import
thib
parents:
diff changeset
134 // ·ΡΎ΅‘§Event::Video
223b71206888 Initial import
thib
parents:
diff changeset
135 void Press(void);
223b71206888 Initial import
thib
parents:
diff changeset
136 void Motion(int x, int y);
223b71206888 Initial import
thib
parents:
diff changeset
137
223b71206888 Initial import
thib
parents:
diff changeset
138 /* ·ΡΎ΅ : PicWidget */
223b71206888 Initial import
thib
parents:
diff changeset
139 void activate(void) { Event::Video::activate();}
223b71206888 Initial import
thib
parents:
diff changeset
140 void deactivate(void) { Event::Video::deactivate();}
223b71206888 Initial import
thib
parents:
diff changeset
141 void SetRegion(const Rect& new_rect) { Event::Video::SetRegion(new_rect);}
223b71206888 Initial import
thib
parents:
diff changeset
142 };
223b71206888 Initial import
thib
parents:
diff changeset
143
223b71206888 Initial import
thib
parents:
diff changeset
144 struct TextButton : public Button {
223b71206888 Initial import
thib
parents:
diff changeset
145 enum Attribute {CENTER=1, REVERSE=2, NOPADDING=4};
223b71206888 Initial import
thib
parents:
diff changeset
146 PicRoot& root;
223b71206888 Initial import
thib
parents:
diff changeset
147 Surface* surface;
223b71206888 Initial import
thib
parents:
diff changeset
148 Attribute attribute;
223b71206888 Initial import
thib
parents:
diff changeset
149 int text_size;
223b71206888 Initial import
thib
parents:
diff changeset
150 Color fore, pressed, back;
223b71206888 Initial import
thib
parents:
diff changeset
151 TextButton(Event::Container& container, PicContainer* parent, const char* s, int text_size, Attribute attr, const Rect& r, int _z, const Color& fore, const Color& pressed, const Color& back);
223b71206888 Initial import
thib
parents:
diff changeset
152 void SetText(const char* s, const Color& fore, const Color& pressed, const Color& back);
223b71206888 Initial import
thib
parents:
diff changeset
153 void SetText(const char* s) {
223b71206888 Initial import
thib
parents:
diff changeset
154 SetText(s, fore, pressed, back);
223b71206888 Initial import
thib
parents:
diff changeset
155 }
223b71206888 Initial import
thib
parents:
diff changeset
156 ~TextButton();
223b71206888 Initial import
thib
parents:
diff changeset
157 };
223b71206888 Initial import
thib
parents:
diff changeset
158
223b71206888 Initial import
thib
parents:
diff changeset
159 struct Text : public Event::Video, Event::Time, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
160 typedef TextGlyphStream::iterator iterator;
223b71206888 Initial import
thib
parents:
diff changeset
161
223b71206888 Initial import
thib
parents:
diff changeset
162 private:
223b71206888 Initial import
thib
parents:
diff changeset
163 Event::Container& event;
223b71206888 Initial import
thib
parents:
diff changeset
164 public:
223b71206888 Initial import
thib
parents:
diff changeset
165 PicBase* pictext;
223b71206888 Initial import
thib
parents:
diff changeset
166 private:
223b71206888 Initial import
thib
parents:
diff changeset
167 TimeCursor* cursor;
223b71206888 Initial import
thib
parents:
diff changeset
168 Surface* surface;
223b71206888 Initial import
thib
parents:
diff changeset
169 TextGlyphStream gstream;
223b71206888 Initial import
thib
parents:
diff changeset
170 std::vector<int> bottom_pos; // ΉΤΉβ€΅(height)€ΞΞί·ΧΓΝ
223b71206888 Initial import
thib
parents:
diff changeset
171 XKFont::HorizLayout layout;
223b71206888 Initial import
thib
parents:
diff changeset
172 int fontsize;
223b71206888 Initial import
thib
parents:
diff changeset
173
223b71206888 Initial import
thib
parents:
diff changeset
174 iterator cur_pos;
223b71206888 Initial import
thib
parents:
diff changeset
175 int line_number;
223b71206888 Initial import
thib
parents:
diff changeset
176 Rect srcrect;
223b71206888 Initial import
thib
parents:
diff changeset
177 int press_count;
223b71206888 Initial import
thib
parents:
diff changeset
178 int scrolled_count;
223b71206888 Initial import
thib
parents:
diff changeset
179 int scroll_height;
223b71206888 Initial import
thib
parents:
diff changeset
180 bool window_activated;
223b71206888 Initial import
thib
parents:
diff changeset
181 bool cursor_activated;
223b71206888 Initial import
thib
parents:
diff changeset
182
223b71206888 Initial import
thib
parents:
diff changeset
183 int speed; // chars / sec or -1
223b71206888 Initial import
thib
parents:
diff changeset
184 int wait_delay; // msec
223b71206888 Initial import
thib
parents:
diff changeset
185 int old_time;
223b71206888 Initial import
thib
parents:
diff changeset
186 int wait_starttime;
223b71206888 Initial import
thib
parents:
diff changeset
187
223b71206888 Initial import
thib
parents:
diff changeset
188 int CalcScrollHeight(void);
223b71206888 Initial import
thib
parents:
diff changeset
189 void DrawText(int& nChar);
223b71206888 Initial import
thib
parents:
diff changeset
190 void Scrollup(int& nChar);
223b71206888 Initial import
thib
parents:
diff changeset
191 public:
223b71206888 Initial import
thib
parents:
diff changeset
192 Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int fontsize);
223b71206888 Initial import
thib
parents:
diff changeset
193 ~Text();
223b71206888 Initial import
thib
parents:
diff changeset
194
223b71206888 Initial import
thib
parents:
diff changeset
195 TextStream stream;
223b71206888 Initial import
thib
parents:
diff changeset
196 enum {PREPARE, DRAW, WAIT, SCROLL, DRAW2, WAIT2} status;
223b71206888 Initial import
thib
parents:
diff changeset
197
223b71206888 Initial import
thib
parents:
diff changeset
198 void Clear(void);
223b71206888 Initial import
thib
parents:
diff changeset
199 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
200 void Flush(void);
223b71206888 Initial import
thib
parents:
diff changeset
201
223b71206888 Initial import
thib
parents:
diff changeset
202 void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
203 static bool Pressed(int x, int y, void* pointer);
223b71206888 Initial import
thib
parents:
diff changeset
204 void activate(void);
223b71206888 Initial import
thib
parents:
diff changeset
205 void deactivate(void);
223b71206888 Initial import
thib
parents:
diff changeset
206 void SetSpeed(int new_speed);
223b71206888 Initial import
thib
parents:
diff changeset
207 void SetWait(int new_wait);
223b71206888 Initial import
thib
parents:
diff changeset
208
223b71206888 Initial import
thib
parents:
diff changeset
209 void SetCursor(TimeCursor* cursor);
223b71206888 Initial import
thib
parents:
diff changeset
210 };
223b71206888 Initial import
thib
parents:
diff changeset
211
223b71206888 Initial import
thib
parents:
diff changeset
212 extern void SetFont(const char* fontname);
223b71206888 Initial import
thib
parents:
diff changeset
213
223b71206888 Initial import
thib
parents:
diff changeset
214 struct Label : PicWidget{
223b71206888 Initial import
thib
parents:
diff changeset
215 private:
223b71206888 Initial import
thib
parents:
diff changeset
216 Surface* surface;
223b71206888 Initial import
thib
parents:
diff changeset
217 bool is_center;
223b71206888 Initial import
thib
parents:
diff changeset
218 PicRoot& root;
223b71206888 Initial import
thib
parents:
diff changeset
219 int text_size;
223b71206888 Initial import
thib
parents:
diff changeset
220 public:
223b71206888 Initial import
thib
parents:
diff changeset
221 Label(PicContainer* parent, const Rect& r_orig, bool is_center=true, const char* text=0, int textsize = 26);
223b71206888 Initial import
thib
parents:
diff changeset
222 ~Label();
223b71206888 Initial import
thib
parents:
diff changeset
223 void SetText(const char* text);
223b71206888 Initial import
thib
parents:
diff changeset
224 };
223b71206888 Initial import
thib
parents:
diff changeset
225
223b71206888 Initial import
thib
parents:
diff changeset
226 class Dialog : public Event::Video, PicWidget {
223b71206888 Initial import
thib
parents:
diff changeset
227 Surface* surface_btn;
223b71206888 Initial import
thib
parents:
diff changeset
228 Surface* surface_diag;
223b71206888 Initial import
thib
parents:
diff changeset
229 public:
223b71206888 Initial import
thib
parents:
diff changeset
230 enum { WAIT, OK, CANCEL} status;
223b71206888 Initial import
thib
parents:
diff changeset
231 Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel);
223b71206888 Initial import
thib
parents:
diff changeset
232 ~Dialog();
223b71206888 Initial import
thib
parents:
diff changeset
233 static void press_ok(void* pointer, Button* btn);
223b71206888 Initial import
thib
parents:
diff changeset
234 static void press_cancel(void* pointer, Button* btn);
223b71206888 Initial import
thib
parents:
diff changeset
235 static void DrawBox(Surface* s, const Rect& r);
223b71206888 Initial import
thib
parents:
diff changeset
236 typedef void (*SetFunc)(void* pointer, Dialog* from);
223b71206888 Initial import
thib
parents:
diff changeset
237 SetFunc set_func;
223b71206888 Initial import
thib
parents:
diff changeset
238 void* set_pointer;
223b71206888 Initial import
thib
parents:
diff changeset
239 };
223b71206888 Initial import
thib
parents:
diff changeset
240
223b71206888 Initial import
thib
parents:
diff changeset
241 struct AnmTime : public Event::Time, PicAnm {
223b71206888 Initial import
thib
parents:
diff changeset
242 enum { PLAYING=1, FINISHED=3 } status;
223b71206888 Initial import
thib
parents:
diff changeset
243 unsigned int start_time;
223b71206888 Initial import
thib
parents:
diff changeset
244 unsigned int total_time;
223b71206888 Initial import
thib
parents:
diff changeset
245 int all_count;
223b71206888 Initial import
thib
parents:
diff changeset
246
223b71206888 Initial import
thib
parents:
diff changeset
247 AnmTime(Event::Container& container, PicBase* _pic, int total_time, int all_count = 0);
223b71206888 Initial import
thib
parents:
diff changeset
248 AnmTime(Event::Container& container, std::vector<PicBase*> _pic, int total_time, int all_count = 0);
223b71206888 Initial import
thib
parents:
diff changeset
249 virtual ~AnmTime() {}
223b71206888 Initial import
thib
parents:
diff changeset
250 void SetAllCount(int new_all_count) { all_count = new_all_count; }
223b71206888 Initial import
thib
parents:
diff changeset
251 void SetTotalTime(int new_total) { total_time = new_total; }
223b71206888 Initial import
thib
parents:
diff changeset
252 void Elapsed(unsigned int current_time);
223b71206888 Initial import
thib
parents:
diff changeset
253 void Play(void) {
223b71206888 Initial import
thib
parents:
diff changeset
254 start_time = 0;
223b71206888 Initial import
thib
parents:
diff changeset
255 status = PLAYING;
223b71206888 Initial import
thib
parents:
diff changeset
256 }
223b71206888 Initial import
thib
parents:
diff changeset
257
223b71206888 Initial import
thib
parents:
diff changeset
258 virtual void Start(void) {};
223b71206888 Initial import
thib
parents:
diff changeset
259 virtual void Exec(int count) = 0;
223b71206888 Initial import
thib
parents:
diff changeset
260 virtual void Finish(void) {};
223b71206888 Initial import
thib
parents:
diff changeset
261 void Abort(void);
223b71206888 Initial import
thib
parents:
diff changeset
262 bool IsEnd(void);
223b71206888 Initial import
thib
parents:
diff changeset
263 };
223b71206888 Initial import
thib
parents:
diff changeset
264
223b71206888 Initial import
thib
parents:
diff changeset
265 struct AnmMove : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
266 Rect from, to;
223b71206888 Initial import
thib
parents:
diff changeset
267 AnmMove(Event::Container& container, PicBase* _pic, const Rect& to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
268 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
269 };
223b71206888 Initial import
thib
parents:
diff changeset
270 #define ALPHA_MAX 255
223b71206888 Initial import
thib
parents:
diff changeset
271 struct AnmAlpha : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
272 int from, to;
223b71206888 Initial import
thib
parents:
diff changeset
273 unsigned char alpha; Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
274 AnmAlpha(Event::Container& container, PicBase* _pic, int alpha_from, int alpha_to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
275 AnmAlpha(Event::Container& container, std::vector<PicBase*> _pic, int alpha_from, int alpha_to, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
276 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
277 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
278 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
279 };
223b71206888 Initial import
thib
parents:
diff changeset
280 struct AnmAlphaMove : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
281 struct Ptn {
223b71206888 Initial import
thib
parents:
diff changeset
282 Rect pos;
223b71206888 Initial import
thib
parents:
diff changeset
283 Rect surface_pos;
223b71206888 Initial import
thib
parents:
diff changeset
284 unsigned char alpha;
223b71206888 Initial import
thib
parents:
diff changeset
285 unsigned int next_tick;
223b71206888 Initial import
thib
parents:
diff changeset
286 Ptn(const Rect& _r, const Rect& _surface_r, unsigned char _a, unsigned int _n) :
223b71206888 Initial import
thib
parents:
diff changeset
287 pos(_r), surface_pos(_surface_r), alpha(_a), next_tick(_n) {}
223b71206888 Initial import
thib
parents:
diff changeset
288 };
223b71206888 Initial import
thib
parents:
diff changeset
289 std::vector<Ptn> ptns;
223b71206888 Initial import
thib
parents:
diff changeset
290 int cur_count;
223b71206888 Initial import
thib
parents:
diff changeset
291 AnmAlphaMove(Event::Container& container, PicBase* _pic);
223b71206888 Initial import
thib
parents:
diff changeset
292 void SetPtn(void);
223b71206888 Initial import
thib
parents:
diff changeset
293 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
294 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
295 };
223b71206888 Initial import
thib
parents:
diff changeset
296 struct AnmPtnSolid : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
297 AnmPtnSolid(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
298 ~AnmPtnSolid() { delete[] alpha; }
223b71206888 Initial import
thib
parents:
diff changeset
299 const unsigned char* ptn;
223b71206888 Initial import
thib
parents:
diff changeset
300 int ptn_len;
223b71206888 Initial import
thib
parents:
diff changeset
301 unsigned char* alpha;
223b71206888 Initial import
thib
parents:
diff changeset
302 Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
303
223b71206888 Initial import
thib
parents:
diff changeset
304 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
305 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
306 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
307 };
223b71206888 Initial import
thib
parents:
diff changeset
308 struct AnmPtnAlpha : public AnmTime {
223b71206888 Initial import
thib
parents:
diff changeset
309 AnmPtnAlpha(Event::Container& container, PicBase* _pic, const unsigned char* ptn, const Rect& alpha_r, int alpha_bandwidth, int total_time);
223b71206888 Initial import
thib
parents:
diff changeset
310 ~AnmPtnAlpha() { delete[] alpha; }
223b71206888 Initial import
thib
parents:
diff changeset
311 const unsigned char* ptn;
223b71206888 Initial import
thib
parents:
diff changeset
312 int ptn_len;
223b71206888 Initial import
thib
parents:
diff changeset
313 int band;
223b71206888 Initial import
thib
parents:
diff changeset
314 unsigned char* alpha;
223b71206888 Initial import
thib
parents:
diff changeset
315 Rect alpha_r;
223b71206888 Initial import
thib
parents:
diff changeset
316 void Start(void);
223b71206888 Initial import
thib
parents:
diff changeset
317 void Exec(int count);
223b71206888 Initial import
thib
parents:
diff changeset
318 void Finish(void);
223b71206888 Initial import
thib
parents:
diff changeset
319 };
223b71206888 Initial import
thib
parents:
diff changeset
320
223b71206888 Initial import
thib
parents:
diff changeset
321 // } /* end of namespace Widget */
223b71206888 Initial import
thib
parents:
diff changeset
322
223b71206888 Initial import
thib
parents:
diff changeset
323 #undef Text
223b71206888 Initial import
thib
parents:
diff changeset
324
223b71206888 Initial import
thib
parents:
diff changeset
325 #endif
223b71206888 Initial import
thib
parents:
diff changeset
326