--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 22:14:13 1.77 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/11 22:49:13 1.78 @@ -202,17 +202,6 @@ warn "no draw defined for $self\n"; } -sub bbox { - my ($self) = @_; - my ($w, $h) = $self->size_request; - ( - $self->{x}, - $self->{y}, - $self->{x} = $w, - $self->{y} = $h - ) -} - sub find_widget { my ($self, $x, $y) = @_; @@ -223,8 +212,6 @@ () } -sub del_parent { $_[0]->{parent} = undef } - sub set_parent { my ($self, $par) = @_; @@ -539,10 +526,9 @@ sub size_request { my ($self) = @_; - my ($w, $h) = - $self->{user_w} && $self->{user_h} - ? ($self->{user_w}, $self->{user_h}) - : ($self->SUPER::size_request); + return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; + + my ($w, $h) = $self->SUPER::size_request; $h += $tex[1]->{h}; $h += $tex[4]->{h}; @@ -670,6 +656,15 @@ use SDL::OpenGL; +sub new { + my $class = shift; + + $class->SUPER::new ( + col_expand => [], + @_ + ) +} + sub add { my ($self, $x, $y, $chld) = @_; @@ -708,8 +703,8 @@ my ($ws, $hs) = $self->get_wh; ( - (List::Util::sum @$ws), - (List::Util::sum @$hs), + (sum @$ws), + (sum @$hs), ) } @@ -720,12 +715,17 @@ my ($ws, $hs) = $self->get_wh; - my $req_w = List::Util::sum @$ws; - my $req_h = List::Util::sum @$hs; + my $req_w = sum @$ws; + my $req_h = sum @$hs; + + # TODO: nicer code && do row_expand + my @col_expand = @{$self->{col_expand}}; + @col_expand = (1) x @$ws unless @col_expand; + my $col_expand = (sum @col_expand) || 1; # linearly scale sizes - $_ *= $w / $req_w for @$ws; - $_ *= $h / $req_h for @$hs; + $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; + $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; my $y; @@ -812,7 +812,7 @@ if ($req_h > $h) { # ah well, not enough space - $_ = $h[$_] * $h / $req_h for @h; + $_ *= $h / $req_h for @h; } else { my $exp = List::Util::sum map $_->{expand}, @$children; $exp ||= 1; @@ -870,7 +870,7 @@ if ($req_h > $h) { # ah well, not enough space - $_ = $h[$_] * $h / $req_h for @h; + $_ *= $h / $req_h for @h; } else { my $exp = List::Util::sum map $_->{expand}, @$children; $exp ||= 1; @@ -977,6 +977,7 @@ my $tex = $self->{texture} ||= do { $self->{layout}->set_width ($self->{w}); + $self->{layout}->set_height (List::Util::min $self->{h}, $self->{height}); new_from_layout CFClient::Texture $self->{layout} };