--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/08 22:08:24 1.25 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/09 00:09:50 1.29 @@ -125,7 +125,7 @@ sub add { my ($self, $chld) = @_; $self->SUPER::add ($chld); - $self->render_chld; + $self->render_chld; #TODO: Move this to the size_request event propably? } sub render_chld { @@ -150,7 +150,8 @@ sub _draw { my ($self) = @_; - my ($w, $h) = $self->size_request;#TODO# use widht/height of texture + my ($w, $h) = $self->size_request;#TODO# use width/height of texture + my $tex = $self->{texture} or return; @@ -190,6 +191,8 @@ my $chld = $self->get; + $chld->move (2, 2, 0); #TODO:move to size_request + my ($w, $h) = $chld->size_request; glColor 1, 0, 0; @@ -200,10 +203,7 @@ glTexCoord 1, 0; glVertex $w + 4 , 0; glEnd; - glPushMatrix; - glTranslate (2, 2, 0); $chld->draw; - glPopMatrix; } package Crossfire::Client::Widget::Table; @@ -274,11 +274,11 @@ for (my $xi = 0; $xi <= $#{$self->{childs}->[$yi]}; $xi++) { - glPushMatrix; - glTranslate ($x, $y, 0);#TODO#there must be no translate here, instead the widget must be moved my $c = $self->{childs}->[$yi]->[$xi]; - $c->draw if $c; - glPopMatrix; + if ($c) { + $c->move ($x, $y, 0); #TODO: Move to size_request + $c->draw if $c; + } $x += $self->max_col_width ($xi); } @@ -316,10 +316,8 @@ my ($x, $y); for (@{$self->{childs} || []}) { - glPushMatrix; - glTranslate (0, $y, 0);# see above TODO + $_->move (0, $y, 0); #TODO: move to size_request $_->draw; - glPopMatrix; my ($w, $h) = $_->size_request; $y += $h; } @@ -332,9 +330,9 @@ use SDL::OpenGL; sub new { - my ($class, $x, $y, $z, $ttf, $text) = @_; + my ($class, $x, $y, $z, $height, $text) = @_; - my $self = $class->SUPER::new (x => $x, y => $y, z => $z, ttf => $ttf); + my $self = $class->SUPER::new (x => $x, y => $y, z => $z, height => $height); $self->set_text ($text); @@ -343,11 +341,15 @@ sub set_text { my ($self, $text) = @_; - $self->{texture} = new_from_ttf Crossfire::Client::Texture $self->{ttf}, $self->{text} = $text; + + $self->{text} = $text; + + $self->{texture} = new_from_text Crossfire::Client::Texture $text, $self->{height}; } sub get_text { my ($self, $text) = @_; + $self->{text} } @@ -370,7 +372,7 @@ glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; glBindTexture GL_TEXTURE_2D, $tex->{name}; - glColor 1, 1, 1; + glColor 1, 1, 1, 0.8; glBegin GL_QUADS; glTexCoord 0, 0; glVertex 0 , 0; @@ -435,13 +437,13 @@ my $sh = 1 + int $::HEIGHT / 32; if ($::CONN->{mapw} > $sw) { - $xofs = ($sw - $::CONN->{mapw}) * 0.5; + $xofs = $mx + ($::CONN->{mapw} - $sw) * 0.5; } else { $xofs = $self->{xofs} = min $mx, max $mx + $::CONN->{mapw} - $sw + 1, $self->{xofs}; } if ($::CONN->{maph} > $sh) { - $yofs = ($sh - $::CONN->{maph}) * 0.5; + $yofs = $my + ($::CONN->{maph} - $sh) * 0.5; } else { $yofs = $self->{yofs} = min $my, max $my + $::CONN->{maph} - $sh + 1, $self->{yofs}; } @@ -450,8 +452,6 @@ glEnable GL_BLEND; glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE; - warn "<$mx,$my> <$xofs,$yofs>\n";#d# - for my $x (0 .. $sw - 1) { for my $y (0 .. $sh - 1) {