--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/17 21:03:31 1.127 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/17 21:21:30 1.128 @@ -114,9 +114,12 @@ sub move { my ($self, $x, $y, $z) = @_; + $self->{x} = int $x; $self->{y} = int $y; $self->{z} = $z if defined $z; + + $self->update; } sub needs_redraw { @@ -128,7 +131,7 @@ Carp::confess "size_request is abtract"; } -sub _size_allocate { +sub configure { my ($self, $x, $y, $w, $h) = @_; $self->{x} = $x; @@ -139,13 +142,11 @@ $self->{w} = $w; $self->{h} = $h; - 1 + $self->size_allocate ($w, $h); } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h); + # nothing to be done } # return top left coordinates @@ -273,6 +274,9 @@ $self->{parent}->check_size if $self->{parent}; + + $self->size_allocate ($w, $h); + $self->update; } } @@ -456,11 +460,9 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; + my ($self, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; - - $self->{children}[0]->size_allocate (0, 0, $w, $h); + $self->{children}[0]->configure (0, 0, $w, $h); } ############################################################################# @@ -496,11 +498,9 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; + my ($self, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; - - $self->child->size_allocate (0, 0, $w, $h); + $self->child->configure (0, 0, $w, $h); $self->render_chld; } @@ -541,12 +541,6 @@ @$self{qw(child_w child_h)} } -sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; -} - sub _draw { my ($self) = @_; @@ -575,9 +569,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h) or return; - - $self->child->size_allocate (2, 2, $w - 4, $h - 4); + $self->child->configure (2, 2, $w - 4, $h - 4); } sub _draw { @@ -637,14 +629,12 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; $h -= List::Util::max 0, $self->{border} * 2; $w -= List::Util::max 0, $self->{border} * 2; - $self->child->size_allocate ($self->{border}, $self->{border}, $w, $h); + $self->child->configure ($self->{border}, $self->{border}, $w, $h); } sub button_down { @@ -663,7 +653,7 @@ $self->{user_w} = $bw + $x - $ox; $self->{user_h} = $bh + $y - $oy; - $self->update; + $self->check_size; }; } elsif ($x >= 0 && $x < $self->{w} @@ -803,9 +793,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; my ($ws, $hs) = $self->get_wh; @@ -837,7 +825,7 @@ my $col_w = $ws->[$c]; if (my $widget = $row->[$c]) { - $widget->size_allocate ($x, $y, $col_w, $row_h); + $widget->configure ($x, $y, $col_w, $row_h); } $x += $col_w; @@ -892,9 +880,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; ($h, $w) = ($w, $h); @@ -926,7 +912,7 @@ for (0 .. $#$children) { my $child = $children->[$_]; my $h = $h[$_]; - $child->size_allocate ($y, 0, $h, $w); + $child->configure ($y, 0, $h, $w); $y += $h; } @@ -954,9 +940,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; my $children = $self->{children}; @@ -984,7 +968,7 @@ for (0 .. $#$children) { my $child = $children->[$_]; my $h = $h[$_]; - $child->size_allocate (0, $y, $w, $h); + $child->configure (0, $y, $w, $h); $y += $h; } @@ -1065,9 +1049,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; delete $self->{texture}; } @@ -1166,9 +1148,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->SUPER::size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; $self->_set_text ($self->{text}); } @@ -1398,12 +1378,6 @@ ($self->{padding} * 2 + 6) x 2 } -sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->_size_allocate ($x, $y, $w, $h) or return; -} - sub button_down { my ($self, $ev, $x, $y) = @_; @@ -1745,9 +1719,7 @@ } sub size_allocate { - my ($self, $x, $y, $w, $h) = @_; - - $self->SUPER::size_allocate ($x, $y, $w, $h) or return; + my ($self, $w, $h) = @_; $self->{layout}->set_height ($self->{fontsize}); $self->{layout}->set_width ($self->{w}); @@ -2174,19 +2146,19 @@ sub check_size { my ($self) = @_; - $self->size_allocate (0, 0, $::WITH, $::HEIGHT); + $self->configure (0, 0, $::WITH, $::HEIGHT); } sub size_request { ($::WIDTH, $::HEIGHT) } -sub size_allocate { +sub configure { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h); + $self->SUPER::configure ($x, $y, $w, $h); - $_->size_allocate ($_->{x}, $_->{y}, $_->size_request) + $_->configure ($_->{x}, $_->{y}, $_->size_request) for @{$self->{children}}; } @@ -2204,11 +2176,9 @@ } sub add { - my ($self, $widget) = @_; - - $self->SUPER::add ($widget); + my ($self, $child) = @_; - $widget->size_allocate (int $widget->{x}, int $widget->{y}, $widget->size_request); + $self->SUPER::add ($child); } sub on_refresh {