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.39 by root, Sun Apr 9 21:39:08 2006 UTC vs.
Revision 1.41 by root, Sun Apr 9 21:50:21 2006 UTC

4 4
5use Scalar::Util; 5use Scalar::Util;
6 6
7use SDL::OpenGL; 7use SDL::OpenGL;
8use SDL::OpenGL::Constants; 8use SDL::OpenGL::Constants;
9
10use Crossfire::Client;
9 11
10our $FOCUS; # the widget with current focus 12our $FOCUS; # the widget with current focus
11 13
12# class methods for events 14# class methods for events
13sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS } 15sub feed_sdl_key_down_event { $FOCUS->key_down ($_[0]) if $FOCUS }
37 Carp::confess "size_request is abtract"; 39 Carp::confess "size_request is abtract";
38} 40}
39 41
40sub size_allocate { 42sub size_allocate {
41 my ($self, $w, $h) = @_; 43 my ($self, $w, $h) = @_;
44
42 $self->w ($w); 45 $self->{w} = $w;
43 $self->h ($h); 46 $self->{h} = $h;
44} 47}
45 48
46sub focus_in { 49sub focus_in {
47 my ($widget) = @_; 50 my ($widget) = @_;
48 $FOCUS = $widget; 51 $FOCUS = $widget;
334} 337}
335 338
336sub size_allocate { 339sub size_allocate {
337 my ($self, $w, $h) = @_; 340 my ($self, $w, $h) = @_;
338 341
339 $self->w ($w); 342 $self->SUPER::size_allocate ($w, $h);
340 $self->h ($h);
341 343
342 $self->child->size_allocate ($w - 4, $h - 4); 344 $self->child->size_allocate ($w - 4, $h - 4);
343 $self->child->move (2, 2); 345 $self->child->move (2, 2);
344} 346}
345 347
363 365
364############################################################################# 366#############################################################################
365 367
366package Crossfire::Client::Widget::FancyFrame; 368package Crossfire::Client::Widget::FancyFrame;
367 369
368our @ISA = Crossfire::Client::Widget::Frame::; 370our @ISA = Crossfire::Client::Widget::Bin::;
369 371
370use SDL::OpenGL; 372use SDL::OpenGL;
371 373
372sub new { 374my @tex =
373 my ($self, $theme) = @_;
374 $self = $self->SUPER::new;
375
376 $self->{txts} = [
377 map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } 375 map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ }
378 qw/d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png/ 376 qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
379 ];
380 $self
381}
382 377
383sub size_request { 378sub size_request {
384 my ($self) = @_; 379 my ($self) = @_;
385 380
386 my ($w, $h) = $self->SUPER::size_request; 381 my ($w, $h) = $self->SUPER::size_request;
387 382
388 $h += $self->{txts}->[1]->{height}; 383 $h += $tex[1]->{height};
389 $h += $self->{txts}->[4]->{height}; 384 $h += $tex[4]->{height};
390 $w += $self->{txts}->[2]->{width}; 385 $w += $tex[2]->{width};
391 $w += $self->{txts}->[3]->{width}; 386 $w += $tex[3]->{width};
392 387
393 ($w, $h) 388 ($w, $h)
394} 389}
395 390
396sub size_allocate { 391sub size_allocate {
397 my ($self, $w, $h) = @_; 392 my ($self, $w, $h) = @_;
398 393
399 $self->w ($w); 394 $self->SUPER::size_allocate ($w, $h);
400 $self->h ($h); 395
401 $h -= $self->{txts}->[1]->{height}; 396 $h -= $tex[1]->{height};
402 $h -= $self->{txts}->[4]->{height}; 397 $h -= $tex[4]->{height};
403 $w -= $self->{txts}->[2]->{width}; 398 $w -= $tex[2]->{width};
404 $w -= $self->{txts}->[3]->{width}; 399 $w -= $tex[3]->{width};
405 400
406 $h = $h < 0 ? 0 : $h; 401 $h = $h < 0 ? 0 : $h;
407 $w = $w < 0 ? 0 : $w; 402 $w = $w < 0 ? 0 : $w;
408 warn "CHILD:$w $h\n"; 403 warn "CHILD:$w $h\n";
409 $self->child->size_allocate ($w, $h); 404 $self->child->size_allocate ($w, $h);
419 glEnable GL_BLEND; 414 glEnable GL_BLEND;
420 glEnable GL_TEXTURE_2D; 415 glEnable GL_TEXTURE_2D;
421 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 416 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
422 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 417 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
423 418
424 my $top = $self->{txts}->[1]; 419 my $top = $tex[1];
425 glBindTexture GL_TEXTURE_2D, $top->{name}; 420 glBindTexture GL_TEXTURE_2D, $top->{name};
426 421
427 glBegin GL_QUADS; 422 glBegin GL_QUADS;
428 glTexCoord 0, 0; glVertex 0 , 0; 423 glTexCoord 0, 0; glVertex 0 , 0;
429 glTexCoord 0, 1; glVertex 0 , $top->{height}; 424 glTexCoord 0, 1; glVertex 0 , $top->{height};
430 glTexCoord 1, 1; glVertex $w , $top->{height}; 425 glTexCoord 1, 1; glVertex $w , $top->{height};
431 glTexCoord 1, 0; glVertex $w , 0; 426 glTexCoord 1, 0; glVertex $w , 0;
432 glEnd; 427 glEnd;
433 428
434 my $left = $self->{txts}->[3]; 429 my $left = $tex[3];
435 glBindTexture GL_TEXTURE_2D, $left->{name}; 430 glBindTexture GL_TEXTURE_2D, $left->{name};
436 431
437 glBegin GL_QUADS; 432 glBegin GL_QUADS;
438 glTexCoord 0, 0; glVertex 0 , $top->{height}; 433 glTexCoord 0, 0; glVertex 0 , $top->{height};
439 glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; 434 glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch;
440 glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; 435 glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch;
441 glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; 436 glTexCoord 1, 0; glVertex $left->{width}, $top->{height};
442 glEnd; 437 glEnd;
443 438
444 my $right = $self->{txts}->[2]; 439 my $right = $tex[2];
445 glBindTexture GL_TEXTURE_2D, $right->{name}; 440 glBindTexture GL_TEXTURE_2D, $right->{name};
446 441
447 glBegin GL_QUADS; 442 glBegin GL_QUADS;
448 glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; 443 glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height};
449 glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; 444 glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch;
450 glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; 445 glTexCoord 1, 1; glVertex $w , $top->{height} + $ch;
451 glTexCoord 1, 0; glVertex $w , $top->{height}; 446 glTexCoord 1, 0; glVertex $w , $top->{height};
452 glEnd; 447 glEnd;
453 448
454 my $bottom = $self->{txts}->[4]; 449 my $bottom = $tex[4];
455 glBindTexture GL_TEXTURE_2D, $bottom->{name}; 450 glBindTexture GL_TEXTURE_2D, $bottom->{name};
456 451
457 glBegin GL_QUADS; 452 glBegin GL_QUADS;
458 glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; 453 glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height};
459 glTexCoord 0, 1; glVertex 0 , $h; 454 glTexCoord 0, 1; glVertex 0 , $h;
460 glTexCoord 1, 1; glVertex $w , $h; 455 glTexCoord 1, 1; glVertex $w , $h;
461 glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; 456 glTexCoord 1, 0; glVertex $w , $h - $bottom->{height};
462 glEnd; 457 glEnd;
463 458
464 my $bg = $self->{txts}->[0]; 459 my $bg = $tex[0];
465 glBindTexture GL_TEXTURE_2D, $bg->{name}; 460 glBindTexture GL_TEXTURE_2D, $bg->{name};
466 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 461 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
467 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; 462 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT;
468 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; 463 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT;
469 464

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines