--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/09 01:37:58 1.33 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/09 02:44:51 1.34 @@ -293,7 +293,114 @@ use SDL::OpenGL; -#TODO: implement themed frame +sub new { + my ($self, $theme) = @_; + $self = $self->SUPER::new; + + $self->{txts} = [ + map { new_from_file Crossfire::Client::Texture Crossfire::Client::find_rcfile $_ } + qw/d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png/ + ]; + $self + +} + +sub size_request { + my ($self) = @_; + my ($w, $h) = $self->get->size_request; + + $h += $self->{txts}->[1]->{height}; + $h += $self->{txts}->[4]->{height}; + $w += $self->{txts}->[2]->{width}; + $w += $self->{txts}->[3]->{width}; + + $self->get->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); + + ($w, $h) +} + +sub _draw { + my ($self) = @_; + + my ($w, $h) = $self->size_request; + my ($cw, $ch) = $self->get->size_request; + + glEnable GL_BLEND; + glEnable GL_TEXTURE_2D; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; + + + my $top = $self->{txts}->[1]; + glBindTexture GL_TEXTURE_2D, $top->{name}; + + glColor 1, 1, 1, 0.8; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex 0 , 0; + glTexCoord 0, 1; glVertex 0 , $top->{height}; + glTexCoord 1, 1; glVertex $w , $top->{height}; + glTexCoord 1, 0; glVertex $w , 0; + glEnd; + + my $left = $self->{txts}->[3]; + glBindTexture GL_TEXTURE_2D, $left->{name}; + + glColor 1, 1, 1, 0.8; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex 0 , $top->{height}; + glTexCoord 0, 1; glVertex 0 , $top->{height} + $ch; + glTexCoord 1, 1; glVertex $left->{width}, $top->{height} + $ch; + glTexCoord 1, 0; glVertex $left->{width}, $top->{height}; + glEnd; + + my $right = $self->{txts}->[2]; + glBindTexture GL_TEXTURE_2D, $right->{name}; + + glColor 1, 1, 1, 0.8; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex $w - $right->{width}, $top->{height}; + glTexCoord 0, 1; glVertex $w - $right->{width}, $top->{height} + $ch; + glTexCoord 1, 1; glVertex $w , $top->{height} + $ch; + glTexCoord 1, 0; glVertex $w , $top->{height}; + glEnd; + + my $bottom = $self->{txts}->[4]; + glBindTexture GL_TEXTURE_2D, $bottom->{name}; + + glColor 1, 1, 1, 0.8; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex 0 , $h - $bottom->{height}; + glTexCoord 0, 1; glVertex 0 , $h; + glTexCoord 1, 1; glVertex $w , $h; + glTexCoord 1, 0; glVertex $w , $h - $bottom->{height}; + glEnd; + + my $bg = $self->{txts}->[0]; + glBindTexture GL_TEXTURE_2D, $bg->{name}; + glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; + glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; + + glColor 1, 1, 1, 0.8; + + my $rep_x = $cw / $bg->{width}; + my $rep_y = $ch / $bg->{height}; + + glBegin GL_QUADS; + glTexCoord 0, 0; glVertex $left->{width}, $top->{height}; + glTexCoord 0, $rep_y; glVertex $left->{width}, $top->{height} + $ch; + glTexCoord $rep_x, $rep_y; glVertex $left->{width} + $cw , $top->{height} + $ch; + glTexCoord $rep_x, 0; glVertex $left->{width} + $cw , $top->{height}; + glEnd; + + $self->get->draw; + + glDisable GL_BLEND; + glDisable GL_TEXTURE_2D; +} package Crossfire::Client::Widget::Table;