ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.173 by root, Tue Apr 25 10:30:48 2006 UTC vs.
Revision 1.175 by root, Tue Apr 25 11:48:31 2006 UTC

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 }
643} 651}
644 652
645sub update { 653sub update {
646 my ($self) = @_; 654 my ($self) = @_;
647 655
648 # we want to do this delayed... 656 $ROOT->on_refresh ($self => sub { $self->render_child });
649 $self->render_chld;
650 $self->SUPER::update; 657 $self->SUPER::update;
651} 658}
652 659
660sub size_allocate {
661 my ($self, $w, $h) = @_;
662
663 $self->SUPER::size_allocate ($w, $h);
664 $self->update;
665}
666
653sub render_chld { 667sub render_child {
654 my ($self) = @_; 668 my ($self) = @_;
655 669
656 $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 {
657 glClearColor 0, 0, 0, 1; 671 glClearColor 0, 0, 0, 0;
658 glClear GL_COLOR_BUFFER_BIT; 672 glClear GL_COLOR_BUFFER_BIT;
659 $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;
660 }; 681 };
661}
662
663sub size_allocate {
664 my ($self, $w, $h) = @_;
665
666 $self->child->configure (0, 0, $w, $h);
667
668 $self->render_chld;
669} 682}
670 683
671sub _draw { 684sub _draw {
672 my ($self) = @_; 685 my ($self) = @_;
673 686
675 688
676 my $tex = $self->{texture} 689 my $tex = $self->{texture}
677 or return; 690 or return;
678 691
679 glEnable GL_BLEND; 692 glEnable GL_BLEND;
680 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 693 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
681 glEnable GL_TEXTURE_2D; 694 glEnable GL_TEXTURE_2D;
682 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;
683 697
684 $tex->draw_quad (0, 0, $w, $h); 698 $tex->draw_quad (0, 0, $w, $h);
685 699
686 glDisable GL_BLEND; 700 glDisable GL_BLEND;
687 glDisable GL_TEXTURE_2D; 701 glDisable GL_TEXTURE_2D;
2153 2167
2154 delete $self->{texture}; 2168 delete $self->{texture};
2155 } 2169 }
2156 2170
2157 $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 {
2158 glClearColor 0, 0, 0, 1; 2172 glClearColor 0, 0, 0, 0;
2159 glClear GL_COLOR_BUFFER_BIT; 2173 glClear GL_COLOR_BUFFER_BIT;
2160 2174
2161 glEnable GL_BLEND; 2175 glEnable GL_BLEND;
2162 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; 2176 glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA;
2163 glEnable GL_TEXTURE_2D; 2177 glEnable GL_TEXTURE_2D;
2196 2210
2197sub _draw { 2211sub _draw {
2198 my ($self) = @_; 2212 my ($self) = @_;
2199 2213
2200 if ($self->{texture}) { 2214 if ($self->{texture}) {
2215 glEnable GL_BLEND;
2216 glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA;
2201 glEnable GL_TEXTURE_2D; 2217 glEnable GL_TEXTURE_2D;
2202 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2218 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2203 glColor 1, 1, 1, 1; 2219 glColor 1, 1, 1, 1;
2204 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); 2220 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
2205 glDisable GL_TEXTURE_2D; 2221 glDisable GL_TEXTURE_2D;
2222 glDisable GL_BLEND;
2206 } 2223 }
2207 2224
2208 $self->{children}[1]->draw; 2225 $self->{children}[1]->draw;
2209 2226
2210} 2227}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines