Mercurial > otakunoraifu
comparison window/widget.cc @ 52:15a18fbe6f21
* Known bugs added to the README
* Code cleaning (0 -> NULL when needed, indentation, spaces, ...)
author | thib |
---|---|
date | Sat, 18 Apr 2009 18:35:39 +0000 |
parents | 5f548e5957a8 |
children | ddbcbd000206 |
comparison
equal
deleted
inserted
replaced
51:cbb301016a4e | 52:15a18fbe6f21 |
---|---|
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include"widget.h" | 28 #include "widget.h" |
29 #include<algorithm> | 29 #include <algorithm> |
30 #include<map> | 30 #include <map> |
31 #include<string> | 31 #include <string> |
32 | 32 |
33 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect, | 33 Rect DSurfaceRenderText(TextGlyphStream::iterator start, TextGlyphStream::iterator end, const Rect& srcrect, |
34 Surface* dst, const Rect& dstrect); | 34 Surface* dst, const Rect& dstrect); |
35 void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a = 0xff); | 35 void DSurfaceFill(Surface* src, const Rect& rect, int r, int g, int b, int a = 0xff); |
36 void DSurfaceMove(Surface* src, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); | 36 void DSurfaceMove(Surface* src, const Rect& srcrect, Surface* dst_o, const Rect& dstrect); |
47 delete it->second; | 47 delete it->second; |
48 } | 48 } |
49 size_to_layout.clear(); | 49 size_to_layout.clear(); |
50 wdefault_font = font; | 50 wdefault_font = font; |
51 } | 51 } |
52 | |
52 // namespace Widget { | 53 // namespace Widget { |
53 #define TimeCursor WidTimeCursor | 54 #define TimeCursor WidTimeCursor |
54 #define MouseCursor WidMouseCursor | 55 #define MouseCursor WidMouseCursor |
55 #define Button WidButton | 56 #define Button WidButton |
56 #define Scale WidScale | 57 #define Scale WidScale |
70 return size_to_layout[text_size]; | 71 return size_to_layout[text_size]; |
71 } | 72 } |
72 | 73 |
73 void PicWidget::activate(void) { | 74 void PicWidget::activate(void) { |
74 } | 75 } |
76 | |
75 void PicWidget::deactivate(void) { | 77 void PicWidget::deactivate(void) { |
76 } | 78 } |
79 | |
77 void PicWidget::SetRegion(const Rect& apos) { | 80 void PicWidget::SetRegion(const Rect& apos) { |
78 } | 81 } |
82 | |
79 void PicWidget::show(void) { | 83 void PicWidget::show(void) { |
80 Pic()->show(); | 84 Pic()->show(); |
81 } | 85 } |
86 | |
82 void PicWidget::hide(void) { | 87 void PicWidget::hide(void) { |
83 Pic()->hide(); | 88 Pic()->hide(); |
84 } | 89 } |
90 | |
85 void PicWidget::show_all(void) { | 91 void PicWidget::show_all(void) { |
86 Pic()->show_all(); | 92 Pic()->show_all(); |
87 } | 93 } |
88 | 94 |
89 TimeCursor::TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r) : | 95 TimeCursor::TimeCursor(Event::Container& container, int _interval, PicContainer* parent, const char* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r) : |
117 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0)); | 123 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0)); |
118 Pic()->SetSurface(s, x, y); | 124 Pic()->SetSurface(s, x, y); |
119 x = 0; y = 0; | 125 x = 0; y = 0; |
120 container.RegisterGlobalMotionFunc(&Motionfunc, (void*)this); | 126 container.RegisterGlobalMotionFunc(&Motionfunc, (void*)this); |
121 } | 127 } |
128 | |
122 MouseCursor::MouseCursor(Event::Container& _container, PicContainer* parent, Surface* s, int x, int y, int w, int h) : | 129 MouseCursor::MouseCursor(Event::Container& _container, PicContainer* parent, Surface* s, int x, int y, int w, int h) : |
123 Event::Video(_container), container(_container) { | 130 Event::Video(_container), container(_container) { |
124 int sx, sy; | 131 int sx, sy; |
125 _container.MousePos(sx, sy); | 132 _container.MousePos(sx, sy); |
126 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0)); | 133 SetPic(parent->create_leaf(Rect(sx, sy, sx+w, sy+h), 0)); |
146 SetPic(parent->create_leaf(r, 0)); | 153 SetPic(parent->create_leaf(r, 0)); |
147 Pic()->SetSurface(s, _sx, _sy); | 154 Pic()->SetSurface(s, _sx, _sy); |
148 show(); | 155 show(); |
149 is_in = false; | 156 is_in = false; |
150 is_toggled = false; | 157 is_toggled = false; |
151 press_func = 0; | 158 press_func = NULL; |
152 press_pointer = 0; | 159 press_pointer = NULL; |
153 drag_func = 0; | 160 drag_func = NULL; |
154 drag_pointer = 0; | 161 drag_pointer = NULL; |
155 is_toggle_switch = false; | 162 is_toggle_switch = false; |
156 } | 163 } |
164 | |
157 Button::Button(Event::Container& container, PicContainer* parent, Surface* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) { | 165 Button::Button(Event::Container& container, PicContainer* parent, Surface* s, int _sx, int _sy, int _sdx, int _sdy, int _nptn, const Rect& r, int _z) : sx(_sx), sy(_sy), sdx(_sdx), sdy(_sdy), nptn(_nptn) ,Event::Video(container,r, _z) { |
158 SetPic(parent->create_leaf(r, 0)); | 166 SetPic(parent->create_leaf(r, 0)); |
159 Pic()->SetSurface(s, _sx, _sy); | 167 Pic()->SetSurface(s, _sx, _sy); |
160 show(); | 168 show(); |
161 is_in = false; | 169 is_in = false; |
162 is_toggled = false; | 170 is_toggled = false; |
163 press_func = 0; | 171 press_func = NULL; |
164 press_pointer = 0; | 172 press_pointer = NULL; |
165 drag_func = 0; | 173 drag_func = NULL; |
166 drag_pointer = 0; | 174 drag_pointer = NULL; |
167 is_toggle_switch = false; | 175 is_toggle_switch = false; |
168 } | 176 } |
177 | |
169 Button::~Button() { | 178 Button::~Button() { |
170 } | 179 } |
180 | |
171 void Button::In(void) { | 181 void Button::In(void) { |
172 is_in = true; | 182 is_in = true; |
173 if (nptn > 1) | 183 if (nptn > 1) |
174 if (! is_toggled) | 184 if (! is_toggled) |
175 Pic()->SetSurfacePos(sx+sdx, sy+sdy); | 185 Pic()->SetSurfacePos(sx+sdx, sy+sdy); |
176 } | 186 } |
187 | |
177 void Button::Out(void) { | 188 void Button::Out(void) { |
178 is_in = false; | 189 is_in = false; |
179 if (!is_toggled) | 190 if (!is_toggled) |
180 Pic()->SetSurfacePos(sx, sy); | 191 Pic()->SetSurfacePos(sx, sy); |
181 } | 192 } |
193 | |
182 void Button::Toggle(bool new_toggle) { | 194 void Button::Toggle(bool new_toggle) { |
183 if (is_toggled == new_toggle) { | 195 if (is_toggled == new_toggle) { |
184 return; | 196 return; |
185 } | 197 } |
186 is_toggled = new_toggle; | 198 is_toggled = new_toggle; |
194 Pic()->SetSurfacePos(sx, sy); | 206 Pic()->SetSurfacePos(sx, sy); |
195 } else { | 207 } else { |
196 Pic()->SetSurfacePos(sx, sy); | 208 Pic()->SetSurfacePos(sx, sy); |
197 } | 209 } |
198 } | 210 } |
211 | |
199 void Button::Press(void) { | 212 void Button::Press(void) { |
200 is_in = true; | 213 is_in = true; |
201 if (is_toggled) ; | 214 if (is_toggled) ; |
202 else if (nptn > 2) | 215 else if (nptn > 2) |
203 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2); | 216 Pic()->SetSurfacePos(sx+sdx*2, sy+sdy*2); |
204 else if (nptn > 1) | 217 else if (nptn > 1) |
205 Pic()->SetSurfacePos(sx+sdx, sy+sdy); | 218 Pic()->SetSurfacePos(sx+sdx, sy+sdy); |
206 if (press_func) press_func(press_pointer, this); | 219 if (press_func) press_func(press_pointer, this); |
207 if (is_toggle_switch) Toggle(!is_toggled); | 220 if (is_toggle_switch) Toggle(!is_toggled); |
208 } | 221 } |
222 | |
209 void Button::Release(void) { | 223 void Button::Release(void) { |
210 if (is_toggled) ; | 224 if (is_toggled) ; |
211 else if (nptn > 1 && is_in) | 225 else if (nptn > 1 && is_in) |
212 Pic()->SetSurfacePos(sx+sdx, sy+sdy); | 226 Pic()->SetSurfacePos(sx+sdx, sy+sdy); |
213 else if (nptn > 1) | 227 else if (nptn > 1) |
214 Pic()->SetSurfacePos(sx, sy); | 228 Pic()->SetSurfacePos(sx, sy); |
215 } | 229 } |
230 | |
216 void Button::Drag(int x_from, int y_from, int x_to, int y_to) { | 231 void Button::Drag(int x_from, int y_from, int x_to, int y_to) { |
217 if (drag_func) drag_func(x_from,y_from,x_to, y_to,drag_pointer, this); | 232 if (drag_func) drag_func(x_from,y_from,x_to, y_to,drag_pointer, this); |
218 } | 233 } |
219 | 234 |
220 Scale::Scale(Event::Container& _container, PicContainer* _parent, const Rect& r_orig, const Color& _color, bool _is_vertical) : | 235 Scale::Scale(Event::Container& _container, PicContainer* _parent, const Rect& r_orig, const Color& _color, bool _is_vertical) : |
222 container(_container), parent(_parent), cursor_color(_color), | 237 container(_container), parent(_parent), cursor_color(_color), |
223 mouse_x(0), mouse_y(0), max(0), min(0), | 238 mouse_x(0), mouse_y(0), max(0), min(0), |
224 value(0), value_add(0), value_dragstart(0), is_vertical(_is_vertical), | 239 value(0), value_add(0), value_dragstart(0), is_vertical(_is_vertical), |
225 change_func(0), change_pointer(0) { | 240 change_func(0), change_pointer(0) { |
226 | 241 |
227 arrow_down = 0; | 242 arrow_down = NULL; |
228 arrow_up = 0; | 243 arrow_up = NULL; |
229 cursor = 0; | 244 cursor = NULL; |
230 panel = 0; | 245 panel = NULL; |
231 | 246 |
232 Init(r_orig); | 247 Init(r_orig); |
233 } | 248 } |
234 | 249 |
235 extern char* create_button(int number, int& width, int& height, int r, int g, int b); | 250 extern char* create_button(int number, int& width, int& height, int r, int g, int b); |
236 extern char* create_box(int& width, int& height, int r, int g, int b); | 251 extern char* create_box(int& width, int& height, int r, int g, int b); |
252 | |
237 void Scale::Init(Rect r_orig) { | 253 void Scale::Init(Rect r_orig) { |
238 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b; | 254 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b; |
239 // 矢印 | 255 // 矢印 |
240 int arrow_width = -1; | 256 int arrow_width = -1; |
241 cursor_width = -1; | 257 cursor_width = -1; |
320 InitCursor(0); | 336 InitCursor(0); |
321 } | 337 } |
322 | 338 |
323 void Scale::InitCursor(int width_ratio) { | 339 void Scale::InitCursor(int width_ratio) { |
324 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b; | 340 int r=cursor_color.r, g=cursor_color.g, b=cursor_color.b; |
325 if (cursor) delete cursor; | 341 if (cursor != NULL) delete cursor; |
326 cursor = 0; | 342 cursor = NULL; |
327 Rect region(0,0); | 343 Rect region(0,0); |
328 if (width_ratio < 0) width_ratio = 0; | 344 if (width_ratio < 0) width_ratio = 0; |
329 else if (width_ratio > 1024) width_ratio = 1024; | 345 else if (width_ratio > 1024) width_ratio = 1024; |
330 if (is_vertical) { | 346 if (is_vertical) { |
331 if (width_ratio == 0) cursor_width = Pic()->Width() * 3 / 2; // 幅の1.5倍 | 347 if (width_ratio == 0) cursor_width = Pic()->Width() * 3 / 2; // 幅の1.5倍 |
357 if (is_vertical) bar_width = Pic()->Height(); | 373 if (is_vertical) bar_width = Pic()->Height(); |
358 else bar_width = Pic()->Width(); | 374 else bar_width = Pic()->Width(); |
359 if (bar_width <= 0) value_add = max-min; | 375 if (bar_width <= 0) value_add = max-min; |
360 else if (cursor_width == 0) value_add = 2; | 376 else if (cursor_width == 0) value_add = 2; |
361 else value_add = scale_max*cursor_width/bar_width; | 377 else value_add = scale_max*cursor_width/bar_width; |
362 | |
363 return; | |
364 } | 378 } |
365 | 379 |
366 void Scale::PressArrowDown(void* pointer, Button* from) { | 380 void Scale::PressArrowDown(void* pointer, Button* from) { |
367 Scale* self = (Scale*)pointer; | 381 Scale* self = (Scale*)pointer; |
368 self->SetScaleValue(self->value + self->value_add); | 382 self->SetScaleValue(self->value + self->value_add); |
369 } | 383 } |
384 | |
370 void Scale::PressArrowUp(void* pointer, Button* from){ | 385 void Scale::PressArrowUp(void* pointer, Button* from){ |
371 Scale* self = (Scale*)pointer; | 386 Scale* self = (Scale*)pointer; |
372 self->SetScaleValue(self->value - self->value_add); | 387 self->SetScaleValue(self->value - self->value_add); |
373 } | 388 } |
389 | |
374 void Scale::PressCursor(void* pointer, Button* from){ | 390 void Scale::PressCursor(void* pointer, Button* from){ |
375 Scale* self = (Scale*)pointer; | 391 Scale* self = (Scale*)pointer; |
376 self->value_dragstart = self->value; | 392 self->value_dragstart = self->value; |
377 } | 393 } |
394 | |
378 void Scale::DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from){ | 395 void Scale::DragCursor(int x_from, int y_from,int x, int y, void* pointer, Button* from){ |
379 Scale* self = (Scale*)pointer; | 396 Scale* self = (Scale*)pointer; |
380 int dx, w; | 397 int dx, w; |
381 if (self->is_vertical) { | 398 if (self->is_vertical) { |
382 dx = y-y_from; | 399 dx = y-y_from; |
386 w = self->Event::Video::Region().width(); | 403 w = self->Event::Video::Region().width(); |
387 } | 404 } |
388 if (w == 0) return; | 405 if (w == 0) return; |
389 self->SetScaleValue(self->value_dragstart + dx*scale_max/w); | 406 self->SetScaleValue(self->value_dragstart + dx*scale_max/w); |
390 } | 407 } |
408 | |
391 int Scale::CalcValue(void) { | 409 int Scale::CalcValue(void) { |
392 Rect own_region = Event::Video::Region(); | 410 Rect own_region = Event::Video::Region(); |
393 int x, w; | 411 int x, w; |
394 if (is_vertical) { | 412 if (is_vertical) { |
395 w = own_region.height(); | 413 w = own_region.height(); |
401 if (w == 0) return 0; | 419 if (w == 0) return 0; |
402 if (x < 0) x = 0; | 420 if (x < 0) x = 0; |
403 else if (x > w) x = w; | 421 else if (x > w) x = w; |
404 return x*scale_max/w; | 422 return x*scale_max/w; |
405 } | 423 } |
424 | |
406 void Scale::Press(void){ | 425 void Scale::Press(void){ |
407 int v = CalcValue(); | 426 int v = CalcValue(); |
408 if (v < value) SetScaleValue(value-value_add); | 427 if (v < value) SetScaleValue(value-value_add); |
409 else SetScaleValue(value+value_add); | 428 else SetScaleValue(value+value_add); |
410 return; | 429 } |
411 } | 430 |
412 void Scale::Motion(int x, int y){ | 431 void Scale::Motion(int x, int y){ |
413 mouse_x = x; | 432 mouse_x = x; |
414 mouse_y = y; | 433 mouse_y = y; |
415 } | 434 } |
416 | 435 |
417 void Scale::SetRange(int new_min, int new_max) { | 436 void Scale::SetRange(int new_min, int new_max) { |
418 min = new_min; | 437 min = new_min; |
419 max = new_max; | 438 max = new_max; |
420 SetValue(value); | 439 SetValue(value); |
421 return; | 440 } |
422 } | 441 |
423 void Scale::SetValue(int new_value) { | 442 void Scale::SetValue(int new_value) { |
424 if (min == max) { | 443 if (min == max) { |
425 value = min; | 444 value = min; |
426 SetScaleValue(0); | 445 SetScaleValue(0); |
427 return; | 446 return; |
428 } | 447 } |
429 int scale_value = (new_value-min) * scale_max / (max-min); | 448 int scale_value = (new_value-min) * scale_max / (max-min); |
430 SetScaleValue(scale_value); | 449 SetScaleValue(scale_value); |
431 } | 450 } |
451 | |
432 int Scale::GetValue(void) const{ | 452 int Scale::GetValue(void) const{ |
433 return min + value * (max-min) / scale_max; | 453 return min + value * (max-min) / scale_max; |
434 } | 454 } |
455 | |
435 void Scale::SetScaleValue(int new_value) { | 456 void Scale::SetScaleValue(int new_value) { |
436 if (new_value < 0) value = 0; | 457 if (new_value < 0) value = 0; |
437 else if (new_value > scale_max) value = scale_max; | 458 else if (new_value > scale_max) value = scale_max; |
438 else value = new_value; | 459 else value = new_value; |
439 if (is_vertical) { | 460 if (is_vertical) { |
448 cursor->Pic()->Move(x, 0); | 469 cursor->Pic()->Move(x, 0); |
449 } | 470 } |
450 if (change_func) { | 471 if (change_func) { |
451 (*change_func)(change_pointer, this); | 472 (*change_func)(change_pointer, this); |
452 } | 473 } |
453 return; | |
454 } | 474 } |
455 | 475 |
456 TextButton::TextButton(Event::Container& container, PicContainer* parent, const char* text, int _text_size, Attribute attr, const Rect& r_orig, int _z, const Color& _fore, const Color& _pressed, const Color& _back) : | 476 TextButton::TextButton(Event::Container& container, PicContainer* parent, const char* text, int _text_size, Attribute attr, const Rect& r_orig, int _z, const Color& _fore, const Color& _pressed, const Color& _back) : |
457 Button(container, parent, (Surface*)0, 0, 0, 0, 0, 0, r_orig, _z), | 477 Button(container, parent, (Surface*)0, 0, 0, 0, 0, 0, r_orig, _z), |
458 root(parent->Root()), surface(0), attribute(attr), text_size(_text_size), | 478 root(parent->Root()), surface(0), attribute(attr), text_size(_text_size), |
460 { | 480 { |
461 bool rect_changed = false; | 481 bool rect_changed = false; |
462 // まず、テキスト領域の広さを得る | 482 // まず、テキスト領域の広さを得る |
463 Rect r(r_orig); | 483 Rect r(r_orig); |
464 | 484 |
465 if (text == 0) text = ""; | 485 if (text == NULL) text = ""; |
466 int width = r.width(); int height = r.height(); | 486 int width = r.width(); int height = r.height(); |
467 if (width == 0) width = parent->Width() - r.lx; | 487 if (width == 0) width = parent->Width() - r.lx; |
468 | 488 |
469 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); | 489 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); |
470 | 490 |
483 if (rect_changed) { | 503 if (rect_changed) { |
484 // 大きさ変更 | 504 // 大きさ変更 |
485 Pic()->SetSurfaceRect(r); | 505 Pic()->SetSurfaceRect(r); |
486 } | 506 } |
487 | 507 |
488 sx = 0; sy = 0; sdx = 0; sdy = r.height(); nptn = 3; | 508 sx = 0; sy = 0; sdx = 0; |
509 sdy = r.height(); | |
510 nptn = 3; | |
489 int x = 0, y = 0; | 511 int x = 0, y = 0; |
490 if (attribute & CENTER) | 512 if (attribute & CENTER) |
491 x = (Pic()->Width() - gs.width()) / 2; | 513 x = (Pic()->Width() - gs.width()) / 2; |
492 y = (Pic()->Height() - gs.height()) / 2; | 514 y = (Pic()->Height() - gs.height()) / 2; |
493 | 515 |
516 //FIXME: (back.a == NULL ?) | |
494 if (back.a == 0) { // 背景なし、もしくはボタン押の状態のみ背景あり | 517 if (back.a == 0) { // 背景なし、もしくはボタン押の状態のみ背景あり |
495 surface = root.NewSurface(r.width(), r.height()*2, ALPHA_MASK); | 518 surface = root.NewSurface(r.width(), r.height()*2, ALPHA_MASK); |
496 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | 519 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); |
497 if (attribute & REVERSE) { | 520 if (attribute & REVERSE) { |
498 DSurfaceFill(surface, Rect(0,r.height(),r.width(),r.height()*2), pressed.r, pressed.g, pressed.b, 0xff); | 521 DSurfaceFill(surface, Rect(0,r.height(),r.width(),r.height()*2), pressed.r, pressed.g, pressed.b, 0xff); |
528 } | 551 } |
529 | 552 |
530 Pic()->SetSurface(surface, 0, 0); | 553 Pic()->SetSurface(surface, 0, 0); |
531 show(); | 554 show(); |
532 } | 555 } |
556 | |
533 void TextButton::SetText(const char* text, const Color& _fore, const Color& _pressed, const Color& _back) | 557 void TextButton::SetText(const char* text, const Color& _fore, const Color& _pressed, const Color& _back) |
534 { | 558 { |
535 int width = Pic()->Width(); int height = Pic()->Height(); | 559 int width = Pic()->Width(); int height = Pic()->Height(); |
536 // まず、テキスト領域の広さを得る | 560 // まず、テキスト領域の広さを得る |
537 if (text == 0) text = ""; | 561 if (text == NULL) text = ""; |
538 | 562 |
539 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); | 563 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); |
540 | 564 |
541 int x = 0, y = 0; | 565 int x = 0, y = 0; |
542 if (attribute & CENTER) { | 566 if (attribute & CENTER) { |
545 } | 569 } |
546 int surf_x = Pic()->SurfacePosX(); | 570 int surf_x = Pic()->SurfacePosX(); |
547 int surf_y = Pic()->SurfacePosY(); | 571 int surf_y = Pic()->SurfacePosY(); |
548 Pic()->SetSurface( (Surface*)0,0,0); | 572 Pic()->SetSurface( (Surface*)0,0,0); |
549 root.DeleteSurface(surface); | 573 root.DeleteSurface(surface); |
550 surface = 0; | 574 surface = NULL; |
551 | 575 |
576 //FIXME: (back.a == NULL) ? | |
552 if (back.a == 0) { // 背景なし | 577 if (back.a == 0) { // 背景なし |
553 surface = root.NewSurface(width, height*2, ALPHA_MASK); | 578 surface = root.NewSurface(width, height*2, ALPHA_MASK); |
554 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | 579 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); |
555 if (attribute & REVERSE) { | 580 if (attribute & REVERSE) { |
556 DSurfaceFill(surface, Rect(0,height,width,height*2), pressed.r, pressed.g, pressed.b, 0xff); | 581 DSurfaceFill(surface, Rect(0,height,width,height*2), pressed.r, pressed.g, pressed.b, 0xff); |
584 show(); | 609 show(); |
585 } | 610 } |
586 | 611 |
587 TextButton::~TextButton() { | 612 TextButton::~TextButton() { |
588 if (surface) root.DeleteSurface(surface); | 613 if (surface) root.DeleteSurface(surface); |
589 surface = 0; | 614 surface = NULL; |
590 return; | |
591 } | 615 } |
592 | 616 |
593 Text::Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int _fontsize) : | 617 Text::Text(Event::Container& container, PicContainer* parent, const Rect& r, const Rect& text_r, int _fontsize) : |
594 Event::Video(container), | 618 Event::Video(container), |
595 Event::Time(container), | 619 Event::Time(container), |
620 } | 644 } |
621 | 645 |
622 void Text::SetSpeed(int new_speed) { | 646 void Text::SetSpeed(int new_speed) { |
623 speed = new_speed; | 647 speed = new_speed; |
624 } | 648 } |
649 | |
625 void Text::SetWait(int new_wait) { | 650 void Text::SetWait(int new_wait) { |
626 if (new_wait < 0) new_wait = 100000000; | 651 if (new_wait < 0) new_wait = 100000000; |
627 wait_delay = new_wait; | 652 wait_delay = new_wait; |
628 } | 653 } |
629 | 654 |
635 for (i=line_number; i<len; i++) | 660 for (i=line_number; i<len; i++) |
636 if (bottom_pos[i] - y0 > height) break; | 661 if (bottom_pos[i] - y0 > height) break; |
637 if (i == line_number) i = line_number + 1; | 662 if (i == line_number) i = line_number + 1; |
638 return i - line_number - 1; | 663 return i - line_number - 1; |
639 } | 664 } |
665 | |
640 void Text::Elapsed(unsigned int current_time) { | 666 void Text::Elapsed(unsigned int current_time) { |
641 SetWakeup(current_time + 50); | 667 SetWakeup(current_time + 50); |
642 if (status == PREPARE) { | 668 if (status == PREPARE) { |
643 old_time = current_time; | 669 old_time = current_time; |
644 return; | 670 return; |
708 nChar = 0; | 734 nChar = 0; |
709 cursor_activated = false; | 735 cursor_activated = false; |
710 if (cursor) cursor->hide(); | 736 if (cursor) cursor->hide(); |
711 } | 737 } |
712 status = PREPARE; | 738 status = PREPARE; |
713 return; | |
714 } | 739 } |
715 | 740 |
716 bool Text::Pressed(int x, int y, void* pointer) { | 741 bool Text::Pressed(int x, int y, void* pointer) { |
717 Text* wid = (Text*)pointer; | 742 Text* wid = (Text*)pointer; |
718 if (wid->Pic()->IsHidden()) return true; | 743 if (wid->Pic()->IsHidden()) return true; |
774 } | 799 } |
775 // 描画する | 800 // 描画する |
776 Rect r = DSurfaceRenderText(cur_pos, it, srcrect, surface, Rect(0,0,0,0)); | 801 Rect r = DSurfaceRenderText(cur_pos, it, srcrect, surface, Rect(0,0,0,0)); |
777 pictext->ReBlit(r); | 802 pictext->ReBlit(r); |
778 cur_pos = it; | 803 cur_pos = it; |
779 return; | |
780 } | 804 } |
781 | 805 |
782 void Text::Scrollup(int& nChar) { | 806 void Text::Scrollup(int& nChar) { |
783 if (nChar < 0) { // 一画面分スクロールする | 807 if (nChar < 0) { // 一画面分スクロールする |
784 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | 808 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); |
809 Rect r(*surface); | 833 Rect r(*surface); |
810 DSurfaceMove(surface, r, surface, Rect(0, -cur_dy, 0, 0)); | 834 DSurfaceMove(surface, r, surface, Rect(0, -cur_dy, 0, 0)); |
811 r.ty = r.by-cur_dy; | 835 r.ty = r.by-cur_dy; |
812 DSurfaceFill(surface, r, 0, 0, 0, 0); | 836 DSurfaceFill(surface, r, 0, 0, 0, 0); |
813 pictext->ReBlit(); | 837 pictext->ReBlit(); |
814 return; | |
815 } | 838 } |
816 | 839 |
817 void Text::activate(void) { | 840 void Text::activate(void) { |
818 event.RegisterGlobalPressFunc(&Pressed, (void*)this); | 841 event.RegisterGlobalPressFunc(&Pressed, (void*)this); |
819 Event::Video::activate(); | 842 Event::Video::activate(); |
820 window_activated = true; | 843 window_activated = true; |
821 if (cursor_activated && window_activated && cursor) cursor->show(); | 844 if (cursor_activated && window_activated && cursor) cursor->show(); |
822 } | 845 } |
846 | |
823 void Text::deactivate(void) { | 847 void Text::deactivate(void) { |
824 event.DeleteGlobalPressFunc(&Pressed, (void*)this); | 848 event.DeleteGlobalPressFunc(&Pressed, (void*)this); |
825 Event::Video::deactivate(); | 849 Event::Video::deactivate(); |
826 window_activated = false; | 850 window_activated = false; |
827 if (cursor) cursor->hide(); | 851 if (cursor) cursor->hide(); |
828 } | 852 } |
853 | |
829 void Text::SetCursor(TimeCursor* c) { | 854 void Text::SetCursor(TimeCursor* c) { |
830 cursor = c; | 855 cursor = c; |
831 if (c) { | 856 if (c) { |
832 if (cursor_activated && window_activated) c->show(); | 857 if (cursor_activated && window_activated) c->show(); |
833 else c->hide(); | 858 else c->hide(); |
838 is_center(_is_center), | 863 is_center(_is_center), |
839 root(parent->Root()), | 864 root(parent->Root()), |
840 text_size(_text_size) { | 865 text_size(_text_size) { |
841 Rect r(r_orig); | 866 Rect r(r_orig); |
842 | 867 |
843 if (text == 0) text = ""; | 868 if (text == NULL) text = ""; |
844 int width = r.width(); int height = r.height(); | 869 int width = r.width(); |
870 int height = r.height(); | |
845 if (width == 0) width = parent->Width() - r.lx; | 871 if (width == 0) width = parent->Width() - r.lx; |
846 | 872 |
847 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); | 873 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, width); |
848 | 874 |
849 if (r.width() == 0) { // 文字に合わせてウィジット作成 | 875 if (r.width() == 0) { // 文字に合わせてウィジット作成 |
869 DSurfaceRenderText(gs.begin(), gs.end(), Rect(*surface), surface, Rect(x,y)); | 895 DSurfaceRenderText(gs.begin(), gs.end(), Rect(*surface), surface, Rect(x,y)); |
870 | 896 |
871 Pic()->SetSurface(surface, 0, 0); | 897 Pic()->SetSurface(surface, 0, 0); |
872 show(); | 898 show(); |
873 } | 899 } |
900 | |
874 Label::~Label() { | 901 Label::~Label() { |
875 root.DeleteSurface(surface); | 902 root.DeleteSurface(surface); |
876 } | 903 } |
904 | |
877 void Label::SetText(const char* text) { | 905 void Label::SetText(const char* text) { |
878 if (text == 0) text = ""; | 906 if (text == NULL) text = ""; |
879 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, Pic()->Width()); | 907 TextGlyphStream gs = DefaultLayout(text_size)->Layout(text, Pic()->Width()); |
880 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); | 908 DSurfaceFill(surface, Rect(*surface), 0, 0, 0, 0); |
881 int x = 0, y = 0; | 909 int x = 0, y = 0; |
882 if (is_center) { | 910 if (is_center) { |
883 x = (Pic()->Width() - gs.width()) / 2; | 911 x = (Pic()->Width() - gs.width()) / 2; |
891 Dialog::Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel) : | 919 Dialog::Dialog(Event::Container& container, PicContainer* parent, const char* text, bool with_cancel) : |
892 Event::Video(container) { | 920 Event::Video(container) { |
893 | 921 |
894 int x,y; | 922 int x,y; |
895 status = WAIT; | 923 status = WAIT; |
896 set_func = 0; | 924 set_func = NULL; |
897 set_pointer = 0; | 925 set_pointer = NULL; |
898 | 926 |
899 XKFont::HorizLayout& layout = *DefaultLayout(26); | 927 XKFont::HorizLayout& layout = *DefaultLayout(26); |
900 int dialog_width = parent->Width() / 2; | 928 int dialog_width = parent->Width() / 2; |
901 TextGlyphStream s_ok = layout.Layout("OK", dialog_width); | 929 TextGlyphStream s_ok = layout.Layout("OK", dialog_width); |
902 TextGlyphStream s_cancel = layout.Layout("取消", dialog_width); | 930 TextGlyphStream s_cancel = layout.Layout("取消", dialog_width); |
967 Pic()->SetSurface(surface_diag, 0, 0); | 995 Pic()->SetSurface(surface_diag, 0, 0); |
968 Pic()->ZMove(ZMOVE_TOP); | 996 Pic()->ZMove(ZMOVE_TOP); |
969 | 997 |
970 show_all(); | 998 show_all(); |
971 } | 999 } |
1000 | |
972 Dialog::~Dialog() { | 1001 Dialog::~Dialog() { |
973 PicRoot& root = PicNode()->Root(); | 1002 PicRoot& root = PicNode()->Root(); |
974 SetPic(0); | 1003 SetPic(NULL); |
975 root.DeleteSurface(surface_btn); | 1004 root.DeleteSurface(surface_btn); |
976 root.DeleteSurface(surface_diag); | 1005 root.DeleteSurface(surface_diag); |
977 return; | |
978 } | 1006 } |
979 | 1007 |
980 void Dialog::press_ok(void* pointer, Button* btn) { | 1008 void Dialog::press_ok(void* pointer, Button* btn) { |
981 if (pointer) { | 1009 if (pointer) { |
982 Dialog* wid = (Dialog*)pointer; | 1010 Dialog* wid = (Dialog*)pointer; |
984 if (wid->set_func) { | 1012 if (wid->set_func) { |
985 (*wid->set_func)(wid->set_pointer, wid); | 1013 (*wid->set_func)(wid->set_pointer, wid); |
986 } | 1014 } |
987 } | 1015 } |
988 } | 1016 } |
1017 | |
989 void Dialog::press_cancel(void* pointer, Button* btn) { | 1018 void Dialog::press_cancel(void* pointer, Button* btn) { |
990 if (pointer) { | 1019 if (pointer) { |
991 Dialog* wid = (Dialog*)pointer; | 1020 Dialog* wid = (Dialog*)pointer; |
992 wid->status = CANCEL; | 1021 wid->status = CANCEL; |
993 if (wid->set_func) { | 1022 if (wid->set_func) { |
1014 Event::Time(container), | 1043 Event::Time(container), |
1015 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) { | 1044 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) { |
1016 status = FINISHED; | 1045 status = FINISHED; |
1017 if (total_time == 0) total_time = 1; | 1046 if (total_time == 0) total_time = 1; |
1018 } | 1047 } |
1048 | |
1019 AnmTime::AnmTime(Event::Container& container, std::vector<PicBase*> _pic, int _total_time, int _all_count) : | 1049 AnmTime::AnmTime(Event::Container& container, std::vector<PicBase*> _pic, int _total_time, int _all_count) : |
1020 Event::Time(container), | 1050 Event::Time(container), |
1021 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) { | 1051 PicAnm(_pic), start_time(0), total_time(_total_time), all_count(_all_count) { |
1022 status = FINISHED; | 1052 status = FINISHED; |
1023 if (total_time == 0) total_time = 1; | 1053 if (total_time == 0) total_time = 1; |
1024 } | 1054 } |
1055 | |
1025 void AnmTime::Elapsed(unsigned int current_time) { | 1056 void AnmTime::Elapsed(unsigned int current_time) { |
1026 if (total_time == 0) return; | 1057 if (total_time == 0) return; |
1027 if (status == FINISHED || current_time == 0) {SetWakeup(current_time+1); return;} | 1058 if (status == FINISHED || current_time == 0) {SetWakeup(current_time+1); return;} |
1028 if (start_time == 0) { | 1059 if (start_time == 0) { |
1029 start_time = current_time; | 1060 start_time = current_time; |
1038 } else { | 1069 } else { |
1039 Exec(all_count); | 1070 Exec(all_count); |
1040 Finish(); | 1071 Finish(); |
1041 status = FINISHED; | 1072 status = FINISHED; |
1042 } | 1073 } |
1043 return; | 1074 } |
1044 } | 1075 |
1045 void AnmTime::Abort(void) { | 1076 void AnmTime::Abort(void) { |
1046 if (status == FINISHED) return; | 1077 if (status == FINISHED) return; |
1047 if (start_time == 0) { | 1078 if (start_time == 0) { |
1048 Start(); | 1079 Start(); |
1049 Exec(all_count); | 1080 Exec(all_count); |
1051 if (total_time) { | 1082 if (total_time) { |
1052 Finish(); | 1083 Finish(); |
1053 } | 1084 } |
1054 status = FINISHED; | 1085 status = FINISHED; |
1055 } | 1086 } |
1087 | |
1056 bool AnmTime::IsEnd(void) { | 1088 bool AnmTime::IsEnd(void) { |
1057 return status == FINISHED; | 1089 return status == FINISHED; |
1058 } | 1090 } |
1091 | |
1059 AnmMove::AnmMove(Event::Container& container, PicBase* _pic, const Rect& _to, int total_time) : | 1092 AnmMove::AnmMove(Event::Container& container, PicBase* _pic, const Rect& _to, int total_time) : |
1060 AnmTime(container, _pic, total_time), | 1093 AnmTime(container, _pic, total_time), |
1061 from(0,0), to(_to) { | 1094 from(0,0), to(_to) { |
1062 from.lx = _pic->PosX(); | 1095 from.lx = _pic->PosX(); |
1063 from.ty = _pic->PosY(); | 1096 from.ty = _pic->PosY(); |
1070 if (dy < 0) dy = -dy; | 1103 if (dy < 0) dy = -dy; |
1071 if (dx < dy) dx = dy; | 1104 if (dx < dy) dx = dy; |
1072 if (dx == 0) dx = 1; | 1105 if (dx == 0) dx = 1; |
1073 SetAllCount(dx); | 1106 SetAllCount(dx); |
1074 } | 1107 } |
1108 | |
1075 void AnmMove::Exec(int count) { | 1109 void AnmMove::Exec(int count) { |
1076 Rect r(from); | 1110 Rect r(from); |
1077 int dx = to.lx - from.lx; | 1111 int dx = to.lx - from.lx; |
1078 int dy = to.ty - from.ty; | 1112 int dy = to.ty - from.ty; |
1079 r.rmove(dx*count/all_count, dy*count/all_count); | 1113 r.rmove(dx*count/all_count, dy*count/all_count); |
1080 iterator it; | 1114 iterator it; |
1081 for (it=pic.begin(); it!=pic.end(); it++) (*it)->Move(r.lx, r.ty); | 1115 for (it=pic.begin(); it!=pic.end(); it++) |
1082 } | 1116 (*it)->Move(r.lx, r.ty); |
1117 } | |
1118 | |
1083 AnmAlpha::AnmAlpha(Event::Container& container, PicBase* _pic, int alpha_from, int alpha_to, int total_time) : | 1119 AnmAlpha::AnmAlpha(Event::Container& container, PicBase* _pic, int alpha_from, int alpha_to, int total_time) : |
1084 AnmTime(container, _pic, total_time), | 1120 AnmTime(container, _pic, total_time), |
1085 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) { | 1121 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) { |
1086 if (from < 0) from = 0; | 1122 if (from < 0) from = 0; |
1087 if (from >= ALPHA_MAX) from = ALPHA_MAX; | 1123 if (from >= ALPHA_MAX) from = ALPHA_MAX; |
1090 int c = from - to; | 1126 int c = from - to; |
1091 if (c < 0) c = -c; | 1127 if (c < 0) c = -c; |
1092 if (c == 0) c = 1; | 1128 if (c == 0) c = 1; |
1093 SetAllCount(c); | 1129 SetAllCount(c); |
1094 } | 1130 } |
1131 | |
1095 AnmAlpha::AnmAlpha(Event::Container& container, std::vector<PicBase*> _pic, int alpha_from, int alpha_to, int total_time) : | 1132 AnmAlpha::AnmAlpha(Event::Container& container, std::vector<PicBase*> _pic, int alpha_from, int alpha_to, int total_time) : |
1096 AnmTime(container, _pic, total_time), | 1133 AnmTime(container, _pic, total_time), |
1097 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) { | 1134 from(alpha_from), to(alpha_to), alpha_r(0,0,1,1) { |
1098 if (from < 0) from = 0; | 1135 if (from < 0) from = 0; |
1099 if (from >= ALPHA_MAX) from = ALPHA_MAX; | 1136 if (from >= ALPHA_MAX) from = ALPHA_MAX; |
1102 int c = from - to; | 1139 int c = from - to; |
1103 if (c < 0) c = -c; | 1140 if (c < 0) c = -c; |
1104 if (c == 0) c = 1; | 1141 if (c == 0) c = 1; |
1105 SetAllCount(c); | 1142 SetAllCount(c); |
1106 } | 1143 } |
1144 | |
1107 void AnmAlpha::Start(void) { | 1145 void AnmAlpha::Start(void) { |
1108 iterator it; | 1146 iterator it; |
1109 for (it=pic.begin(); it!=pic.end(); it++) (*it)->show(); | 1147 for (it=pic.begin(); it!=pic.end(); it++) |
1110 } | 1148 (*it)->show(); |
1149 } | |
1150 | |
1111 void AnmAlpha::Exec(int count) { | 1151 void AnmAlpha::Exec(int count) { |
1112 alpha = (from * (all_count-count) + (to-from) * count) / all_count; | 1152 alpha = (from * (all_count-count) + (to-from) * count) / all_count; |
1113 iterator it; | 1153 iterator it; |
1114 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(&alpha, alpha_r); | 1154 for (it=pic.begin(); it!=pic.end(); it++) |
1115 } | 1155 (*it)->SetSurfaceAlpha(&alpha, alpha_r); |
1156 } | |
1157 | |
1116 void AnmAlpha::Finish(void) { | 1158 void AnmAlpha::Finish(void) { |
1117 iterator it; | 1159 iterator it; |
1118 for (it=pic.begin(); it!=pic.end(); it++) { | 1160 for (it=pic.begin(); it!=pic.end(); it++) { |
1119 if (to == 0) (*it)->hide(); | 1161 if (to == 0) (*it)->hide(); |
1120 else if (to != ALPHA_MAX) fprintf(stderr,"Warning in AnmAlpha::Finish: alpha value suddenly changed.\n"); | 1162 else if (to != ALPHA_MAX) fprintf(stderr,"Warning in AnmAlpha::Finish: alpha value suddenly changed.\n"); |
1121 (*it)->SetSurfaceAlpha(0,Rect(0,0)); | 1163 (*it)->SetSurfaceAlpha(0,Rect(0,0)); |
1122 } | 1164 } |
1123 } | 1165 } |
1166 | |
1124 AnmAlphaMove::AnmAlphaMove(Event::Container& container, PicBase* _pic) : | 1167 AnmAlphaMove::AnmAlphaMove(Event::Container& container, PicBase* _pic) : |
1125 AnmTime(container, _pic, 0) { | 1168 AnmTime(container, _pic, 0) { |
1126 } | 1169 } |
1170 | |
1127 void AnmAlphaMove::SetPtn(void) { | 1171 void AnmAlphaMove::SetPtn(void) { |
1128 int total = 0; | 1172 int total = 0; |
1129 std::vector<Ptn>::iterator it; | 1173 std::vector<Ptn>::iterator it; |
1130 for (it=ptns.begin(); it!=ptns.end(); it++) { | 1174 for (it=ptns.begin(); it!=ptns.end(); it++) { |
1131 if (total < it->next_tick) total = it->next_tick; | 1175 if (total < it->next_tick) total = it->next_tick; |
1132 } | 1176 } |
1133 SetAllCount(total); | 1177 SetAllCount(total); |
1134 SetTotalTime(total); | 1178 SetTotalTime(total); |
1135 cur_count = 0; | 1179 cur_count = 0; |
1136 } | 1180 } |
1181 | |
1137 void AnmAlphaMove::Exec(int count) { | 1182 void AnmAlphaMove::Exec(int count) { |
1138 if (ptns.empty()) return; | 1183 if (ptns.empty()) return; |
1139 if (cur_count != 0 && ptns[cur_count].next_tick > count) return; | 1184 if (cur_count != 0 && ptns[cur_count].next_tick > count) return; |
1140 if (cur_count >= ptns.size()) return; | 1185 if (cur_count >= ptns.size()) return; |
1141 // 次のパターンを探す | 1186 // 次のパターンを探す |
1159 if (it->alpha == 0) (*p)->hide(); | 1204 if (it->alpha == 0) (*p)->hide(); |
1160 else if (it->alpha == ALPHA_MAX) { (*p)->show(); (*p)->SetSurfaceAlpha(0, Rect(0,0)); } | 1205 else if (it->alpha == ALPHA_MAX) { (*p)->show(); (*p)->SetSurfaceAlpha(0, Rect(0,0)); } |
1161 else { (*p)->show(); (*p)->SetSurfaceAlpha( &(it->alpha), Rect(0,0,1,1)); } | 1206 else { (*p)->show(); (*p)->SetSurfaceAlpha( &(it->alpha), Rect(0,0,1,1)); } |
1162 } | 1207 } |
1163 } | 1208 } |
1209 | |
1164 void AnmAlphaMove::Finish(void) { | 1210 void AnmAlphaMove::Finish(void) { |
1165 if (ptns.empty()) return; | 1211 if (ptns.empty()) return; |
1166 if (cur_count >= ptns.size() - 1) return; | 1212 if (cur_count >= ptns.size() - 1) return; |
1167 cur_count = ptns.size() - 1; | 1213 cur_count = ptns.size() - 1; |
1168 Exec(ptns[cur_count].next_tick); // 最後の pattern の状態にする | 1214 Exec(ptns[cur_count].next_tick); // 最後の pattern の状態にする |
1197 for (i=0; i<ptn_len; i++) { | 1243 for (i=0; i<ptn_len; i++) { |
1198 if (ptn[i] <= count) alpha[i] = ALPHA_MAX; | 1244 if (ptn[i] <= count) alpha[i] = ALPHA_MAX; |
1199 else alpha[i] = 0; | 1245 else alpha[i] = 0; |
1200 } | 1246 } |
1201 iterator it; | 1247 iterator it; |
1202 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(alpha, alpha_r); | 1248 for (it=pic.begin(); it!=pic.end(); it++) |
1203 } | 1249 (*it)->SetSurfaceAlpha(alpha, alpha_r); |
1250 } | |
1251 | |
1204 void AnmPtnAlpha::Exec(int count) { | 1252 void AnmPtnAlpha::Exec(int count) { |
1205 int i; | 1253 int i; |
1206 int ptn_zero = count; | 1254 int ptn_zero = count; |
1207 int ptn_max = count - band; | 1255 int ptn_max = count - band; |
1208 for (i=0; i<ptn_len; i++) { | 1256 for (i=0; i<ptn_len; i++) { |
1214 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(alpha, alpha_r); | 1262 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(alpha, alpha_r); |
1215 } | 1263 } |
1216 | 1264 |
1217 void AnmPtnSolid::Start(void) { | 1265 void AnmPtnSolid::Start(void) { |
1218 iterator it; | 1266 iterator it; |
1219 for (it=pic.begin(); it!=pic.end(); it++) (*it)->show(); | 1267 for (it=pic.begin(); it!=pic.end(); it++) |
1220 } | 1268 (*it)->show(); |
1269 } | |
1270 | |
1221 void AnmPtnSolid::Finish(void) { | 1271 void AnmPtnSolid::Finish(void) { |
1222 iterator it; | 1272 iterator it; |
1223 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0)); | 1273 for (it=pic.begin(); it!=pic.end(); it++) |
1224 } | 1274 (*it)->SetSurfaceAlpha(0, Rect(0,0)); |
1275 } | |
1276 | |
1225 void AnmPtnAlpha::Start(void) { | 1277 void AnmPtnAlpha::Start(void) { |
1226 iterator it; | 1278 iterator it; |
1227 for (it=pic.begin(); it!=pic.end(); it++) (*it)->show(); | 1279 for (it=pic.begin(); it!=pic.end(); it++) |
1228 } | 1280 (*it)->show(); |
1281 } | |
1282 | |
1229 void AnmPtnAlpha::Finish(void) { | 1283 void AnmPtnAlpha::Finish(void) { |
1230 iterator it; | 1284 iterator it; |
1231 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0)); | 1285 for (it=pic.begin(); it!=pic.end(); it++) (*it)->SetSurfaceAlpha(0, Rect(0,0)); |
1232 } | 1286 } |
1233 | 1287 |