… | |
… | |
221 | } |
221 | } |
222 | |
222 | |
223 | $self |
223 | $self |
224 | } |
224 | } |
225 | |
225 | |
226 | sub toggle_visibility { |
|
|
227 | my ($self) = @_; |
|
|
228 | |
|
|
229 | if ($self->{visible}) { |
|
|
230 | $self->hide; |
|
|
231 | } else { |
|
|
232 | $self->show; |
|
|
233 | } |
|
|
234 | } |
|
|
235 | |
|
|
236 | sub destroy { |
226 | sub destroy { |
237 | my ($self) = @_; |
227 | my ($self) = @_; |
238 | |
228 | |
239 | $self->hide; |
229 | $self->hide; |
240 | %$self = (); |
230 | %$self = (); |
241 | } |
231 | } |
242 | |
232 | |
243 | sub show { |
233 | sub show { |
244 | my ($self) = @_; |
234 | my ($self) = @_; |
|
|
235 | |
245 | return if $self->{parent}; |
236 | return if $self->{parent}; |
246 | |
237 | |
247 | $CFClient::UI::ROOT->add ($self); |
238 | $CFClient::UI::ROOT->add ($self); |
248 | } |
239 | } |
249 | |
240 | |
250 | sub center { |
241 | sub center { |
251 | my ($self) = @_; |
242 | my ($self) = @_; |
252 | |
243 | |
253 | $CFClient::UI::ROOT->on_post_alloc ( |
244 | $CFClient::UI::ROOT->on_post_alloc ( |
254 | "center_$self" => sub { |
245 | "center_$self" => sub { |
255 | $self->move (($::WIDTH - $self->{w}) * 0.5, ($::HEIGHT - $self->{h}) * 0.5); |
246 | $self->move (($self->{parent}{w} - $self->{w}) * 0.5, ($self->{parent}{h} - $self->{h}) * 0.5); |
256 | }, |
247 | }, |
257 | ); |
248 | ); |
258 | |
249 | |
259 | $self->update; |
250 | $self->update; |
260 | } |
251 | } |
… | |
… | |
265 | return if $self->{visible}; |
256 | return if $self->{visible}; |
266 | |
257 | |
267 | $self->{root} = $self->{parent}{root}; |
258 | $self->{root} = $self->{parent}{root}; |
268 | $self->{visible} = $self->{parent}{visible} + 1; |
259 | $self->{visible} = $self->{parent}{visible} + 1; |
269 | |
260 | |
270 | $self->emit (visibility_change => 1) |
261 | $self->emit (visibility_change => 1); |
271 | } |
262 | } |
272 | |
263 | |
273 | sub set_invisible { |
264 | sub set_invisible { |
274 | my ($self) = @_; |
265 | my ($self) = @_; |
275 | |
266 | |
… | |
… | |
287 | if $CFClient::UI::TOOLTIP->{owner} == $self; |
278 | if $CFClient::UI::TOOLTIP->{owner} == $self; |
288 | |
279 | |
289 | $self->focus_out; |
280 | $self->focus_out; |
290 | |
281 | |
291 | $self->emit (visibility_change => 0); |
282 | $self->emit (visibility_change => 0); |
|
|
283 | } |
|
|
284 | |
|
|
285 | sub set_visibility { |
|
|
286 | my ($self, $visible) = @_; |
|
|
287 | |
|
|
288 | return if $self->{visible} == $visible; |
|
|
289 | |
|
|
290 | $visible ? $self->hide |
|
|
291 | : $self->show; |
|
|
292 | } |
|
|
293 | |
|
|
294 | sub toggle_visibility { |
|
|
295 | my ($self) = @_; |
|
|
296 | |
|
|
297 | $self->{visible} |
|
|
298 | ? $self->hide |
|
|
299 | : $self->show; |
292 | } |
300 | } |
293 | |
301 | |
294 | sub hide { |
302 | sub hide { |
295 | my ($self) = @_; |
303 | my ($self) = @_; |
296 | |
304 | |
… | |
… | |
344 | $self->{y} = $y; |
352 | $self->{y} = $y; |
345 | $self->update; |
353 | $self->update; |
346 | } |
354 | } |
347 | |
355 | |
348 | if ($self->{w} != $w || $self->{h} != $h) { |
356 | if ($self->{w} != $w || $self->{h} != $h) { |
349 | $CFClient::UI::ROOT->{size_alloc}{$self} = [$self, $w, $h]; |
357 | $CFClient::UI::ROOT->{size_alloc}{$self+0} = [$self, $w, $h]; |
350 | } |
358 | } |
351 | } |
359 | } |
352 | |
360 | |
353 | sub size_allocate { |
361 | sub size_allocate { |
354 | # nothing to be done |
362 | # nothing to be done |
… | |
… | |
3007 | if exists $child->{req_x}; |
3015 | if exists $child->{req_x}; |
3008 | |
3016 | |
3009 | $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1 |
3017 | $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1 |
3010 | if exists $child->{req_y}; |
3018 | if exists $child->{req_y}; |
3011 | |
3019 | |
3012 | delete @$child{qw(req_x req_y)}; |
3020 | #delete @$child{qw(req_x req_y)};#d# def_x, def_y |
3013 | |
3021 | |
3014 | $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5; |
3022 | $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5; |
3015 | $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5; |
3023 | $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5; |
3016 | |
3024 | |
3017 | $child->configure ($X, $Y, $W, $H); |
3025 | $child->configure ($X, $Y, $W, $H); |
… | |
… | |
3090 | } |
3098 | } |
3091 | |
3099 | |
3092 | if ($self->{check_size}) { |
3100 | if ($self->{check_size}) { |
3093 | my @queue; |
3101 | my @queue; |
3094 | |
3102 | |
3095 | for (;;) { |
3103 | while () { |
3096 | if ($self->{check_size}) { |
3104 | if ($self->{check_size}) { |
3097 | #TODO use array-of-depth approach |
3105 | #TODO use array-of-depth approach |
3098 | |
3106 | |
3099 | @queue = sort { $a->{visible} <=> $b->{visible} } |
3107 | @queue = sort { $a->{visible} <=> $b->{visible} } |
3100 | @queue, values %{delete $self->{check_size}}; |
3108 | @queue, values %{delete $self->{check_size}}; |
… | |
… | |
3121 | if $widget->{parent}; |
3129 | if $widget->{parent}; |
3122 | } |
3130 | } |
3123 | } |
3131 | } |
3124 | } |
3132 | } |
3125 | |
3133 | |
3126 | while ($self->{size_alloc}) { |
3134 | while (my $size_alloc = delete $self->{size_alloc}) { |
3127 | for (values %{delete $self->{size_alloc}}) { |
3135 | my @queue = sort $b->[0]{visible} <=> $a->[0]{visible}, |
3128 | my ($widget, $w, $h) = @$_; |
3136 | values %$size_alloc; |
|
|
3137 | |
|
|
3138 | while () { |
|
|
3139 | my ($widget, $w, $h) = @{ pop @queue or last }; |
3129 | |
3140 | |
3130 | $w = 0 if $w < 0; |
3141 | $w = 0 if $w < 0; |
3131 | $h = 0 if $h < 0; |
3142 | $h = 0 if $h < 0; |
3132 | |
3143 | |
3133 | $widget->{w} = $w; |
3144 | $widget->{w} = $w; |