--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/08 20:39:34 1.186 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/08 22:17:38 1.190 @@ -405,6 +405,27 @@ sub check_size { my ($self) = @_; + $self->_check_size; + return; + #TODO: but needs a vastly more difficult algorithm + my $check_size = $CFClient::UI::ROOT->{_check_size} ||= {}; + + $check_size->{$self} = $self; + + $CFClient::UI::ROOT->on_refresh (_check_size => sub { + while (%$check_size) { + my @widgets = values %$check_size; + $_->_check_size + for @widgets; + } + }); +} + +sub _check_size { + my ($self) = @_; + + delete $CFClient::UI::ROOT->{_check_size}{$self}; + $self->{parent} or return 1; @@ -416,7 +437,7 @@ $self->{req_w} = $w; $self->{req_h} = $h; - $self->{parent}->check_size + $self->{parent}->_check_size or $self->size_allocate ( (List::Util::max $self->{w}, $w), (List::Util::max $self->{h}, $h), @@ -431,8 +452,19 @@ sub update { my ($self) = @_; - $self->{parent}->update - if $self->{parent}; + my $update = $CFClient::UI::ROOT->{_update} ||= {}; + + $update->{$self} = $self; + + $CFClient::UI::ROOT->on_refresh (_update => sub { + while (%$update) { + my @widgets = values %$update; + %$update = (); + + $_->{parent} && $_->{parent}->update + for @widgets; + } + }); } sub connect { @@ -532,18 +564,21 @@ } sub add { - my ($self, $child) = @_; + my ($self, @widgets) = @_; - $child->set_parent ($self); + $_->set_parent ($self) + for @widgets; use sort 'stable'; $self->{children} = [ sort { $a->{z} <=> $b->{z} } - @{$self->{children}}, $child + @{$self->{children}}, @widgets ]; - $child->check_size; + $_->check_size + for @widgets; + $self->update; } @@ -2704,7 +2739,7 @@ if ($old_w && $old_h) { for my $child ($self->children) { $child->{x} = int 0.5 + $child->{x} * $w / $old_w; - $child->{w} = int 0.5 + $child->{req_w} * $w / $old_w; + $child->{w} = int 0.5 + $child->{w} * $w / $old_w; $child->{req_w} = int 0.5 + $child->{req_w} * $w / $old_w if exists $child->{req_w}; $child->{user_w} = int 0.5 + $child->{user_w} * $w / $old_w if exists $child->{user_w}; $child->{y} = int 0.5 + $child->{y} * $h / $old_h;