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.186 by root, Mon May 8 20:39:34 2006 UTC vs.
Revision 1.189 by root, Mon May 8 22:17:24 2006 UTC

403} 403}
404 404
405sub check_size { 405sub check_size {
406 my ($self) = @_; 406 my ($self) = @_;
407 407
408 $self->_check_size;
409 return;
410 my $check_size = $CFClient::UI::ROOT->{_check_size} ||= {};
411
412 $check_size->{$self} = $self;
413
414 $CFClient::UI::ROOT->on_refresh (_check_size => sub {
415 while (%$check_size) {
416 my @widgets = values %$check_size;
417 $_->_check_size
418 for @widgets;
419 }
420 });
421}
422
423sub _check_size {
424 my ($self) = @_;
425
426 delete $CFClient::UI::ROOT->{_check_size}{$self};
427
408 $self->{parent} 428 $self->{parent}
409 or return 1; 429 or return 1;
410 430
411 my ($w, $h) = $self->{user_w} && $self->{user_h} 431 my ($w, $h) = $self->{user_w} && $self->{user_h}
412 ? @$self{qw(user_w user_h)} 432 ? @$self{qw(user_w user_h)}
414 434
415 if ($w != $self->{req_w} || $h != $self->{req_h}) { 435 if ($w != $self->{req_w} || $h != $self->{req_h}) {
416 $self->{req_w} = $w; 436 $self->{req_w} = $w;
417 $self->{req_h} = $h; 437 $self->{req_h} = $h;
418 438
419 $self->{parent}->check_size 439 $self->{parent}->_check_size
420 or $self->size_allocate ( 440 or $self->size_allocate (
421 (List::Util::max $self->{w}, $w), 441 (List::Util::max $self->{w}, $w),
422 (List::Util::max $self->{h}, $h), 442 (List::Util::max $self->{h}, $h),
423 ); 443 );
424 444
429} 449}
430 450
431sub update { 451sub update {
432 my ($self) = @_; 452 my ($self) = @_;
433 453
434 $self->{parent}->update 454 my $update = $CFClient::UI::ROOT->{_update} ||= {};
435 if $self->{parent}; 455
456 $update->{$self} = $self;
457
458 $CFClient::UI::ROOT->on_refresh (_update => sub {
459 while (%$update) {
460 my @widgets = values %$update;
461 %$update = ();
462
463 $_->{parent} && $_->{parent}->update
464 for @widgets;
465 }
466 });
436} 467}
437 468
438sub connect { 469sub connect {
439 my ($self, $signal, $cb) = @_; 470 my ($self, $signal, $cb) = @_;
440 471
530 561
531 $self 562 $self
532} 563}
533 564
534sub add { 565sub add {
535 my ($self, $child) = @_; 566 my ($self, @widgets) = @_;
536 567
537 $child->set_parent ($self); 568 $_->set_parent ($self)
569 for @widgets;
538 570
539 use sort 'stable'; 571 use sort 'stable';
540 572
541 $self->{children} = [ 573 $self->{children} = [
542 sort { $a->{z} <=> $b->{z} } 574 sort { $a->{z} <=> $b->{z} }
543 @{$self->{children}}, $child 575 @{$self->{children}}, @widgets
544 ]; 576 ];
545 577
546 $child->check_size; 578 $_->check_size
579 for @widgets;
580
547 $self->update; 581 $self->update;
548} 582}
549 583
550sub children { 584sub children {
551 @{ $_[0]{children} } 585 @{ $_[0]{children} }
2702 my $old_h = $self->{old_h}; 2736 my $old_h = $self->{old_h};
2703 2737
2704 if ($old_w && $old_h) { 2738 if ($old_w && $old_h) {
2705 for my $child ($self->children) { 2739 for my $child ($self->children) {
2706 $child->{x} = int 0.5 + $child->{x} * $w / $old_w; 2740 $child->{x} = int 0.5 + $child->{x} * $w / $old_w;
2707 $child->{w} = int 0.5 + $child->{req_w} * $w / $old_w; 2741 $child->{w} = int 0.5 + $child->{w} * $w / $old_w;
2708 $child->{req_w} = int 0.5 + $child->{req_w} * $w / $old_w if exists $child->{req_w}; 2742 $child->{req_w} = int 0.5 + $child->{req_w} * $w / $old_w if exists $child->{req_w};
2709 $child->{user_w} = int 0.5 + $child->{user_w} * $w / $old_w if exists $child->{user_w}; 2743 $child->{user_w} = int 0.5 + $child->{user_w} * $w / $old_w if exists $child->{user_w};
2710 $child->{y} = int 0.5 + $child->{y} * $h / $old_h; 2744 $child->{y} = int 0.5 + $child->{y} * $h / $old_h;
2711 $child->{h} = int 0.5 + $child->{h} * $h / $old_h; 2745 $child->{h} = int 0.5 + $child->{h} * $h / $old_h;
2712 $child->{req_h} = int 0.5 + $child->{req_h} * $h / $old_h if exists $child->{req_h}; 2746 $child->{req_h} = int 0.5 + $child->{req_h} * $h / $old_h if exists $child->{req_h};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines