--- deliantra/Deliantra-Client/DC/UI.pm 2006/04/17 20:29:37 1.124 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/04/17 20:52:15 1.125 @@ -262,6 +262,20 @@ Scalar::Util::weaken ($self->{parent} = $parent); } +sub check_size { + my ($self) = @_; + + my ($w, $h) = $self->size_request; + + if ($w != $self->{req_w} || $h != $self->{req_h}) { + $self->{req_w} = $w; + $self->{req_h} = $h; + + $self->{parent}->check_size + if $self->{parent}; + } +} + sub update { my ($self) = @_; @@ -378,7 +392,7 @@ $self->{children} = [ grep $_ != $widget, @{ $self->{children} } ]; - $self->size_allocate (0, 0, $self->{w}, $self->{h}); + $self->check_size; } sub find_widget { @@ -511,6 +525,36 @@ ############################################################################# +package CFClient::UI::ViewPort; + +our @ISA = CFClient::UI::Window::; + +sub new { die } + +sub size_request { + my ($self) = @_; + + @$self{qw(child_w child_h)} = $self->child->size_request; + $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); + + @$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) = @_; + + $self->{children}[1]->draw; +} + + +############################################################################# + package CFClient::UI::Frame; our @ISA = CFClient::UI::Bin::; @@ -848,7 +892,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h); + $self->_size_allocate ($x, $y, $w, $h) or return; ($h, $w) = ($w, $h); @@ -884,6 +928,8 @@ $y += $h; } + + 1 } ############################################################################# @@ -908,7 +954,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h); + $self->_size_allocate ($x, $y, $w, $h) or return; my $children = $self->{children}; @@ -940,6 +986,8 @@ $y += $h; } + + 1 } ############################################################################# @@ -1118,7 +1166,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->SUPER::size_allocate ($x, $y, $w, $h); + $self->SUPER::size_allocate ($x, $y, $w, $h) or return; $self->_set_text ($self->{text}); } @@ -1349,7 +1397,7 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->_size_allocate ($x, $y, $w, $h); + $self->_size_allocate ($x, $y, $w, $h) or return; } sub button_down { @@ -1692,12 +1740,13 @@ sub size_allocate { my ($self, $x, $y, $w, $h) = @_; - $self->SUPER::size_allocate ($x, $y, $w, $h); + $self->SUPER::size_allocate ($x, $y, $w, $h) or return; $self->{layout}->set_height ($self->{fontsize}); $self->{layout}->set_width ($self->{w}); $self->reflow; + $self->update; } sub add_paragraph { @@ -2115,6 +2164,12 @@ use SDL::OpenGL; +sub check_size { + my ($self) = @_; + + $self->size_allocate (0, 0, $::WITH, $::HEIGHT); +} + sub size_request { ($::WIDTH, $::HEIGHT) } @@ -2137,7 +2192,7 @@ sub update { my ($self) = @_; - $self->size_allocate (0, 0, $::WIDTH, $::HEIGHT); + $self->check_size; ::refresh (); }