… | |
… | |
133 | my ($self, $x, $y, $w, $h) = @_; |
133 | my ($self, $x, $y, $w, $h) = @_; |
134 | |
134 | |
135 | $self->_size_allocate ($x, $y, $w, $h); |
135 | $self->_size_allocate ($x, $y, $w, $h); |
136 | } |
136 | } |
137 | |
137 | |
138 | # translate global koordinates to local coordinate system |
138 | # translate global coordinates to local coordinate system |
139 | sub translate { |
139 | sub translate { |
140 | my ($self, $x, $y) = @_; |
140 | my ($self, $x, $y) = @_; |
141 | |
141 | |
142 | $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); |
142 | $self->{parent}->translate ($x - $self->{x}, $y - $self->{y}); |
143 | } |
143 | } |
… | |
… | |
637 | |
637 | |
638 | my $bg = $tex[0]; |
638 | my $bg = $tex[0]; |
639 | |
639 | |
640 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
640 | glBindTexture GL_TEXTURE_2D, $bg->{name}; |
641 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
641 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
642 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT; |
|
|
643 | glTexParameter GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT; |
|
|
644 | |
642 | |
645 | my $rep_x = $cw / $bg->{w}; |
643 | my $rep_x = $cw / $bg->{w}; |
646 | my $rep_y = $ch / $bg->{h}; |
644 | my $rep_y = $ch / $bg->{h}; |
647 | |
645 | |
648 | $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch); |
646 | $bg->draw_quad ($left->{w}, $top->{h}, $cw, $ch); |
… | |
… | |
941 | |
939 | |
942 | $self->{text} = $text; |
940 | $self->{text} = $text; |
943 | $self->{layout}->set_markup ($text); |
941 | $self->{layout}->set_markup ($text); |
944 | |
942 | |
945 | delete $self->{texture}; |
943 | delete $self->{texture}; |
|
|
944 | # $self->{w} = $self->{h} = -1; |
946 | $self->update; |
945 | $self->update; |
947 | } |
946 | } |
948 | |
947 | |
949 | sub get_text { |
948 | sub get_text { |
950 | my ($self, $text) = @_; |
949 | my ($self, $text) = @_; |
… | |
… | |
983 | sub _draw { |
982 | sub _draw { |
984 | my ($self) = @_; |
983 | my ($self) = @_; |
985 | |
984 | |
986 | my $tex = $self->{texture} ||= do { |
985 | my $tex = $self->{texture} ||= do { |
987 | $self->{layout}->set_width ($self->{w}); |
986 | $self->{layout}->set_width ($self->{w}); |
988 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{height}); |
987 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
989 | new_from_layout CFClient::Texture $self->{layout} |
988 | new_from_layout CFClient::Texture $self->{layout} |
990 | }; |
989 | }; |
991 | |
990 | |
992 | glEnable GL_BLEND; |
991 | glEnable GL_BLEND; |
993 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
992 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
… | |
… | |
999 | my $x = |
998 | my $x = |
1000 | $self->{align} < 0 ? $self->{padding} |
999 | $self->{align} < 0 ? $self->{padding} |
1001 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1000 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1002 | : ($self->{w} - $tex->{w}) * 0.5; |
1001 | : ($self->{w} - $tex->{w}) * 0.5; |
1003 | |
1002 | |
1004 | $tex->draw_quad ($x, $self->{padding}); |
1003 | glTranslate $x, $self->{padding}, 0; |
|
|
1004 | $tex->draw_quad (0, 0); |
1005 | |
1005 | |
1006 | glDisable GL_TEXTURE_2D; |
1006 | glDisable GL_TEXTURE_2D; |
1007 | glDisable GL_BLEND; |
1007 | glDisable GL_BLEND; |
1008 | } |
1008 | } |
1009 | |
1009 | |
… | |
… | |
1033 | |
1033 | |
1034 | $self->{last_activity} = $::NOW; |
1034 | $self->{last_activity} = $::NOW; |
1035 | |
1035 | |
1036 | $self->{text} = $text; |
1036 | $self->{text} = $text; |
1037 | $self->{layout}->set_width ($self->{w}); |
1037 | $self->{layout}->set_width ($self->{w}); |
|
|
1038 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
1038 | |
1039 | |
1039 | $text =~ s/./*/g if $self->{hidden}; |
1040 | $text =~ s/./*/g if $self->{hidden}; |
1040 | |
1041 | |
1041 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1042 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1042 | |
1043 | |