… | |
… | |
24 | |
24 | |
25 | my $tip = $widget->{tooltip}; |
25 | my $tip = $widget->{tooltip}; |
26 | |
26 | |
27 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
27 | $tip = $tip->($widget) if CODE:: eq ref $tip; |
28 | |
28 | |
29 | $TOOLTIP->set_markup ($widget->{tooltip}); |
29 | $TOOLTIP->set_markup ($widget->{tooltip}, $widget->{tooltip_font}); |
30 | |
30 | |
31 | $TOOLTIP->show; |
31 | $TOOLTIP->show; |
32 | |
32 | |
33 | my ($x, $y) = $widget->coord2global ($widget->{w}, 0); |
33 | my ($x, $y) = $widget->coord2global ($widget->{w}, 0); |
34 | |
34 | |
… | |
… | |
1672 | |
1672 | |
1673 | if ($GRAB == $self) { |
1673 | if ($GRAB == $self) { |
1674 | $self->{fg} = $self->{active_fg}; |
1674 | $self->{fg} = $self->{active_fg}; |
1675 | } |
1675 | } |
1676 | |
1676 | |
1677 | glEnable GL_BLEND; |
|
|
1678 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1679 | glEnable GL_TEXTURE_2D; |
1677 | glEnable GL_TEXTURE_2D; |
1680 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1678 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1681 | glColor 0, 0, 0, 1; |
1679 | glColor 0, 0, 0, 1; |
1682 | |
1680 | |
1683 | $tex[0]->draw_quad (0, 0, $self->{w}, $self->{h}); |
1681 | $tex[0]->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
1684 | |
1682 | |
1685 | glDisable GL_TEXTURE_2D; |
1683 | glDisable GL_TEXTURE_2D; |
1686 | glDisable GL_BLEND; |
|
|
1687 | |
1684 | |
1688 | $self->SUPER::_draw; |
1685 | $self->SUPER::_draw; |
1689 | } |
1686 | } |
1690 | |
1687 | |
1691 | ############################################################################# |
1688 | ############################################################################# |
… | |
… | |
1738 | |
1735 | |
1739 | my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2; |
1736 | my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2; |
1740 | |
1737 | |
1741 | glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} }; |
1738 | glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} }; |
1742 | |
1739 | |
1743 | glEnable GL_BLEND; |
|
|
1744 | glEnable GL_TEXTURE_2D; |
1740 | glEnable GL_TEXTURE_2D; |
1745 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1746 | |
1741 | |
1747 | my $tex = $self->{state} ? $tex[1] : $tex[0]; |
1742 | my $tex = $self->{state} ? $tex[1] : $tex[0]; |
1748 | |
1743 | |
1749 | $tex->draw_quad (0, 0, $s, $s); |
1744 | $tex->draw_quad_alpha (0, 0, $s, $s); |
1750 | |
1745 | |
1751 | glDisable GL_TEXTURE_2D; |
1746 | glDisable GL_TEXTURE_2D; |
1752 | glDisable GL_BLEND; |
|
|
1753 | } |
1747 | } |
1754 | |
1748 | |
1755 | ############################################################################# |
1749 | ############################################################################# |
1756 | |
1750 | |
1757 | package CFClient::UI::Image; |
1751 | package CFClient::UI::Image; |
… | |
… | |
1800 | glTranslate 0, -$self->{w}, 0; |
1794 | glTranslate 0, -$self->{w}, 0; |
1801 | |
1795 | |
1802 | ($w, $h) = ($h, $w); |
1796 | ($w, $h) = ($h, $w); |
1803 | } |
1797 | } |
1804 | |
1798 | |
1805 | glEnable GL_BLEND; |
|
|
1806 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1807 | glEnable GL_TEXTURE_2D; |
1799 | glEnable GL_TEXTURE_2D; |
1808 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1800 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1809 | |
1801 | |
1810 | $tex->draw_quad (0, 0, $w, $h); |
1802 | $tex->draw_quad_alpha (0, 0, $w, $h); |
1811 | |
1803 | |
1812 | glDisable GL_BLEND; |
|
|
1813 | glDisable GL_TEXTURE_2D; |
1804 | glDisable GL_TEXTURE_2D; |
1814 | } |
1805 | } |
1815 | |
1806 | |
1816 | ############################################################################# |
1807 | ############################################################################# |
1817 | |
1808 | |
… | |
… | |
2109 | $page ||= 2; |
2100 | $page ||= 2; |
2110 | |
2101 | |
2111 | my $knob_a = $inner_pad_px + ($value - $page * 0.5); |
2102 | my $knob_a = $inner_pad_px + ($value - $page * 0.5); |
2112 | my $knob_b = $inner_pad_px + ($value + $page * 0.5); |
2103 | my $knob_b = $inner_pad_px + ($value + $page * 0.5); |
2113 | |
2104 | |
2114 | glEnable GL_BLEND; |
|
|
2115 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
2116 | glEnable GL_TEXTURE_2D; |
2105 | glEnable GL_TEXTURE_2D; |
2117 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2106 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2118 | |
2107 | |
2119 | # draw background |
2108 | # draw background |
2120 | $tex[1]->draw_quad (0, 0, $w, $h); |
2109 | $tex[1]->draw_quad_alpha (0, 0, $w, $h); |
2121 | |
2110 | |
2122 | # draw handle |
2111 | # draw handle |
2123 | $tex[0]->draw_quad ($knob_a, 0, $knob_b - $knob_a, $h); |
2112 | $tex[0]->draw_quad_alpha ($knob_a, 0, $knob_b - $knob_a, $h); |
2124 | |
2113 | |
2125 | glDisable GL_BLEND; |
|
|
2126 | glDisable GL_TEXTURE_2D; |
2114 | glDisable GL_TEXTURE_2D; |
2127 | } |
2115 | } |
2128 | |
2116 | |
2129 | ############################################################################# |
2117 | ############################################################################# |
2130 | |
2118 | |
… | |
… | |
2141 | fontsize => 1, |
2129 | fontsize => 1, |
2142 | can_events => 0, |
2130 | can_events => 0, |
2143 | #font => default_font |
2131 | #font => default_font |
2144 | @_, |
2132 | @_, |
2145 | |
2133 | |
2146 | layout => (new CFClient::Layout), |
2134 | layout => (new CFClient::Layout 1), |
2147 | par => [], |
2135 | par => [], |
2148 | height => 0, |
2136 | height => 0, |
2149 | children => [ |
2137 | children => [ |
2150 | (new CFClient::UI::Empty expand => 1), |
2138 | (new CFClient::UI::Empty expand => 1), |
2151 | (new CFClient::UI::Slider vertical => 1), |
2139 | (new CFClient::UI::Slider vertical => 1), |
… | |
… | |
2169 | |
2157 | |
2170 | my $layout = $self->{layout}; |
2158 | my $layout = $self->{layout}; |
2171 | |
2159 | |
2172 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2160 | $layout->set_height ($self->{fontsize} * $::FONTSIZE); |
2173 | $layout->set_width ($self->{children}[0]{w}); |
2161 | $layout->set_width ($self->{children}[0]{w}); |
2174 | $layout->set_text ($text); |
2162 | $layout->set_markup ($text); |
2175 | |
2163 | |
2176 | ($layout->size)[1] |
2164 | ($layout->size)[1] |
2177 | } |
2165 | } |
2178 | |
2166 | |
2179 | sub reflow { |
2167 | sub reflow { |
… | |
… | |
2235 | |
2223 | |
2236 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { |
2224 | $self->{texture} ||= new_from_opengl CFClient::Texture $self->{children}[0]{w}, $self->{children}[0]{h}, sub { |
2237 | glClearColor 0, 0, 0, 0; |
2225 | glClearColor 0, 0, 0, 0; |
2238 | glClear GL_COLOR_BUFFER_BIT; |
2226 | glClear GL_COLOR_BUFFER_BIT; |
2239 | |
2227 | |
2240 | glEnable GL_BLEND; |
|
|
2241 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
2242 | glEnable GL_TEXTURE_2D; |
2228 | glEnable GL_TEXTURE_2D; |
2243 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2229 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2244 | |
2230 | |
2245 | my $top = int $self->{children}[1]{range}[0]; |
2231 | my $top = int $self->{children}[1]{range}[0]; |
2246 | |
2232 | |
… | |
… | |
2255 | |
2241 | |
2256 | for my $par (@{$self->{par}}) { |
2242 | for my $par (@{$self->{par}}) { |
2257 | my $h = $par->[0]; |
2243 | my $h = $par->[0]; |
2258 | |
2244 | |
2259 | if ($y0 < $y + $h && $y < $y1) { |
2245 | if ($y0 < $y + $h && $y < $y1) { |
|
|
2246 | $layout->set_foreground (@{ $par->[1] }); |
2260 | $layout->set_text ($par->[2]); |
2247 | $layout->set_markup ($par->[2]); |
2261 | |
2248 | |
2262 | glColor @{ $par->[1] }; |
|
|
2263 | my ($W, $H) = $layout->size; |
2249 | my ($W, $H) = $layout->size; |
2264 | CFClient::Texture->new_from_layout ($layout)->draw_quad (0, $y - $y0); |
2250 | CFClient::Texture->new_from_layout ($layout)->draw_quad_alpha_premultiplied (0, $y - $y0); |
2265 | } |
2251 | } |
2266 | |
2252 | |
2267 | $y += $h; |
2253 | $y += $h; |
2268 | } |
2254 | } |
2269 | |
2255 | |
2270 | glDisable GL_TEXTURE_2D; |
2256 | glDisable GL_TEXTURE_2D; |
2271 | glDisable GL_BLEND; |
|
|
2272 | }; |
2257 | }; |
2273 | }); |
2258 | }); |
2274 | } |
2259 | } |
2275 | |
2260 | |
2276 | sub _draw { |
2261 | sub _draw { |
2277 | my ($self) = @_; |
2262 | my ($self) = @_; |
2278 | |
2263 | |
2279 | glEnable GL_BLEND; |
|
|
2280 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
|
|
2281 | glEnable GL_TEXTURE_2D; |
2264 | glEnable GL_TEXTURE_2D; |
2282 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2265 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2283 | glColor 1, 1, 1, 1; |
2266 | glColor 1, 1, 1, 1; |
2284 | $self->{texture}->draw_quad (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2267 | $self->{texture}->draw_quad_alpha_premultiplied (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2285 | glDisable GL_TEXTURE_2D; |
2268 | glDisable GL_TEXTURE_2D; |
2286 | glDisable GL_BLEND; |
|
|
2287 | |
2269 | |
2288 | $self->{children}[1]->draw; |
2270 | $self->{children}[1]->draw; |
2289 | |
2271 | |
2290 | } |
2272 | } |
2291 | |
2273 | |
… | |
… | |
2386 | can_events => 0, |
2368 | can_events => 0, |
2387 | ) |
2369 | ) |
2388 | } |
2370 | } |
2389 | |
2371 | |
2390 | sub set_markup { |
2372 | sub set_markup { |
2391 | my ($self, $text) = @_; |
2373 | my ($self, $text, $font) = @_; |
2392 | |
2374 | |
2393 | $self->{label} ||= new CFClient::UI::Label fontsize => 0.8, fg => [0, 0, 0]; |
2375 | $self->{label} = new CFClient::UI::Label |
|
|
2376 | fontsize => 0.8, |
|
|
2377 | fg => [0, 0, 0], |
|
|
2378 | font => ($font || $::FONT_PROP); |
|
|
2379 | |
|
|
2380 | $self->{label}->set_max_size ($::WIDTH * 0.3); |
2394 | $self->{label}->set_markup ($text); |
2381 | $self->{label}->set_markup ($text); |
2395 | $self->add ($self->{label}); |
2382 | $self->add ($self->{label}); |
2396 | } |
2383 | } |
2397 | |
2384 | |
2398 | sub size_request { |
2385 | sub size_request { |
2399 | my ($self) = @_; |
2386 | my ($self) = @_; |
2400 | |
|
|
2401 | $self->child->set_max_size ($::WIDTH * 0.3); |
|
|
2402 | |
2387 | |
2403 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2388 | my ($w, $h) = @{$self->child}{qw(req_w req_h)}; |
2404 | |
2389 | |
2405 | ($w + 4, $h + 4) |
2390 | ($w + 4, $h + 4) |
2406 | } |
2391 | } |
… | |
… | |
2468 | return unless $::CONN;#d# manage and cache textures differently |
2453 | return unless $::CONN;#d# manage and cache textures differently |
2469 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; |
2454 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$self->{face}]]; |
2470 | |
2455 | |
2471 | # TODO animation |
2456 | # TODO animation |
2472 | if ($tex) { |
2457 | if ($tex) { |
2473 | glEnable GL_BLEND; |
|
|
2474 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
2475 | glEnable GL_TEXTURE_2D; |
2458 | glEnable GL_TEXTURE_2D; |
2476 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2459 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2477 | glColor 1, 1, 1, 1; |
2460 | glColor 1, 1, 1, 1; |
2478 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
2461 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2479 | glDisable GL_TEXTURE_2D; |
2462 | glDisable GL_TEXTURE_2D; |
2480 | glDisable GL_BLEND; |
|
|
2481 | } |
2463 | } |
2482 | } |
2464 | } |
2483 | |
2465 | |
2484 | ############################################################################# |
2466 | ############################################################################# |
2485 | |
2467 | |