--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/21 15:03:46 1.146 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/22 12:14:45 1.148 @@ -142,7 +142,7 @@ sub size_request { require Carp; - Carp::confess "size_request is abtract"; + Carp::confess "size_request is abstract"; } sub configure { @@ -154,8 +154,8 @@ # use alignment to adjust x, y - $x += ($w - $w2) * 0.5; - $y += ($h - $h2) * 0.5; + $x += int +($w - $w2) * 0.5; + $y += int +($h - $h2) * 0.5; ($w, $h) = ($w2, $h2); } @@ -584,38 +584,60 @@ use CFClient::OpenGL; -sub size_request { - my ($self) = @_; - my $chld = $self->child - or return (0, 0); +sub new { + my $class = shift; - $chld->move (2, 2); + my $self = $class->SUPER::new ( + bg => [1, 1, 1, 1], + border_bg => [1, 1, 1, 1], + border => 0.8, + @_ + ); - map { $_ + 4 } $chld->size_request; + $self +} + +sub set_size { + my ($self, $w, $h) = @_; + $self->{req_w} = $w; + $self->{req_h} = $h; + $self->check_size; +} + +sub size_request { + my ($self) = @_; + ($self->{req_w}, $self->{req_h}) } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->child->configure (2, 2, $w - 4, $h - 4); + my ($self, $w, $h) = @_; + $self->{w} = $w; + $self->{h} = $h; + $self->child->configure (0, 0, $w, $h); } sub _draw { my ($self) = @_; - my $chld = $self->child; + my ($w, $h) = ($self->{w}, $self->{h}); - my ($w, $h) = $chld->size_request; + glEnable GL_BLEND; + glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; + glEnable GL_TEXTURE_2D; + glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; + +# glBegin GL_QUADS; +# glColor 0, 0, 0, 0; +# glVertex 0 , 0; +# glVertex 0 , $h; +# glVertex $w, $h; +# glVertex $w, 0; +# glEnd; - glBegin GL_QUADS; - glColor 0, 0, 0; - glVertex 0 , 0; - glVertex 0 , $h + 4; - glVertex $w + 4 , $h + 4; - glVertex $w + 4 , 0; - glEnd; - $chld->draw; + $self->child->draw; + glDisable GL_BLEND; + glDisable GL_TEXTURE_2D; } ############################################################################# @@ -1117,7 +1139,7 @@ my ($self, $fontsize) = @_; $self->{fontsize} = $fontsize; - $self->update; + $self->check_size; } sub _draw { @@ -1490,6 +1512,8 @@ my $tex = $self->{tex} = $loaded_images{$self->{image}}; + Scalar::Util::weaken $loaded_images{$self->{image}}; + $self->{aspect} = $tex->{w} / $tex->{h}; $self @@ -1666,7 +1690,6 @@ $self->{value}->set_fontsize ($fsize); $self->{max} ->set_fontsize ($fsize); - $self->update; } sub set_value {