… | |
… | |
43 | |
43 | |
44 | my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); |
44 | my $widget = $GRAB || $TOPLEVEL->find_widget ($x, $y); |
45 | |
45 | |
46 | $BUTTON_STATE &= ~(1 << ($ev->button - 1)); |
46 | $BUTTON_STATE &= ~(1 << ($ev->button - 1)); |
47 | |
47 | |
48 | $GRAB->button_down ($ev, $GRAB->translate ($x, $y)) if $GRAB; |
48 | $GRAB->button_up ($ev, $GRAB->translate ($x, $y)) if $GRAB; |
49 | |
49 | |
50 | if (!$BUTTON_STATE) { |
50 | if (!$BUTTON_STATE) { |
51 | my $grab = $GRAB; undef $GRAB; |
51 | my $grab = $GRAB; undef $GRAB; |
52 | $grab->update if $grab; |
52 | $grab->update if $grab; |
53 | $GRAB->update if $GRAB; |
53 | $GRAB->update if $GRAB; |
… | |
… | |
79 | use SDL::OpenGL; |
79 | use SDL::OpenGL; |
80 | |
80 | |
81 | sub new { |
81 | sub new { |
82 | my $class = shift; |
82 | my $class = shift; |
83 | |
83 | |
84 | bless { |
84 | my $self = bless { |
85 | x => 0, |
85 | x => 0, |
86 | y => 0, |
86 | y => 0, |
87 | z => 0, |
87 | z => 0, |
88 | w => -1, |
88 | w => -1, |
89 | h => -1, |
89 | h => -1, |
90 | @_ |
90 | @_ |
91 | }, $class |
91 | }, $class; |
|
|
92 | |
|
|
93 | for (keys %$self) { |
|
|
94 | if (/^connect_(.*)$/) { |
|
|
95 | $self->connect ($1 => delete $self->{$_}); |
|
|
96 | } |
|
|
97 | } |
|
|
98 | |
|
|
99 | $self |
92 | } |
100 | } |
93 | |
101 | |
94 | sub move { |
102 | sub move { |
95 | my ($self, $x, $y, $z) = @_; |
103 | my ($self, $x, $y, $z) = @_; |
96 | $self->{x} = $x; |
104 | $self->{x} = $x; |
… | |
… | |
200 | my ($self) = @_; |
208 | my ($self) = @_; |
201 | |
209 | |
202 | warn "no draw defined for $self\n"; |
210 | warn "no draw defined for $self\n"; |
203 | } |
211 | } |
204 | |
212 | |
205 | sub bbox { |
|
|
206 | my ($self) = @_; |
|
|
207 | my ($w, $h) = $self->size_request; |
|
|
208 | ( |
|
|
209 | $self->{x}, |
|
|
210 | $self->{y}, |
|
|
211 | $self->{x} = $w, |
|
|
212 | $self->{y} = $h |
|
|
213 | ) |
|
|
214 | } |
|
|
215 | |
|
|
216 | sub find_widget { |
213 | sub find_widget { |
217 | my ($self, $x, $y) = @_; |
214 | my ($self, $x, $y) = @_; |
218 | |
215 | |
219 | return $self |
216 | return $self |
220 | if $x >= $self->{x} && $x < $self->{x} + $self->{w} |
217 | if $x >= $self->{x} && $x < $self->{x} + $self->{w} |
221 | && $y >= $self->{y} && $y < $self->{y} + $self->{h}; |
218 | && $y >= $self->{y} && $y < $self->{y} + $self->{h}; |
222 | |
219 | |
223 | () |
220 | () |
224 | } |
221 | } |
225 | |
222 | |
226 | sub del_parent { $_[0]->{parent} = undef } |
|
|
227 | |
|
|
228 | sub set_parent { |
223 | sub set_parent { |
229 | my ($self, $par) = @_; |
224 | my ($self, $par) = @_; |
230 | |
225 | |
231 | $self->{parent} = $par; |
226 | $self->{parent} = $par; |
232 | Scalar::Util::weaken $self->{parent}; |
227 | Scalar::Util::weaken $self->{parent}; |
… | |
… | |
276 | |
271 | |
277 | # range [value, low, high, page] |
272 | # range [value, low, high, page] |
278 | |
273 | |
279 | $class->SUPER::new ( |
274 | $class->SUPER::new ( |
280 | bg => [0, 0, 0, 0.2], |
275 | bg => [0, 0, 0, 0.2], |
281 | active_bg => [1, 1, 1], |
276 | active_bg => [1, 1, 1, 0.5], |
282 | @_ |
277 | @_ |
283 | ) |
278 | ) |
284 | } |
279 | } |
285 | |
280 | |
286 | sub _draw { |
281 | sub _draw { |
… | |
… | |
330 | |
325 | |
331 | $self |
326 | $self |
332 | } |
327 | } |
333 | |
328 | |
334 | sub add { |
329 | sub add { |
335 | my ($self, $chld, $expand) = @_; |
330 | my ($self, $chld) = @_; |
336 | |
331 | |
337 | $chld->{expand} = $expand; |
|
|
338 | $chld->set_parent ($self); |
332 | $chld->set_parent ($self); |
339 | |
333 | |
340 | $self->{children} = [ |
334 | $self->{children} = [ |
341 | sort { $a->{z} <=> $b->{z} } |
335 | sort { $a->{z} <=> $b->{z} } |
342 | @{$self->{children}}, $chld |
336 | @{$self->{children}}, $chld |
… | |
… | |
538 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
532 | qw(d1_bg.png d1_border_top.png d1_border_right.png d1_border_left.png d1_border_bottom.png); |
539 | |
533 | |
540 | sub size_request { |
534 | sub size_request { |
541 | my ($self) = @_; |
535 | my ($self) = @_; |
542 | |
536 | |
|
|
537 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
|
|
538 | |
543 | my ($w, $h) = $self->SUPER::size_request; |
539 | my ($w, $h) = $self->SUPER::size_request; |
544 | |
540 | |
545 | $h += $tex[1]->{h}; |
541 | $h += $tex[1]->{h}; |
546 | $h += $tex[4]->{h}; |
542 | $h += $tex[4]->{h}; |
547 | $w += $tex[2]->{w}; |
543 | $w += $tex[2]->{w}; |
… | |
… | |
553 | sub size_allocate { |
549 | sub size_allocate { |
554 | my ($self, $x, $y, $w, $h) = @_; |
550 | my ($self, $x, $y, $w, $h) = @_; |
555 | |
551 | |
556 | $self->_size_allocate ($x, $y, $w, $h) or return; |
552 | $self->_size_allocate ($x, $y, $w, $h) or return; |
557 | |
553 | |
558 | $h -= $tex[1]->{h}; |
554 | $h -= $tex[1]{h}; |
559 | $h -= $tex[4]->{h}; |
555 | $h -= $tex[4]{h}; |
560 | $w -= $tex[2]->{w}; |
556 | $w -= $tex[2]{w}; |
561 | $w -= $tex[3]->{w}; |
557 | $w -= $tex[3]{w}; |
562 | |
558 | |
563 | $h = $h < 0 ? 0 : $h; |
559 | $h = $h < 0 ? 0 : $h; |
564 | $w = $w < 0 ? 0 : $w; |
560 | $w = $w < 0 ? 0 : $w; |
565 | |
561 | |
566 | my $child = $self->child; |
562 | my $child = $self->child; |
567 | |
563 | |
568 | $child->size_allocate ($tex[3]->{w}, $tex[1]->{h}, $w, $h); |
564 | $child->size_allocate ($tex[3]->{w}, $tex[1]->{h}, $w, $h); |
|
|
565 | } |
|
|
566 | |
|
|
567 | sub button_down { |
|
|
568 | my ($self, $ev, $x, $y) = @_; |
|
|
569 | |
|
|
570 | if ($x < $self->{w} && $x >= $self->{w} - $tex[2]{w} |
|
|
571 | && $y < $self->{h} && $y >= $self->{h} - $tex[4]{h}) { |
|
|
572 | |
|
|
573 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
|
|
574 | my ($bw, $bh) = ($self->{w}, $self->{h}); |
|
|
575 | |
|
|
576 | $self->{motion} = sub { |
|
|
577 | my ($ev, $x, $y) = @_; |
|
|
578 | |
|
|
579 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
|
|
580 | |
|
|
581 | $self->{user_w} = $bw + $x - $ox; |
|
|
582 | $self->{user_h} = $bh + $y - $oy; |
|
|
583 | $self->update; |
|
|
584 | }; |
|
|
585 | |
|
|
586 | } elsif ($x >= 0 && $x < $self->{w} |
|
|
587 | && $y >= 0 && $y < $tex[1]{h}) { |
|
|
588 | |
|
|
589 | my ($ox, $oy) = ($ev->button_x, $ev->button_y); |
|
|
590 | my ($bx, $by) = ($self->{x}, $self->{y}); |
|
|
591 | |
|
|
592 | $self->{motion} = sub { |
|
|
593 | my ($ev, $x, $y) = @_; |
|
|
594 | |
|
|
595 | ($x, $y) = ($ev->motion_x, $ev->motion_y); |
|
|
596 | |
|
|
597 | $self->move ($bx + $x - $ox, $by + $y - $oy); |
|
|
598 | $self->update; |
|
|
599 | }; |
|
|
600 | } |
|
|
601 | } |
|
|
602 | |
|
|
603 | sub button_up { |
|
|
604 | my ($self, $ev, $x, $y) = @_; |
|
|
605 | |
|
|
606 | delete $self->{motion}; |
|
|
607 | } |
|
|
608 | |
|
|
609 | sub mouse_motion { |
|
|
610 | my ($self, $ev, $x, $y) = @_; |
|
|
611 | |
|
|
612 | $self->{motion}->($ev, $x, $y) if $self->{motion}; |
569 | } |
613 | } |
570 | |
614 | |
571 | sub _draw { |
615 | sub _draw { |
572 | my ($self) = @_; |
616 | my ($self) = @_; |
573 | |
617 | |
… | |
… | |
618 | |
662 | |
619 | use List::Util qw(max sum); |
663 | use List::Util qw(max sum); |
620 | |
664 | |
621 | use SDL::OpenGL; |
665 | use SDL::OpenGL; |
622 | |
666 | |
|
|
667 | sub new { |
|
|
668 | my $class = shift; |
|
|
669 | |
|
|
670 | $class->SUPER::new ( |
|
|
671 | col_expand => [], |
|
|
672 | @_ |
|
|
673 | ) |
|
|
674 | } |
|
|
675 | |
623 | sub add { |
676 | sub add { |
624 | my ($self, $x, $y, $chld) = @_; |
677 | my ($self, $x, $y, $chld) = @_; |
625 | |
678 | |
626 | $self->{children}[$y][$x] = $chld; |
679 | $self->{children}[$y][$x] = $chld; |
627 | $chld->set_parent ($self); |
680 | $chld->set_parent ($self); |
… | |
… | |
656 | my ($self) = @_; |
709 | my ($self) = @_; |
657 | |
710 | |
658 | my ($ws, $hs) = $self->get_wh; |
711 | my ($ws, $hs) = $self->get_wh; |
659 | |
712 | |
660 | ( |
713 | ( |
661 | (List::Util::sum @$ws), |
714 | (sum @$ws), |
662 | (List::Util::sum @$hs), |
715 | (sum @$hs), |
663 | ) |
716 | ) |
664 | } |
717 | } |
665 | |
718 | |
666 | sub size_allocate { |
719 | sub size_allocate { |
667 | my ($self, $x, $y, $w, $h) = @_; |
720 | my ($self, $x, $y, $w, $h) = @_; |
668 | |
721 | |
669 | $self->_size_allocate ($x, $y, $w, $h) or return; |
722 | $self->_size_allocate ($x, $y, $w, $h) or return; |
670 | |
723 | |
671 | my ($ws, $hs) = $self->get_wh; |
724 | my ($ws, $hs) = $self->get_wh; |
672 | |
725 | |
673 | my $req_w = List::Util::sum @$ws; |
726 | my $req_w = sum @$ws; |
674 | my $req_h = List::Util::sum @$hs; |
727 | my $req_h = sum @$hs; |
|
|
728 | |
|
|
729 | # TODO: nicer code && do row_expand |
|
|
730 | my @col_expand = @{$self->{col_expand}}; |
|
|
731 | @col_expand = (1) x @$ws unless @col_expand; |
|
|
732 | my $col_expand = (sum @col_expand) || 1; |
675 | |
733 | |
676 | # linearly scale sizes |
734 | # linearly scale sizes |
677 | $_ *= $req_w / $w for @$ws; |
735 | $ws->[$_] += $col_expand[$_] / $col_expand * ($w - $req_w) for 0 .. $#$ws; |
678 | $_ *= $req_h / $h for @$hs; |
736 | $hs->[$_] *= 1 * $h / $req_h for 0 .. $#$hs; |
679 | |
737 | |
680 | my $y; |
738 | my $y; |
681 | |
739 | |
682 | for my $r (0 .. $#{$self->{children}}) { |
740 | for my $r (0 .. $#{$self->{children}}) { |
683 | my $row = $self->{children}[$r] |
741 | my $row = $self->{children}[$r] |
… | |
… | |
760 | |
818 | |
761 | my $req_h = List::Util::sum @h; |
819 | my $req_h = List::Util::sum @h; |
762 | |
820 | |
763 | if ($req_h > $h) { |
821 | if ($req_h > $h) { |
764 | # ah well, not enough space |
822 | # ah well, not enough space |
765 | $_ = $h[$_] * $h / $req_h for @h; |
823 | $_ *= $h / $req_h for @h; |
766 | } else { |
824 | } else { |
767 | my @exp = grep $_->{expand}, @$children; |
825 | my $exp = List::Util::sum map $_->{expand}, @$children; |
768 | @exp = @$children unless @exp; |
826 | $exp ||= 1; |
769 | |
827 | |
770 | my %exp = map +($_ => 1), @exp; |
|
|
771 | |
|
|
772 | for (0 .. $#$children) { |
828 | for (0 .. $#$children) { |
773 | my $child = $children->[$_]; |
829 | my $child = $children->[$_]; |
774 | |
830 | |
775 | my $alloc_h = $h[$_]; |
831 | my $alloc_h = $h[$_]; |
776 | $alloc_h += ($h - $req_h) / @exp if $exp{$child}; |
832 | $alloc_h += ($h - $req_h) * $child->{expand} / $exp; |
777 | $h[$_] = $alloc_h; |
833 | $h[$_] = $alloc_h; |
778 | } |
834 | } |
779 | } |
835 | } |
780 | |
836 | |
781 | my $y = 0; |
837 | my $y = 0; |
… | |
… | |
820 | |
876 | |
821 | my $req_h = List::Util::sum @h; |
877 | my $req_h = List::Util::sum @h; |
822 | |
878 | |
823 | if ($req_h > $h) { |
879 | if ($req_h > $h) { |
824 | # ah well, not enough space |
880 | # ah well, not enough space |
825 | $_ = $h[$_] * $h / $req_h for @h; |
881 | $_ *= $h / $req_h for @h; |
826 | } else { |
882 | } else { |
827 | my @exp = grep $_->{expand}, @$children; |
883 | my $exp = List::Util::sum map $_->{expand}, @$children; |
828 | @exp = @$children unless @exp; |
884 | $exp ||= 1; |
829 | |
885 | |
830 | my %exp = map +($_ => 1), @exp; |
|
|
831 | |
|
|
832 | for (0 .. $#$children) { |
886 | for (0 .. $#$children) { |
833 | my $child = $children->[$_]; |
887 | my $child = $children->[$_]; |
834 | |
888 | |
835 | my $alloc_h = $h[$_]; |
889 | $h[$_] += ($h - $req_h) * $child->{expand} / $exp; |
836 | $alloc_h += ($h - $req_h) / @exp if $exp{$child}; |
|
|
837 | $h[$_] = $alloc_h; |
|
|
838 | } |
890 | } |
839 | } |
891 | } |
840 | |
892 | |
841 | my $y = 0; |
893 | my $y = 0; |
842 | for (0 .. $#$children) { |
894 | for (0 .. $#$children) { |
… | |
… | |
889 | |
941 | |
890 | $self->{text} = $text; |
942 | $self->{text} = $text; |
891 | $self->{layout}->set_markup ($text); |
943 | $self->{layout}->set_markup ($text); |
892 | |
944 | |
893 | delete $self->{texture}; |
945 | delete $self->{texture}; |
|
|
946 | # $self->{w} = $self->{h} = -1; |
894 | $self->update; |
947 | $self->update; |
895 | } |
948 | } |
896 | |
949 | |
897 | sub get_text { |
950 | sub get_text { |
898 | my ($self, $text) = @_; |
951 | my ($self, $text) = @_; |
… | |
… | |
931 | sub _draw { |
984 | sub _draw { |
932 | my ($self) = @_; |
985 | my ($self) = @_; |
933 | |
986 | |
934 | my $tex = $self->{texture} ||= do { |
987 | my $tex = $self->{texture} ||= do { |
935 | $self->{layout}->set_width ($self->{w}); |
988 | $self->{layout}->set_width ($self->{w}); |
|
|
989 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
936 | new_from_layout CFClient::Texture $self->{layout} |
990 | new_from_layout CFClient::Texture $self->{layout} |
937 | }; |
991 | }; |
938 | |
992 | |
939 | glEnable GL_BLEND; |
993 | glEnable GL_BLEND; |
940 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
994 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
… | |
… | |
946 | my $x = |
1000 | my $x = |
947 | $self->{align} < 0 ? $self->{padding} |
1001 | $self->{align} < 0 ? $self->{padding} |
948 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1002 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
949 | : ($self->{w} - $tex->{w}) * 0.5; |
1003 | : ($self->{w} - $tex->{w}) * 0.5; |
950 | |
1004 | |
951 | $tex->draw_quad ($x, 0); |
1005 | $tex->draw_quad ($x, $self->{padding}); |
952 | |
1006 | |
953 | glDisable GL_TEXTURE_2D; |
1007 | glDisable GL_TEXTURE_2D; |
954 | glDisable GL_BLEND; |
1008 | glDisable GL_BLEND; |
955 | } |
1009 | } |
956 | |
1010 | |
… | |
… | |
967 | my $class = shift; |
1021 | my $class = shift; |
968 | |
1022 | |
969 | $class->SUPER::new ( |
1023 | $class->SUPER::new ( |
970 | fg => [1, 1, 1], |
1024 | fg => [1, 1, 1], |
971 | bg => [0, 0, 0, 0.2], |
1025 | bg => [0, 0, 0, 0.2], |
972 | active_bg => [1, 1, 1], |
1026 | active_bg => [1, 1, 1, 0.5], |
973 | active_fg => [0, 0, 0], |
1027 | active_fg => [0, 0, 0], |
974 | @_ |
1028 | @_ |
975 | ) |
1029 | ) |
976 | } |
1030 | } |
977 | |
1031 | |
… | |
… | |
1110 | } |
1164 | } |
1111 | } |
1165 | } |
1112 | |
1166 | |
1113 | ############################################################################# |
1167 | ############################################################################# |
1114 | |
1168 | |
|
|
1169 | package CFClient::UI::Button; |
|
|
1170 | |
|
|
1171 | our @ISA = CFClient::UI::Label::; |
|
|
1172 | |
|
|
1173 | use SDL; |
|
|
1174 | use SDL::OpenGL; |
|
|
1175 | |
|
|
1176 | sub new { |
|
|
1177 | my $class = shift; |
|
|
1178 | |
|
|
1179 | $class->SUPER::new ( |
|
|
1180 | padding => 4, |
|
|
1181 | fg => [1, 1, 1], |
|
|
1182 | bg => [1, 1, 1, 0.2], |
|
|
1183 | active_bg => [0, 0, 0, 0.5], |
|
|
1184 | active_fg => [1, 1, 0], |
|
|
1185 | border_fg => [1, 1, 0], |
|
|
1186 | @_ |
|
|
1187 | ) |
|
|
1188 | } |
|
|
1189 | |
|
|
1190 | sub button_up { |
|
|
1191 | my ($self, $ev, $x, $y) = @_; |
|
|
1192 | |
|
|
1193 | if ($x >= 0 && $x < $self->{w} |
|
|
1194 | && $y >= 0 && $y < $self->{h}) { |
|
|
1195 | $self->emit ("activate"); |
|
|
1196 | } |
|
|
1197 | } |
|
|
1198 | |
|
|
1199 | sub _draw { |
|
|
1200 | my ($self) = @_; |
|
|
1201 | |
|
|
1202 | local $self->{fg} = $self->{fg}; |
|
|
1203 | |
|
|
1204 | glEnable GL_BLEND; |
|
|
1205 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1206 | |
|
|
1207 | glTranslate 0.375, 0.375, 0; # make line and polyogon coordinates behave similarly |
|
|
1208 | |
|
|
1209 | glBegin GL_LINE_LOOP; |
|
|
1210 | glColor @{$self->{border_fg}}; |
|
|
1211 | glVertex 1 , 1; |
|
|
1212 | glVertex 1 , $self->{h} - 2; |
|
|
1213 | glVertex $self->{w} - 2, $self->{h} - 2; |
|
|
1214 | glVertex $self->{w} - 2, 1; |
|
|
1215 | glEnd; |
|
|
1216 | |
|
|
1217 | if ($GRAB == $self) { |
|
|
1218 | glColor @{$self->{active_bg}}; |
|
|
1219 | $self->{fg} = $self->{active_fg}; |
|
|
1220 | } else { |
|
|
1221 | glColor @{$self->{bg}}; |
|
|
1222 | } |
|
|
1223 | |
|
|
1224 | glBegin GL_QUADS; |
|
|
1225 | glVertex 2 , 2; |
|
|
1226 | glVertex 2 , $self->{h} - 2; |
|
|
1227 | glVertex $self->{w} - 2, $self->{h} - 2; |
|
|
1228 | glVertex $self->{w} - 2, 2; |
|
|
1229 | glEnd; |
|
|
1230 | glDisable GL_BLEND; |
|
|
1231 | |
|
|
1232 | $self->SUPER::_draw; |
|
|
1233 | } |
|
|
1234 | |
|
|
1235 | ############################################################################# |
|
|
1236 | |
1115 | package CFClient::UI::Slider; |
1237 | package CFClient::UI::Slider; |
1116 | |
1238 | |
1117 | use strict; |
1239 | use strict; |
1118 | |
1240 | |
1119 | use SDL::OpenGL; |
1241 | use SDL::OpenGL; |
… | |
… | |
1197 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1319 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1198 | |
1320 | |
1199 | $w -= $page; |
1321 | $w -= $page; |
1200 | $page &= ~1; |
1322 | $page &= ~1; |
1201 | glTranslate $page * 0.5, 0, 0; |
1323 | glTranslate $page * 0.5, 0, 0; |
|
|
1324 | $page ||= 2; |
1202 | |
1325 | |
1203 | glColor @$fg; |
1326 | glColor @$fg; |
1204 | glBegin GL_LINES; |
1327 | glBegin GL_LINES; |
1205 | glVertex 0, 0; glVertex 0, $h; |
1328 | glVertex 0, 0; glVertex 0, $h; |
1206 | glVertex $w - 1, 0; glVertex $w - 1, $h; |
1329 | glVertex $w - 1, 0; glVertex $w - 1, $h; |
… | |
… | |
1257 | sub key_up { |
1380 | sub key_up { |
1258 | } |
1381 | } |
1259 | |
1382 | |
1260 | sub size_request { |
1383 | sub size_request { |
1261 | ( |
1384 | ( |
1262 | 1 + int $::WIDTH / 32, |
1385 | 1 + 32 * int $::WIDTH / 32, |
1263 | 1 + int $::HEIGHT / 32, |
1386 | 1 + 32 * int $::HEIGHT / 32, |
1264 | ) |
1387 | ) |
1265 | } |
1388 | } |
1266 | |
1389 | |
1267 | sub update { |
1390 | sub update { |
1268 | my ($self) = @_; |
1391 | my ($self) = @_; |
1269 | |
1392 | |
1270 | $self->{need_update} = 1; |
1393 | $self->{need_update} = 1; |
1271 | $self->SUPER::update; |
1394 | $self->SUPER::update; |
1272 | } |
1395 | } |
1273 | |
1396 | |
1274 | sub _draw { |
1397 | sub draw { |
1275 | my ($self) = @_; |
1398 | my ($self) = @_; |
1276 | |
1399 | |
1277 | if (delete $self->{need_update}) { |
1400 | if (delete $self->{need_update}) { |
1278 | glNewList $self->{list}, GL_COMPILE; |
1401 | glNewList $self->{list}, GL_COMPILE; |
1279 | |
1402 | |