… | |
… | |
18 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
18 | for (my $widget = $HOVER; $widget; $widget = $widget->{parent}) { |
19 | if (exists $widget->{tooltip}) { |
19 | if (exists $widget->{tooltip}) { |
20 | |
20 | |
21 | if ($TOOLTIP->{owner} != $widget) { |
21 | if ($TOOLTIP->{owner} != $widget) { |
22 | $TOOLTIP->{owner} = $widget; |
22 | $TOOLTIP->{owner} = $widget; |
|
|
23 | |
|
|
24 | my $tip = $widget->{tooltip}; |
|
|
25 | |
|
|
26 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
|
|
27 | |
23 | $TOOLTIP->set_text ($widget->{tooltip}); |
28 | $TOOLTIP->set_text ($widget->{tooltip}); |
24 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
29 | $TOOLTIP->move ($widget->coord2global ($widget->{w}, 0)); |
25 | $TOOLTIP->show; |
30 | $TOOLTIP->show; |
26 | } |
31 | } |
27 | |
32 | |
… | |
… | |
137 | } |
142 | } |
138 | |
143 | |
139 | $self |
144 | $self |
140 | } |
145 | } |
141 | |
146 | |
|
|
147 | sub destroy { |
|
|
148 | my ($self) = @_; |
|
|
149 | |
|
|
150 | $self->hide; |
|
|
151 | %$self = (); |
|
|
152 | } |
|
|
153 | |
142 | sub show { |
154 | sub show { |
143 | my ($self) = @_; |
155 | my ($self) = @_; |
144 | |
156 | |
145 | return if $self->{parent}; |
157 | return if $self->{parent}; |
146 | |
158 | |
… | |
… | |
163 | $self->{z} = $z if defined $z; |
175 | $self->{z} = $z if defined $z; |
164 | |
176 | |
165 | $self->update; |
177 | $self->update; |
166 | } |
178 | } |
167 | |
179 | |
168 | sub needs_redraw { |
180 | sub set_size { |
169 | 0 |
181 | my ($self, $w, $h) = @_; |
|
|
182 | |
|
|
183 | $self->{user_w} = $w; |
|
|
184 | $self->{user_h} = $h; |
|
|
185 | |
|
|
186 | $self->check_size; |
170 | } |
187 | } |
171 | |
188 | |
172 | sub size_request { |
189 | sub size_request { |
173 | require Carp; |
190 | require Carp; |
174 | Carp::confess "size_request is abstract"; |
191 | Carp::confess "size_request is abstract"; |
… | |
… | |
204 | } |
221 | } |
205 | } |
222 | } |
206 | |
223 | |
207 | sub size_allocate { |
224 | sub size_allocate { |
208 | # nothing to be done |
225 | # nothing to be done |
|
|
226 | } |
|
|
227 | |
|
|
228 | sub set_max_size { |
|
|
229 | my ($self, $w, $h) = @_; |
|
|
230 | |
|
|
231 | delete $self->{max_w}; $self->{max_w} = $w if $w; |
|
|
232 | delete $self->{max_h}; $self->{max_h} = $h if $h; |
209 | } |
233 | } |
210 | |
234 | |
211 | # return top left coordinates |
235 | # return top left coordinates |
212 | sub _topleft { |
236 | sub _topleft { |
213 | my ($self, $x, $y) = @_; |
237 | my ($self, $x, $y) = @_; |
… | |
… | |
325 | } |
349 | } |
326 | |
350 | |
327 | sub check_size { |
351 | sub check_size { |
328 | my ($self) = @_; |
352 | my ($self) = @_; |
329 | |
353 | |
330 | return unless $self->{parent}; |
354 | $self->{parent} |
|
|
355 | or return 1; |
331 | |
356 | |
332 | my ($w, $h) = $self->size_request; |
357 | my ($w, $h) = $self->{user_w} && $self->{user_h} |
|
|
358 | ? @$self{qw(user_w user_h)} |
|
|
359 | : $self->size_request; |
333 | |
360 | |
334 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
361 | if ($w != $self->{req_w} || $h != $self->{req_h}) { |
335 | $self->{req_w} = $w; |
362 | $self->{req_w} = $w; |
336 | $self->{req_h} = $h; |
363 | $self->{req_h} = $h; |
337 | |
364 | |
338 | $self->{parent}->check_size; |
365 | $self->{parent}->check_size |
|
|
366 | or $self->size_allocate ( |
|
|
367 | (List::Util::max $self->{w}, $w), |
|
|
368 | (List::Util::max $self->{h}, $h), |
|
|
369 | ); |
|
|
370 | |
|
|
371 | 1 |
|
|
372 | } else { |
|
|
373 | 0 |
339 | } |
374 | } |
340 | } |
375 | } |
341 | |
376 | |
342 | sub update { |
377 | sub update { |
343 | my ($self) = @_; |
378 | my ($self) = @_; |
… | |
… | |
631 | border => 0.8, |
666 | border => 0.8, |
632 | @_ |
667 | @_ |
633 | ); |
668 | ); |
634 | |
669 | |
635 | $self |
670 | $self |
636 | } |
|
|
637 | |
|
|
638 | sub set_size { |
|
|
639 | my ($self, $w, $h) = @_; |
|
|
640 | $self->{req_w} = $w; |
|
|
641 | $self->{req_h} = $h; |
|
|
642 | $self->check_size; |
|
|
643 | } |
|
|
644 | |
|
|
645 | sub size_request { |
|
|
646 | my ($self) = @_; |
|
|
647 | ($self->{req_w}, $self->{req_h}) |
|
|
648 | } |
|
|
649 | |
|
|
650 | sub size_allocate { |
|
|
651 | my ($self, $w, $h) = @_; |
|
|
652 | $self->{w} = $w; |
|
|
653 | $self->{h} = $h; |
|
|
654 | $self->child->configure (0, 0, $w, $h); |
|
|
655 | } |
671 | } |
656 | |
672 | |
657 | sub _draw { |
673 | sub _draw { |
658 | my ($self) = @_; |
674 | my ($self) = @_; |
659 | |
675 | |
… | |
… | |
716 | int $_[0]{border} * $::FONTSIZE |
732 | int $_[0]{border} * $::FONTSIZE |
717 | } |
733 | } |
718 | |
734 | |
719 | sub size_request { |
735 | sub size_request { |
720 | my ($self) = @_; |
736 | my ($self) = @_; |
721 | |
|
|
722 | return ($self->{user_w}, $self->{user_h}) if $self->{user_w} && $self->{user_h}; |
|
|
723 | |
737 | |
724 | my ($w, $h) = $self->SUPER::size_request; |
738 | my ($w, $h) = $self->SUPER::size_request; |
725 | |
739 | |
726 | ( |
740 | ( |
727 | $w + $self->border * 2, |
741 | $w + $self->border * 2, |
… | |
… | |
1094 | sub new { |
1108 | sub new { |
1095 | my ($class, %arg) = @_; |
1109 | my ($class, %arg) = @_; |
1096 | |
1110 | |
1097 | my $self = $class->SUPER::new ( |
1111 | my $self = $class->SUPER::new ( |
1098 | fg => [1, 1, 1], |
1112 | fg => [1, 1, 1], |
|
|
1113 | #font => default_font |
1099 | fontsize => 1, |
1114 | fontsize => 1, |
1100 | text => "", |
1115 | text => "", |
1101 | align => -1, |
1116 | align => -1, |
1102 | valign => -1, |
1117 | valign => -1, |
1103 | padding => 2, |
1118 | padding => 2, |
… | |
… | |
1149 | } |
1164 | } |
1150 | |
1165 | |
1151 | sub size_request { |
1166 | sub size_request { |
1152 | my ($self) = @_; |
1167 | my ($self) = @_; |
1153 | |
1168 | |
1154 | $self->{layout}->set_width; |
1169 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
|
|
1170 | $self->{layout}->set_width ($self->{max_w} || -1); |
1155 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1171 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1156 | |
1172 | |
1157 | my ($w, $h) = $self->{layout}->size; |
1173 | my ($w, $h) = $self->{layout}->size; |
1158 | |
1174 | |
1159 | if (exists $self->{template}) { |
1175 | if (exists $self->{template}) { |
|
|
1176 | $self->{template}->set_font ($self->{font}) if $self->{font}; |
1160 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1177 | $self->{template}->set_height ($self->{fontsize} * $::FONTSIZE); |
1161 | |
1178 | |
1162 | my ($w2, $h2) = $self->{template}->size; |
1179 | my ($w2, $h2) = $self->{template}->size; |
1163 | |
1180 | |
1164 | $w = List::Util::max $w, $w2; |
1181 | $w = List::Util::max $w, $w2; |
… | |
… | |
1179 | |
1196 | |
1180 | sub set_fontsize { |
1197 | sub set_fontsize { |
1181 | my ($self, $fontsize) = @_; |
1198 | my ($self, $fontsize) = @_; |
1182 | |
1199 | |
1183 | $self->{fontsize} = $fontsize; |
1200 | $self->{fontsize} = $fontsize; |
|
|
1201 | delete $self->{texture}; |
1184 | $self->check_size; |
1202 | $self->check_size; |
|
|
1203 | $self->update; |
1185 | } |
1204 | } |
1186 | |
1205 | |
1187 | sub _draw { |
1206 | sub _draw { |
1188 | my ($self) = @_; |
1207 | my ($self) = @_; |
1189 | |
1208 | |
1190 | my $tex = $self->{texture} ||= do { |
1209 | my $tex = $self->{texture} ||= do { |
|
|
1210 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1191 | $self->{layout}->set_width ($self->{w}); |
1211 | $self->{layout}->set_width ($self->{w}); |
1192 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); |
1212 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{fontsize} * $::FONTSIZE); |
1193 | new_from_layout CFClient::Texture $self->{layout} |
1213 | new_from_layout CFClient::Texture $self->{layout} |
1194 | }; |
1214 | }; |
1195 | |
1215 | |
… | |
… | |
1598 | |
1618 | |
1599 | package CFClient::UI::VGauge; |
1619 | package CFClient::UI::VGauge; |
1600 | |
1620 | |
1601 | our @ISA = CFClient::UI::Base::; |
1621 | our @ISA = CFClient::UI::Base::; |
1602 | |
1622 | |
|
|
1623 | use List::Util qw(min max); |
|
|
1624 | |
1603 | use CFClient::OpenGL; |
1625 | use CFClient::OpenGL; |
1604 | |
1626 | |
1605 | my %tex = ( |
1627 | my %tex = ( |
1606 | food => [ |
1628 | food => [ |
1607 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1629 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1608 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
1630 | qw/g1_food_gauge_empty.png g1_food_gauge_full.png/ |
1609 | ], |
1631 | ], |
1610 | grace => [ |
1632 | grace => [ |
1611 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1633 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1612 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png/ |
1634 | qw/g1_grace_gauge_empty.png g1_grace_gauge_full.png g1_grace_gauge_overflow.png/ |
1613 | ], |
1635 | ], |
1614 | hp => [ |
1636 | hp => [ |
1615 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1637 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1616 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
1638 | qw/g1_hp_gauge_empty.png g1_hp_gauge_full.png/ |
1617 | ], |
1639 | ], |
1618 | mana => [ |
1640 | mana => [ |
1619 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1641 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_, mipmap => 1 } |
1620 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png/ |
1642 | qw/g1_mana_gauge_empty.png g1_mana_gauge_full.png g1_mana_gauge_overflow.png/ |
1621 | ], |
1643 | ], |
1622 | ); |
1644 | ); |
1623 | |
1645 | |
1624 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
1646 | # eg. VGauge->new (gauge => 'food'), default gauge: food |
1625 | sub new { |
1647 | sub new { |
… | |
… | |
1663 | |
1685 | |
1664 | sub _draw { |
1686 | sub _draw { |
1665 | my ($self) = @_; |
1687 | my ($self) = @_; |
1666 | |
1688 | |
1667 | my $tex = $tex{$self->{type}}; |
1689 | my $tex = $tex{$self->{type}}; |
|
|
1690 | my ($t1, $t2, $t3) = @$tex; |
1668 | |
1691 | |
1669 | my ($w, $h) = ($self->{w}, $self->{h}); |
1692 | my ($w, $h) = ($self->{w}, $self->{h}); |
1670 | |
1693 | |
1671 | if ($self->{vertical}) { |
1694 | if ($self->{vertical}) { |
1672 | glRotate 90, 0, 0, 1; |
1695 | glRotate 90, 0, 0, 1; |
… | |
… | |
1674 | |
1697 | |
1675 | ($w, $h) = ($h, $w); |
1698 | ($w, $h) = ($h, $w); |
1676 | } |
1699 | } |
1677 | |
1700 | |
1678 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
1701 | my $ycut = $self->{val} / ($self->{max_val} || 1); |
1679 | $ycut = 1 if $self->{val} > $self->{max_val}; |
|
|
1680 | |
1702 | |
1681 | my $t1 = $tex->[0]; |
1703 | my $ycut1 = max 0, min 1, $ycut; |
1682 | my $t2 = $tex->[1]; |
1704 | my $ycut2 = max 0, min 1, $ycut - 1; |
|
|
1705 | |
|
|
1706 | my $h1 = $self->{h} * (1 - $ycut1); |
|
|
1707 | my $h2 = $self->{h} * (1 - $ycut2); |
1683 | |
1708 | |
1684 | glEnable GL_BLEND; |
1709 | glEnable GL_BLEND; |
1685 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1710 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1686 | glEnable GL_TEXTURE_2D; |
1711 | glEnable GL_TEXTURE_2D; |
1687 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1712 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1688 | |
1713 | |
1689 | my $h1 = $self->{h} - $ycut * $self->{h}; |
|
|
1690 | my $h2 = $ycut * $self->{h}; |
|
|
1691 | |
|
|
1692 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1714 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
1693 | glBegin GL_QUADS; |
1715 | glBegin GL_QUADS; |
1694 | glTexCoord 0 , 0; glVertex 0 , 0; |
1716 | glTexCoord 0 , 0; glVertex 0 , 0; |
1695 | glTexCoord 0 , $t1->{t} * (1 - $ycut); glVertex 0 , $h1; |
1717 | glTexCoord 0 , $t1->{t} * (1 - $ycut1); glVertex 0 , $h1; |
1696 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut); glVertex $w, $h1; |
1718 | glTexCoord $t1->{s}, $t1->{t} * (1 - $ycut1); glVertex $w, $h1; |
1697 | glTexCoord $t1->{s}, 0; glVertex $w, 0; |
1719 | glTexCoord $t1->{s}, 0; glVertex $w, 0; |
1698 | glEnd; |
1720 | glEnd; |
1699 | |
1721 | |
|
|
1722 | my $ycut1 = List::Util::min 1, $ycut; |
1700 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1723 | glBindTexture GL_TEXTURE_2D, $t2->{name}; |
1701 | glBegin GL_QUADS; |
1724 | glBegin GL_QUADS; |
1702 | glTexCoord 0 , $t2->{t} * (1 - $ycut); glVertex 0 , $h1; |
1725 | glTexCoord 0 , $t2->{t} * (1 - $ycut1); glVertex 0 , $h1; |
1703 | glTexCoord 0 , $t2->{t}; glVertex 0 , $h1 + $h2; |
1726 | glTexCoord 0 , $t2->{t} * (1 - $ycut2); glVertex 0 , $h2; |
1704 | glTexCoord $t2->{s}, $t2->{t}; glVertex $w, $h1 + $h2; |
1727 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut2); glVertex $w, $h2; |
1705 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut); glVertex $w, $h1; |
1728 | glTexCoord $t2->{s}, $t2->{t} * (1 - $ycut1); glVertex $w, $h1; |
1706 | glEnd; |
1729 | glEnd; |
|
|
1730 | |
|
|
1731 | if ($t3) { |
|
|
1732 | glBindTexture GL_TEXTURE_2D, $t3->{name}; |
|
|
1733 | glBegin GL_QUADS; |
|
|
1734 | glTexCoord 0 , $t3->{t} * (1 - $ycut2); glVertex 0 , $h2; |
|
|
1735 | glTexCoord 0 , $t3->{t}; glVertex 0 , $self->{h}; |
|
|
1736 | glTexCoord $t3->{s}, $t3->{t}; glVertex $w, $self->{h}; |
|
|
1737 | glTexCoord $t3->{s}, $t3->{t} * (1 - $ycut2); glVertex $w, $h2; |
|
|
1738 | glEnd; |
|
|
1739 | } |
1707 | |
1740 | |
1708 | glDisable GL_BLEND; |
1741 | glDisable GL_BLEND; |
1709 | glDisable GL_TEXTURE_2D; |
1742 | glDisable GL_TEXTURE_2D; |
1710 | } |
1743 | } |
1711 | |
1744 | |
… | |
… | |
1721 | my $self = $class->SUPER::new ( |
1754 | my $self = $class->SUPER::new ( |
1722 | tooltip => $arg{type}, |
1755 | tooltip => $arg{type}, |
1723 | %arg, |
1756 | %arg, |
1724 | ); |
1757 | ); |
1725 | |
1758 | |
1726 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); |
1759 | $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999", can_events => 1, can_hover => 1); |
1727 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1); |
1760 | $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_events => 1, can_hover => 1); |
1728 | $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999"); |
1761 | $self->add ($self->{max} = new CFClient::UI::Label valign => -1, align => 0, template => "999", can_events => 1, can_hover => 1); |
1729 | |
1762 | |
1730 | $self |
1763 | $self |
1731 | } |
1764 | } |
1732 | |
1765 | |
1733 | sub set_fontsize { |
1766 | sub set_fontsize { |
… | |
… | |
1900 | sub new { |
1933 | sub new { |
1901 | my $class = shift; |
1934 | my $class = shift; |
1902 | |
1935 | |
1903 | my $self = $class->SUPER::new ( |
1936 | my $self = $class->SUPER::new ( |
1904 | fontsize => 1, |
1937 | fontsize => 1, |
|
|
1938 | #font => default_font |
1905 | @_, |
1939 | @_, |
1906 | |
1940 | |
1907 | layout => (new CFClient::Layout), |
1941 | layout => (new CFClient::Layout), |
1908 | par => [], |
1942 | par => [], |
1909 | height => 0, |
1943 | height => 0, |
… | |
… | |
1949 | sub size_allocate { |
1983 | sub size_allocate { |
1950 | my ($self, $w, $h) = @_; |
1984 | my ($self, $w, $h) = @_; |
1951 | |
1985 | |
1952 | $self->SUPER::size_allocate ($w, $h); |
1986 | $self->SUPER::size_allocate ($w, $h); |
1953 | |
1987 | |
|
|
1988 | $self->{layout}->set_font ($self->{font}) if $self->{font}; |
1954 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1989 | $self->{layout}->set_height ($self->{fontsize} * $::FONTSIZE); |
1955 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1990 | $self->{layout}->set_width ($self->{children}[0]{w}); |
1956 | |
1991 | |
1957 | $self->reflow; |
1992 | $self->reflow; |
1958 | } |
1993 | } |
… | |
… | |
2010 | my $y1 = $top + $self->{h}; |
2045 | my $y1 = $top + $self->{h}; |
2011 | |
2046 | |
2012 | my $y = 0; |
2047 | my $y = 0; |
2013 | |
2048 | |
2014 | my $layout = $self->{layout}; |
2049 | my $layout = $self->{layout}; |
|
|
2050 | |
|
|
2051 | $layout->set_font ($self->{font}) if $self->{font}; |
2015 | |
2052 | |
2016 | for my $par (@{$self->{par}}) { |
2053 | for my $par (@{$self->{par}}) { |
2017 | my $h = $par->[0]; |
2054 | my $h = $par->[0]; |
2018 | |
2055 | |
2019 | if ($y0 < $y + $h && $y < $y1) { |
2056 | if ($y0 < $y + $h && $y < $y1) { |
… | |
… | |
2129 | $self->emit (changed => $self->{state}); |
2166 | $self->emit (changed => $self->{state}); |
2130 | } |
2167 | } |
2131 | |
2168 | |
2132 | ############################################################################# |
2169 | ############################################################################# |
2133 | |
2170 | |
|
|
2171 | package CFClient::UI::Tooltip; |
|
|
2172 | |
|
|
2173 | our @ISA = CFClient::UI::Bin::; |
|
|
2174 | |
|
|
2175 | use CFClient::OpenGL; |
|
|
2176 | |
|
|
2177 | sub new { |
|
|
2178 | my $class = shift; |
|
|
2179 | |
|
|
2180 | $class->SUPER::new ( |
|
|
2181 | @_, |
|
|
2182 | can_events => 0, |
|
|
2183 | ) |
|
|
2184 | } |
|
|
2185 | |
|
|
2186 | sub set_text { |
|
|
2187 | my ($self, $text) = @_; |
|
|
2188 | |
|
|
2189 | $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0]; |
|
|
2190 | $self->{label}->set_text ($text); |
|
|
2191 | $self->add ($self->{label}); |
|
|
2192 | } |
|
|
2193 | |
|
|
2194 | sub size_request { |
|
|
2195 | my ($self) = @_; |
|
|
2196 | |
|
|
2197 | $self->child->set_max_size ($::WIDTH * 0.2); |
|
|
2198 | |
|
|
2199 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
|
|
2200 | |
|
|
2201 | ($w + 4, $h + 4) |
|
|
2202 | } |
|
|
2203 | |
|
|
2204 | sub _draw { |
|
|
2205 | my ($self) = @_; |
|
|
2206 | |
|
|
2207 | glPushMatrix; |
|
|
2208 | glTranslate 0.375, 0.375; |
|
|
2209 | |
|
|
2210 | my ($w, $h) = @$self{qw(w h)}; |
|
|
2211 | |
|
|
2212 | glColor 1, 0.8, 0.4; |
|
|
2213 | glBegin GL_QUADS; |
|
|
2214 | glVertex 0 , 0; |
|
|
2215 | glVertex 0 , $h; |
|
|
2216 | glVertex $w, $h; |
|
|
2217 | glVertex $w, 0; |
|
|
2218 | glEnd; |
|
|
2219 | |
|
|
2220 | glColor 0, 0, 0; |
|
|
2221 | glBegin GL_LINE_LOOP; |
|
|
2222 | glVertex 0 , 0; |
|
|
2223 | glVertex 0 , $h; |
|
|
2224 | glVertex $w, $h; |
|
|
2225 | glVertex $w, 0; |
|
|
2226 | glEnd; |
|
|
2227 | |
|
|
2228 | glPopMatrix; |
|
|
2229 | |
|
|
2230 | glTranslate 2, 2; |
|
|
2231 | $self->SUPER::_draw; |
|
|
2232 | } |
|
|
2233 | |
|
|
2234 | ############################################################################# |
|
|
2235 | |
2134 | package CFClient::UI::Root; |
2236 | package CFClient::UI::Root; |
2135 | |
2237 | |
2136 | our @ISA = CFClient::UI::Container::; |
2238 | our @ISA = CFClient::UI::Container::; |
2137 | |
2239 | |
2138 | use CFClient::OpenGL; |
2240 | use CFClient::OpenGL; |
… | |
… | |
2213 | ############################################################################# |
2315 | ############################################################################# |
2214 | |
2316 | |
2215 | package CFClient::UI; |
2317 | package CFClient::UI; |
2216 | |
2318 | |
2217 | $ROOT = new CFClient::UI::Root; |
2319 | $ROOT = new CFClient::UI::Root; |
2218 | $TOOLTIP = new CFClient::UI::Label fontsize => 0.8, can_events => 0; |
2320 | $TOOLTIP = new CFClient::UI::Tooltip; |
2219 | |
2321 | |
2220 | 1 |
2322 | 1 |
2221 | |
2323 | |