… | |
… | |
5 | |
5 | |
6 | use Scalar::Util (); |
6 | use Scalar::Util (); |
7 | use List::Util (); |
7 | use List::Util (); |
8 | |
8 | |
9 | use CFClient; |
9 | use CFClient; |
|
|
10 | use CFClient::Texture; |
10 | |
11 | |
11 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
12 | our ($FOCUS, $HOVER, $GRAB); # various widgets |
12 | |
13 | |
|
|
14 | our $LAYOUT; |
13 | our $ROOT; |
15 | our $ROOT; |
14 | our $TOOLTIP; |
16 | our $TOOLTIP; |
15 | our $BUTTON_STATE; |
17 | our $BUTTON_STATE; |
16 | |
18 | |
17 | our %WIDGET; # all widgets, weak-referenced |
19 | our %WIDGET; # all widgets, weak-referenced |
|
|
20 | |
|
|
21 | sub get_layout { |
|
|
22 | for (grep { $_->{name} } values %WIDGET) { |
|
|
23 | $LAYOUT->{$_->{name}} = { |
|
|
24 | x => $_->{x} / $::WIDTH, |
|
|
25 | y => $_->{y} / $::HEIGHT, |
|
|
26 | w => $_->{w} / $::WIDTH, |
|
|
27 | h => $_->{h} / $::HEIGHT |
|
|
28 | }; |
|
|
29 | } |
|
|
30 | |
|
|
31 | return $LAYOUT; |
|
|
32 | } |
|
|
33 | |
|
|
34 | sub set_layout { |
|
|
35 | my ($layout) = @_; |
|
|
36 | $LAYOUT = $layout; |
|
|
37 | } |
18 | |
38 | |
19 | sub check_tooltip { |
39 | sub check_tooltip { |
20 | if (!$GRAB) { |
40 | if (!$GRAB) { |
21 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
41 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
22 | if (length $widget->{tooltip}) { |
42 | if (length $widget->{tooltip}) { |
… | |
… | |
155 | for my $widget (values %WIDGET) { |
175 | for my $widget (values %WIDGET) { |
156 | if ($widget->{is_toplevel}) { |
176 | if ($widget->{is_toplevel}) { |
157 | $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}; |
158 | $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}; |
159 | $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}; |
160 | $widget->{user_w} = int 0.5 + $widget->{user_w} * $sx if exists $widget->{user_w}; |
|
|
161 | $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}; |
162 | $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}; |
163 | $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}; |
164 | $widget->{user_h} = int 0.5 + $widget->{user_h} * $sy if exists $widget->{user_h}; |
|
|
165 | } |
183 | } |
166 | } |
184 | } |
167 | |
185 | |
168 | reconfigure_widgets; |
186 | reconfigure_widgets; |
169 | } |
187 | } |
… | |
… | |
186 | can_events => 1, |
204 | can_events => 1, |
187 | @_ |
205 | @_ |
188 | }, $class; |
206 | }, $class; |
189 | |
207 | |
190 | for (keys %$self) { |
208 | for (keys %$self) { |
191 | if (/^connect_(.*)$/) { |
209 | if (/^on_(.*)$/) { |
192 | $self->connect ($1 => delete $self->{$_}); |
210 | $self->connect ($1 => delete $self->{$_}); |
193 | } |
211 | } |
194 | } |
212 | } |
195 | |
213 | |
196 | Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self); |
214 | Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self); |
197 | |
215 | |
|
|
216 | if (my $layout = $CFClient::UI::LAYOUT->{$self->{name}}) { |
|
|
217 | $self->{req_x} = $layout->{x} * $::WIDTH; |
|
|
218 | $self->{req_y} = $layout->{y} * $::HEIGHT; |
|
|
219 | $self->{def_w} = ($layout->{w} != 0 ? $layout->{w} : 1) * $::WIDTH; |
|
|
220 | $self->{def_h} = ($layout->{h} != 0 ? $layout->{h} : 1) * $::HEIGHT; |
|
|
221 | } |
|
|
222 | |
198 | $self |
223 | $self |
|
|
224 | } |
|
|
225 | |
|
|
226 | sub toggle_visibility { |
|
|
227 | my ($self) = @_; |
|
|
228 | |
|
|
229 | if ($self->{visible}) { |
|
|
230 | $self->hide; |
|
|
231 | } else { |
|
|
232 | $self->show; |
|
|
233 | } |
199 | } |
234 | } |
200 | |
235 | |
201 | sub destroy { |
236 | sub destroy { |
202 | my ($self) = @_; |
237 | my ($self) = @_; |
203 | |
238 | |
… | |
… | |
223 | $self->move (($::WIDTH - $self->{w}) * 0.5, ($::HEIGHT - $self->{h}) * 0.5); |
258 | $self->move (($::WIDTH - $self->{w}) * 0.5, ($::HEIGHT - $self->{h}) * 0.5); |
224 | }, |
259 | }, |
225 | ); |
260 | ); |
226 | } |
261 | } |
227 | |
262 | |
|
|
263 | sub set_visible { |
|
|
264 | my ($self) = @_; |
|
|
265 | |
|
|
266 | return if $self->{visible}; |
|
|
267 | |
|
|
268 | $self->{root} = $self->{parent}{root}; |
|
|
269 | $self->{visible} = $self->{parent}{visible} + 1; |
|
|
270 | |
|
|
271 | $self->emit (visibility_change => 1) |
|
|
272 | } |
|
|
273 | |
228 | sub set_invisible { |
274 | sub set_invisible { |
229 | my ($self) = @_; |
275 | my ($self) = @_; |
230 | |
276 | |
|
|
277 | return unless $self->{visible}; |
|
|
278 | |
231 | # broken show/hide model |
279 | # broken show/hide model |
232 | |
280 | |
|
|
281 | delete $self->{root}; |
233 | delete $self->{visible}; |
282 | delete $self->{visible}; |
234 | |
283 | |
235 | undef $GRAB if $GRAB == $self; |
284 | undef $GRAB if $GRAB == $self; |
236 | undef $HOVER if $HOVER == $self; |
285 | undef $HOVER if $HOVER == $self; |
237 | |
286 | |
238 | CFClient::UI::check_tooltip |
287 | CFClient::UI::check_tooltip |
239 | if $CFClient::UI::TOOLTIP->{owner} == $self; |
288 | if $CFClient::UI::TOOLTIP->{owner} == $self; |
240 | |
289 | |
241 | $self->focus_out; |
290 | $self->focus_out; |
|
|
291 | |
|
|
292 | $self->emit (visibility_change => 0); |
242 | } |
293 | } |
243 | |
294 | |
244 | sub hide { |
295 | sub hide { |
245 | my ($self) = @_; |
296 | my ($self) = @_; |
246 | |
297 | |
… | |
… | |
261 | } |
312 | } |
262 | |
313 | |
263 | sub set_size { |
314 | sub set_size { |
264 | my ($self, $w, $h) = @_; |
315 | my ($self, $w, $h) = @_; |
265 | |
316 | |
266 | $self->{user_w} = $w; |
317 | $self->{def_w} = $w; |
267 | $self->{user_h} = $h; |
318 | $self->{def_h} = $h; |
268 | |
319 | |
269 | $self->check_size; |
320 | $self->check_size; |
270 | } |
321 | } |
271 | |
322 | |
272 | sub size_request { |
323 | sub size_request { |
… | |
… | |
321 | delete $self->{max_h}; $self->{max_h} = $h if $h; |
372 | delete $self->{max_h}; $self->{max_h} = $h if $h; |
322 | } |
373 | } |
323 | |
374 | |
324 | sub set_tooltip { |
375 | sub set_tooltip { |
325 | my ($self, $tooltip) = @_; |
376 | my ($self, $tooltip) = @_; |
|
|
377 | |
|
|
378 | $tooltip =~ s/^\s+//; |
|
|
379 | $tooltip =~ s/\s+$//; |
|
|
380 | |
|
|
381 | return if $self->{tooltip} eq $tooltip; |
326 | |
382 | |
327 | $self->{tooltip} = $tooltip; |
383 | $self->{tooltip} = $tooltip; |
328 | |
384 | |
329 | if ($CFClient::UI::TOOLTIP->{owner} == $self) { |
385 | if ($CFClient::UI::TOOLTIP->{owner} == $self) { |
330 | delete $CFClient::UI::TOOLTIP->{owner}; |
386 | delete $CFClient::UI::TOOLTIP->{owner}; |
… | |
… | |
420 | if ($ENV{PCLIENT_DEBUG}) { |
476 | if ($ENV{PCLIENT_DEBUG}) { |
421 | glPushMatrix; |
477 | glPushMatrix; |
422 | glColor 1, 1, 0, 1; |
478 | glColor 1, 1, 0, 1; |
423 | glTranslate $self->{x} + 0.375, $self->{y} + 0.375; |
479 | glTranslate $self->{x} + 0.375, $self->{y} + 0.375; |
424 | glBegin GL_LINE_LOOP; |
480 | glBegin GL_LINE_LOOP; |
425 | glVertex 0 , 0; |
481 | glVertex 0 , 0; |
426 | glVertex $self->{w}, 0; |
482 | glVertex $self->{w} - 1, 0; |
427 | glVertex $self->{w}, $self->{h}; |
483 | glVertex $self->{w} - 1, $self->{h} - 1; |
428 | glVertex 0 , $self->{h}; |
484 | glVertex 0 , $self->{h} - 1; |
429 | glEnd; |
485 | glEnd; |
430 | glPopMatrix; |
486 | glPopMatrix; |
431 | #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
487 | #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
432 | } |
488 | } |
433 | } |
489 | } |
… | |
… | |
453 | sub set_parent { |
509 | sub set_parent { |
454 | my ($self, $parent) = @_; |
510 | my ($self, $parent) = @_; |
455 | |
511 | |
456 | Scalar::Util::weaken ($self->{parent} = $parent); |
512 | Scalar::Util::weaken ($self->{parent} = $parent); |
457 | |
513 | |
458 | # TODO: req_w _does_change after ->reconfigure |
514 | $self->set_visible; |
|
|
515 | |
459 | $self->check_size |
516 | $self->check_size; |
460 | unless exists $self->{req_w}; |
|
|
461 | |
|
|
462 | $self->show; |
517 | $self->show; |
463 | } |
518 | } |
464 | |
519 | |
465 | sub check_size { |
520 | sub check_size { |
466 | my ($self, $forced) = @_; |
521 | my ($self, $forced) = @_; |
… | |
… | |
491 | sub emit { |
546 | sub emit { |
492 | my ($self, $signal, @args) = @_; |
547 | my ($self, $signal, @args) = @_; |
493 | |
548 | |
494 | $self->_emit ($signal, @args) |
549 | $self->_emit ($signal, @args) |
495 | || $self->$signal (@args); |
550 | || $self->$signal (@args); |
|
|
551 | } |
|
|
552 | |
|
|
553 | sub visibility_change { |
|
|
554 | #my ($self, $visible) = @_; |
496 | } |
555 | } |
497 | |
556 | |
498 | sub DESTROY { |
557 | sub DESTROY { |
499 | my ($self) = @_; |
558 | my ($self) = @_; |
500 | |
559 | |
… | |
… | |
613 | delete $child->{parent}; |
672 | delete $child->{parent}; |
614 | $child->hide; |
673 | $child->hide; |
615 | |
674 | |
616 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
675 | $self->{children} = [ grep $_ != $child, @{ $self->{children} } ]; |
617 | |
676 | |
618 | $self->check_size; |
677 | $self->check_size (1); |
619 | $self->update; |
678 | $self->update; |
620 | } |
679 | } |
621 | |
680 | |
622 | sub clear { |
681 | sub clear { |
623 | my ($self) = @_; |
682 | my ($self) = @_; |
… | |
… | |
763 | |
822 | |
764 | package CFClient::UI::ViewPort; |
823 | package CFClient::UI::ViewPort; |
765 | |
824 | |
766 | our @ISA = CFClient::UI::Window::; |
825 | our @ISA = CFClient::UI::Window::; |
767 | |
826 | |
|
|
827 | sub new { |
|
|
828 | my $class = shift; |
|
|
829 | |
|
|
830 | $class->SUPER::new ( |
|
|
831 | scroll_x => 0, |
|
|
832 | scroll_y => 1, |
|
|
833 | @_, |
|
|
834 | ) |
|
|
835 | } |
|
|
836 | |
768 | sub size_request { |
837 | sub size_request { |
769 | my ($self) = @_; |
838 | my ($self) = @_; |
770 | |
839 | |
771 | @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; |
840 | @$self{qw(child_w child_h)} = @{$self->child}{qw(req_w req_h)}; |
772 | |
841 | |
… | |
… | |
774 | } |
843 | } |
775 | |
844 | |
776 | sub size_allocate { |
845 | sub size_allocate { |
777 | my ($self, $w, $h) = @_; |
846 | my ($self, $w, $h) = @_; |
778 | |
847 | |
779 | my ($cw, $ch) = @$self{qw(child_w child_h)}; |
848 | $w = $self->{child_w} if $self->{scroll_x} && $self->{child_w}; |
780 | # $w = $self->{w}; |
849 | $h = $self->{child_h} if $self->{scroll_y} && $self->{child_h}; |
|
|
850 | |
781 | $self->child->configure (0, 0, $cw, $ch); |
851 | $self->child->configure (0, 0, $w, $h); |
782 | $self->update; |
852 | $self->update; |
783 | } |
853 | } |
784 | |
854 | |
785 | sub set_offset { |
855 | sub set_offset { |
786 | my ($self, $x, $y) = @_; |
856 | my ($self, $x, $y) = @_; |
… | |
… | |
837 | my $class = shift; |
907 | my $class = shift; |
838 | |
908 | |
839 | my $self; |
909 | my $self; |
840 | |
910 | |
841 | my $slider = new CFClient::UI::Slider |
911 | my $slider = new CFClient::UI::Slider |
842 | vertical => 1, |
912 | vertical => 1, |
843 | range => [0, 0, 1, 0.01], # HACK fix |
913 | range => [0, 0, 1, 0.01], # HACK fix |
844 | connect_changed => sub { |
914 | on_changed => sub { |
845 | $self->{vp}->set_offset (0, $_[1]); |
915 | $self->{vp}->set_offset (0, $_[1]); |
846 | }, |
916 | }, |
847 | ; |
917 | ; |
848 | |
918 | |
849 | $self = $class->SUPER::new ( |
919 | $self = $class->SUPER::new ( |
… | |
… | |
855 | $self->{vp}->add ($self->{scrolled}); |
925 | $self->{vp}->add ($self->{scrolled}); |
856 | $self->add ($self->{vp}); |
926 | $self->add ($self->{vp}); |
857 | $self->add ($self->{slider}); |
927 | $self->add ($self->{slider}); |
858 | |
928 | |
859 | $self |
929 | $self |
|
|
930 | } |
|
|
931 | |
|
|
932 | sub update { |
|
|
933 | my ($self) = @_; |
|
|
934 | |
|
|
935 | $self->SUPER::update; |
|
|
936 | |
|
|
937 | # todo: overwrite size_allocate of child |
|
|
938 | my $child = $self->{vp}->child; |
|
|
939 | $self->{slider}->set_range ([$self->{slider}{range}[0], 0, $child->{h}, $self->{vp}{h}, 1]); |
860 | } |
940 | } |
861 | |
941 | |
862 | sub size_allocate { |
942 | sub size_allocate { |
863 | my ($self, $w, $h) = @_; |
943 | my ($self, $w, $h) = @_; |
864 | |
944 | |
… | |
… | |
923 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1003 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
924 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
1004 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
925 | |
1005 | |
926 | sub new { |
1006 | sub new { |
927 | my $class = shift; |
1007 | my $class = shift; |
928 | |
|
|
929 | # TODO: user_x, user_y, overwrite moveto? |
|
|
930 | |
1008 | |
931 | my $self = $class->SUPER::new ( |
1009 | my $self = $class->SUPER::new ( |
932 | bg => [1, 1, 1, 1], |
1010 | bg => [1, 1, 1, 1], |
933 | border_bg => [1, 1, 1, 1], |
1011 | border_bg => [1, 1, 1, 1], |
934 | border => 0.6, |
1012 | border => 0.6, |
… | |
… | |
994 | my ($ev, $x, $y) = @_; |
1072 | my ($ev, $x, $y) = @_; |
995 | |
1073 | |
996 | my $dx = $ev->{x} - $ox; |
1074 | my $dx = $ev->{x} - $ox; |
997 | my $dy = $ev->{y} - $oy; |
1075 | my $dy = $ev->{y} - $oy; |
998 | |
1076 | |
|
|
1077 | $self->{user_x} = $wx + $dx * $mx; |
|
|
1078 | $self->{user_y} = $wy + $dy * $my; |
999 | $self->{user_w} = $bw + $dx * ($mx ? -1 : 1); |
1079 | $self->{def_w} = $bw + $dx * ($mx ? -1 : 1); |
1000 | $self->{user_h} = $bh + $dy * ($my ? -1 : 1); |
1080 | $self->{def_h} = $bh + $dy * ($my ? -1 : 1); |
1001 | $self->move ($wx + $dx * $mx, $wy + $dy * $my); |
1081 | $self->move ($self->{user_x}, $self->{user_y}); |
1002 | $self->check_size; |
1082 | $self->check_size; |
1003 | }; |
1083 | }; |
1004 | |
1084 | |
1005 | } elsif ($lr ^ $td) { |
1085 | } elsif ($lr ^ $td) { |
1006 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
1086 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
… | |
… | |
1009 | $self->{motion} = sub { |
1089 | $self->{motion} = sub { |
1010 | my ($ev, $x, $y) = @_; |
1090 | my ($ev, $x, $y) = @_; |
1011 | |
1091 | |
1012 | ($x, $y) = ($ev->{x}, $ev->{y}); |
1092 | ($x, $y) = ($ev->{x}, $ev->{y}); |
1013 | |
1093 | |
1014 | $self->move ($bx + $x - $ox, $by + $y - $oy); |
1094 | $self->{user_x} = $bx + $x - $ox; |
|
|
1095 | $self->{user_y} = $by + $y - $oy; |
|
|
1096 | |
|
|
1097 | $self->move ($self->{user_x}, $self->{user_y}); |
1015 | $self->update; |
1098 | $self->update; |
1016 | }; |
1099 | }; |
1017 | } |
1100 | } |
1018 | } |
1101 | } |
1019 | |
1102 | |
… | |
… | |
1081 | sub new { |
1164 | sub new { |
1082 | my $class = shift; |
1165 | my $class = shift; |
1083 | |
1166 | |
1084 | $class->SUPER::new ( |
1167 | $class->SUPER::new ( |
1085 | col_expand => [], |
1168 | col_expand => [], |
1086 | @_ |
1169 | @_, |
1087 | ) |
1170 | ) |
|
|
1171 | } |
|
|
1172 | |
|
|
1173 | sub children { |
|
|
1174 | grep $_, map @$_, grep $_, @{ $_[0]{children} } |
1088 | } |
1175 | } |
1089 | |
1176 | |
1090 | sub add { |
1177 | sub add { |
1091 | my ($self, $x, $y, $child) = @_; |
1178 | my ($self, $x, $y, $child) = @_; |
1092 | |
1179 | |
1093 | $child->set_parent ($self); |
1180 | $child->set_parent ($self); |
1094 | $self->{children}[$y][$x] = $child; |
1181 | $self->{children}[$y][$x] = $child; |
1095 | |
1182 | |
1096 | $child->check_size; |
1183 | $self->check_size (1); |
1097 | } |
1184 | } |
1098 | |
1185 | |
1099 | sub children { |
|
|
1100 | grep $_, map @$_, grep $_, @{ $_[0]{children} } |
|
|
1101 | } |
|
|
1102 | |
|
|
1103 | # TODO: move to container class maybe? send childs a signal on removal? |
1186 | # TODO: move to container class maybe? send children a signal on removal? |
1104 | sub clear { |
1187 | sub clear { |
1105 | my ($self) = @_; |
1188 | my ($self) = @_; |
1106 | |
1189 | |
1107 | my @children = $self->children; |
1190 | my @children = $self->children; |
1108 | delete $self->{children}; |
1191 | delete $self->{children}; |
… | |
… | |
1110 | for (@children) { |
1193 | for (@children) { |
1111 | delete $_->{parent}; |
1194 | delete $_->{parent}; |
1112 | $_->hide; |
1195 | $_->hide; |
1113 | } |
1196 | } |
1114 | |
1197 | |
|
|
1198 | $self->check_size (1); |
1115 | $self->update; |
1199 | $self->update; |
1116 | } |
1200 | } |
1117 | |
1201 | |
1118 | sub get_wh { |
1202 | sub get_wh { |
1119 | my ($self) = @_; |
1203 | my ($self) = @_; |
… | |
… | |
1151 | sub size_allocate { |
1235 | sub size_allocate { |
1152 | my ($self, $w, $h) = @_; |
1236 | my ($self, $w, $h) = @_; |
1153 | |
1237 | |
1154 | my ($ws, $hs) = $self->get_wh; |
1238 | my ($ws, $hs) = $self->get_wh; |
1155 | |
1239 | |
1156 | my $req_w = sum @$ws; |
1240 | my $req_w = (sum @$ws) || 1; |
1157 | my $req_h = sum @$hs; |
1241 | my $req_h = (sum @$hs) || 1; |
1158 | |
1242 | |
1159 | # TODO: nicer code && do row_expand |
1243 | # TODO: nicer code && do row_expand |
1160 | my @col_expand = @{$self->{col_expand}}; |
1244 | my @col_expand = @{$self->{col_expand}}; |
1161 | @col_expand = (1) x @$ws unless @col_expand; |
1245 | @col_expand = (1) x @$ws unless @col_expand; |
1162 | my $col_expand = (sum @col_expand) || 1; |
1246 | my $col_expand = (sum @col_expand) || 1; |
… | |
… | |
1216 | } |
1300 | } |
1217 | } |
1301 | } |
1218 | |
1302 | |
1219 | ############################################################################# |
1303 | ############################################################################# |
1220 | |
1304 | |
1221 | package CFClient::UI::HBox; |
1305 | package CFClient::UI::Box; |
1222 | |
|
|
1223 | # TODO: wrap into common Box base class |
|
|
1224 | |
1306 | |
1225 | our @ISA = CFClient::UI::Container::; |
1307 | our @ISA = CFClient::UI::Container::; |
1226 | |
1308 | |
1227 | sub size_request { |
1309 | sub size_request { |
1228 | my ($self) = @_; |
1310 | my ($self) = @_; |
1229 | |
1311 | |
1230 | my @alloc = map [$_->size_request], @{$self->{children}}; |
1312 | $self->{vertical} |
1231 | |
1313 | ? ( |
1232 | ( |
1314 | (List::Util::max map $_->{req_w}, @{$self->{children}}), |
1233 | (List::Util::sum map $_->[0], @alloc), |
1315 | (List::Util::sum map $_->{req_h}, @{$self->{children}}), |
1234 | (List::Util::max map $_->[1], @alloc), |
1316 | ) |
1235 | ) |
1317 | : ( |
|
|
1318 | (List::Util::sum map $_->{req_w}, @{$self->{children}}), |
|
|
1319 | (List::Util::max map $_->{req_h}, @{$self->{children}}), |
|
|
1320 | ) |
1236 | } |
1321 | } |
1237 | |
1322 | |
1238 | sub size_allocate { |
1323 | sub size_allocate { |
1239 | my ($self, $w, $h) = @_; |
1324 | my ($self, $w, $h) = @_; |
1240 | |
1325 | |
1241 | ($h, $w) = ($w, $h); |
1326 | my $space = $self->{vertical} ? $h : $w; |
1242 | |
|
|
1243 | my $children = $self->{children}; |
1327 | my $children = $self->{children}; |
1244 | |
1328 | |
1245 | my @h = map $_->{req_w}, @$children; |
1329 | my @req = map $_->{$self->{vertical} ? "req_h" : "req_w"}, @$children; |
1246 | |
|
|
1247 | my $req_h = List::Util::sum @h; |
1330 | my $req = List::Util::sum @req; |
1248 | |
1331 | |
1249 | if ($req_h > $h) { |
1332 | if ($req > $space) { |
1250 | # ah well, not enough space |
1333 | # ah well, not enough space |
1251 | $_ *= $h / $req_h for @h; |
1334 | $_ *= $space / $req for @req; |
1252 | } else { |
1335 | } else { |
1253 | my $exp = List::Util::sum map $_->{expand}, @$children; |
1336 | my $expand = (List::Util::sum map $_->{expand}, @$children) || 1; |
1254 | $exp ||= 1; |
|
|
1255 | |
1337 | |
|
|
1338 | $req[$_] += ($space - $req) * $children->[$_]{expand} / $expand |
1256 | for (0 .. $#$children) { |
1339 | for 0 .. $#$children; |
1257 | my $child = $children->[$_]; |
|
|
1258 | |
|
|
1259 | my $alloc_h = $h[$_]; |
|
|
1260 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
|
|
1261 | $h[$_] = $alloc_h; |
|
|
1262 | } |
|
|
1263 | } |
1340 | } |
1264 | |
1341 | |
1265 | CFClient::UI::harmonize \@h; |
1342 | CFClient::UI::harmonize \@req; |
1266 | |
1343 | |
1267 | my $y = 0; |
1344 | my $pos = 0; |
1268 | for (0 .. $#$children) { |
1345 | for (0 .. $#$children) { |
1269 | my $child = $children->[$_]; |
|
|
1270 | my $h = $h[$_]; |
1346 | my $alloc = $req[$_]; |
1271 | $child->configure ($y, 0, $h, $w); |
1347 | $children->[$_]->configure ($self->{vertical} ? (0, $pos, $w, $alloc) : ($pos, 0, $alloc, $h)); |
1272 | |
1348 | |
1273 | $y += $h; |
1349 | $pos += $alloc; |
1274 | } |
1350 | } |
1275 | |
1351 | |
1276 | 1 |
1352 | 1 |
1277 | } |
1353 | } |
1278 | |
1354 | |
1279 | ############################################################################# |
1355 | ############################################################################# |
1280 | |
1356 | |
|
|
1357 | package CFClient::UI::HBox; |
|
|
1358 | |
|
|
1359 | our @ISA = CFClient::UI::Box::; |
|
|
1360 | |
|
|
1361 | sub new { |
|
|
1362 | my $class = shift; |
|
|
1363 | |
|
|
1364 | $class->SUPER::new ( |
|
|
1365 | vertical => 0, |
|
|
1366 | @_, |
|
|
1367 | ) |
|
|
1368 | } |
|
|
1369 | |
|
|
1370 | ############################################################################# |
|
|
1371 | |
1281 | package CFClient::UI::VBox; |
1372 | package CFClient::UI::VBox; |
1282 | |
1373 | |
1283 | # TODO: wrap into common Box base class |
|
|
1284 | |
|
|
1285 | our @ISA = CFClient::UI::Container::; |
1374 | our @ISA = CFClient::UI::Box::; |
1286 | |
1375 | |
1287 | sub size_request { |
1376 | sub new { |
1288 | my ($self) = @_; |
1377 | my $class = shift; |
1289 | |
1378 | |
1290 | my @alloc = map [$_->size_request], @{$self->{children}}; |
1379 | $class->SUPER::new ( |
1291 | |
1380 | vertical => 1, |
1292 | ( |
1381 | @_, |
1293 | (List::Util::max map $_->[0], @alloc), |
|
|
1294 | (List::Util::sum map $_->[1], @alloc), |
|
|
1295 | ) |
1382 | ) |
1296 | } |
|
|
1297 | |
|
|
1298 | sub size_allocate { |
|
|
1299 | my ($self, $w, $h) = @_; |
|
|
1300 | |
|
|
1301 | Carp::confess "negative size" if $w < 0 || $h < 0;#d# |
|
|
1302 | |
|
|
1303 | my $children = $self->{children}; |
|
|
1304 | |
|
|
1305 | my @h = map $_->{req_h}, @$children; |
|
|
1306 | |
|
|
1307 | my $req_h = List::Util::sum @h; |
|
|
1308 | |
|
|
1309 | if ($req_h > $h) { |
|
|
1310 | # ah well, not enough space |
|
|
1311 | $_ *= $h / $req_h for @h; |
|
|
1312 | } else { |
|
|
1313 | my $exp = List::Util::sum map $_->{expand}, @$children; |
|
|
1314 | $exp ||= 1; |
|
|
1315 | |
|
|
1316 | for (0 .. $#$children) { |
|
|
1317 | my $child = $children->[$_]; |
|
|
1318 | |
|
|
1319 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
|
|
1320 | } |
|
|
1321 | } |
|
|
1322 | |
|
|
1323 | CFClient::UI::harmonize \@h; |
|
|
1324 | |
|
|
1325 | my $y = 0; |
|
|
1326 | for (0 .. $#$children) { |
|
|
1327 | my $child = $children->[$_]; |
|
|
1328 | my $h = $h[$_]; |
|
|
1329 | $child->configure (0, $y, $w, $h); |
|
|
1330 | |
|
|
1331 | $y += $h; |
|
|
1332 | } |
|
|
1333 | |
|
|
1334 | 1 |
|
|
1335 | } |
1383 | } |
1336 | |
1384 | |
1337 | ############################################################################# |
1385 | ############################################################################# |
1338 | |
1386 | |
1339 | package CFClient::UI::Label; |
1387 | package CFClient::UI::Label; |
… | |
… | |
2116 | } |
2164 | } |
2117 | |
2165 | |
2118 | sub set_range { |
2166 | sub set_range { |
2119 | my ($self, $range) = @_; |
2167 | my ($self, $range) = @_; |
2120 | |
2168 | |
2121 | $self->{range} = $range; |
2169 | ($range, $self->{range}) = ($self->{range}, $range); |
2122 | |
2170 | |
2123 | $self->update; |
2171 | $self->update |
|
|
2172 | if "@$range" ne "@{$self->{range}}"; |
2124 | } |
2173 | } |
2125 | |
2174 | |
2126 | sub set_value { |
2175 | sub set_value { |
2127 | my ($self, $value) = @_; |
2176 | my ($self, $value) = @_; |
2128 | |
2177 | |
… | |
… | |
2511 | |
2560 | |
2512 | sub new { |
2561 | sub new { |
2513 | my $class = shift; |
2562 | my $class = shift; |
2514 | |
2563 | |
2515 | my $self = $class->SUPER::new ( |
2564 | my $self = $class->SUPER::new ( |
2516 | state => 0, |
2565 | state => 0, |
2517 | connect_activate => \&toggle_flopper, |
2566 | on_activate => \&toggle_flopper, |
2518 | @_ |
2567 | @_ |
2519 | ); |
2568 | ); |
2520 | |
2569 | |
2521 | if ($self->{state}) { |
|
|
2522 | $self->{state} = 0; |
|
|
2523 | $self->toggle_flopper; |
|
|
2524 | } |
|
|
2525 | |
|
|
2526 | $self |
2570 | $self |
2527 | } |
2571 | } |
2528 | |
2572 | |
2529 | sub toggle_flopper { |
2573 | sub toggle_flopper { |
2530 | my ($self) = @_; |
2574 | my ($self) = @_; |
2531 | |
2575 | |
2532 | # TODO: use animation |
2576 | $self->{other}->toggle_visibility; |
2533 | if ($self->{state} = !$self->{state}) { |
|
|
2534 | $CFClient::UI::ROOT->add ($self->{other}); |
|
|
2535 | $self->{other}->move ($self->coord2global (0, $self->{h})); |
|
|
2536 | $self->_emit ("open"); |
|
|
2537 | } else { |
|
|
2538 | $CFClient::UI::ROOT->remove ($self->{other}); |
|
|
2539 | $self->_emit ("close"); |
|
|
2540 | } |
|
|
2541 | |
|
|
2542 | $self->_emit (changed => $self->{state}); |
|
|
2543 | } |
2577 | } |
2544 | |
2578 | |
2545 | ############################################################################# |
2579 | ############################################################################# |
2546 | |
2580 | |
2547 | package CFClient::UI::Tooltip; |
2581 | package CFClient::UI::Tooltip; |
… | |
… | |
2623 | |
2657 | |
2624 | sub new { |
2658 | sub new { |
2625 | my $class = shift; |
2659 | my $class = shift; |
2626 | |
2660 | |
2627 | my $self = $class->SUPER::new ( |
2661 | my $self = $class->SUPER::new ( |
2628 | aspect => 1, |
2662 | aspect => 1, |
|
|
2663 | can_events => 0, |
2629 | @_, |
2664 | @_, |
2630 | ); |
2665 | ); |
2631 | |
2666 | |
2632 | if ($self->{anim} && $self->{animspeed}) { |
2667 | if ($self->{anim} && $self->{animspeed}) { |
2633 | Scalar::Util::weaken (my $widget = $self); |
2668 | Scalar::Util::weaken (my $widget = $self); |
… | |
… | |
2692 | $self->SUPER::DESTROY; |
2727 | $self->SUPER::DESTROY; |
2693 | } |
2728 | } |
2694 | |
2729 | |
2695 | ############################################################################# |
2730 | ############################################################################# |
2696 | |
2731 | |
2697 | package CFClient::UI::InventoryItem; |
2732 | package CFClient::UI::Inventory; |
2698 | |
2733 | |
2699 | our @ISA = CFClient::UI::HBox::; |
2734 | our @ISA = CFClient::UI::ScrolledWindow::; |
2700 | |
|
|
2701 | sub _item_to_desc { |
|
|
2702 | my ($item) = @_; |
|
|
2703 | |
|
|
2704 | my $desc = |
|
|
2705 | $item->{nrof} < 2 |
|
|
2706 | ? $item->{name} |
|
|
2707 | : "$item->{nrof} × $item->{name_pl}"; |
|
|
2708 | |
|
|
2709 | $item->{flags} & Crossfire::Protocol::F_OPEN |
|
|
2710 | and $desc .= " (open)"; |
|
|
2711 | $item->{flags} & Crossfire::Protocol::F_APPLIED |
|
|
2712 | and $desc .= " (applied)"; |
|
|
2713 | $item->{flags} & Crossfire::Protocol::F_UNPAID |
|
|
2714 | and $desc .= " (unpaid)"; |
|
|
2715 | $item->{flags} & Crossfire::Protocol::F_MAGIC |
|
|
2716 | and $desc .= " (magic)"; |
|
|
2717 | $item->{flags} & Crossfire::Protocol::F_CURSED |
|
|
2718 | and $desc .= " (cursed)"; |
|
|
2719 | $item->{flags} & Crossfire::Protocol::F_DAMNED |
|
|
2720 | and $desc .= " (damned)"; |
|
|
2721 | $item->{flags} & Crossfire::Protocol::F_LOCKED |
|
|
2722 | and $desc .= " *"; |
|
|
2723 | |
|
|
2724 | $desc |
|
|
2725 | } |
|
|
2726 | |
2735 | |
2727 | sub new { |
2736 | sub new { |
2728 | my $class = shift; |
2737 | my $class = shift; |
2729 | |
2738 | |
2730 | my %args = @_; |
|
|
2731 | |
|
|
2732 | my $item = delete $args{item}; |
|
|
2733 | |
|
|
2734 | my $desc = _item_to_desc ($item); |
|
|
2735 | |
|
|
2736 | my $self = $class->SUPER::new ( |
2739 | my $self = $class->SUPER::new ( |
2737 | can_hover => 1, |
|
|
2738 | can_events => 1, |
|
|
2739 | tooltip => ((CFClient::UI::Label::escape $desc) |
|
|
2740 | . "\n<small>leftclick - examine\nshift+leftclick - move/pickup/drop\nmiddle click - apply\nrightclick - menu</small>"), |
|
|
2741 | connect_button_down => sub { |
|
|
2742 | my ($self, $ev, $x, $y) = @_; |
|
|
2743 | |
|
|
2744 | # todo: maybe put examine on 1? but should just be a tooltip :( |
|
|
2745 | if (($ev->{mod} & CFClient::KMOD_SHIFT) && $ev->{button} == 1) { |
|
|
2746 | my $targ = $::CONN->{player}{tag}; |
|
|
2747 | |
|
|
2748 | if ($item->{container} == $::CONN->{player}{tag}) { |
|
|
2749 | $targ = $main::OPENCONT; |
|
|
2750 | } |
|
|
2751 | |
|
|
2752 | $::CONN->send ("move $targ $item->{tag} 0"); |
|
|
2753 | } elsif ($ev->{button} == 1) { |
|
|
2754 | $::CONN->send ("examine $item->{tag}"); |
|
|
2755 | } elsif ($ev->{button} == 2) { |
|
|
2756 | $::CONN->send ("apply $item->{tag}"); |
|
|
2757 | } elsif ($ev->{button} == 3) { |
|
|
2758 | my @menu_items = ( |
|
|
2759 | ["examine", sub { $::CONN->send ("examine $item->{tag}") }], |
|
|
2760 | ["mark", sub { $::CONN->send ("mark ". pack "N", $item->{tag}) }], |
|
|
2761 | ["apply", sub { $::CONN->send ("apply $item->{tag}") }], |
|
|
2762 | ( |
|
|
2763 | $item->{flags} & Crossfire::Protocol::F_LOCKED |
|
|
2764 | ? ( |
|
|
2765 | ["unlock", sub { $::CONN->send ("lock " . pack "CN", 0, $item->{tag}) }], |
|
|
2766 | ) |
|
|
2767 | : ( |
|
|
2768 | ["lock", sub { $::CONN->send ("lock " . pack "CN", 1, $item->{tag}) }], |
|
|
2769 | ["drop", sub { $::CONN->send ("move $main::OPENCONT $item->{tag} 0") }], |
|
|
2770 | ) |
|
|
2771 | ), |
|
|
2772 | ); |
|
|
2773 | |
|
|
2774 | CFClient::UI::Menu->new (items => \@menu_items)->popup ($ev); |
|
|
2775 | } |
|
|
2776 | |
|
|
2777 | 1 |
|
|
2778 | }, |
|
|
2779 | %args |
|
|
2780 | ); |
|
|
2781 | |
|
|
2782 | |
|
|
2783 | $self->add (new CFClient::UI::Face |
|
|
2784 | can_events => 0, |
|
|
2785 | face => $item->{face}, |
|
|
2786 | anim => $item->{anim}, |
|
|
2787 | animspeed => $item->{animspeed}, |
|
|
2788 | ); |
|
|
2789 | |
|
|
2790 | $self->add ($self->{name_lbl} = new CFClient::UI::Label can_events => 0); |
|
|
2791 | |
|
|
2792 | $self->{item} = $item; |
|
|
2793 | |
|
|
2794 | $self->update_item; |
|
|
2795 | |
|
|
2796 | $self |
|
|
2797 | } |
|
|
2798 | |
|
|
2799 | sub update_item { |
|
|
2800 | my ($self) = @_; |
|
|
2801 | |
|
|
2802 | my $desc = _item_to_desc ($self->{item}); |
|
|
2803 | |
|
|
2804 | $self->{name_lbl}->set_text ($desc); |
|
|
2805 | } |
|
|
2806 | |
|
|
2807 | ############################################################################# |
|
|
2808 | |
|
|
2809 | package CFClient::UI::Inventory; |
|
|
2810 | |
|
|
2811 | our @ISA = CFClient::UI::ScrolledWindow::; |
|
|
2812 | |
|
|
2813 | sub new { |
|
|
2814 | my $class = shift; |
|
|
2815 | |
|
|
2816 | my $self = $class->SUPER::new ( |
|
|
2817 | scrolled => (new CFClient::UI::Table), |
2740 | scrolled => (new CFClient::UI::Table col_expand => [0, 1, 0]), |
2818 | @_, |
2741 | @_, |
2819 | ); |
2742 | ); |
2820 | |
2743 | |
2821 | $self |
2744 | $self |
2822 | } |
2745 | } |
… | |
… | |
2832 | or ($a->{name} cmp $b->{name}) |
2755 | or ($a->{name} cmp $b->{name}) |
2833 | } @$items; |
2756 | } @$items; |
2834 | |
2757 | |
2835 | $self->{real_items} = \@items; |
2758 | $self->{real_items} = \@items; |
2836 | |
2759 | |
|
|
2760 | my $row = 0; |
2837 | for my $item (@items) { |
2761 | for my $item (@items) { |
2838 | $item->{item} = $item; |
2762 | CFClient::Item::update_widgets $item; |
2839 | $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item; |
|
|
2840 | $item->update_item (); |
|
|
2841 | } |
|
|
2842 | |
2763 | |
2843 | my $i = 0; |
2764 | $self->{scrolled}->add (0, $row, $item->{face_widget}); |
2844 | for (@items) { |
2765 | $self->{scrolled}->add (1, $row, $item->{desc_widget}); |
2845 | $self->{scrolled}->add (0, $i, $_); |
2766 | $self->{scrolled}->add (2, $row, $item->{weight_widget}); |
2846 | my $nrof = $_->{item}->{nrof} || 1; |
|
|
2847 | $self->{scrolled}->add (1, $i++, new CFClient::UI::Label text => ($_->{item}->{weight} * $nrof) / 1000); |
|
|
2848 | } |
|
|
2849 | |
2767 | |
2850 | # $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; |
2768 | $row++; |
2851 | } |
2769 | } |
2852 | |
|
|
2853 | sub size_request { |
|
|
2854 | my ($self) = @_; |
|
|
2855 | ($self->{req_w}, $self->{req_h}); |
|
|
2856 | } |
2770 | } |
2857 | |
2771 | |
2858 | ############################################################################# |
2772 | ############################################################################# |
2859 | |
2773 | |
2860 | package CFClient::UI::Menu; |
2774 | package CFClient::UI::Menu; |
… | |
… | |
3047 | |
2961 | |
3048 | sub new { |
2962 | sub new { |
3049 | my $class = shift; |
2963 | my $class = shift; |
3050 | |
2964 | |
3051 | $class->SUPER::new ( |
2965 | $class->SUPER::new ( |
|
|
2966 | visible => 1, |
3052 | @_, |
2967 | @_, |
3053 | ) |
2968 | ) |
3054 | } |
2969 | } |
3055 | |
2970 | |
3056 | sub configure { |
2971 | sub configure { |
… | |
… | |
3083 | if exists $child->{req_x}; |
2998 | if exists $child->{req_x}; |
3084 | |
2999 | |
3085 | $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1 |
3000 | $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1 |
3086 | if exists $child->{req_y}; |
3001 | if exists $child->{req_y}; |
3087 | |
3002 | |
|
|
3003 | delete @$child{qw(req_x req_y)}; |
|
|
3004 | |
3088 | $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5; |
3005 | $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5; |
3089 | $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5; |
3006 | $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5; |
3090 | |
3007 | |
3091 | $child->configure ($X, $Y, $W, $H); |
3008 | $child->configure ($X, $Y, $W, $H); |
3092 | } |
3009 | } |
… | |
… | |
3111 | $::WANT_REFRESH++; |
3028 | $::WANT_REFRESH++; |
3112 | } |
3029 | } |
3113 | |
3030 | |
3114 | sub add { |
3031 | sub add { |
3115 | my ($self, @children) = @_; |
3032 | my ($self, @children) = @_; |
3116 | |
|
|
3117 | for (my @widgets = @children; my $w = pop @widgets; ) { |
|
|
3118 | push @widgets, $w->children; |
|
|
3119 | $w->{root} = $self; |
|
|
3120 | $w->{visible} = 1; |
|
|
3121 | } |
|
|
3122 | |
3033 | |
3123 | for my $child (@children) { |
3034 | for my $child (@children) { |
3124 | $child->{is_toplevel} = 1; |
3035 | $child->{is_toplevel} = 1; |
3125 | |
3036 | |
3126 | # integerise window positions |
3037 | # integerise window positions |
3127 | $child->{x} = int $child->{x}; |
3038 | $child->{x} = int $child->{x}; |
3128 | $child->{y} = int $child->{y}; |
3039 | $child->{y} = int $child->{y}; |
3129 | } |
3040 | } |
3130 | |
3041 | |
3131 | $self->SUPER::add (@children); |
3042 | $self->SUPER::add (@children); |
|
|
3043 | |
|
|
3044 | for (my @widgets = @children; my $w = pop @widgets; ) { |
|
|
3045 | push @widgets, $w->children; |
|
|
3046 | $w->set_visible; |
|
|
3047 | } |
|
|
3048 | |
3132 | } |
3049 | } |
3133 | |
3050 | |
3134 | sub remove { |
3051 | sub remove { |
3135 | my ($self, @children) = @_; |
3052 | my ($self, @children) = @_; |
3136 | |
3053 | |
… | |
… | |
3162 | $_->() |
3079 | $_->() |
3163 | for values %{delete $self->{refresh_hook}}; |
3080 | for values %{delete $self->{refresh_hook}}; |
3164 | } |
3081 | } |
3165 | |
3082 | |
3166 | if ($self->{check_size}) { |
3083 | if ($self->{check_size}) { |
3167 | my @queue = ([], []); |
3084 | my @queue; |
3168 | |
3085 | |
3169 | for (;;) { |
3086 | for (;;) { |
3170 | if ($self->{check_size}) { |
3087 | if ($self->{check_size}) { |
3171 | # heuristic: check containers last |
3088 | #TODO use array-of-depth approach |
3172 | push @{ $queue[ ! ! $_->isa ("CFClient::UI::Container") ] }, $_ |
3089 | |
|
|
3090 | @queue = sort { $a->{visible} <=> $b->{visible} } |
3173 | for values %{delete $self->{check_size}} |
3091 | @queue, values %{delete $self->{check_size}}; |
3174 | } |
3092 | } |
3175 | |
3093 | |
3176 | my $widget = (pop @{ $queue[0] }) || (pop @{ $queue[1] }) || last; |
3094 | my $widget = pop @queue || last; |
3177 | |
3095 | |
|
|
3096 | defined $widget->{visible} or last; # do not resize invisible widgets |
|
|
3097 | |
3178 | my ($w, $h) = $widget->{user_w} && $widget->{user_h} |
3098 | my ($w, $h) = $widget->{def_w} && $widget->{def_h} |
3179 | ? @$widget{qw(user_w user_h)} |
3099 | ? @$widget{qw(def_w def_h)} |
3180 | : $widget->size_request; |
3100 | : $widget->size_request; |
3181 | |
3101 | |
3182 | if (delete $widget->{force_alloc} |
3102 | if (delete $widget->{force_alloc} |
3183 | or $w != $widget->{req_w} or $h != $widget->{req_h}) { |
3103 | or $w != $widget->{req_w} or $h != $widget->{req_h}) { |
3184 | Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d# |
3104 | Carp::confess "$widget: size_request is negative" if $w < 0 || $h < 0;#d# |