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.198 by root, Fri May 12 02:08:52 2006 UTC vs.
Revision 1.206 by root, Mon May 15 17:45:29 2006 UTC

11our ($FOCUS, $HOVER, $GRAB); # various widgets 11our ($FOCUS, $HOVER, $GRAB); # various widgets
12 12
13our $ROOT; 13our $ROOT;
14our $TOOLTIP; 14our $TOOLTIP;
15our $BUTTON_STATE; 15our $BUTTON_STATE;
16
17our %WIDGET; # all widgets, weak-referenced
16 18
17sub check_tooltip { 19sub check_tooltip {
18 if (!$GRAB) { 20 if (!$GRAB) {
19 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { 21 for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) {
20 if (length $widget->{tooltip}) { 22 if (length $widget->{tooltip}) {
29 $TOOLTIP->set_tooltip_from ($widget); 31 $TOOLTIP->set_tooltip_from ($widget);
30 $TOOLTIP->show; 32 $TOOLTIP->show;
31 33
32 my ($x, $y) = $widget->coord2global ($widget->{w}, 0); 34 my ($x, $y) = $widget->coord2global ($widget->{w}, 0);
33 35
34 if ($x + $TOOLTIP->{w} > $::WIDTH) {
35 ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0); 36 ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0)
36 } 37 if $x + $TOOLTIP->{w} > $::WIDTH;
37 38
38 $TOOLTIP->move ($x, $y); 39 $TOOLTIP->move ($x, $y);
39 $TOOLTIP->check_size; 40 $TOOLTIP->check_size;
40 $TOOLTIP->update; 41 $TOOLTIP->update;
41 } 42 }
132 133
133 for (@$vals) { 134 for (@$vals) {
134 my $i = int $_ + $rem; 135 my $i = int $_ + $rem;
135 $rem += $_ - $i; 136 $rem += $_ - $i;
136 $_ = $i; 137 $_ = $i;
138 }
139}
140
141# call when resolution changes etc.
142sub rescale_widgets {
143 my ($sx, $sy) = @_;
144
145 for my $widget (values %WIDGET) {
146 if ($widget->{toplevel}) {
147 $widget->{x} = int 0.5 + $widget->{x} * $sx if exists $widget->{x};
148 $widget->{w} = int 0.5 + $widget->{w} * $sx if exists $widget->{w};
149 $widget->{req_w} = int 0.5 + $widget->{req_w} * $sx if exists $widget->{req_w};
150 $widget->{user_w} = int 0.5 + $widget->{user_w} * $sx if exists $widget->{user_w};
151 $widget->{y} = int 0.5 + $widget->{y} * $sy if exists $widget->{y};
152 $widget->{h} = int 0.5 + $widget->{h} * $sy if exists $widget->{h};
153 $widget->{req_h} = int 0.5 + $widget->{req_h} * $sy if exists $widget->{req_h};
154 $widget->{user_h} = int 0.5 + $widget->{user_h} * $sy if exists $widget->{user_h};
155 }
156
157 $widget->reconfigure;
137 } 158 }
138} 159}
139 160
140############################################################################# 161#############################################################################
141 162
160 if (/^connect_(.*)$/) { 181 if (/^connect_(.*)$/) {
161 $self->connect ($1 => delete $self->{$_}); 182 $self->connect ($1 => delete $self->{$_});
162 } 183 }
163 } 184 }
164 185
186 Scalar::Util::weaken ($CFClient::UI::WIDGET{$self+0} = $self);
187
165 $self 188 $self
166} 189}
167 190
168sub destroy { 191sub destroy {
169 my ($self) = @_; 192 my ($self) = @_;
242 265
243sub size_allocate { 266sub size_allocate {
244 # nothing to be done 267 # nothing to be done
245} 268}
246 269
247sub children {
248}
249
250# call when resolution changes etc.
251sub reconfigure { 270sub reconfigure {
252 my ($self) = @_; 271 my ($self) = @_;
253
254 $_->reconfigure
255 for $self->children;
256 272
257 $self->check_size (1); 273 $self->check_size (1);
258 $self->update; 274 $self->update;
275}
276
277sub children {
259} 278}
260 279
261sub set_max_size { 280sub set_max_size {
262 my ($self, $w, $h) = @_; 281 my ($self, $w, $h) = @_;
263 282
356 glVertex $self->{w}, 0; 375 glVertex $self->{w}, 0;
357 glVertex $self->{w}, $self->{h}; 376 glVertex $self->{w}, $self->{h};
358 glVertex 0 , $self->{h}; 377 glVertex 0 , $self->{h};
359 glEnd; 378 glEnd;
360 glPopMatrix; 379 glPopMatrix;
361 CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; 380 #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw;
362 } 381 }
363} 382}
364 383
365sub _draw { 384sub _draw {
366 my ($self) = @_; 385 my ($self) = @_;
383sub set_parent { 402sub set_parent {
384 my ($self, $parent) = @_; 403 my ($self, $parent) = @_;
385 404
386 Scalar::Util::weaken ($self->{parent} = $parent); 405 Scalar::Util::weaken ($self->{parent} = $parent);
387 406
388
389 # TODO: req_w _does_change after ->reconfigure 407 # TODO: req_w _does_change after ->reconfigure
390 $self->check_size 408 $self->check_size
391 unless exists $self->{req_w}; 409 unless exists $self->{req_w};
392} 410}
393 411
418} 436}
419 437
420sub DESTROY { 438sub DESTROY {
421 my ($self) = @_; 439 my ($self) = @_;
422 440
441 delete $WIDGET{$self+0};
423 #$self->deactivate; 442 #$self->deactivate;
424} 443}
425 444
426############################################################################# 445#############################################################################
427 446
777 $self->add ($self->{slider}); 796 $self->add ($self->{slider});
778 797
779 $self 798 $self
780} 799}
781 800
782#TODO# update range on size_allocate depeneing on child 801#TODO# update range on size_allocate depending on child
783# update viewport offset on scroll 802# update viewport offset on scroll
784 803
785############################################################################# 804#############################################################################
786 805
787package CFClient::UI::Frame; 806package CFClient::UI::Frame;
788 807
789our @ISA = CFClient::UI::Bin::; 808our @ISA = CFClient::UI::Bin::;
790 809
791use CFClient::OpenGL; 810use CFClient::OpenGL;
811
812sub new {
813 my $class = shift;
814
815 $class->SUPER::new (
816 bg => undef,
817 @_,
818 )
819}
820
821sub _draw {
822 my ($self) = @_;
823
824 if ($self->{bg}) {
825 my ($w, $h) = @$self{qw(w h)};
826
827 glEnable GL_BLEND;
828 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
829 glColor @{ $self->{bg} };
830
831 glBegin GL_QUADS;
832 glVertex 0 , 0;
833 glVertex 0 , $h;
834 glVertex $w, $h;
835 glVertex $w, 0;
836 glEnd;
837
838 glDisable GL_BLEND;
839 }
840
841 $self->SUPER::_draw;
842}
792 843
793############################################################################# 844#############################################################################
794 845
795package CFClient::UI::FancyFrame; 846package CFClient::UI::FancyFrame;
796 847
809 860
810 my $self = $class->SUPER::new ( 861 my $self = $class->SUPER::new (
811 bg => [1, 1, 1, 1], 862 bg => [1, 1, 1, 1],
812 border_bg => [1, 1, 1, 1], 863 border_bg => [1, 1, 1, 1],
813 border => 0.6, 864 border => 0.6,
865 toplevel => 1,
814 can_events => 1, 866 can_events => 1,
815 @_ 867 @_
816 ); 868 );
817 869
818 $self->{title} &&= new CFClient::UI::Label 870 $self->{title} &&= new CFClient::UI::Label
1449 my $sym = $ev->{sym}; 1501 my $sym = $ev->{sym};
1450 my $uni = $ev->{unicode}; 1502 my $uni = $ev->{unicode};
1451 1503
1452 my $text = $self->get_text; 1504 my $text = $self->get_text;
1453 1505
1454 if ($sym == 8) { 1506 if ($uni == 8) {
1455 substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; 1507 substr $text, --$self->{cursor}, 1, "" if $self->{cursor};
1456 } elsif ($sym == 127) { 1508 } elsif ($uni == 127) {
1457 substr $text, $self->{cursor}, 1, ""; 1509 substr $text, $self->{cursor}, 1, "";
1458 } elsif ($sym == CFClient::SDLK_LEFT) { 1510 } elsif ($sym == CFClient::SDLK_LEFT) {
1459 --$self->{cursor} if $self->{cursor}; 1511 --$self->{cursor} if $self->{cursor};
1460 } elsif ($sym == CFClient::SDLK_RIGHT) { 1512 } elsif ($sym == CFClient::SDLK_RIGHT) {
1461 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1513 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1462 } elsif ($sym == CFClient::SDLK_HOME) { 1514 } elsif ($sym == CFClient::SDLK_HOME) {
1463 $self->{cursor} = 0; 1515 $self->{cursor} = 0;
1464 } elsif ($sym == CFClient::SDLK_END) { 1516 } elsif ($sym == CFClient::SDLK_END) {
1465 $self->{cursor} = length $text; 1517 $self->{cursor} = length $text;
1466 } elsif ($sym == 27) { 1518 } elsif ($uni == 27) {
1467 $self->emit ('escape'); 1519 $self->emit ('escape');
1468 } elsif ($uni) { 1520 } elsif ($uni) {
1469 substr $text, $self->{cursor}++, 0, chr $uni; 1521 substr $text, $self->{cursor}++, 0, chr $uni;
1470 } 1522 }
1471 1523
1958 qw(s1_slider.png s1_slider_bg.png); 2010 qw(s1_slider.png s1_slider_bg.png);
1959 2011
1960sub new { 2012sub new {
1961 my $class = shift; 2013 my $class = shift;
1962 2014
1963 # range [value, low, high, page] 2015 # range [value, low, high, page, unit]
1964 2016
1965 # TODO: 0-width page 2017 # TODO: 0-width page
1966 # TODO: req_w/h are wrong with vertical 2018 # TODO: req_w/h are wrong with vertical
1967 # TODO: calculations are off 2019 # TODO: calculations are off
1968 my $self = $class->SUPER::new ( 2020 my $self = $class->SUPER::new (
1971 range => [0, 0, 100, 10], 2023 range => [0, 0, 100, 10],
1972 req_w => $::WIDTH / 80, 2024 req_w => $::WIDTH / 80,
1973 req_h => $::WIDTH / 80, 2025 req_h => $::WIDTH / 80,
1974 vertical => 0, 2026 vertical => 0,
1975 can_hover => 1, 2027 can_hover => 1,
1976 inner_pad => 5, 2028 inner_pad => .05,
1977 @_ 2029 @_
1978 ); 2030 );
1979 2031
2032 $self->set_value ($self->{range}[0]);
2033 $self->update;
2034
1980 $self 2035 $self
2036}
2037
2038sub set_value {
2039 my ($self, $value) = @_;
2040
2041 my ($old_value, $lo, $hi, $page, $unit) = @{$self->{range}};
2042
2043 $hi = $lo + 1 if $hi <= $lo;
2044
2045 $value = $lo if $value < $lo;
2046 $value = $hi if $value > $hi;
2047
2048 $value = $lo + $unit * int +($value - $lo + $unit * 0.5) / $unit
2049 if $unit;
2050
2051 $page = $hi - $lo if $page > $hi - $lo;
2052
2053 @{$self->{range}} = ($value, $lo, $hi, $page, $unit);
2054
2055 if ($value != $old_value) {
2056 $self->emit (changed => $value);
2057 $self->update;
2058 }
1981} 2059}
1982 2060
1983sub size_request { 2061sub size_request {
1984 my ($self) = @_; 2062 my ($self) = @_;
1985 2063
1998 2076
1999sub mouse_motion { 2077sub mouse_motion {
2000 my ($self, $ev, $x, $y) = @_; 2078 my ($self, $ev, $x, $y) = @_;
2001 2079
2002 if ($GRAB == $self) { 2080 if ($GRAB == $self) {
2081 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w});
2082
2083 my (undef, $lo, $hi, $page) = @{$self->{range}};
2084
2085 $x = $x / ($w * (1 - 2 * $self->{inner_pad})) - $self->{inner_pad};
2086
2087 $self->set_value ($x * ($hi - $lo) + $lo);
2088 }
2089}
2090
2091sub update {
2092 my ($self) = @_;
2093
2094 $CFClient::UI::ROOT->on_post_alloc ($self => sub {
2095 $self->set_value ($self->{range}[0]);
2096
2003 my ($value, $lo, $hi, $page) = @{$self->{range}}; 2097 my ($value, $lo, $hi, $page) = @{$self->{range}};
2004 2098
2005 my ($x, $w) = $self->{vertical} ? ($y, $self->{h}) : ($x, $self->{w}); 2099 my $inner_w = 1 - 2 * $self->{inner_pad};
2006 2100
2007 my $inner_pad_px = $self->_calc_inner_pad_px ($w); 2101 $self->{scale} = ($inner_w / ($hi - $lo)) || 1;
2008 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
2009 2102
2010 $x -= $inner_pad_px; # substract the padding 2103 $page = $self->{scale} * $page || 10 / ($self->{w} || 1);
2011 $x = $x * ($hi - $lo) / $inner_w + $lo; 2104 $value = $self->{scale} * ($value - $lo);
2012 $x = $lo if $x < $lo;
2013 $x = $hi - $page if $x > $hi - $page;
2014 $self->{range}[0] = $x;
2015 2105
2016 $self->emit (changed => $x); 2106 $value = $self->{inner_pad} + ($value - $page * 0.5);
2017 $self->update; 2107
2108 $value = 0 if $value < 0;
2109 $page = 1 - $value if $value + $page > 1;
2110
2111 $self->{knob_x} = $value;
2112 $self->{knob_w} = $page;
2018 } 2113 });
2019}
2020 2114
2021# the inner_* stuff is for generating a padding for the slider handle, 2115 $self->SUPER::update;
2022# so that the handle doesn't leave the texture. This calculation isn't 100%
2023# correct propably, but it does the job for now
2024sub _calc_inner_pad_px {
2025 my ($self, $w) = @_;
2026 ($w / 100) * $self->{inner_pad} # % to pixels
2027} 2116}
2028 2117
2029sub _draw { 2118sub _draw {
2030 my ($self) = @_; 2119 my ($self) = @_;
2031 2120
2032 $self->SUPER::_draw (); 2121 $self->SUPER::_draw ();
2033 2122
2034 my ($w, $h) = @$self{qw(w h)}; 2123 glScale $self->{w}, $self->{h};
2035 2124
2036 if ($self->{vertical}) { 2125 if ($self->{vertical}) {
2037 # draw a vertical slider like a rotated horizontal slider 2126 # draw a vertical slider like a rotated horizontal slider
2038 2127
2039 glRotate 90, 0, 0, 1; 2128 glRotate 90, 0, 0, 1;
2040 glTranslate 0, -$self->{w}, 0; 2129 glTranslate 0, 1, 0;
2041
2042 ($w, $h) = ($h, $w);
2043 } 2130 }
2044 2131
2045 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg}; 2132 my $fg = $FOCUS == $self ? $self->{active_fg} : $self->{fg};
2046 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg}; 2133 my $bg = $FOCUS == $self ? $self->{active_bg} : $self->{bg};
2047 2134
2048 my ($value, $lo, $hi, $page) = @{$self->{range}};
2049
2050 $hi = $value + 1 if $lo == $hi;
2051
2052 my $inner_pad_px = $self->_calc_inner_pad_px ($w);
2053 my $inner_w = $w - $inner_pad_px * 2; # * 2 for left & right
2054
2055 $page = int $page * $inner_w / ($hi - $lo);
2056 $value = int +($value - $lo) * $inner_w / ($hi - $lo);
2057
2058 $w -= $page;
2059 $page &= ~1;
2060 glTranslate $page * 0.5, 0, 0;
2061 $page ||= 2;
2062
2063 my $knob_a = $inner_pad_px + ($value - $page * 0.5);
2064 my $knob_b = $inner_pad_px + ($value + $page * 0.5);
2065
2066 glEnable GL_TEXTURE_2D; 2135 glEnable GL_TEXTURE_2D;
2067 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2136 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2068 2137
2069 # draw background 2138 # draw background
2070 $tex[1]->draw_quad_alpha (0, 0, $w, $h); 2139 $tex[1]->draw_quad_alpha (0, 0, 1, 1);
2071 2140
2072 # draw handle 2141 # draw handle
2073 $tex[0]->draw_quad_alpha ($knob_a, 0, $knob_b - $knob_a, $h); 2142 $tex[0]->draw_quad_alpha ($self->{knob_x}, 0, $self->{knob_w}, 1);
2074 2143
2075 glDisable GL_TEXTURE_2D; 2144 glDisable GL_TEXTURE_2D;
2076} 2145}
2077 2146
2078############################################################################# 2147#############################################################################
2507 my ($self, $items) = @_; 2576 my ($self, $items) = @_;
2508 2577
2509 $self->{scrolled}->clear; 2578 $self->{scrolled}->clear;
2510 return unless $items; 2579 return unless $items;
2511 2580
2512 my @items = sort { $a->{type} <=> $b->{type} } @$items; 2581 my @items = sort {
2582 ($a->{type} <=> $b->{type})
2583 or ($a->{name} cmp $b->{name})
2584 } @$items;
2513 2585
2514 $self->{real_items} = \@items; 2586 $self->{real_items} = \@items;
2515 2587
2516 for my $item (@items) { 2588 for my $item (@items) {
2517 my $desc = $item->{nrof} < 2 2589 my $desc = $item->{nrof} < 2
2518 ? $item->{name} 2590 ? $item->{name}
2519 : "$item->{nrof} $item->{name_pl}"; 2591 : "$item->{nrof} $item->{name_pl}";
2520 2592
2521 $self->{scrolled}->add ($item->{widget} ||= new CFClient::UI::InventoryItem item => $item); 2593 $item = $item->{widget} ||= new CFClient::UI::InventoryItem item => $item;
2522 } 2594 }
2595
2596 $self->{scrolled}->add (@items);
2523 2597
2524# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page]; 2598# $range->{range} = [$self->{pos}, 0, $self->{max_pos}, $page];
2525} 2599}
2526 2600
2527sub size_request { 2601sub size_request {
2632 ? "<b>$item->{count} ×</b> $item->{text}" 2706 ? "<b>$item->{count} ×</b> $item->{text}"
2633 : $item->{text}; 2707 : $item->{text};
2634 2708
2635 for ($short) { 2709 for ($short) {
2636 s/^\s+//; 2710 s/^\s+//;
2637 s/\012.*/…/s; 2711 s/\s+/ /g;
2638 my $len = int 40 / $item->{fontsize}; 2712 my $len = int 40 / $item->{fontsize};
2639 substr $_, $len, length, "…" if $len < length; 2713 substr $_, $len, length, "…" if $len < length;
2640 } 2714 }
2641 2715
2642 new CFClient::UI::Label 2716 new CFClient::UI::Label
2643 markup => $short, 2717 markup => $short,
2644 tooltip => $item->{tooltip}, 2718 tooltip => $item->{tooltip},
2645 tooltip_font => $::FONT_PROP, 2719 tooltip_font => $::FONT_PROP,
2646 tooltip_width => 0.67, 2720 tooltip_width => 0.67,
2647 fontsize => $item->{fontsize}, 2721 fontsize => $item->{fontsize},
2648 color => $item->{color}, 2722 fg => $item->{fg},
2649 can_events => 1, 2723 can_events => 1,
2650 can_hover => 1 2724 can_hover => 1
2651 }; 2725 };
2652 } 2726 }
2653 2727
2680 id => ++$self->{id}, 2754 id => ++$self->{id},
2681 text => $text, 2755 text => $text,
2682 timeout => $timeout, 2756 timeout => $timeout,
2683 tooltip => $text, 2757 tooltip => $text,
2684 fontsize => 0.8, 2758 fontsize => 0.8,
2685 color => [0.8, 0.8, 0.8, 0.8], 2759 fg => [0.8, 0.8, 0.8, 0.8],
2686 pri => 0, 2760 pri => 0,
2687 count => 1, 2761 count => 1,
2688 %arg, 2762 %arg,
2689 }; 2763 };
2690 } 2764 }
2729} 2803}
2730 2804
2731sub size_allocate { 2805sub size_allocate {
2732 my ($self, $w, $h) = @_; 2806 my ($self, $w, $h) = @_;
2733 2807
2734 my $old_w = $self->{old_w}; 2808 my $old_w = $self->{old_w}; $self->{old_w} = $w;
2735 my $old_h = $self->{old_h}; 2809 my $old_h = $self->{old_h}; $self->{old_h} = $h;
2736 2810
2737 if ($old_w && $old_h) { 2811 CFClient::UI::rescale_widgets $w / $old_w, $h / $old_h
2738 for my $child ($self->children) { 2812 if $old_w && $old_h && ($old_w != $w || $old_h != $h);
2739 $child->{x} = int 0.5 + $child->{x} * $w / $old_w;
2740 $child->{w} = int 0.5 + $child->{w} * $w / $old_w;
2741 $child->{req_w} = int 0.5 + $child->{req_w} * $w / $old_w if exists $child->{req_w};
2742 $child->{user_w} = int 0.5 + $child->{user_w} * $w / $old_w if exists $child->{user_w};
2743 $child->{y} = int 0.5 + $child->{y} * $h / $old_h;
2744 $child->{h} = int 0.5 + $child->{h} * $h / $old_h;
2745 $child->{req_h} = int 0.5 + $child->{req_h} * $h / $old_h if exists $child->{req_h};
2746 $child->{user_h} = int 0.5 + $child->{user_h} * $h / $old_h if exists $child->{user_h};
2747 }
2748 }
2749 2813
2750 for my $child ($self->children) { 2814 for my $child ($self->children) {
2751 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)}; 2815 my ($X, $Y, $W, $H) = @$child{qw(x y req_w req_h)};
2752 2816
2817 $X = $child->{req_x} > 0 ? $child->{req_x} : $w - $W - $child->{req_x} + 1
2818 if exists $child->{req_x};
2819
2820 $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1
2821 if exists $child->{req_y};
2822
2753 $X = List::Util::max 0, List::Util::min $w - $W, $X; 2823 $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5;
2754 $Y = List::Util::max 0, List::Util::min $h - $H, $Y; 2824 $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5;
2825
2755 $child->configure ($X, $Y, $W, $H); 2826 $child->configure ($X, $Y, $W, $H);
2756 } 2827 }
2757
2758 $self->{old_w} = $w;
2759 $self->{old_h} = $h;
2760} 2828}
2761 2829
2762sub coord2local { 2830sub coord2local {
2763 my ($self, $x, $y) = @_; 2831 my ($self, $x, $y) = @_;
2764 2832
2777 $self->check_size; 2845 $self->check_size;
2778 $::WANT_REFRESH++; 2846 $::WANT_REFRESH++;
2779} 2847}
2780 2848
2781sub add { 2849sub add {
2782 my ($self, $child) = @_; 2850 my ($self, @children) = @_;
2783 2851
2852 for my $child (@children) {
2853 $child->{toplevel} = 1;
2854
2784 # integerise window positions 2855 # integerise window positions
2785 $child->{x} = int $child->{x}; 2856 $child->{x} = int $child->{x};
2786 $child->{y} = int $child->{y}; 2857 $child->{y} = int $child->{y};
2858 }
2787 2859
2788 $self->SUPER::add ($child); 2860 $self->SUPER::add (@children);
2789} 2861}
2790 2862
2791sub on_refresh { 2863sub on_refresh {
2792 my ($self, $id, $cb) = @_; 2864 my ($self, $id, $cb) = @_;
2793 2865

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines