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.40 by root, Sun Apr 9 21:41:11 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 }
335} 337}
336 338
337sub size_allocate { 339sub size_allocate {
338 my ($self, $w, $h) = @_; 340 my ($self, $w, $h) = @_;
339 341
340 $self->w ($w); 342 $self->SUPER::size_allocate ($w, $h);
341 $self->h ($h);
342 343
343 $self->child->size_allocate ($w - 4, $h - 4); 344 $self->child->size_allocate ($w - 4, $h - 4);
344 $self->child->move (2, 2); 345 $self->child->move (2, 2);
345} 346}
346 347
364 365
365############################################################################# 366#############################################################################
366 367
367package Crossfire::Client::Widget::FancyFrame; 368package Crossfire::Client::Widget::FancyFrame;
368 369
369our @ISA = Crossfire::Client::Widget::Frame::; 370our @ISA = Crossfire::Client::Widget::Bin::;
370 371
371use SDL::OpenGL; 372use SDL::OpenGL;
372 373
373sub new { 374my @tex =
374 my ($self, $theme) = @_;
375 $self = $self->SUPER::new;
376
377 $self->{txts} = [
378 map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } 375 map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ }
379 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);
380 ];
381 $self
382}
383 377
384sub size_request { 378sub size_request {
385 my ($self) = @_; 379 my ($self) = @_;
386 380
387 my ($w, $h) = $self->SUPER::size_request; 381 my ($w, $h) = $self->SUPER::size_request;
388 382
389 $h += $self->{txts}->[1]->{height}; 383 $h += $tex[1]->{height};
390 $h += $self->{txts}->[4]->{height}; 384 $h += $tex[4]->{height};
391 $w += $self->{txts}->[2]->{width}; 385 $w += $tex[2]->{width};
392 $w += $self->{txts}->[3]->{width}; 386 $w += $tex[3]->{width};
393 387
394 ($w, $h) 388 ($w, $h)
395} 389}
396 390
397sub size_allocate { 391sub size_allocate {
398 my ($self, $w, $h) = @_; 392 my ($self, $w, $h) = @_;
399 393
400 $self->SUPER::size_allocate ($w, $h); 394 $self->SUPER::size_allocate ($w, $h);
401 395
402 $h -= $self->{txts}->[1]->{height}; 396 $h -= $tex[1]->{height};
403 $h -= $self->{txts}->[4]->{height}; 397 $h -= $tex[4]->{height};
404 $w -= $self->{txts}->[2]->{width}; 398 $w -= $tex[2]->{width};
405 $w -= $self->{txts}->[3]->{width}; 399 $w -= $tex[3]->{width};
406 400
407 $h = $h < 0 ? 0 : $h; 401 $h = $h < 0 ? 0 : $h;
408 $w = $w < 0 ? 0 : $w; 402 $w = $w < 0 ? 0 : $w;
409 warn "CHILD:$w $h\n"; 403 warn "CHILD:$w $h\n";
410 $self->child->size_allocate ($w, $h); 404 $self->child->size_allocate ($w, $h);
420 glEnable GL_BLEND; 414 glEnable GL_BLEND;
421 glEnable GL_TEXTURE_2D; 415 glEnable GL_TEXTURE_2D;
422 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 416 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
423 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 417 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
424 418
425 my $top = $self->{txts}->[1]; 419 my $top = $tex[1];
426 glBindTexture GL_TEXTURE_2D, $top->{name}; 420 glBindTexture GL_TEXTURE_2D, $top->{name};
427 421
428 glBegin GL_QUADS; 422 glBegin GL_QUADS;
429 glTexCoord 0, 0; glVertex 0 , 0; 423 glTexCoord 0, 0; glVertex 0 , 0;
430 glTexCoord 0, 1; glVertex 0 , $top->{height}; 424 glTexCoord 0, 1; glVertex 0 , $top->{height};
431 glTexCoord 1, 1; glVertex $w , $top->{height}; 425 glTexCoord 1, 1; glVertex $w , $top->{height};
432 glTexCoord 1, 0; glVertex $w , 0; 426 glTexCoord 1, 0; glVertex $w , 0;
433 glEnd; 427 glEnd;
434 428
435 my $left = $self->{txts}->[3]; 429 my $left = $tex[3];
436 glBindTexture GL_TEXTURE_2D, $left->{name}; 430 glBindTexture GL_TEXTURE_2D, $left->{name};
437 431
438 glBegin GL_QUADS; 432 glBegin GL_QUADS;
439 glTexCoord 0, 0; glVertex 0 , $top->{height}; 433 glTexCoord 0, 0; glVertex 0 , $top->{height};
440 glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; 434 glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch;
441 glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; 435 glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch;
442 glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; 436 glTexCoord 1, 0; glVertex $left->{width}, $top->{height};
443 glEnd; 437 glEnd;
444 438
445 my $right = $self->{txts}->[2]; 439 my $right = $tex[2];
446 glBindTexture GL_TEXTURE_2D, $right->{name}; 440 glBindTexture GL_TEXTURE_2D, $right->{name};
447 441
448 glBegin GL_QUADS; 442 glBegin GL_QUADS;
449 glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; 443 glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height};
450 glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; 444 glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch;
451 glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; 445 glTexCoord 1, 1; glVertex $w , $top->{height} + $ch;
452 glTexCoord 1, 0; glVertex $w , $top->{height}; 446 glTexCoord 1, 0; glVertex $w , $top->{height};
453 glEnd; 447 glEnd;
454 448
455 my $bottom = $self->{txts}->[4]; 449 my $bottom = $tex[4];
456 glBindTexture GL_TEXTURE_2D, $bottom->{name}; 450 glBindTexture GL_TEXTURE_2D, $bottom->{name};
457 451
458 glBegin GL_QUADS; 452 glBegin GL_QUADS;
459 glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; 453 glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height};
460 glTexCoord 0, 1; glVertex 0 , $h; 454 glTexCoord 0, 1; glVertex 0 , $h;
461 glTexCoord 1, 1; glVertex $w , $h; 455 glTexCoord 1, 1; glVertex $w , $h;
462 glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; 456 glTexCoord 1, 0; glVertex $w , $h - $bottom->{height};
463 glEnd; 457 glEnd;
464 458
465 my $bg = $self->{txts}->[0]; 459 my $bg = $tex[0];
466 glBindTexture GL_TEXTURE_2D, $bg->{name}; 460 glBindTexture GL_TEXTURE_2D, $bg->{name};
467 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 461 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
468 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; 462 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT;
469 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; 463 glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT;
470 464

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines