--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/28 22:24:24 1.251 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/29 01:53:23 1.254 @@ -42,6 +42,8 @@ if (length $widget->{tooltip}) { if ($TOOLTIP->{owner} != $widget) { + $TOOLTIP->hide; + $TOOLTIP->{owner} = $widget; my $tip = $widget->{tooltip}; @@ -50,14 +52,6 @@ $TOOLTIP->set_tooltip_from ($widget); $TOOLTIP->show; - - my ($x, $y) = $widget->coord2global ($widget->{w}, 0); - - ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0) - if $x + $TOOLTIP->{w} > $::WIDTH; - - $TOOLTIP->move ($x, $y); - $TOOLTIP->realloc; } return; @@ -259,7 +253,7 @@ $self->emit (visibility_change => 1); - $self->realloc unless exists $self->{req_w}; + $self->realloc if !exists $self->{req_w}; $_->set_visible for $self->children; } @@ -471,8 +465,6 @@ Scalar::Util::weaken ($self->{parent} = $parent); $self->set_visible if $parent->{visible}; - - $self->realloc; } sub connect { @@ -501,12 +493,14 @@ sub realloc { my ($self) = @_; - return unless $self->{visible}; + if ($self->{visible}) { + return if $self->{root}{realloc}{$self}; - return if $self->{root}{realloc}{$self}; - - $self->{root}{realloc}{$self} = $self; - $self->{root}->update; + $self->{root}{realloc}{$self} = $self; + $self->{root}->update; + } else { + delete $self->{req_w}; + } } sub update { @@ -1471,6 +1465,7 @@ $self->{layout}->set_text ($text); $self->realloc; + $self->update; } sub set_markup { @@ -1485,6 +1480,7 @@ $self->{layout}->set_markup ($markup); $self->realloc; + $self->update; } sub size_request { @@ -2642,6 +2638,24 @@ $self->SUPER::size_allocate ($w - 4, $h - 4, $changed); } +sub visibility_change { + my ($self, $visible) = @_; + + return unless $visible; + + $self->{root}->on_post_alloc ("move_$self" => sub { + my $widget = $self->{owner} + or return; + + my ($x, $y) = $widget->coord2global ($widget->{w}, 0); + + ($x, $y) = $widget->coord2global (-$self->{w}, 0) + if $x + $self->{w} > $::WIDTH; + + $self->move ($x, $y); + }); +} + sub _draw { my ($self) = @_; @@ -2666,6 +2680,7 @@ glEnd; glTranslate 2 - 0.375, 2 - 0.375; + $self->SUPER::_draw; } @@ -3125,7 +3140,7 @@ $widget->{req_w} = $w; $widget->{req_h} = $h; - $self->{size_alloc}{$widget} = [$widget, $widget->{w}, $widget->{h}]; + $self->{size_alloc}{$widget} = [$widget, $widget->{w} || $w, $widget->{h} || $h]; push @queue, $widget->{parent} if $widget->{parent}; @@ -3142,9 +3157,12 @@ $w = 0 if $w < 0; $h = 0 if $h < 0; + my $changed = $widget->{w} != $w || $widget->{h} != $h; + $widget->{w} = $w; $widget->{h} = $h; - $widget->emit (size_allocate => $w, $h, 1); + + $widget->emit (size_allocate => $w, $h, $changed); } }