… | |
… | |
37 | Carp::confess "size_request is abtract"; |
37 | Carp::confess "size_request is abtract"; |
38 | } |
38 | } |
39 | |
39 | |
40 | sub size_allocate { |
40 | sub size_allocate { |
41 | my ($self, $w, $h) = @_; |
41 | my ($self, $w, $h) = @_; |
|
|
42 | |
42 | $self->w ($w); |
43 | $self->{w} = $w; |
43 | $self->h ($h); |
44 | $self->{h} = $h; |
44 | } |
45 | } |
45 | |
46 | |
46 | sub focus_in { |
47 | sub focus_in { |
47 | my ($widget) = @_; |
48 | my ($widget) = @_; |
48 | $FOCUS = $widget; |
49 | $FOCUS = $widget; |
… | |
… | |
134 | my ($self) = @_; |
135 | my ($self) = @_; |
135 | |
136 | |
136 | #$self->deactivate; |
137 | #$self->deactivate; |
137 | } |
138 | } |
138 | |
139 | |
|
|
140 | ############################################################################# |
|
|
141 | |
139 | package Crossfire::Client::Widget::Container; |
142 | package Crossfire::Client::Widget::Container; |
140 | |
143 | |
141 | our @ISA = Crossfire::Client::Widget::; |
144 | our @ISA = Crossfire::Client::Widget::; |
142 | |
145 | |
143 | sub new { |
146 | sub new { |
… | |
… | |
200 | my ($self) = @_; |
203 | my ($self) = @_; |
201 | |
204 | |
202 | $_->draw for @{$self->{children}}; |
205 | $_->draw for @{$self->{children}}; |
203 | } |
206 | } |
204 | |
207 | |
|
|
208 | ############################################################################# |
|
|
209 | |
205 | package Crossfire::Client::Widget::Bin; |
210 | package Crossfire::Client::Widget::Bin; |
206 | |
211 | |
207 | our @ISA = Crossfire::Client::Widget::Container::; |
212 | our @ISA = Crossfire::Client::Widget::Container::; |
208 | |
213 | |
209 | sub get { $_[0]->{children}[0] } |
214 | sub child { $_[0]->{children}[0] } |
210 | |
215 | |
211 | sub size_request { |
216 | sub size_request { |
212 | $_[0]{children}[0]->size_request if $_[0]{children}[0]; |
217 | $_[0]{children}[0]->size_request if $_[0]{children}[0]; |
213 | } |
218 | } |
214 | |
219 | |
… | |
… | |
217 | $self->SUPER::size_allocate ($w, $h); |
222 | $self->SUPER::size_allocate ($w, $h); |
218 | $self->{children}[0]->size_allocate ($w, $h) |
223 | $self->{children}[0]->size_allocate ($w, $h) |
219 | if $self->{children}[0] |
224 | if $self->{children}[0] |
220 | } |
225 | } |
221 | |
226 | |
|
|
227 | ############################################################################# |
|
|
228 | |
222 | package Crossfire::Client::Widget::Toplevel; |
229 | package Crossfire::Client::Widget::Toplevel; |
223 | |
230 | |
224 | our @ISA = Crossfire::Client::Widget::Container::; |
231 | our @ISA = Crossfire::Client::Widget::Container::; |
225 | |
232 | |
226 | sub update { |
233 | sub update { |
227 | my ($self) = @_; |
234 | my ($self) = @_; |
228 | |
235 | |
229 | ::refresh (); |
236 | ::refresh (); |
230 | } |
237 | } |
|
|
238 | |
|
|
239 | ############################################################################# |
231 | |
240 | |
232 | package Crossfire::Client::Widget::Window; |
241 | package Crossfire::Client::Widget::Window; |
233 | |
242 | |
234 | our @ISA = Crossfire::Client::Widget::Bin::; |
243 | our @ISA = Crossfire::Client::Widget::Bin::; |
235 | |
244 | |
… | |
… | |
305 | |
314 | |
306 | glDisable GL_BLEND; |
315 | glDisable GL_BLEND; |
307 | glDisable GL_TEXTURE_2D; |
316 | glDisable GL_TEXTURE_2D; |
308 | } |
317 | } |
309 | |
318 | |
|
|
319 | ############################################################################# |
|
|
320 | |
310 | package Crossfire::Client::Widget::Frame; |
321 | package Crossfire::Client::Widget::Frame; |
311 | |
322 | |
312 | our @ISA = Crossfire::Client::Widget::Bin::; |
323 | our @ISA = Crossfire::Client::Widget::Bin::; |
313 | |
324 | |
314 | use SDL::OpenGL; |
325 | use SDL::OpenGL; |
315 | |
326 | |
316 | sub size_request { |
327 | sub size_request { |
317 | my ($self) = @_; |
328 | my ($self) = @_; |
318 | my $chld = $self->get |
329 | my $chld = $self->child |
319 | or return (0, 0); |
330 | or return (0, 0); |
320 | |
331 | |
321 | $chld->move (2, 2); |
332 | $chld->move (2, 2); |
322 | |
333 | |
323 | map { $_ + 4 } $chld->size_request; |
334 | map { $_ + 4 } $chld->size_request; |
… | |
… | |
327 | my ($self, $w, $h) = @_; |
338 | my ($self, $w, $h) = @_; |
328 | |
339 | |
329 | $self->w ($w); |
340 | $self->w ($w); |
330 | $self->h ($h); |
341 | $self->h ($h); |
331 | |
342 | |
332 | $self->get->size_allocate ($w - 4, $h - 4); |
343 | $self->child->size_allocate ($w - 4, $h - 4); |
333 | $self->get->move (2, 2); |
344 | $self->child->move (2, 2); |
334 | } |
345 | } |
335 | |
346 | |
336 | sub _draw { |
347 | sub _draw { |
337 | my ($self) = @_; |
348 | my ($self) = @_; |
338 | |
349 | |
339 | my $chld = $self->get; |
350 | my $chld = $self->child; |
340 | |
351 | |
341 | my ($w, $h) = $chld->size_request; |
352 | my ($w, $h) = $chld->size_request; |
342 | |
353 | |
343 | glBegin GL_QUADS; |
354 | glBegin GL_QUADS; |
344 | glColor 0, 0, 0; |
355 | glColor 0, 0, 0; |
… | |
… | |
349 | glEnd; |
360 | glEnd; |
350 | |
361 | |
351 | $chld->draw; |
362 | $chld->draw; |
352 | } |
363 | } |
353 | |
364 | |
|
|
365 | ############################################################################# |
|
|
366 | |
354 | package Crossfire::Client::Widget::FancyFrame; |
367 | package Crossfire::Client::Widget::FancyFrame; |
355 | |
368 | |
356 | our @ISA = Crossfire::Client::Widget::Frame::; |
369 | our @ISA = Crossfire::Client::Widget::Frame::; |
357 | |
370 | |
358 | use SDL::OpenGL; |
371 | use SDL::OpenGL; |
… | |
… | |
361 | my ($self, $theme) = @_; |
374 | my ($self, $theme) = @_; |
362 | $self = $self->SUPER::new; |
375 | $self = $self->SUPER::new; |
363 | |
376 | |
364 | $self->{txts} = [ |
377 | $self->{txts} = [ |
365 | map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } |
378 | map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } |
366 | qw/d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png/ |
379 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png) |
367 | ]; |
380 | ]; |
368 | $self |
381 | $self |
369 | } |
382 | } |
370 | |
383 | |
371 | sub size_request { |
384 | sub size_request { |
372 | my ($self) = @_; |
385 | my ($self) = @_; |
|
|
386 | |
373 | my ($w, $h) = $self->get->size_request; |
387 | my ($w, $h) = $self->SUPER::size_request; |
374 | |
388 | |
375 | $h += $self->{txts}->[1]->{height}; |
389 | $h += $self->{txts}->[1]->{height}; |
376 | $h += $self->{txts}->[4]->{height}; |
390 | $h += $self->{txts}->[4]->{height}; |
377 | $w += $self->{txts}->[2]->{width}; |
391 | $w += $self->{txts}->[2]->{width}; |
378 | $w += $self->{txts}->[3]->{width}; |
392 | $w += $self->{txts}->[3]->{width}; |
… | |
… | |
381 | } |
395 | } |
382 | |
396 | |
383 | sub size_allocate { |
397 | sub size_allocate { |
384 | my ($self, $w, $h) = @_; |
398 | my ($self, $w, $h) = @_; |
385 | |
399 | |
386 | $self->w ($w); |
400 | $self->SUPER::size_allocate ($w, $h); |
387 | $self->h ($h); |
401 | |
388 | $h -= $self->{txts}->[1]->{height}; |
402 | $h -= $self->{txts}->[1]->{height}; |
389 | $h -= $self->{txts}->[4]->{height}; |
403 | $h -= $self->{txts}->[4]->{height}; |
390 | $w -= $self->{txts}->[2]->{width}; |
404 | $w -= $self->{txts}->[2]->{width}; |
391 | $w -= $self->{txts}->[3]->{width}; |
405 | $w -= $self->{txts}->[3]->{width}; |
392 | |
406 | |
393 | $h = $h < 0 ? 0 : $h; |
407 | $h = $h < 0 ? 0 : $h; |
394 | $w = $w < 0 ? 0 : $w; |
408 | $w = $w < 0 ? 0 : $w; |
395 | warn "CHILD:$w $h\n"; |
409 | warn "CHILD:$w $h\n"; |
396 | $self->get->size_allocate ($w, $h); |
410 | $self->child->size_allocate ($w, $h); |
397 | $self->get->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); |
411 | $self->child->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); |
398 | } |
412 | } |
399 | |
413 | |
400 | sub _draw { |
414 | sub _draw { |
401 | my ($self) = @_; |
415 | my ($self) = @_; |
402 | |
416 | |
403 | my ($w, $h) = ($self->w, $self->h); |
417 | my ($w, $h) = ($self->w, $self->h); |
404 | my ($cw, $ch) = ($self->get->w, $self->get->h); |
418 | my ($cw, $ch) = ($self->child->w, $self->child->h); |
405 | |
419 | |
406 | glEnable GL_BLEND; |
420 | glEnable GL_BLEND; |
407 | glEnable GL_TEXTURE_2D; |
421 | glEnable GL_TEXTURE_2D; |
408 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
422 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
409 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
423 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
… | |
… | |
465 | glEnd; |
479 | glEnd; |
466 | |
480 | |
467 | glDisable GL_BLEND; |
481 | glDisable GL_BLEND; |
468 | glDisable GL_TEXTURE_2D; |
482 | glDisable GL_TEXTURE_2D; |
469 | |
483 | |
470 | $self->get->draw; |
484 | $self->child->draw; |
471 | |
485 | |
472 | } |
486 | } |
|
|
487 | |
|
|
488 | ############################################################################# |
473 | |
489 | |
474 | package Crossfire::Client::Widget::Table; |
490 | package Crossfire::Client::Widget::Table; |
475 | |
491 | |
476 | our @ISA = Crossfire::Client::Widget::Bin::; |
492 | our @ISA = Crossfire::Client::Widget::Bin::; |
477 | |
493 | |
… | |
… | |
553 | } |
569 | } |
554 | |
570 | |
555 | $y += $self->max_row_height ($yi); |
571 | $y += $self->max_row_height ($yi); |
556 | } |
572 | } |
557 | } |
573 | } |
|
|
574 | |
|
|
575 | ############################################################################# |
558 | |
576 | |
559 | package Crossfire::Client::Widget::VBox; |
577 | package Crossfire::Client::Widget::VBox; |
560 | |
578 | |
561 | our @ISA = Crossfire::Client::Widget::Container::; |
579 | our @ISA = Crossfire::Client::Widget::Container::; |
562 | |
580 | |
… | |
… | |
611 | $_->draw; |
629 | $_->draw; |
612 | $y += $_->h; |
630 | $y += $_->h; |
613 | } |
631 | } |
614 | } |
632 | } |
615 | |
633 | |
|
|
634 | ############################################################################# |
|
|
635 | |
616 | package Crossfire::Client::Widget::Label; |
636 | package Crossfire::Client::Widget::Label; |
617 | |
637 | |
618 | our @ISA = Crossfire::Client::Widget::; |
638 | our @ISA = Crossfire::Client::Widget::; |
619 | |
639 | |
620 | use SDL::OpenGL; |
640 | use SDL::OpenGL; |
… | |
… | |
676 | |
696 | |
677 | glDisable GL_BLEND; |
697 | glDisable GL_BLEND; |
678 | glDisable GL_TEXTURE_2D; |
698 | glDisable GL_TEXTURE_2D; |
679 | } |
699 | } |
680 | |
700 | |
|
|
701 | ############################################################################# |
|
|
702 | |
681 | package Crossfire::Client::Widget::TextEntry; |
703 | package Crossfire::Client::Widget::TextEntry; |
682 | |
704 | |
683 | our @ISA = Crossfire::Client::Widget::Label::; |
705 | our @ISA = Crossfire::Client::Widget::Label::; |
684 | |
706 | |
685 | use SDL; |
707 | use SDL; |
… | |
… | |
702 | } elsif ($uni) { |
724 | } elsif ($uni) { |
703 | $text .= chr $uni; |
725 | $text .= chr $uni; |
704 | } |
726 | } |
705 | $self->set_text ($text); |
727 | $self->set_text ($text); |
706 | } |
728 | } |
|
|
729 | |
|
|
730 | ############################################################################# |
707 | |
731 | |
708 | package Crossfire::Client::Widget::MapWidget; |
732 | package Crossfire::Client::Widget::MapWidget; |
709 | |
733 | |
710 | use strict; |
734 | use strict; |
711 | |
735 | |
… | |
… | |
878 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
902 | if (!($mod & KMOD_CTRL ) && delete $self->{ctrl}) { |
879 | $::CONN->send ("command run_stop"); |
903 | $::CONN->send ("command run_stop"); |
880 | } |
904 | } |
881 | } |
905 | } |
882 | |
906 | |
|
|
907 | ############################################################################# |
|
|
908 | |
883 | package Crossfire::Client::Widget::Animator; |
909 | package Crossfire::Client::Widget::Animator; |
884 | |
910 | |
885 | use SDL::OpenGL; |
911 | use SDL::OpenGL; |
886 | |
912 | |
887 | our @ISA = Crossfire::Client::Widget::Bin::; |
913 | our @ISA = Crossfire::Client::Widget::Bin::; |