--- deliantra/Deliantra-Client/DC/UI.pm 2006/05/30 02:55:45 1.258 +++ deliantra/Deliantra-Client/DC/UI.pm 2006/05/30 07:13:09 1.259 @@ -221,10 +221,10 @@ } if (my $layout = $CFClient::UI::LAYOUT->{$self->{name}}) { - $self->{x} = $layout->{x} * $CFClient::UI::ROOT->{w} if exists $layout->{x}; - $self->{y} = $layout->{y} * $CFClient::UI::ROOT->{h} if exists $layout->{y}; - $self->{force_w} = $layout->{w} * $CFClient::UI::ROOT->{w} if exists $layout->{w}; - $self->{force_h} = $layout->{h} * $CFClient::UI::ROOT->{h} if exists $layout->{h}; + $self->{x} = $layout->{x} * $CFClient::UI::ROOT->{alloc_w} if exists $layout->{x}; + $self->{y} = $layout->{y} * $CFClient::UI::ROOT->{alloc_h} if exists $layout->{y}; + $self->{force_w} = $layout->{w} * $CFClient::UI::ROOT->{alloc_w} if exists $layout->{w}; + $self->{force_h} = $layout->{h} * $CFClient::UI::ROOT->{alloc_h} if exists $layout->{h}; $self->{x} -= $self->{force_w} * 0.5 if exists $layout->{x}; $self->{y} -= $self->{force_h} * 0.5 if exists $layout->{y}; @@ -357,10 +357,13 @@ $self->update; } - if ($self->{w} != $w || $self->{h} != $h) { + if ($self->{alloc_w} != $w || $self->{alloc_h} != $h) { return unless $self->{visible}; - $self->{root}->{size_alloc}{$self+0} = [$self, $w, $h]; + $self->{alloc_w} = $w; + $self->{alloc_h} = $h; + + $self->{root}{size_alloc}{$self+0} = $self; } } @@ -500,12 +503,13 @@ my ($self) = @_; if ($self->{visible}) { - return if $self->{root}{realloc}{$self}; + return if $self->{root}{realloc}{$self+0}; - $self->{root}{realloc}{$self} = $self; + $self->{root}{realloc}{$self+0} = $self; $self->{root}->update; } else { delete $self->{req_w}; + delete $self->{req_h}; } } @@ -548,7 +552,7 @@ glDisable GL_BLEND; } - if ($ENV{CFPLUS_DEBUG}) { + if ($ENV{CFPLUS_DEBUG} & 1) { glPushMatrix; glColor 1, 1, 0, 1; glTranslate $self->{x} + 0.375, $self->{y} + 0.375; @@ -767,7 +771,7 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; $self->{children}[0]->configure (0, 0, $w, $h); } @@ -794,11 +798,10 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; - $self->SUPER::size_allocate ($w, $h, $changed); - $self->update - if $changed; + $self->SUPER::size_allocate ($w, $h); + $self->update; } sub _render { @@ -852,7 +855,7 @@ sub size_request { my ($self) = @_; - my ($w, $h) = @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; + my ($w, $h) = @{$self->child}{qw(req_w req_h)}; $w = 10 if $self->{scroll_x}; $h = 10 if $self->{scroll_y}; @@ -861,10 +864,12 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; + + my $child = $self->child; - $w = $self->{child_w} if $self->{scroll_x} && $self->{child_w}; - $h = $self->{child_h} if $self->{scroll_y} && $self->{child_h}; + $w = $child->{req_w} if $self->{scroll_x} && $child->{req_w}; + $h = $child->{req_h} if $self->{scroll_y} && $child->{req_h}; $self->child->configure (0, 0, $w, $h); $self->update; @@ -958,9 +963,9 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; - $self->SUPER::size_allocate ($w, $h, $changed); + $self->SUPER::size_allocate ($w, $h); my $child = $self->{vp}->child; $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $child->{h}, $self->{vp}{h}, 1]); @@ -1063,9 +1068,7 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; - - return unless $changed; + my ($self, $w, $h) = @_; $h -= List::Util::max 0, $self->border * 2; $w -= List::Util::max 0, $self->border * 2; @@ -1247,7 +1250,7 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; my ($ws, $hs) = $self->get_wh; @@ -1335,7 +1338,7 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; my $space = $self->{vertical} ? $h : $w; my $children = $self->{children}; @@ -1519,10 +1522,9 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; - delete $self->{texture} - if $changed; + delete $self->{texture}; } sub set_fontsize { @@ -2384,11 +2386,9 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; - - $self->SUPER::size_allocate ($w, $h, $changed); + my ($self, $w, $h) = @_; - return unless $changed; + $self->SUPER::size_allocate ($w, $h); $self->{layout}->set_font ($self->{font}) if $self->{font}; $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); @@ -2621,8 +2621,17 @@ sub set_tooltip_from { my ($self, $widget) = @_; + my $tooltip = $widget->{tooltip}; + + if ($ENV{CFPLUS_DEBUG} & 2) { + $tooltip .= "\n\n" . (ref $widget) . "\n" + . "$widget->{x} $widget->{y} $widget->{w} $widget->{h}\n" + . "req $widget->{req_w} $widget->{req_h}\n" + . "visible $widget->{visible}"; + } + $self->add (new CFClient::UI::Label - markup => $widget->{tooltip}, + markup => $tooltip, max_w => ($widget->{tooltip_width} || 0.25) * $::WIDTH, fontsize => 0.8, fg => [0, 0, 0, 1], @@ -2640,11 +2649,9 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; - - return unless $changed; + my ($self, $w, $h) = @_; - $self->SUPER::size_allocate ($w - 4, $h - 4, $changed); + $self->SUPER::size_allocate ($w - 4, $h - 4); } sub visibility_change { @@ -3018,22 +3025,6 @@ $self } -sub configure { - my ($self, $x, $y, $w, $h) = @_; - - $self->{w} = $w; - $self->{h} = $h; -} - -sub reconfigure { - my ($self) = @_; - - $self->SUPER::reconfigure; - - $self->size_allocate ($self->{w}, $self->{h}, 1) - if $self->{w}; -} - sub size_request { my ($self) = @_; @@ -3055,7 +3046,7 @@ } sub size_allocate { - my ($self, $w, $h, $changed) = @_; + my ($self, $w, $h) = @_; for my $child ($self->children) { my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; @@ -3139,6 +3130,8 @@ if ($self->{realloc}) { #TODO use array-of-depth approach + use sort 'stable'; + @queue = sort { $a->{visible} <=> $b->{visible} } @queue, values %{delete $self->{realloc}}; } @@ -3155,25 +3148,33 @@ $w = $widget->{force_w} if exists $widget->{force_w}; $h = $widget->{force_h} if exists $widget->{force_h}; - $widget->{req_w} = $w; - $widget->{req_h} = $h; - - $self->{size_alloc}{$widget} = [$widget, undef, undef]; + if ($widget->{req_w} != $w || $widget->{req_h} != $h + || delete $widget->{force_realloc}) { + $widget->{req_w} = $w; + $widget->{req_h} = $h; + + $self->{size_alloc}{$widget+0} = $widget; + + if (my $parent = $widget->{parent}) { + $self->{realloc}{$parent+0} = $parent; + #unshift @queue, $parent; + $parent->{force_size_alloc} = 1; + $self->{size_alloc}{$parent+0} = $parent; + } + } - push @queue, $widget->{parent} - if ($self->{w} != $w || $self->{h} != $h) && $widget->{parent}; + delete $self->{realloc}{$widget+0}; } } while (my $size_alloc = delete $self->{size_alloc}) { - my @queue = sort $b->[0]{visible} <=> $a->[0]{visible}, + my @queue = sort { $b->{visible} <=> $a->{visible} } values %$size_alloc; while () { - my ($widget, $w, $h) = @{ pop @queue or last }; + my $widget = pop @queue || last; - $w = $widget->{w} || $widget->{req_w} unless defined $w; - $h = $widget->{h} || $widget->{req_h} unless defined $h; + my ($w, $h) = @$widget{qw(alloc_w alloc_h)}; $w = 0 if $w < 0; $h = 0 if $h < 0; @@ -3181,12 +3182,12 @@ $w = int $w + 0.5; $h = int $h + 0.5; - my $changed = $widget->{w} != $w || $widget->{h} != $h; - - $widget->{w} = $w; - $widget->{h} = $h; + if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { + $widget->{w} = $w; + $widget->{h} = $h; - $widget->emit (size_allocate => $w, $h, $changed); + $widget->emit (size_allocate => $w, $h); + } } } @@ -3195,6 +3196,7 @@ for values %{delete $self->{post_alloc_hook}}; } + glViewport 0, 0, $::WIDTH, $::HEIGHT; glClearColor +($::CFG->{fow_intensity}) x 3, 1; glClear GL_COLOR_BUFFER_BIT;