… | |
… | |
24 | my $tip = $widget->{tooltip}; |
24 | my $tip = $widget->{tooltip}; |
25 | |
25 | |
26 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
26 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
27 | |
27 | |
28 | $TOOLTIP->set_markup ($widget->{tooltip}); |
28 | $TOOLTIP->set_markup ($widget->{tooltip}); |
29 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
29 | |
30 | $TOOLTIP->show; |
30 | $TOOLTIP->show; |
|
|
31 | |
|
|
32 | my ($x, $y) = $widget->coord2global ($widget->{w}, 0); |
|
|
33 | |
|
|
34 | if ($x + $TOOLTIP->{w} > $::WIDTH) { |
|
|
35 | ($x, $y) = $widget->coord2global (-$TOOLTIP->{w}, 0); |
|
|
36 | } |
|
|
37 | |
|
|
38 | $TOOLTIP->move ($x, $y); |
31 | } |
39 | } |
32 | |
40 | |
33 | return; |
41 | return; |
34 | } |
42 | } |
35 | } |
43 | } |
… | |
… | |
137 | |
145 | |
138 | sub new { |
146 | sub new { |
139 | my $class = shift; |
147 | my $class = shift; |
140 | |
148 | |
141 | my $self = bless { |
149 | my $self = bless { |
142 | x => 0, |
150 | x => 0, |
143 | y => 0, |
151 | y => 0, |
144 | z => 0, |
152 | z => 0, |
145 | can_events => 1, |
153 | can_events => 1, |
146 | @_ |
154 | @_ |
147 | }, $class; |
155 | }, $class; |
148 | |
156 | |
149 | for (keys %$self) { |
157 | for (keys %$self) { |
… | |
… | |
236 | |
244 | |
237 | sub size_allocate { |
245 | sub size_allocate { |
238 | # nothing to be done |
246 | # nothing to be done |
239 | } |
247 | } |
240 | |
248 | |
|
|
249 | sub children { |
|
|
250 | } |
|
|
251 | |
|
|
252 | # call when resoltuion changes etc. |
|
|
253 | sub reconfigure { |
|
|
254 | my ($self) = @_; |
|
|
255 | |
|
|
256 | $_->reconfigure |
|
|
257 | for $self->children; |
|
|
258 | |
|
|
259 | $_->check_size; |
|
|
260 | } |
|
|
261 | |
241 | sub set_max_size { |
262 | sub set_max_size { |
242 | my ($self, $w, $h) = @_; |
263 | my ($self, $w, $h) = @_; |
243 | |
264 | |
244 | delete $self->{max_w}; $self->{max_w} = $w if $w; |
265 | delete $self->{max_w}; $self->{max_w} = $w if $w; |
245 | delete $self->{max_h}; $self->{max_h} = $h if $h; |
266 | delete $self->{max_h}; $self->{max_h} = $h if $h; |
246 | } |
267 | } |
247 | |
268 | |
248 | # return top left coordinates |
269 | # return top left coordinates |
249 | sub _topleft { |
270 | sub _topleft { |
250 | my ($self, $x, $y) = @_; |
271 | my ($self, $x, $y) = @_; |
|
|
272 | |
|
|
273 | $self->{parent} |
|
|
274 | or Carp::confess "no parent widget in _topleft\n";#d# |
251 | |
275 | |
252 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
276 | $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); |
253 | } |
277 | } |
254 | |
278 | |
255 | # translate global coordinates to local coordinate system |
279 | # translate global coordinates to local coordinate system |
… | |
… | |
492 | sub new { |
516 | sub new { |
493 | my ($class, %arg) = @_; |
517 | my ($class, %arg) = @_; |
494 | |
518 | |
495 | my $children = delete $arg{children} || []; |
519 | my $children = delete $arg{children} || []; |
496 | |
520 | |
497 | my $self = $class->SUPER::new (children => [], can_events => 0, %arg); |
521 | my $self = $class->SUPER::new ( |
|
|
522 | children => [], |
|
|
523 | can_events => 0, |
|
|
524 | %arg, |
|
|
525 | ); |
498 | $self->add ($_) for @$children; |
526 | $self->add ($_) for @$children; |
499 | |
527 | |
500 | $self |
528 | $self |
501 | } |
529 | } |
502 | |
530 | |
… | |
… | |
513 | ]; |
541 | ]; |
514 | |
542 | |
515 | $child->check_size; |
543 | $child->check_size; |
516 | } |
544 | } |
517 | |
545 | |
|
|
546 | sub children { |
|
|
547 | @{ $_[0]{children} } |
|
|
548 | } |
|
|
549 | |
518 | sub remove { |
550 | sub remove { |
519 | my ($self, $child) = @_; |
551 | my ($self, $child) = @_; |
520 | |
552 | |
521 | delete $child->{parent}; |
553 | delete $child->{parent}; |
522 | $child->hide; |
554 | $child->hide; |
… | |
… | |
619 | } |
651 | } |
620 | |
652 | |
621 | sub update { |
653 | sub update { |
622 | my ($self) = @_; |
654 | my ($self) = @_; |
623 | |
655 | |
624 | # we want to do this delayed... |
656 | $ROOT->on_refresh ($self => sub { $self->render_child }); |
625 | $self->render_chld; |
|
|
626 | $self->SUPER::update; |
657 | $self->SUPER::update; |
627 | } |
658 | } |
628 | |
659 | |
|
|
660 | sub size_allocate { |
|
|
661 | my ($self, $w, $h) = @_; |
|
|
662 | |
|
|
663 | $self->SUPER::size_allocate ($w, $h); |
|
|
664 | $self->update; |
|
|
665 | } |
|
|
666 | |
629 | sub render_chld { |
667 | sub render_child { |
630 | my ($self) = @_; |
668 | my ($self) = @_; |
631 | |
669 | |
632 | $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
670 | $self->{texture} = new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
633 | glClearColor 0, 0, 0, 1; |
671 | glClearColor 0, 0, 0, 0; |
634 | glClear GL_COLOR_BUFFER_BIT; |
672 | glClear GL_COLOR_BUFFER_BIT; |
635 | $self->child->draw; |
673 | $self->child->draw; |
|
|
674 | # glColorMask 1, 1, 1, 0; |
|
|
675 | # glEnable GL_BLEND; |
|
|
676 | # glBlendFunc GL_SRC_ALPHA, GL_ZERO; |
|
|
677 | # glRasterPos 0, 0; |
|
|
678 | # glCopyPixels 0, 0, $self->{w}, $self->{h}; |
|
|
679 | # glDisable GL_BLEND; |
|
|
680 | # glColorMask 1, 1, 1, 1; |
636 | }; |
681 | }; |
637 | } |
|
|
638 | |
|
|
639 | sub size_allocate { |
|
|
640 | my ($self, $w, $h) = @_; |
|
|
641 | |
|
|
642 | $self->child->configure (0, 0, $w, $h); |
|
|
643 | |
|
|
644 | $self->render_chld; |
|
|
645 | } |
682 | } |
646 | |
683 | |
647 | sub _draw { |
684 | sub _draw { |
648 | my ($self) = @_; |
685 | my ($self) = @_; |
649 | |
686 | |
… | |
… | |
651 | |
688 | |
652 | my $tex = $self->{texture} |
689 | my $tex = $self->{texture} |
653 | or return; |
690 | or return; |
654 | |
691 | |
655 | glEnable GL_BLEND; |
692 | glEnable GL_BLEND; |
656 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
693 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
657 | glEnable GL_TEXTURE_2D; |
694 | glEnable GL_TEXTURE_2D; |
658 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
695 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
696 | glColor 0, 0, 0, 1; |
659 | |
697 | |
660 | $tex->draw_quad (0, 0, $w, $h); |
698 | $tex->draw_quad (0, 0, $w, $h); |
661 | |
699 | |
662 | glDisable GL_BLEND; |
700 | glDisable GL_BLEND; |
663 | glDisable GL_TEXTURE_2D; |
701 | glDisable GL_TEXTURE_2D; |
… | |
… | |
748 | my $class = shift; |
786 | my $class = shift; |
749 | |
787 | |
750 | # TODO: user_x, user_y, overwrite moveto? |
788 | # TODO: user_x, user_y, overwrite moveto? |
751 | |
789 | |
752 | my $self = $class->SUPER::new ( |
790 | my $self = $class->SUPER::new ( |
753 | bg => [1, 1, 1, 1], |
791 | bg => [1, 1, 1, 1], |
754 | border_bg => [1, 1, 1, 1], |
792 | border_bg => [1, 1, 1, 1], |
755 | border => 0.8, |
793 | border => 0.8, |
756 | can_events => 1, |
794 | can_events => 1, |
757 | @_ |
795 | @_ |
758 | ); |
796 | ); |
759 | |
797 | |
760 | $self->{title} &&= new CFClient::UI::Label |
798 | $self->{title} &&= new CFClient::UI::Label |
… | |
… | |
908 | $self->{children}[$y][$x] = $child; |
946 | $self->{children}[$y][$x] = $child; |
909 | |
947 | |
910 | $child->check_size; |
948 | $child->check_size; |
911 | } |
949 | } |
912 | |
950 | |
|
|
951 | sub children { |
|
|
952 | grep $_, map @$_, grep $_, @{ $_[0]{children} } |
|
|
953 | } |
|
|
954 | |
913 | # TODO: move to container class maybe? send childs a signal on removal? |
955 | # TODO: move to container class maybe? send childs a signal on removal? |
914 | sub clear { |
956 | sub clear { |
915 | my ($self) = @_; |
957 | my ($self) = @_; |
916 | |
958 | |
917 | my $children = delete $self->{children}; |
959 | my @children = $self->children; |
|
|
960 | delete $self->{children}; |
918 | |
961 | |
919 | for (grep $_, map @$_, grep $_, @$children) { |
962 | for (@children) { |
920 | delete $_->{parent}; |
963 | delete $_->{parent}; |
921 | $_->hide; |
964 | $_->hide; |
922 | } |
965 | } |
923 | |
966 | |
924 | $self->update; |
967 | $self->update; |
… | |
… | |
1151 | |
1194 | |
1152 | sub new { |
1195 | sub new { |
1153 | my ($class, %arg) = @_; |
1196 | my ($class, %arg) = @_; |
1154 | |
1197 | |
1155 | my $self = $class->SUPER::new ( |
1198 | my $self = $class->SUPER::new ( |
1156 | fg => [1, 1, 1], |
1199 | fg => [1, 1, 1], |
1157 | #font => default_font |
1200 | #font => default_font |
1158 | fontsize => 1, |
1201 | fontsize => 1, |
1159 | text => "", |
1202 | text => "", |
1160 | align => -1, |
1203 | align => -1, |
1161 | valign => -1, |
1204 | valign => -1, |
1162 | padding => 2, |
1205 | padding => 2, |
1163 | layout => new CFClient::Layout, |
1206 | layout => new CFClient::Layout, |
1164 | can_events => 0, |
1207 | can_events => 0, |
1165 | %arg |
1208 | %arg |
1166 | ); |
1209 | ); |
1167 | |
1210 | |
1168 | if (exists $self->{template}) { |
1211 | if (exists $self->{template}) { |
… | |
… | |
1185 | s/</</g; |
1228 | s/</</g; |
1186 | |
1229 | |
1187 | $_[1] |
1230 | $_[1] |
1188 | } |
1231 | } |
1189 | |
1232 | |
|
|
1233 | sub update { |
|
|
1234 | my ($self) = @_; |
|
|
1235 | |
|
|
1236 | delete $self->{texture}; |
|
|
1237 | $self->SUPER::update; |
|
|
1238 | } |
|
|
1239 | |
|
|
1240 | sub reconfigure { |
|
|
1241 | my ($self) = @_; |
|
|
1242 | |
|
|
1243 | delete $self->{texture}; |
|
|
1244 | } |
|
|
1245 | |
1190 | sub set_text { |
1246 | sub set_text { |
1191 | my ($self, $text) = @_; |
1247 | my ($self, $text) = @_; |
1192 | |
1248 | |
|
|
1249 | return if $self->{text} eq "T$text"; |
|
|
1250 | $self->{text} = "T$text"; |
|
|
1251 | |
1193 | $self->{layout}->set_text ($text); |
1252 | $self->{layout}->set_text ($text); |
1194 | |
1253 | |
1195 | delete $self->{texture}; |
1254 | delete $self->{texture}; |
|
|
1255 | $self->update; |
1196 | $self->check_size; |
1256 | $self->check_size; |
1197 | $self->update; |
|
|
1198 | } |
1257 | } |
1199 | |
1258 | |
1200 | sub set_markup { |
1259 | sub set_markup { |
1201 | my ($self, $markup) = @_; |
1260 | my ($self, $markup) = @_; |
1202 | |
1261 | |
|
|
1262 | return if $self->{text} eq "M$markup"; |
|
|
1263 | $self->{text} = "M$markup"; |
|
|
1264 | |
1203 | $self->{layout}->set_markup ($markup); |
1265 | $self->{layout}->set_markup ($markup); |
1204 | |
1266 | |
1205 | delete $self->{texture}; |
1267 | delete $self->{texture}; |
|
|
1268 | $self->update; |
1206 | $self->check_size; |
1269 | $self->check_size; |
1207 | $self->update; |
|
|
1208 | } |
1270 | } |
1209 | |
1271 | |
1210 | sub size_request { |
1272 | sub size_request { |
1211 | my ($self) = @_; |
1273 | my ($self) = @_; |
1212 | |
1274 | |
… | |
… | |
1292 | |
1354 | |
1293 | sub new { |
1355 | sub new { |
1294 | my $class = shift; |
1356 | my $class = shift; |
1295 | |
1357 | |
1296 | $class->SUPER::new ( |
1358 | $class->SUPER::new ( |
1297 | fg => [1, 1, 1], |
1359 | fg => [1, 1, 1], |
1298 | bg => [0, 0, 0, 0.2], |
1360 | bg => [0, 0, 0, 0.2], |
1299 | active_bg => [1, 1, 1, 0.5], |
1361 | active_bg => [1, 1, 1, 0.5], |
1300 | active_fg => [0, 0, 0], |
1362 | active_fg => [0, 0, 0], |
1301 | can_hover => 1, |
1363 | can_hover => 1, |
1302 | can_focus => 1, |
1364 | can_focus => 1, |
1303 | valign => 0, |
1365 | valign => 0, |
1304 | can_events => 1, |
1366 | can_events => 1, |
1305 | @_ |
1367 | @_ |
1306 | ) |
1368 | ) |
1307 | } |
1369 | } |
1308 | |
1370 | |
… | |
… | |
1462 | my ($self, $ev) = @_; |
1524 | my ($self, $ev) = @_; |
1463 | |
1525 | |
1464 | my $sym = $ev->{sym}; |
1526 | my $sym = $ev->{sym}; |
1465 | |
1527 | |
1466 | if ($sym == 13) { |
1528 | if ($sym == 13) { |
|
|
1529 | unshift @{$self->{history}}, |
|
|
1530 | my $txt = $self->get_text; |
|
|
1531 | $self->{history_pointer} = -1; |
|
|
1532 | $self->{history_saveback} = ''; |
1467 | $self->emit (activate => $self->get_text); |
1533 | $self->emit (activate => $txt); |
1468 | $self->update; |
1534 | $self->update; |
|
|
1535 | |
|
|
1536 | } elsif ($sym == CFClient::SDLK_UP) { |
|
|
1537 | if ($self->{history_pointer} < 0) { |
|
|
1538 | $self->{history_saveback} = $self->get_text; |
|
|
1539 | } |
|
|
1540 | if (@{$self->{history} || []} > 0) { |
|
|
1541 | $self->{history_pointer}++; |
|
|
1542 | if ($self->{history_pointer} >= @{$self->{history} || []}) { |
|
|
1543 | $self->{history_pointer} = @{$self->{history} || []} - 1; |
|
|
1544 | } |
|
|
1545 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1546 | } |
|
|
1547 | |
|
|
1548 | } elsif ($sym == CFClient::SDLK_DOWN) { |
|
|
1549 | $self->{history_pointer}--; |
|
|
1550 | $self->{history_pointer} = -1 if $self->{history_pointer} < 0; |
|
|
1551 | |
|
|
1552 | if ($self->{history_pointer} >= 0) { |
|
|
1553 | $self->set_text ($self->{history}->[$self->{history_pointer}]); |
|
|
1554 | } else { |
|
|
1555 | $self->set_text ($self->{history_saveback}); |
|
|
1556 | } |
1469 | |
1557 | |
1470 | } else { |
1558 | } else { |
1471 | $self->SUPER::key_down ($ev); |
1559 | $self->SUPER::key_down ($ev); |
1472 | } |
1560 | } |
1473 | |
1561 | |
… | |
… | |
1487 | |
1575 | |
1488 | sub new { |
1576 | sub new { |
1489 | my $class = shift; |
1577 | my $class = shift; |
1490 | |
1578 | |
1491 | $class->SUPER::new ( |
1579 | $class->SUPER::new ( |
1492 | padding => 4, |
1580 | padding => 4, |
1493 | fg => [1, 1, 1], |
1581 | fg => [1, 1, 1], |
1494 | bg => [1, 1, 1, 0.2], |
1582 | bg => [1, 1, 1, 0.2], |
1495 | active_fg => [0, 0, 1], |
1583 | active_fg => [0, 0, 1], |
1496 | can_hover => 1, |
1584 | can_hover => 1, |
1497 | align => 0, |
1585 | align => 0, |
1498 | valign => 0, |
1586 | valign => 0, |
1499 | can_events => 1, |
1587 | can_events => 1, |
1500 | @_ |
1588 | @_ |
1501 | ) |
1589 | ) |
1502 | } |
1590 | } |
1503 | |
1591 | |
… | |
… | |
1710 | } |
1798 | } |
1711 | |
1799 | |
1712 | sub set_max { |
1800 | sub set_max { |
1713 | my ($self, $max) = @_; |
1801 | my ($self, $max) = @_; |
1714 | |
1802 | |
|
|
1803 | return if $self->{max_val} == $max; |
|
|
1804 | |
1715 | $self->{max_val} = $max; |
1805 | $self->{max_val} = $max; |
|
|
1806 | $self->update; |
1716 | } |
1807 | } |
1717 | |
1808 | |
1718 | sub set_value { |
1809 | sub set_value { |
1719 | my ($self, $val, $max) = @_; |
1810 | my ($self, $val, $max) = @_; |
1720 | |
1811 | |
1721 | $self->set_max ($max) |
1812 | $self->set_max ($max) |
1722 | if defined $max; |
1813 | if defined $max; |
1723 | |
1814 | |
1724 | $max = $self->{max_val}; |
1815 | return if $self->{val} == $val; |
|
|
1816 | |
1725 | $self->{val} = $val; |
1817 | $self->{val} = $val; |
1726 | |
|
|
1727 | $self->update; |
1818 | $self->update; |
1728 | } |
1819 | } |
1729 | |
1820 | |
1730 | sub _draw { |
1821 | sub _draw { |
1731 | my ($self) = @_; |
1822 | my ($self) = @_; |
… | |
… | |
1794 | |
1885 | |
1795 | sub new { |
1886 | sub new { |
1796 | my ($class, %arg) = @_; |
1887 | my ($class, %arg) = @_; |
1797 | |
1888 | |
1798 | my $self = $class->SUPER::new ( |
1889 | my $self = $class->SUPER::new ( |
1799 | tooltip => $arg{type}, |
1890 | tooltip => $arg{type}, |
|
|
1891 | can_hover => 1, |
1800 | can_events => 1, |
1892 | can_events => 1, |
1801 | can_hover => 1, |
|
|
1802 | %arg, |
1893 | %arg, |
1803 | ); |
1894 | ); |
1804 | |
1895 | |
1805 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1896 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1806 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
1897 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); |
… | |
… | |
1814 | |
1905 | |
1815 | $self->{value}->set_fontsize ($fsize); |
1906 | $self->{value}->set_fontsize ($fsize); |
1816 | $self->{max} ->set_fontsize ($fsize); |
1907 | $self->{max} ->set_fontsize ($fsize); |
1817 | } |
1908 | } |
1818 | |
1909 | |
|
|
1910 | sub set_max { |
|
|
1911 | my ($self, $max) = @_; |
|
|
1912 | |
|
|
1913 | $self->{gauge}->set_max ($max); |
|
|
1914 | $self->{max}->set_text ($max); |
|
|
1915 | } |
|
|
1916 | |
1819 | sub set_value { |
1917 | sub set_value { |
1820 | my ($self, $val, $max) = @_; |
1918 | my ($self, $val, $max) = @_; |
1821 | |
1919 | |
1822 | $self->set_max ($max) |
1920 | $self->set_max ($max) |
1823 | if defined $max; |
1921 | if defined $max; |
1824 | |
1922 | |
1825 | $self->{gauge}->set_value ($val, $max); |
1923 | $self->{gauge}->set_value ($val, $max); |
1826 | $self->{value}->set_text ($val); |
1924 | $self->{value}->set_text ($val); |
1827 | } |
|
|
1828 | |
|
|
1829 | sub set_max { |
|
|
1830 | my ($self, $max) = @_; |
|
|
1831 | |
|
|
1832 | $self->{gauge}->set_max ($max); |
|
|
1833 | $self->{max}->set_text ($max); |
|
|
1834 | } |
1925 | } |
1835 | |
1926 | |
1836 | ############################################################################# |
1927 | ############################################################################# |
1837 | |
1928 | |
1838 | package CFClient::UI::Slider; |
1929 | package CFClient::UI::Slider; |
… | |
… | |
1978 | |
2069 | |
1979 | sub new { |
2070 | sub new { |
1980 | my $class = shift; |
2071 | my $class = shift; |
1981 | |
2072 | |
1982 | my $self = $class->SUPER::new ( |
2073 | my $self = $class->SUPER::new ( |
1983 | fontsize => 1, |
2074 | fontsize => 1, |
|
|
2075 | can_events => 0, |
1984 | #font => default_font |
2076 | #font => default_font |
1985 | @_, |
2077 | @_, |
1986 | |
2078 | |
1987 | layout => (new CFClient::Layout), |
2079 | layout => (new CFClient::Layout), |
1988 | par => [], |
2080 | par => [], |
1989 | height => 0, |
2081 | height => 0, |
1990 | children => [ |
2082 | children => [ |
1991 | (new CFClient::UI::Empty expand => 1), |
2083 | (new CFClient::UI::Empty expand => 1), |
1992 | (new CFClient::UI::Slider vertical => 1), |
2084 | (new CFClient::UI::Slider vertical => 1), |
1993 | ], |
2085 | ], |
1994 | ); |
2086 | ); |
1995 | |
2087 | |
… | |
… | |
2075 | |
2167 | |
2076 | delete $self->{texture}; |
2168 | delete $self->{texture}; |
2077 | } |
2169 | } |
2078 | |
2170 | |
2079 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
2171 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{w}, $self->{h}, sub { |
2080 | glClearColor 0, 0, 0, 1; |
2172 | glClearColor 0, 0, 0, 0; |
2081 | glClear GL_COLOR_BUFFER_BIT; |
2173 | glClear GL_COLOR_BUFFER_BIT; |
2082 | |
2174 | |
2083 | glEnable GL_BLEND; |
2175 | glEnable GL_BLEND; |
2084 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
2176 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
2085 | glEnable GL_TEXTURE_2D; |
2177 | glEnable GL_TEXTURE_2D; |
… | |
… | |
2118 | |
2210 | |
2119 | sub _draw { |
2211 | sub _draw { |
2120 | my ($self) = @_; |
2212 | my ($self) = @_; |
2121 | |
2213 | |
2122 | if ($self->{texture}) { |
2214 | if ($self->{texture}) { |
|
|
2215 | glEnable GL_BLEND; |
|
|
2216 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2123 | glEnable GL_TEXTURE_2D; |
2217 | glEnable GL_TEXTURE_2D; |
2124 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2218 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
2219 | glColor 1, 1, 1, 1; |
2125 | $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); |
2220 | $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); |
2126 | glDisable GL_TEXTURE_2D; |
2221 | glDisable GL_TEXTURE_2D; |
|
|
2222 | glDisable GL_BLEND; |
2127 | } |
2223 | } |
2128 | |
2224 | |
2129 | $self->{children}[1]->draw; |
2225 | $self->{children}[1]->draw; |
2130 | |
2226 | |
2131 | } |
2227 | } |
… | |
… | |
2180 | |
2276 | |
2181 | sub new { |
2277 | sub new { |
2182 | my $class = shift; |
2278 | my $class = shift; |
2183 | |
2279 | |
2184 | my $self = $class->SUPER::new ( |
2280 | my $self = $class->SUPER::new ( |
2185 | state => 0, |
2281 | state => 0, |
2186 | connect_activate => \&toggle_flopper, |
2282 | connect_activate => \&toggle_flopper, |
2187 | can_events => 1, |
|
|
2188 | @_ |
2283 | @_ |
2189 | ); |
2284 | ); |
2190 | |
2285 | |
2191 | if ($self->{state}) { |
2286 | if ($self->{state}) { |
2192 | $self->{state} = 0; |
2287 | $self->{state} = 0; |