--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/09 22:00:58 1.42 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/09 22:12:11 1.43 @@ -164,7 +164,8 @@ sort { $a->{z} <=> $b->{z} } @{$self->{children}}, $chld; - $self->size_allocate ($self->{w}, $self->{h}); + $self->size_allocate ($self->{w}, $self->{h}) + if $self->{w}; #TODO: check for "realised state" } sub remove { @@ -188,19 +189,6 @@ () } -sub size_request { - my ($self) = @_; - - my ($hs, $ws) = (0, 0); - for (@{$self->{children} || []}) { - my ($w, $h) = $_->size_request; - $hs += $h; - if ($ws < $w) { $ws = $w } - } - - return ($ws, $hs); -} - sub _draw { my ($self) = @_; @@ -397,16 +385,16 @@ $h = $h < 0 ? 0 : $h; $w = $w < 0 ? 0 : $w; - warn "CHILD:$w $h\n"; + $self->child->size_allocate ($w, $h); - $self->child->move ($self->{txts}->[3]->{width}, $self->{txts}->[1]->{height}); + $self->child->move ($tex[3]->{width}, $tex[1]->{height}); } sub _draw { my ($self) = @_; - my ($w, $h) = ($self->w, $self->h); - my ($cw, $ch) = ($self->child->w, $self->child->h); + my ($w, $h) = ($self->{w}, $self->{h}); + my ($cw, $ch) = ($self->child->{w}, $self->child->{h}); glEnable GL_BLEND; glEnable GL_TEXTURE_2D; @@ -571,6 +559,17 @@ use SDL::OpenGL; +sub size_request { + my ($self) = @_; + + my @alloc = map [$_->size_request], @{$self->{children}}; + + ( + (List::Util::max map $_->[0], @alloc), + (List::Util::sum map $_->[1], @alloc), + ) +} + sub size_allocate { my ($self, $w, $h) = @_; @@ -612,16 +611,6 @@ } } -sub _draw { - my ($self) = @_; - - my ($x, $y); - for (@{$self->{children} || []}) { - $_->draw; - $y += $_->h; - } -} - ############################################################################# package Crossfire::Client::Widget::Label;