… | |
… | |
548 | return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w) |
548 | return if ($draw_x + $self->{w} < 0) || ($draw_x >= $draw_w) |
549 | || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h); |
549 | || ($draw_y + $self->{h} < 0) || ($draw_y >= $draw_h); |
550 | |
550 | |
551 | glPushMatrix; |
551 | glPushMatrix; |
552 | glTranslate $self->{x}, $self->{y}, 0; |
552 | glTranslate $self->{x}, $self->{y}, 0; |
553 | $self->_draw; |
|
|
554 | glPopMatrix; |
|
|
555 | |
553 | |
556 | if ($self == $HOVER && $self->{can_hover}) { |
554 | if ($self == $HOVER && $self->{can_hover}) { |
557 | my ($x, $y) = @$self{qw(x y)}; |
|
|
558 | |
|
|
559 | glColor 1, 0.8, 0.5, 0.2; |
555 | glColor 1*0.2, 0.8*0.2, 0.5*0.2, 0.2; |
560 | glEnable GL_BLEND; |
556 | glEnable GL_BLEND; |
561 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
557 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
562 | glBegin GL_QUADS; |
558 | glBegin GL_QUADS; |
563 | glVertex $x , $y; |
559 | glVertex 0 , 0; |
564 | glVertex $x + $self->{w}, $y; |
560 | glVertex $self->{w}, 0; |
565 | glVertex $x + $self->{w}, $y + $self->{h}; |
561 | glVertex $self->{w}, $self->{h}; |
566 | glVertex $x , $y + $self->{h}; |
562 | glVertex 0 , $self->{h}; |
567 | glEnd; |
563 | glEnd; |
568 | glDisable GL_BLEND; |
564 | glDisable GL_BLEND; |
569 | } |
565 | } |
570 | |
566 | |
571 | if ($ENV{CFPLUS_DEBUG} & 1) { |
567 | if ($ENV{CFPLUS_DEBUG} & 1) { |
572 | glPushMatrix; |
568 | glPushMatrix; |
573 | glColor 1, 1, 0, 1; |
569 | glColor 1, 1, 0, 1; |
574 | glTranslate $self->{x} + 0.375, $self->{y} + 0.375; |
570 | glTranslate 0.375, 0.375; |
575 | glBegin GL_LINE_LOOP; |
571 | glBegin GL_LINE_LOOP; |
576 | glVertex 0 , 0; |
572 | glVertex 0 , 0; |
577 | glVertex $self->{w} - 1, 0; |
573 | glVertex $self->{w} - 1, 0; |
578 | glVertex $self->{w} - 1, $self->{h} - 1; |
574 | glVertex $self->{w} - 1, $self->{h} - 1; |
579 | glVertex 0 , $self->{h} - 1; |
575 | glVertex 0 , $self->{h} - 1; |
580 | glEnd; |
576 | glEnd; |
581 | glPopMatrix; |
577 | glPopMatrix; |
582 | #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
578 | #CFClient::UI::Label->new (w => $self->{w}, h => $self->{h}, text => $self, fontsize => 0)->_draw; |
583 | } |
579 | } |
|
|
580 | |
|
|
581 | $self->_draw; |
|
|
582 | glPopMatrix; |
584 | } |
583 | } |
585 | |
584 | |
586 | sub _draw { |
585 | sub _draw { |
587 | my ($self) = @_; |
586 | my ($self) = @_; |
588 | |
587 | |
… | |
… | |
626 | |
625 | |
627 | if ($color && (@$color < 4 || $color->[3])) { |
626 | if ($color && (@$color < 4 || $color->[3])) { |
628 | my ($w, $h) = @$self{qw(w h)}; |
627 | my ($w, $h) = @$self{qw(w h)}; |
629 | |
628 | |
630 | glEnable GL_BLEND; |
629 | glEnable GL_BLEND; |
631 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
630 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
632 | glColor @$color; |
631 | glColor_premultiply @$color; |
633 | |
632 | |
634 | glBegin GL_QUADS; |
633 | glBegin GL_QUADS; |
635 | glVertex 0 , 0; |
634 | glVertex 0 , 0; |
636 | glVertex 0 , $h; |
635 | glVertex 0 , $h; |
637 | glVertex $w, $h; |
636 | glVertex $w, $h; |
… | |
… | |
856 | my $tex = $self->{texture} |
855 | my $tex = $self->{texture} |
857 | or return; |
856 | or return; |
858 | |
857 | |
859 | glEnable GL_TEXTURE_2D; |
858 | glEnable GL_TEXTURE_2D; |
860 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
859 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
861 | glColor 1, 1, 1, 1; |
860 | glColor 0, 0, 0, 1; |
862 | |
861 | |
863 | $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); |
862 | $tex->draw_quad_alpha_premultiplied (0, 0, $w, $h); |
864 | |
863 | |
865 | glDisable GL_TEXTURE_2D; |
864 | glDisable GL_TEXTURE_2D; |
866 | } |
865 | } |
… | |
… | |
1035 | |
1034 | |
1036 | if ($self->{bg}) { |
1035 | if ($self->{bg}) { |
1037 | my ($w, $h) = @$self{qw(w h)}; |
1036 | my ($w, $h) = @$self{qw(w h)}; |
1038 | |
1037 | |
1039 | glEnable GL_BLEND; |
1038 | glEnable GL_BLEND; |
1040 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1039 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
1041 | glColor @{ $self->{bg} }; |
1040 | glColor_premultiply @{ $self->{bg} }; |
1042 | |
1041 | |
1043 | glBegin GL_QUADS; |
1042 | glBegin GL_QUADS; |
1044 | glVertex 0 , 0; |
1043 | glVertex 0 , 0; |
1045 | glVertex 0 , $h; |
1044 | glVertex 0 , $h; |
1046 | glVertex $w, $h; |
1045 | glVertex $w, $h; |
… | |
… | |
1160 | my $dy = $ev->{y} - $oy; |
1159 | my $dy = $ev->{y} - $oy; |
1161 | |
1160 | |
1162 | $self->{force_w} = $bw + $dx * ($mx ? -1 : 1); |
1161 | $self->{force_w} = $bw + $dx * ($mx ? -1 : 1); |
1163 | $self->{force_h} = $bh + $dy * ($my ? -1 : 1); |
1162 | $self->{force_h} = $bh + $dy * ($my ? -1 : 1); |
1164 | |
1163 | |
|
|
1164 | $self->move_abs ($wx + $dx * $mx, $wy + $dy * $my); |
1165 | $self->realloc; |
1165 | $self->realloc; |
1166 | $self->move_abs ($wx + $dx * $mx, $wy + $dy * $my); |
|
|
1167 | }; |
1166 | }; |
1168 | |
1167 | |
1169 | } elsif ($lr ^ $td) { |
1168 | } elsif ($lr ^ $td) { |
1170 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
1169 | my ($ox, $oy) = ($ev->{x}, $ev->{y}); |
1171 | my ($bx, $by) = ($self->{x}, $self->{y}); |
1170 | my ($bx, $by) = ($self->{x}, $self->{y}); |
… | |
… | |
1174 | my ($ev, $x, $y) = @_; |
1173 | my ($ev, $x, $y) = @_; |
1175 | |
1174 | |
1176 | ($x, $y) = ($ev->{x}, $ev->{y}); |
1175 | ($x, $y) = ($ev->{x}, $ev->{y}); |
1177 | |
1176 | |
1178 | $self->move_abs ($bx + $x - $ox, $by + $y - $oy); |
1177 | $self->move_abs ($bx + $x - $ox, $by + $y - $oy); |
|
|
1178 | # HACK: the next line is required to enforce placement |
|
|
1179 | $self->{parent}->size_allocate ($self->{parent}{w}, $self->{parent}{h}); |
1179 | }; |
1180 | }; |
1180 | } else { |
1181 | } else { |
1181 | return 0; |
1182 | return 0; |
1182 | } |
1183 | } |
1183 | |
1184 | |
… | |
… | |
1634 | }; |
1635 | }; |
1635 | |
1636 | |
1636 | glEnable GL_TEXTURE_2D; |
1637 | glEnable GL_TEXTURE_2D; |
1637 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1638 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1638 | |
1639 | |
|
|
1640 | glColor_premultiply @{$self->{fg}} |
1639 | if ($tex->{format} == GL_ALPHA) { |
1641 | if $tex->{format} == GL_ALPHA; |
1640 | glColor @{$self->{fg}}; |
1642 | |
1641 | $tex->draw_quad_alpha ($self->{ox}, $self->{oy}); |
|
|
1642 | } else { |
|
|
1643 | $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}); |
1643 | $tex->draw_quad_alpha_premultiplied ($self->{ox}, $self->{oy}); |
1644 | } |
|
|
1645 | |
1644 | |
1646 | glDisable GL_TEXTURE_2D; |
1645 | glDisable GL_TEXTURE_2D; |
1647 | } |
1646 | } |
1648 | |
1647 | |
1649 | ############################################################################# |
1648 | ############################################################################# |
… | |
… | |
1782 | my ($self) = @_; |
1781 | my ($self) = @_; |
1783 | |
1782 | |
1784 | local $self->{fg} = $self->{fg}; |
1783 | local $self->{fg} = $self->{fg}; |
1785 | |
1784 | |
1786 | if ($FOCUS == $self) { |
1785 | if ($FOCUS == $self) { |
1787 | glColor @{$self->{active_bg}}; |
1786 | glColor_premultiply @{$self->{active_bg}}; |
1788 | $self->{fg} = $self->{active_fg}; |
1787 | $self->{fg} = $self->{active_fg}; |
1789 | } else { |
1788 | } else { |
1790 | glColor @{$self->{bg}}; |
1789 | glColor_premultiply @{$self->{bg}}; |
1791 | } |
1790 | } |
1792 | |
1791 | |
1793 | glEnable GL_BLEND; |
1792 | glEnable GL_BLEND; |
1794 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1793 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
1795 | glBegin GL_QUADS; |
1794 | glBegin GL_QUADS; |
1796 | glVertex 0 , 0; |
1795 | glVertex 0 , 0; |
1797 | glVertex 0 , $self->{h}; |
1796 | glVertex 0 , $self->{h}; |
1798 | glVertex $self->{w}, $self->{h}; |
1797 | glVertex $self->{w}, $self->{h}; |
1799 | glVertex $self->{w}, 0; |
1798 | glVertex $self->{w}, 0; |
… | |
… | |
1909 | } |
1908 | } |
1910 | |
1909 | |
1911 | sub _draw { |
1910 | sub _draw { |
1912 | my ($self) = @_; |
1911 | my ($self) = @_; |
1913 | |
1912 | |
1914 | local $self->{fg} = $self->{fg}; |
1913 | local $self->{fg} = $GRAB == $self ? $self->{active_fg} : $self->{fg}; |
1915 | |
|
|
1916 | if ($GRAB == $self) { |
|
|
1917 | $self->{fg} = $self->{active_fg}; |
|
|
1918 | } |
|
|
1919 | |
1914 | |
1920 | glEnable GL_TEXTURE_2D; |
1915 | glEnable GL_TEXTURE_2D; |
1921 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1916 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1922 | glColor 0, 0, 0, 1; |
1917 | glColor 0, 0, 0, 1; |
1923 | |
1918 | |
… | |
… | |
2148 | |
2143 | |
2149 | my $h1 = $self->{h} * (1 - $ycut1); |
2144 | my $h1 = $self->{h} * (1 - $ycut1); |
2150 | my $h2 = $self->{h} * (1 - $ycut2); |
2145 | my $h2 = $self->{h} * (1 - $ycut2); |
2151 | |
2146 | |
2152 | glEnable GL_BLEND; |
2147 | glEnable GL_BLEND; |
2153 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
2148 | glBlendFuncSeparate GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, |
|
|
2149 | GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
2154 | glEnable GL_TEXTURE_2D; |
2150 | glEnable GL_TEXTURE_2D; |
2155 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2151 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2156 | |
2152 | |
2157 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
2153 | glBindTexture GL_TEXTURE_2D, $t1->{name}; |
2158 | glBegin GL_QUADS; |
2154 | glBegin GL_QUADS; |
… | |
… | |
2570 | |
2566 | |
2571 | delete $self->{texture}; |
2567 | delete $self->{texture}; |
2572 | } |
2568 | } |
2573 | |
2569 | |
2574 | $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub { |
2570 | $self->{texture} ||= new_from_opengl CFClient::Texture $W, $H, sub { |
2575 | glClearColor 0.5, 0.5, 0.5, 0; |
2571 | glClearColor 0, 0, 0, 0; |
2576 | glClear GL_COLOR_BUFFER_BIT; |
2572 | glClear GL_COLOR_BUFFER_BIT; |
2577 | |
2573 | |
2578 | my $top = int $self->{children}[1]{range}[0]; |
2574 | my $top = int $self->{children}[1]{range}[0]; |
2579 | |
2575 | |
2580 | my $y0 = $top; |
2576 | my $y0 = $top; |
… | |
… | |
2615 | sub _draw { |
2611 | sub _draw { |
2616 | my ($self) = @_; |
2612 | my ($self) = @_; |
2617 | |
2613 | |
2618 | glEnable GL_TEXTURE_2D; |
2614 | glEnable GL_TEXTURE_2D; |
2619 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2615 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2620 | glColor 1, 1, 1, 1; |
2616 | glColor 0, 0, 0, 1; |
2621 | $self->{texture}->draw_quad_alpha (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2617 | $self->{texture}->draw_quad_alpha_premultiplied (0, 0, $self->{children}[0]{w}, $self->{children}[0]{h}); |
2622 | glDisable GL_TEXTURE_2D; |
2618 | glDisable GL_TEXTURE_2D; |
2623 | |
2619 | |
2624 | $self->{children}[1]->draw; |
2620 | $self->{children}[1]->draw; |
2625 | |
2621 | |
2626 | } |
2622 | } |
… | |
… | |
2853 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]]; |
2849 | my $tex = $::CONN->{texture}[$::CONN->{faceid}[$face || $self->{face}]]; |
2854 | |
2850 | |
2855 | if ($tex) { |
2851 | if ($tex) { |
2856 | glEnable GL_TEXTURE_2D; |
2852 | glEnable GL_TEXTURE_2D; |
2857 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2853 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
2858 | glColor 1, 1, 1, 1; |
2854 | glColor 0, 0, 0, 1; |
2859 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2855 | $tex->draw_quad_alpha (0, 0, $self->{w}, $self->{h}); |
2860 | glDisable GL_TEXTURE_2D; |
2856 | glDisable GL_TEXTURE_2D; |
2861 | } |
2857 | } |
2862 | } |
2858 | } |
2863 | |
2859 | |