… | |
… | |
47 | my $tip = $widget->{tooltip}; |
47 | my $tip = $widget->{tooltip}; |
48 | |
48 | |
49 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
49 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
50 | |
50 | |
51 | $TOOLTIP->set_tooltip_from ($widget); |
51 | $TOOLTIP->set_tooltip_from ($widget); |
52 | $TOOLTIP->show; |
|
|
53 | |
52 | |
54 | my ($x, $y) = $widget->coord2global ($widget->{w}, 0); |
53 | my ($x, $y) = $widget->coord2global ($widget->{w}, 0); |
55 | |
54 | |
56 | ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0) |
55 | ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0) |
57 | if $x + $TOOLTIP->{w} > $::WIDTH; |
56 | if $x + $TOOLTIP->{w} > $::WIDTH; |
58 | |
57 | |
59 | $TOOLTIP->move ($x, $y); |
58 | $TOOLTIP->move ($x, $y); |
60 | $TOOLTIP->realloc; |
59 | $TOOLTIP->show; |
61 | } |
60 | } |
62 | |
61 | |
63 | return; |
62 | return; |
64 | } |
63 | } |
65 | } |
64 | } |
… | |
… | |
257 | $self->{root} = $self->{parent}{root}; |
256 | $self->{root} = $self->{parent}{root}; |
258 | $self->{visible} = $self->{parent}{visible} + 1; |
257 | $self->{visible} = $self->{parent}{visible} + 1; |
259 | |
258 | |
260 | $self->emit (visibility_change => 1); |
259 | $self->emit (visibility_change => 1); |
261 | |
260 | |
262 | $self->realloc unless exists $self->{req_w}; |
261 | $self->realloc if !exists $self->{req_w}; |
263 | |
262 | |
264 | $_->set_visible for $self->children; |
263 | $_->set_visible for $self->children; |
265 | } |
264 | } |
266 | |
265 | |
267 | sub set_invisible { |
266 | sub set_invisible { |
… | |
… | |
469 | my ($self, $parent) = @_; |
468 | my ($self, $parent) = @_; |
470 | |
469 | |
471 | Scalar::Util::weaken ($self->{parent} = $parent); |
470 | Scalar::Util::weaken ($self->{parent} = $parent); |
472 | |
471 | |
473 | $self->set_visible if $parent->{visible}; |
472 | $self->set_visible if $parent->{visible}; |
474 | |
|
|
475 | $self->realloc; |
|
|
476 | } |
473 | } |
477 | |
474 | |
478 | sub connect { |
475 | sub connect { |
479 | my ($self, $signal, $cb) = @_; |
476 | my ($self, $signal, $cb) = @_; |
480 | |
477 | |
… | |
… | |
499 | } |
496 | } |
500 | |
497 | |
501 | sub realloc { |
498 | sub realloc { |
502 | my ($self) = @_; |
499 | my ($self) = @_; |
503 | |
500 | |
504 | return unless $self->{visible}; |
501 | if ($self->{visible}) { |
505 | |
|
|
506 | return if $self->{root}{realloc}{$self}; |
502 | return if $self->{root}{realloc}{$self}; |
507 | |
503 | |
508 | $self->{root}{realloc}{$self} = $self; |
504 | $self->{root}{realloc}{$self} = $self; |
509 | $self->{root}->update; |
505 | $self->{root}->update; |
|
|
506 | } else { |
|
|
507 | delete $self->{req_w}; |
|
|
508 | } |
510 | } |
509 | } |
511 | |
510 | |
512 | sub update { |
511 | sub update { |
513 | my ($self) = @_; |
512 | my ($self) = @_; |
514 | |
513 | |
… | |
… | |
1469 | |
1468 | |
1470 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1469 | $self->{layout} = new CFClient::Layout if $self->{layout}->is_rgba; |
1471 | $self->{layout}->set_text ($text); |
1470 | $self->{layout}->set_text ($text); |
1472 | |
1471 | |
1473 | $self->realloc; |
1472 | $self->realloc; |
|
|
1473 | $self->update; |
1474 | } |
1474 | } |
1475 | |
1475 | |
1476 | sub set_markup { |
1476 | sub set_markup { |
1477 | my ($self, $markup) = @_; |
1477 | my ($self, $markup) = @_; |
1478 | |
1478 | |
… | |
… | |
1483 | |
1483 | |
1484 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1484 | $self->{layout} = new CFClient::Layout $rgba if $self->{layout}->is_rgba != $rgba; |
1485 | $self->{layout}->set_markup ($markup); |
1485 | $self->{layout}->set_markup ($markup); |
1486 | |
1486 | |
1487 | $self->realloc; |
1487 | $self->realloc; |
|
|
1488 | $self->update; |
1488 | } |
1489 | } |
1489 | |
1490 | |
1490 | sub size_request { |
1491 | sub size_request { |
1491 | my ($self) = @_; |
1492 | my ($self) = @_; |
1492 | |
1493 | |
… | |
… | |
2664 | glVertex $w, $h; |
2665 | glVertex $w, $h; |
2665 | glVertex $w, 0; |
2666 | glVertex $w, 0; |
2666 | glEnd; |
2667 | glEnd; |
2667 | |
2668 | |
2668 | glTranslate 2 - 0.375, 2 - 0.375; |
2669 | glTranslate 2 - 0.375, 2 - 0.375; |
|
|
2670 | |
2669 | $self->SUPER::_draw; |
2671 | $self->SUPER::_draw; |
2670 | } |
2672 | } |
2671 | |
2673 | |
2672 | ############################################################################# |
2674 | ############################################################################# |
2673 | |
2675 | |
… | |
… | |
3123 | Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d# |
3125 | Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d# |
3124 | |
3126 | |
3125 | $widget->{req_w} = $w; |
3127 | $widget->{req_w} = $w; |
3126 | $widget->{req_h} = $h; |
3128 | $widget->{req_h} = $h; |
3127 | |
3129 | |
3128 | $self->{size_alloc}{$widget} = [$widget, $widget->{w}, $widget->{h}]; |
3130 | $self->{size_alloc}{$widget} = [$widget, $widget->{w} || $w, $widget->{h} || $h]; |
3129 | |
3131 | |
3130 | push @queue, $widget->{parent} |
3132 | push @queue, $widget->{parent} |
3131 | if $widget->{parent}; |
3133 | if $widget->{parent}; |
3132 | } |
3134 | } |
3133 | } |
3135 | } |
… | |
… | |
3140 | my ($widget, $w, $h) = @{ pop @queue or last }; |
3142 | my ($widget, $w, $h) = @{ pop @queue or last }; |
3141 | |
3143 | |
3142 | $w = 0 if $w < 0; |
3144 | $w = 0 if $w < 0; |
3143 | $h = 0 if $h < 0; |
3145 | $h = 0 if $h < 0; |
3144 | |
3146 | |
|
|
3147 | my $changed = $widget->{w} != $w || $widget->{h} != $h; |
|
|
3148 | |
3145 | $widget->{w} = $w; |
3149 | $widget->{w} = $w; |
3146 | $widget->{h} = $h; |
3150 | $widget->{h} = $h; |
|
|
3151 | |
3147 | $widget->emit (size_allocate => $w, $h, 1); |
3152 | $widget->emit (size_allocate => $w, $h, $changed); |
3148 | } |
3153 | } |
3149 | } |
3154 | } |
3150 | |
3155 | |
3151 | while ($self->{post_alloc_hook}) { |
3156 | while ($self->{post_alloc_hook}) { |
3152 | $_->() |
3157 | $_->() |