ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.38 by root, Sun Apr 9 21:34:49 2006 UTC vs.
Revision 1.40 by root, Sun Apr 9 21:41:11 2006 UTC

37 Carp::confess "size_request is abtract"; 37 Carp::confess "size_request is abtract";
38} 38}
39 39
40sub size_allocate { 40sub 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
46sub focus_in { 47sub 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
139package Crossfire::Client::Widget::Container; 142package Crossfire::Client::Widget::Container;
140 143
141our @ISA = Crossfire::Client::Widget::; 144our @ISA = Crossfire::Client::Widget::;
142 145
143sub new { 146sub 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
205package Crossfire::Client::Widget::Bin; 210package Crossfire::Client::Widget::Bin;
206 211
207our @ISA = Crossfire::Client::Widget::Container::; 212our @ISA = Crossfire::Client::Widget::Container::;
208 213
209sub get { $_[0]->{children}[0] } 214sub child { $_[0]->{children}[0] }
210 215
211sub size_request { 216sub 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
222package Crossfire::Client::Widget::Toplevel; 229package Crossfire::Client::Widget::Toplevel;
223 230
224our @ISA = Crossfire::Client::Widget::Container::; 231our @ISA = Crossfire::Client::Widget::Container::;
225 232
226sub update { 233sub update {
227 my ($self) = @_; 234 my ($self) = @_;
228 235
229 ::refresh (); 236 ::refresh ();
230} 237}
238
239#############################################################################
231 240
232package Crossfire::Client::Widget::Window; 241package Crossfire::Client::Widget::Window;
233 242
234our @ISA = Crossfire::Client::Widget::Bin::; 243our @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
310package Crossfire::Client::Widget::Frame; 321package Crossfire::Client::Widget::Frame;
311 322
312our @ISA = Crossfire::Client::Widget::Bin::; 323our @ISA = Crossfire::Client::Widget::Bin::;
313 324
314use SDL::OpenGL; 325use SDL::OpenGL;
315 326
316sub size_request { 327sub 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
336sub _draw { 347sub _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
354package Crossfire::Client::Widget::FancyFrame; 367package Crossfire::Client::Widget::FancyFrame;
355 368
356our @ISA = Crossfire::Client::Widget::Frame::; 369our @ISA = Crossfire::Client::Widget::Frame::;
357 370
358use SDL::OpenGL; 371use 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
371sub size_request { 384sub 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
383sub size_allocate { 397sub 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
400sub _draw { 414sub _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
474package Crossfire::Client::Widget::Table; 490package Crossfire::Client::Widget::Table;
475 491
476our @ISA = Crossfire::Client::Widget::Bin::; 492our @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
559package Crossfire::Client::Widget::VBox; 577package Crossfire::Client::Widget::VBox;
560 578
561our @ISA = Crossfire::Client::Widget::Container::; 579our @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
616package Crossfire::Client::Widget::Label; 636package Crossfire::Client::Widget::Label;
617 637
618our @ISA = Crossfire::Client::Widget::; 638our @ISA = Crossfire::Client::Widget::;
619 639
620use SDL::OpenGL; 640use 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
681package Crossfire::Client::Widget::TextEntry; 703package Crossfire::Client::Widget::TextEntry;
682 704
683our @ISA = Crossfire::Client::Widget::Label::; 705our @ISA = Crossfire::Client::Widget::Label::;
684 706
685use SDL; 707use 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
708package Crossfire::Client::Widget::MapWidget; 732package Crossfire::Client::Widget::MapWidget;
709 733
710use strict; 734use 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
883package Crossfire::Client::Widget::Animator; 909package Crossfire::Client::Widget::Animator;
884 910
885use SDL::OpenGL; 911use SDL::OpenGL;
886 912
887our @ISA = Crossfire::Client::Widget::Bin::; 913our @ISA = Crossfire::Client::Widget::Bin::;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines