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.242 by elmex, Sat May 27 20:00:40 2006 UTC vs.
Revision 1.250 by root, Sun May 28 02:31:03 2006 UTC

175 for my $widget (values %WIDGET) { 175 for my $widget (values %WIDGET) {
176 if ($widget->{is_toplevel}) { 176 if ($widget->{is_toplevel}) {
177 $widget->{x} = int 0.5 + $widget->{x} * $sx if exists $widget->{x}; 177 $widget->{x} = int 0.5 + $widget->{x} * $sx if exists $widget->{x};
178 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w}; 178 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w};
179 $widget->{req_w} = int 0.5 + $widget->{req_w} * $sx if exists $widget->{req_w}; 179 $widget->{req_w} = int 0.5 + $widget->{req_w} * $sx if exists $widget->{req_w};
180 $widget->{user_w} = int 0.5 + $widget->{user_w} * $sx if exists $widget->{user_w};
181 $widget->{y} = int 0.5 + $widget->{y} * $sy if exists $widget->{y}; 180 $widget->{y} = int 0.5 + $widget->{y} * $sy if exists $widget->{y};
182 $widget->{h} = int 0.5 + $widget->{h} * $sy if exists $widget->{h}; 181 $widget->{h} = int 0.5 + $widget->{h} * $sy if exists $widget->{h};
183 $widget->{req_h} = int 0.5 + $widget->{req_h} * $sy if exists $widget->{req_h}; 182 $widget->{req_h} = int 0.5 + $widget->{req_h} * $sy if exists $widget->{req_h};
184 $widget->{user_h} = int 0.5 + $widget->{user_h} * $sy if exists $widget->{user_h};
185 } 183 }
186 } 184 }
187 185
188 reconfigure_widgets; 186 reconfigure_widgets;
189} 187}
206 can_events => 1, 204 can_events => 1,
207 @_ 205 @_
208 }, $class; 206 }, $class;
209 207
210 for (keys %$self) { 208 for (keys %$self) {
211 if (/^connect_(.*)$/) { 209 if (/^on_(.*)$/) {
212 $self->connect ($1 => delete $self->{$_}); 210 $self->connect ($1 => delete $self->{$_});
213 } 211 }
214 } 212 }
215 213
216 Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self); 214 Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self);
217 215
218 if (my $layout = $CFClient::UI::LAYOUT->{$self->{name}}) { 216 if (my $layout = $CFClient::UI::LAYOUT->{$self->{name}}) {
219 $self->{user_x} = $layout->{x} * $::WIDTH; 217 $self->{req_x} = $layout->{x} * $::WIDTH;
220 $self->{user_y} = $layout->{y} * $::HEIGHT; 218 $self->{req_y} = $layout->{y} * $::HEIGHT;
221 $self->{user_w} = ($layout->{w} != 0 ? $layout->{w} : 1) * $::WIDTH; 219 $self->{def_w} = ($layout->{w} != 0 ? $layout->{w} : 1) * $::WIDTH;
222 $self->{user_h} = ($layout->{h} != 0 ? $layout->{h} : 1) * $::HEIGHT; 220 $self->{def_h} = ($layout->{h} != 0 ? $layout->{h} : 1) * $::HEIGHT;
223 } 221 }
224 222
225 $self 223 $self
226} 224}
227 225
232 %$self = (); 230 %$self = ();
233} 231}
234 232
235sub show { 233sub show {
236 my ($self) = @_; 234 my ($self) = @_;
235
237 return if $self->{parent}; 236 return if $self->{parent};
238 237
239 $CFClient::UI::ROOT->add ($self); 238 $CFClient::UI::ROOT->add ($self);
240} 239}
241 240
242sub show_centered { 241sub center {
243 my ($self) = @_; 242 my ($self) = @_;
244 return if $self->{parent};
245
246 $self->show;
247 243
248 $CFClient::UI::ROOT->on_post_alloc ( 244 $CFClient::UI::ROOT->on_post_alloc (
249 "centered $self" => sub { 245 "center_$self" => sub {
250 $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);
251 }, 247 },
252 ); 248 );
249
250 $self->update;
251}
252
253sub set_visible {
254 my ($self) = @_;
255
256 return if $self->{visible};
257
258 $self->{root} = $self->{parent}{root};
259 $self->{visible} = $self->{parent}{visible} + 1;
260
261 $self->emit (visibility_change => 1);
253} 262}
254 263
255sub set_invisible { 264sub set_invisible {
256 my ($self) = @_; 265 my ($self) = @_;
266
267 return unless $self->{visible};
257 268
258 # broken show/hide model 269 # broken show/hide model
259 270
260 delete $self->{root}; 271 delete $self->{root};
261 delete $self->{visible}; 272 delete $self->{visible};
265 276
266 CFClient::UI::check_tooltip 277 CFClient::UI::check_tooltip
267 if $CFClient::UI::TOOLTIP->{owner} == $self; 278 if $CFClient::UI::TOOLTIP->{owner} == $self;
268 279
269 $self->focus_out; 280 $self->focus_out;
281
282 $self->emit (visibility_change => 0);
283}
284
285sub set_visibility {
286 my ($self, $visible) = @_;
287
288 return if $self->{visible} == $visible;
289
290 $visible ? $self->hide
291 : $self->show;
292}
293
294sub toggle_visibility {
295 my ($self) = @_;
296
297 $self->{visible}
298 ? $self->hide
299 : $self->show;
270} 300}
271 301
272sub hide { 302sub hide {
273 my ($self) = @_; 303 my ($self) = @_;
274 304
289} 319}
290 320
291sub set_size { 321sub set_size {
292 my ($self, $w, $h) = @_; 322 my ($self, $w, $h) = @_;
293 323
294 $self->{user_w} = $w; 324 $self->{def_w} = $w;
295 $self->{user_h} = $h; 325 $self->{def_h} = $h;
296 326
297 $self->check_size; 327 $self->check_size;
298} 328}
299 329
300sub size_request { 330sub size_request {
322 $self->{y} = $y; 352 $self->{y} = $y;
323 $self->update; 353 $self->update;
324 } 354 }
325 355
326 if ($self->{w} != $w || $self->{h} != $h) { 356 if ($self->{w} != $w || $self->{h} != $h) {
327 $CFClient::UI::ROOT->{size_alloc}{$self} = [$self, $w, $h]; 357 $CFClient::UI::ROOT->{size_alloc}{$self+0} = [$self, $w, $h];
328 } 358 }
329} 359}
330 360
331sub size_allocate { 361sub size_allocate {
332 # nothing to be done 362 # nothing to be done
486sub set_parent { 516sub set_parent {
487 my ($self, $parent) = @_; 517 my ($self, $parent) = @_;
488 518
489 Scalar::Util::weaken ($self->{parent} = $parent); 519 Scalar::Util::weaken ($self->{parent} = $parent);
490 520
491 $self->{root} = $parent->{root}; 521 $self->set_visible; #TODO why breakssssss borked damn if $parent->{visible};
492 $self->{visible} = $parent->{visible} + 1;
493 522
494 # TODO: req_w _does_change after ->reconfigure
495 $self->check_size 523 $self->check_size;
496 unless exists $self->{req_w};
497
498 $self->show;
499} 524}
500 525
501sub check_size { 526sub check_size {
502 my ($self, $forced) = @_; 527 my ($self, $forced) = @_;
503 528
527sub emit { 552sub emit {
528 my ($self, $signal, @args) = @_; 553 my ($self, $signal, @args) = @_;
529 554
530 $self->_emit ($signal, @args) 555 $self->_emit ($signal, @args)
531 || $self->$signal (@args); 556 || $self->$signal (@args);
557}
558
559sub visibility_change {
560 #my ($self, $visible) = @_;
532} 561}
533 562
534sub DESTROY { 563sub DESTROY {
535 my ($self) = @_; 564 my ($self) = @_;
536 565
812} 841}
813 842
814sub size_request { 843sub size_request {
815 my ($self) = @_; 844 my ($self) = @_;
816 845
817 @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; 846 my ($w, $h) = @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)};
818 847
819 @$self{qw(child_w child_h)} 848 $w = 10 if $self->{scroll_x};
849 $h = 10 if $self->{scroll_y};
850
851 ($w, $h)
820} 852}
821 853
822sub size_allocate { 854sub size_allocate {
823 my ($self, $w, $h) = @_; 855 my ($self, $w, $h) = @_;
824 856
884 my $class = shift; 916 my $class = shift;
885 917
886 my $self; 918 my $self;
887 919
888 my $slider = new CFClient::UI::Slider 920 my $slider = new CFClient::UI::Slider
889 vertical => 1, 921 vertical => 1,
890 range => [0, 0, 1, 0.01], # HACK fix 922 range => [0, 0, 1, 0.01], # HACK fix
891 connect_changed => sub { 923 on_changed => sub {
892 $self->{vp}->set_offset (0, $_[1]); 924 $self->{vp}->set_offset (0, $_[1]);
893 }, 925 },
894 ; 926 ;
895 927
896 $self = $class->SUPER::new ( 928 $self = $class->SUPER::new (
980 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } 1012 map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 }
981 qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); 1013 qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png);
982 1014
983sub new { 1015sub new {
984 my $class = shift; 1016 my $class = shift;
985
986 # TODO: user_x, user_y, overwrite moveto?
987 1017
988 my $self = $class->SUPER::new ( 1018 my $self = $class->SUPER::new (
989 bg => [1, 1, 1, 1], 1019 bg => [1, 1, 1, 1],
990 border_bg => [1, 1, 1, 1], 1020 border_bg => [1, 1, 1, 1],
991 border => 0.6, 1021 border => 0.6,
1051 my ($ev, $x, $y) = @_; 1081 my ($ev, $x, $y) = @_;
1052 1082
1053 my $dx = $ev->{x} - $ox; 1083 my $dx = $ev->{x} - $ox;
1054 my $dy = $ev->{y} - $oy; 1084 my $dy = $ev->{y} - $oy;
1055 1085
1086 $self->{user_x} = $wx + $dx * $mx;
1087 $self->{user_y} = $wy + $dy * $my;
1056 $self->{user_w} = $bw + $dx * ($mx ? -1 : 1); 1088 $self->{def_w} = $bw + $dx * ($mx ? -1 : 1);
1057 $self->{user_h} = $bh + $dy * ($my ? -1 : 1); 1089 $self->{def_h} = $bh + $dy * ($my ? -1 : 1);
1058 $self->move ($wx + $dx * $mx, $wy + $dy * $my); 1090 $self->move ($self->{user_x}, $self->{user_y});
1059 $self->check_size; 1091 $self->check_size;
1060 }; 1092 };
1061 1093
1062 } elsif ($lr ^ $td) { 1094 } elsif ($lr ^ $td) {
1063 my ($ox, $oy) = ($ev->{x}, $ev->{y}); 1095 my ($ox, $oy) = ($ev->{x}, $ev->{y});
1066 $self->{motion} = sub { 1098 $self->{motion} = sub {
1067 my ($ev, $x, $y) = @_; 1099 my ($ev, $x, $y) = @_;
1068 1100
1069 ($x, $y) = ($ev->{x}, $ev->{y}); 1101 ($x, $y) = ($ev->{x}, $ev->{y});
1070 1102
1071 $self->move ($bx + $x - $ox, $by + $y - $oy); 1103 $self->{user_x} = $bx + $x - $ox;
1104 $self->{user_y} = $by + $y - $oy;
1105
1106 $self->move ($self->{user_x}, $self->{user_y});
1072 $self->update; 1107 $self->update;
1073 }; 1108 };
1074 } 1109 }
1075} 1110}
1076 1111
1274 } 1309 }
1275} 1310}
1276 1311
1277############################################################################# 1312#############################################################################
1278 1313
1279package CFClient::UI::HBox; 1314package CFClient::UI::Box;
1280
1281# TODO: wrap into common Box base class
1282 1315
1283our @ISA = CFClient::UI::Container::; 1316our @ISA = CFClient::UI::Container::;
1284 1317
1285sub size_request { 1318sub size_request {
1286 my ($self) = @_; 1319 my ($self) = @_;
1287 1320
1288 my @alloc = map [$_->size_request], @{$self->{children}}; 1321 $self->{vertical}
1289 1322 ? (
1290 ( 1323 (List::Util::max map $_->{req_w}, @{$self->{children}}),
1291 (List::Util::sum map $_->[0], @alloc), 1324 (List::Util::sum map $_->{req_h}, @{$self->{children}}),
1292 (List::Util::max map $_->[1], @alloc), 1325 )
1293 ) 1326 : (
1327 (List::Util::sum map $_->{req_w}, @{$self->{children}}),
1328 (List::Util::max map $_->{req_h}, @{$self->{children}}),
1329 )
1294} 1330}
1295 1331
1296sub size_allocate { 1332sub size_allocate {
1297 my ($self, $w, $h) = @_; 1333 my ($self, $w, $h) = @_;
1298 1334
1299 ($h, $w) = ($w, $h); 1335 my $space = $self->{vertical} ? $h : $w;
1300
1301 my $children = $self->{children}; 1336 my $children = $self->{children};
1302 1337
1303 my @h = map $_->{req_w}, @$children; 1338 my @req;
1304 1339
1305 my $req_h = List::Util::sum @h; 1340 if ($self->{homogeneous}) {
1306 1341 @req = ($space / (@$children || 1)) x @$children;
1307 if ($req_h > $h) {
1308 # ah well, not enough space
1309 $_ *= $h / $req_h for @h;
1310 } else { 1342 } else {
1343 @req = map $_->{$self->{vertical} ? "req_h" : "req_w"}, @$children;
1344 my $req = List::Util::sum @req;
1345
1346 if ($req > $space) {
1347 # ah well, not enough space
1348 $_ *= $space / $req for @req;
1349 } else {
1311 my $exp = List::Util::sum map $_->{expand}, @$children; 1350 my $expand = (List::Util::sum map $_->{expand}, @$children) || 1;
1312 $exp ||= 1;
1313 1351
1352 $space = ($space - $req) / $expand; # remaining space to give away
1353
1354 $req[$_] += $space * $children->[$_]{expand}
1314 for (0 .. $#$children) { 1355 for 0 .. $#$children;
1315 my $child = $children->[$_];
1316
1317 my $alloc_h = $h[$_];
1318 $alloc_h += ($h - $req_h) * $child->{expand} / $exp;
1319 $h[$_] = $alloc_h;
1320 } 1356 }
1321 } 1357 }
1322 1358
1323 CFClient::UI::harmonize \@h; 1359 CFClient::UI::harmonize \@req;
1324 1360
1325 my $y = 0; 1361 my $pos = 0;
1326 for (0 .. $#$children) { 1362 for (0 .. $#$children) {
1327 my $child = $children->[$_];
1328 my $h = $h[$_]; 1363 my $alloc = $req[$_];
1329 $child->configure ($y, 0, $h, $w); 1364 $children->[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h));
1330 1365
1331 $y += $h; 1366 $pos += $alloc;
1332 } 1367 }
1333 1368
1334 1 1369 1
1335} 1370}
1336 1371
1337############################################################################# 1372#############################################################################
1338 1373
1374package CFClient::UI::HBox;
1375
1376our @ISA = CFClient::UI::Box::;
1377
1378sub new {
1379 my $class = shift;
1380
1381 $class->SUPER::new (
1382 vertical => 0,
1383 @_,
1384 )
1385}
1386
1387#############################################################################
1388
1339package CFClient::UI::VBox; 1389package CFClient::UI::VBox;
1340 1390
1341# TODO: wrap into common Box base class
1342
1343our @ISA = CFClient::UI::Container::; 1391our @ISA = CFClient::UI::Box::;
1344 1392
1345sub size_request { 1393sub new {
1346 my ($self) = @_; 1394 my $class = shift;
1347 1395
1348 my @alloc = map [$_->size_request], @{$self->{children}}; 1396 $class->SUPER::new (
1349 1397 vertical => 1,
1350 ( 1398 @_,
1351 (List::Util::max map $_->[0], @alloc),
1352 (List::Util::sum map $_->[1], @alloc),
1353 ) 1399 )
1354}
1355
1356sub size_allocate {
1357 my ($self, $w, $h) = @_;
1358
1359 Carp::confess "negative size" if $w < 0 || $h < 0;#d#
1360
1361 my $children = $self->{children};
1362
1363 my @h = map $_->{req_h}, @$children;
1364
1365 my $req_h = List::Util::sum @h;
1366
1367 if ($req_h > $h) {
1368 # ah well, not enough space
1369 $_ *= $h / $req_h for @h;
1370 } else {
1371 my $exp = List::Util::sum map $_->{expand}, @$children;
1372 $exp ||= 1;
1373
1374 for (0 .. $#$children) {
1375 my $child = $children->[$_];
1376
1377 $h[$_] += ($h - $req_h) * $child->{expand} / $exp;
1378 }
1379 }
1380
1381 CFClient::UI::harmonize \@h;
1382
1383 my $y = 0;
1384 for (0 .. $#$children) {
1385 my $child = $children->[$_];
1386 my $h = $h[$_];
1387 $child->configure (0, $y, $w, $h);
1388
1389 $y += $h;
1390 }
1391
1392 1
1393} 1400}
1394 1401
1395############################################################################# 1402#############################################################################
1396 1403
1397package CFClient::UI::Label; 1404package CFClient::UI::Label;
2570 2577
2571sub new { 2578sub new {
2572 my $class = shift; 2579 my $class = shift;
2573 2580
2574 my $self = $class->SUPER::new ( 2581 my $self = $class->SUPER::new (
2575 state => 0, 2582 state => 0,
2576 connect_activate => \&toggle_flopper, 2583 on_activate => \&toggle_flopper,
2577 @_ 2584 @_
2578 ); 2585 );
2579 2586
2580 if ($self->{state}) {
2581 $self->{state} = 0;
2582 $self->toggle_flopper;
2583 }
2584
2585 $self 2587 $self
2586} 2588}
2587 2589
2588sub toggle_flopper { 2590sub toggle_flopper {
2589 my ($self) = @_; 2591 my ($self) = @_;
2590 2592
2591 # TODO: use animation 2593 $self->{other}->toggle_visibility;
2592 if ($self->{state} = !$self->{state}) {
2593 $CFClient::UI::ROOT->add ($self->{other});
2594 $self->{other}->move ($self->coord2global (0, $self->{h}));
2595 $self->_emit ("open");
2596 } else {
2597 $CFClient::UI::ROOT->remove ($self->{other});
2598 $self->_emit ("close");
2599 }
2600
2601 $self->_emit (changed => $self->{state});
2602} 2594}
2603 2595
2604############################################################################# 2596#############################################################################
2605 2597
2606package CFClient::UI::Tooltip; 2598package CFClient::UI::Tooltip;
2790 $self->{scrolled}->add (1, $row, $item->{desc_widget}); 2782 $self->{scrolled}->add (1, $row, $item->{desc_widget});
2791 $self->{scrolled}->add (2, $row, $item->{weight_widget}); 2783 $self->{scrolled}->add (2, $row, $item->{weight_widget});
2792 2784
2793 $row++; 2785 $row++;
2794 } 2786 }
2795}
2796
2797sub size_request {
2798 my ($self) = @_;
2799 ($self->{req_w}, $self->{req_h});
2800} 2787}
2801 2788
2802############################################################################# 2789#############################################################################
2803 2790
2804package CFClient::UI::Menu; 2791package CFClient::UI::Menu;
3028 if exists $child->{req_x}; 3015 if exists $child->{req_x};
3029 3016
3030 $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
3031 if exists $child->{req_y}; 3018 if exists $child->{req_y};
3032 3019
3020 #delete @$child{qw(req_x req_y)};#d# def_x, def_y
3021
3033 $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;
3034 $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;
3035 3024
3036 $child->configure ($X, $Y, $W, $H); 3025 $child->configure ($X, $Y, $W, $H);
3037 } 3026 }
3056 $::WANT_REFRESH++; 3045 $::WANT_REFRESH++;
3057} 3046}
3058 3047
3059sub add { 3048sub add {
3060 my ($self, @children) = @_; 3049 my ($self, @children) = @_;
3061
3062 for (my @widgets = @children; my $w = pop @widgets; ) {
3063 push @widgets, $w->children;
3064 $w->{root} = $self;
3065 $w->{visible} = $self->{visible} + 1;
3066 }
3067 3050
3068 for my $child (@children) { 3051 for my $child (@children) {
3069 $child->{is_toplevel} = 1; 3052 $child->{is_toplevel} = 1;
3070 3053
3071 # integerise window positions 3054 # integerise window positions
3072 $child->{x} = int $child->{x}; 3055 $child->{x} = int $child->{x};
3073 $child->{y} = int $child->{y}; 3056 $child->{y} = int $child->{y};
3074 } 3057 }
3075 3058
3076 $self->SUPER::add (@children); 3059 $self->SUPER::add (@children);
3060
3061 for (my @widgets = @children; my $w = pop @widgets; ) {
3062 push @widgets, $w->children;
3063 $w->set_visible;
3064 }
3065
3077} 3066}
3078 3067
3079sub remove { 3068sub remove {
3080 my ($self, @children) = @_; 3069 my ($self, @children) = @_;
3081 3070
3107 $_->() 3096 $_->()
3108 for values %{delete $self->{refresh_hook}}; 3097 for values %{delete $self->{refresh_hook}};
3109 } 3098 }
3110 3099
3111 if ($self->{check_size}) { 3100 if ($self->{check_size}) {
3112 my @queue = ([], []); 3101 my @queue;
3113 3102
3114 for (;;) { 3103 while () {
3115 if ($self->{check_size}) { 3104 if ($self->{check_size}) {
3116 # heuristic: check containers last 3105 #TODO use array-of-depth approach
3117 push @{ $queue[ ! ! $_->isa ("CFClient::UI::Container") ] }, $_ 3106
3107 @queue = sort { $a->{visible} <=> $b->{visible} }
3118 for values %{delete $self->{check_size}} 3108 @queue, values %{delete $self->{check_size}};
3119 } 3109 }
3120 3110
3121 my $widget = (pop @{ $queue[0] }) || (pop @{ $queue[1] }) || last; 3111 my $widget = pop @queue || last;
3122 3112
3113 defined $widget->{visible} or last; # do not resize invisible widgets
3114
3123 my ($w, $h) = $widget->{user_w} && $widget->{user_h} 3115 my ($w, $h) = $widget->{def_w} && $widget->{def_h}
3124 ? @$widget{qw(user_w user_h)} 3116 ? @$widget{qw(def_w def_h)}
3125 : $widget->size_request; 3117 : $widget->size_request;
3126 3118
3127 if (delete $widget->{force_alloc} 3119 if (delete $widget->{force_alloc}
3128 or $w != $widget->{req_w} or $h != $widget->{req_h}) { 3120 or $w != $widget->{req_w} or $h != $widget->{req_h}) {
3129 Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d# 3121 Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d#
3137 if $widget->{parent}; 3129 if $widget->{parent};
3138 } 3130 }
3139 } 3131 }
3140 } 3132 }
3141 3133
3142 while ($self->{size_alloc}) { 3134 while (my $size_alloc = delete $self->{size_alloc}) {
3143 for (values %{delete $self->{size_alloc}}) { 3135 my @queue = sort $b->[0]{visible} <=> $a->[0]{visible},
3144 my ($widget, $w, $h) = @$_; 3136 values %$size_alloc;
3137
3138 while () {
3139 my ($widget, $w, $h) = @{ pop @queue or last };
3145 3140
3146 $w = 0 if $w < 0; 3141 $w = 0 if $w < 0;
3147 $h = 0 if $h < 0; 3142 $h = 0 if $h < 0;
3148 3143
3149 $widget->{w} = $w; 3144 $widget->{w} = $w;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines