ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.265 by root, Thu Jun 1 02:59:46 2006 UTC vs.
Revision 1.266 by root, Thu Jun 1 03:42:58 2006 UTC

40 40
41 $LAYOUT = $layout; 41 $LAYOUT = $layout;
42} 42}
43 43
44sub check_tooltip { 44sub check_tooltip {
45 return if $ENV{CFPLUS_DEBUG} & 8;
46
45 if (!$GRAB) { 47 if (!$GRAB) {
46 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 48 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
47 if (length $widget->{tooltip}) { 49 if (length $widget->{tooltip}) {
48
49 if ($TOOLTIP->{owner} != $widget) { 50 if ($TOOLTIP->{owner} != $widget) {
50 $TOOLTIP->hide; 51 $TOOLTIP->hide;
51 52
52 $TOOLTIP->{owner} = $widget; 53 $TOOLTIP->{owner} = $widget;
53 54
1523 1524
1524sub size_allocate { 1525sub size_allocate {
1525 my ($self, $w, $h) = @_; 1526 my ($self, $w, $h) = @_;
1526 1527
1527 delete $self->{texture} 1528 delete $self->{texture}
1528 ;#d# 1529 unless $w >= $self->{req_w} && $self->{old_w} >= $self->{req_w};
1529} 1530}
1530 1531
1531sub set_fontsize { 1532sub set_fontsize {
1532 my ($self, $fontsize) = @_; 1533 my ($self, $fontsize) = @_;
1533 1534
3372 $_->() 3373 $_->()
3373 for values %{delete $self->{refresh_hook}}; 3374 for values %{delete $self->{refresh_hook}};
3374 } 3375 }
3375 3376
3376 if ($self->{realloc}) { 3377 if ($self->{realloc}) {
3378 my %queue;
3377 my @queue; 3379 my @queue;
3380 my $widget;
3378 3381
3382 outer:
3379 while () { 3383 while () {
3380 if ($self->{realloc}) { 3384 if (my $realloc = delete $self->{realloc}) {
3381 #TODO use array-of-depth approach 3385 for $widget (values %$realloc) {
3386 $widget->{visible} or next; # do not resize invisible widgets
3382 3387
3383 use sort 'stable'; 3388 $queue{$widget+0}++ and next; # duplicates are common
3384 3389
3385 @queue = sort { $a->{visible} <=> $b->{visible} } 3390 push @{ $queue[$widget->{visible}] }, $widget;
3386 @queue, values %{delete $self->{realloc}}; 3391 }
3387 } 3392 }
3388 3393
3394 while () {
3395 @queue or last outer;
3396
3389 my $widget = pop @queue || last; 3397 $widget = pop @{ $queue[-1] || [] }
3398 and last;
3399
3400 pop @queue;
3401 }
3390 3402
3391 $widget->{visible} or last; # do not resize invisible widgets 3403 delete $queue{$widget+0};
3392 3404
3393 my ($w, $h) = $widget->size_request; 3405 my ($w, $h) = $widget->size_request;
3394 3406
3395 $w = List::Util::max $widget->{min_w}, $w + $widget->{padding_x} * 2; 3407 $w = List::Util::max $widget->{min_w}, $w + $widget->{padding_x} * 2;
3396 $h = List::Util::max $widget->{min_h}, $h + $widget->{padding_y} * 2; 3408 $h = List::Util::max $widget->{min_h}, $h + $widget->{padding_y} * 2;
3404 $widget->{req_h} = $h; 3416 $widget->{req_h} = $h;
3405 3417
3406 $self->{size_alloc}{$widget+0} = $widget; 3418 $self->{size_alloc}{$widget+0} = $widget;
3407 3419
3408 if (my $parent = $widget->{parent}) { 3420 if (my $parent = $widget->{parent}) {
3409 $self->{realloc}{$parent+0} = $parent; 3421 $self->{realloc}{$parent+0} = $parent
3410 #unshift @queue, $parent; 3422 unless $queue{$parent+0};
3423
3411 $parent->{force_size_alloc} = 1; 3424 $parent->{force_size_alloc} = 1;
3412 $self->{size_alloc}{$parent+0} = $parent; 3425 $self->{size_alloc}{$parent+0} = $parent;
3413 } 3426 }
3414 } 3427 }
3415 3428
3431 3444
3432 $w = int $w + 0.5; 3445 $w = int $w + 0.5;
3433 $h = int $h + 0.5; 3446 $h = int $h + 0.5;
3434 3447
3435 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) { 3448 if ($widget->{w} != $w || $widget->{h} != $h || delete $widget->{force_size_alloc}) {
3449 $widget->{old_w} = $widget->{w};
3450 $widget->{old_h} = $widget->{h};
3451
3436 $widget->{w} = $w; 3452 $widget->{w} = $w;
3437 $widget->{h} = $h; 3453 $widget->{h} = $h;
3438 3454
3439 $widget->emit (size_allocate => $w, $h); 3455 $widget->emit (size_allocate => $w, $h);
3440 } 3456 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines