--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/28 00:40:51 1.246 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/28 01:16:04 1.247 @@ -247,17 +247,16 @@ $CFClient::UI::ROOT->add ($self); } -sub show_centered { +sub center { my ($self) = @_; - return if $self->{parent}; - - $self->show; $CFClient::UI::ROOT->on_post_alloc ( - "centered $self" => sub { + "center_$self" => sub { $self->move (($::WIDTH - $self->{w}) * 0.5, ($::HEIGHT - $self->{h}) * 0.5); }, ); + + $self->update; } sub set_visible { @@ -511,10 +510,9 @@ Scalar::Util::weaken ($self->{parent} = $parent); - $self->set_visible; + $self->set_visible; #TODO why breakssssss borked damn if $parent->{visible}; $self->check_size; - $self->show; } sub check_size { @@ -837,9 +835,12 @@ sub size_request { my ($self) = @_; - @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; + my ($w, $h) = @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; + + $w = 10 if $self->{scroll_x}; + $h = 10 if $self->{scroll_y}; - @$self{qw(child_w child_h)} + ($w, $h) } sub size_allocate { @@ -1326,17 +1327,25 @@ my $space = $self->{vertical} ? $h : $w; my $children = $self->{children}; - my @req = map $_->{$self->{vertical} ? "req_h" : "req_w"}, @$children; - my $req = List::Util::sum @req; + my @req; - if ($req > $space) { - # ah well, not enough space - $_ *= $space / $req for @req; + if ($self->{homogeneous}) { + @req = ($space / (@$children || 1)) x @$children; } else { - my $expand = (List::Util::sum map $_->{expand}, @$children) || 1; - - $req[$_] += ($space - $req) * $children->[$_]{expand} / $expand - for 0 .. $#$children; + @req = map $_->{$self->{vertical} ? "req_h" : "req_w"}, @$children; + my $req = List::Util::sum @req; + + if ($req > $space) { + # ah well, not enough space + $_ *= $space / $req for @req; + } else { + my $expand = (List::Util::sum map $_->{expand}, @$children) || 1; + + $space = ($space - $req) / $expand; # remaining space to give away + + $req[$_] += $space * $children->[$_]{expand} + for 0 .. $#$children; + } } CFClient::UI::harmonize \@req;