… | |
… | |
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 | |
645 | sub update { |
653 | sub 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 | |
|
|
660 | sub size_allocate { |
|
|
661 | my ($self, $w, $h) = @_; |
|
|
662 | |
|
|
663 | $self->SUPER::size_allocate ($w, $h); |
|
|
664 | $self->update; |
|
|
665 | } |
|
|
666 | |
653 | sub render_chld { |
667 | sub 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; |
660 | }; |
674 | }; |
661 | } |
675 | } |
662 | |
676 | |
663 | sub size_allocate { |
|
|
664 | my ($self, $w, $h) = @_; |
|
|
665 | |
|
|
666 | $self->child->configure (0, 0, $w, $h); |
|
|
667 | |
|
|
668 | $self->render_chld; |
|
|
669 | } |
|
|
670 | |
|
|
671 | sub _draw { |
677 | sub _draw { |
672 | my ($self) = @_; |
678 | my ($self) = @_; |
673 | |
679 | |
674 | my ($w, $h) = ($self->w, $self->h); |
680 | my ($w, $h) = ($self->w, $self->h); |
675 | |
681 | |
676 | my $tex = $self->{texture} |
682 | my $tex = $self->{texture} |
677 | or return; |
683 | or return; |
678 | |
684 | |
679 | glEnable GL_BLEND; |
685 | glEnable GL_BLEND; |
680 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
686 | glBlendFunc GL_ONE, GL_ONE_MINUS_SRC_ALPHA; |
681 | glEnable GL_TEXTURE_2D; |
687 | glEnable GL_TEXTURE_2D; |
682 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
688 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
689 | glColor 0, 0, 0, 1; |
683 | |
690 | |
684 | $tex->draw_quad (0, 0, $w, $h); |
691 | $tex->draw_quad (0, 0, $w, $h); |
685 | |
692 | |
686 | glDisable GL_BLEND; |
693 | glDisable GL_BLEND; |
687 | glDisable GL_TEXTURE_2D; |
694 | glDisable GL_TEXTURE_2D; |