… | |
… | |
294 | } |
294 | } |
295 | |
295 | |
296 | sub check_size { |
296 | sub check_size { |
297 | my ($self) = @_; |
297 | my ($self) = @_; |
298 | |
298 | |
|
|
299 | return unless $self->{parent}; |
|
|
300 | |
299 | my ($w, $h) = $self->size_request; |
301 | my ($w, $h) = $self->size_request; |
300 | |
302 | |
301 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
303 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
302 | $self->{req_w} = $w; |
304 | $self->{req_w} = $w; |
303 | $self->{req_h} = $h; |
305 | $self->{req_h} = $h; |
304 | |
306 | |
305 | $self->{parent}->check_size |
307 | $self->{parent}->check_size; |
306 | if $self->{parent}; |
|
|
307 | } |
308 | } |
308 | } |
309 | } |
309 | |
310 | |
310 | sub update { |
311 | sub update { |
311 | my ($self) = @_; |
312 | my ($self) = @_; |
… | |
… | |
561 | sub new { die } |
562 | sub new { die } |
562 | |
563 | |
563 | sub size_request { |
564 | sub size_request { |
564 | my ($self) = @_; |
565 | my ($self) = @_; |
565 | |
566 | |
566 | @$self{qw(child_w child_h)} = $self->child->size_request; |
567 | @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; |
567 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
568 | $self->child->size_allocate (0, 0, @$self{qw(child_w child_h)}); |
568 | |
569 | |
569 | @$self{qw(child_w child_h)} |
570 | @$self{qw(child_w child_h)} |
570 | } |
571 | } |
571 | |
572 | |
… | |
… | |
837 | or next; |
838 | or next; |
838 | |
839 | |
839 | for my $x (0 .. $#$row) { |
840 | for my $x (0 .. $#$row) { |
840 | my $widget = $row->[$x] |
841 | my $widget = $row->[$x] |
841 | or next; |
842 | or next; |
842 | my ($w, $h) = $widget->size_request; |
843 | my ($w, $h) = @$widget{qw(req_w req_h)}; |
843 | |
844 | |
844 | $w[$x] = max $w[$x], $w; |
845 | $w[$x] = max $w[$x], $w; |
845 | $h[$y] = max $h[$y], $h; |
846 | $h[$y] = max $h[$y], $h; |
846 | } |
847 | } |
847 | } |
848 | } |
… | |
… | |
952 | |
953 | |
953 | ($h, $w) = ($w, $h); |
954 | ($h, $w) = ($w, $h); |
954 | |
955 | |
955 | my $children = $self->{children}; |
956 | my $children = $self->{children}; |
956 | |
957 | |
957 | my @h = map +($_->size_request)[0], @$children; |
958 | my @h = map $_->{req_w}, @$children; |
958 | |
959 | |
959 | my $req_h = List::Util::sum @h; |
960 | my $req_h = List::Util::sum @h; |
960 | |
961 | |
961 | if ($req_h > $h) { |
962 | if ($req_h > $h) { |
962 | # ah well, not enough space |
963 | # ah well, not enough space |
… | |
… | |
1010 | sub size_allocate { |
1011 | sub size_allocate { |
1011 | my ($self, $w, $h) = @_; |
1012 | my ($self, $w, $h) = @_; |
1012 | |
1013 | |
1013 | my $children = $self->{children}; |
1014 | my $children = $self->{children}; |
1014 | |
1015 | |
1015 | my @h = map +($_->size_request)[1], @$children; |
1016 | my @h = map $_->{req_h}, @$children; |
1016 | |
1017 | |
1017 | my $req_h = List::Util::sum @h; |
1018 | my $req_h = List::Util::sum @h; |
1018 | |
1019 | |
1019 | if ($req_h > $h) { |
1020 | if ($req_h > $h) { |
1020 | # ah well, not enough space |
1021 | # ah well, not enough space |
… | |
… | |
1092 | my ($self, $text) = @_; |
1093 | my ($self, $text) = @_; |
1093 | |
1094 | |
1094 | $self->{layout}->set_text ($text); |
1095 | $self->{layout}->set_text ($text); |
1095 | |
1096 | |
1096 | delete $self->{texture}; |
1097 | delete $self->{texture}; |
|
|
1098 | $self->check_size; |
1097 | $self->update; |
1099 | $self->update; |
1098 | } |
1100 | } |
1099 | |
1101 | |
1100 | sub set_markup { |
1102 | sub set_markup { |
1101 | my ($self, $markup) = @_; |
1103 | my ($self, $markup) = @_; |
1102 | |
1104 | |
1103 | $self->{layout}->set_markup ($markup); |
1105 | $self->{layout}->set_markup ($markup); |
1104 | |
1106 | |
1105 | delete $self->{texture}; |
1107 | delete $self->{texture}; |
|
|
1108 | $self->check_size; |
1106 | $self->update; |
1109 | $self->update; |
1107 | } |
1110 | } |
1108 | |
1111 | |
1109 | sub size_request { |
1112 | sub size_request { |
1110 | my ($self) = @_; |
1113 | my ($self) = @_; |
… | |
… | |
1230 | } |
1233 | } |
1231 | |
1234 | |
1232 | sub size_allocate { |
1235 | sub size_allocate { |
1233 | my ($self, $w, $h) = @_; |
1236 | my ($self, $w, $h) = @_; |
1234 | |
1237 | |
1235 | $self->_set_text ($self->{text}); |
1238 | $self->_set_text (delete $self->{text});#d# don't check for == inside _set_text |
1236 | } |
1239 | } |
1237 | |
1240 | |
1238 | sub set_text { |
1241 | sub set_text { |
1239 | my ($self, $text) = @_; |
1242 | my ($self, $text) = @_; |
1240 | |
1243 | |
… | |
… | |
2092 | use CFClient::OpenGL; |
2095 | use CFClient::OpenGL; |
2093 | |
2096 | |
2094 | sub check_size { |
2097 | sub check_size { |
2095 | my ($self) = @_; |
2098 | my ($self) = @_; |
2096 | |
2099 | |
2097 | $self->configure (0, 0, $::WITH, $::HEIGHT); |
2100 | $self->configure (0, 0, $::WIDTH, $::HEIGHT); |
2098 | } |
2101 | } |
2099 | |
2102 | |
2100 | sub size_request { |
2103 | sub size_request { |
2101 | ($::WIDTH, $::HEIGHT) |
2104 | ($::WIDTH, $::HEIGHT) |
2102 | } |
2105 | } |
… | |
… | |
2104 | sub configure { |
2107 | sub configure { |
2105 | my ($self, $x, $y, $w, $h) = @_; |
2108 | my ($self, $x, $y, $w, $h) = @_; |
2106 | |
2109 | |
2107 | $self->SUPER::configure ($x, $y, $w, $h); |
2110 | $self->SUPER::configure ($x, $y, $w, $h); |
2108 | |
2111 | |
2109 | $_->configure ($_->{x}, $_->{y}, $_->size_request) |
|
|
2110 | for @{$self->{children}}; |
2112 | for my $child (@{$self->{children}}) { |
|
|
2113 | my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; |
|
|
2114 | |
|
|
2115 | $X = List::Util::max 0, List::Util::min $w - $W, $X; |
|
|
2116 | $Y = List::Util::max 0, List::Util::min $h - $H, $Y; |
|
|
2117 | $child->configure ($X, $Y, $W,$H); |
|
|
2118 | } |
2111 | } |
2119 | } |
2112 | |
2120 | |
2113 | sub _topleft { |
2121 | sub _topleft { |
2114 | my ($self, $x, $y) = @_; |
2122 | my ($self, $x, $y) = @_; |
2115 | |
2123 | |