… | |
… | |
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); |
… | |
… | |
743 | |
741 | |
744 | my $x = 0; |
742 | my $x = 0; |
745 | my $row_h = $hs->[$r]; |
743 | my $row_h = $hs->[$r]; |
746 | |
744 | |
747 | for my $c (0 .. $#$row) { |
745 | for my $c (0 .. $#$row) { |
748 | my $widget = $row->[$c] |
|
|
749 | or next; |
|
|
750 | |
|
|
751 | my $col_w = $ws->[$c]; |
746 | my $col_w = $ws->[$c]; |
752 | |
747 | |
|
|
748 | if (my $widget = $row->[$c]) { |
753 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
749 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
|
|
750 | } |
754 | |
751 | |
755 | $x += $col_w; |
752 | $x += $col_w; |
756 | } |
753 | } |
757 | |
754 | |
758 | $y += $row_h; |
755 | $y += $row_h; |
… | |
… | |
941 | |
938 | |
942 | $self->{text} = $text; |
939 | $self->{text} = $text; |
943 | $self->{layout}->set_markup ($text); |
940 | $self->{layout}->set_markup ($text); |
944 | |
941 | |
945 | delete $self->{texture}; |
942 | delete $self->{texture}; |
|
|
943 | # $self->{w} = $self->{h} = -1; |
946 | $self->update; |
944 | $self->update; |
947 | } |
945 | } |
948 | |
946 | |
949 | sub get_text { |
947 | sub get_text { |
950 | my ($self, $text) = @_; |
948 | my ($self, $text) = @_; |
… | |
… | |
983 | sub _draw { |
981 | sub _draw { |
984 | my ($self) = @_; |
982 | my ($self) = @_; |
985 | |
983 | |
986 | my $tex = $self->{texture} ||= do { |
984 | my $tex = $self->{texture} ||= do { |
987 | $self->{layout}->set_width ($self->{w}); |
985 | $self->{layout}->set_width ($self->{w}); |
988 | $self->{layout}->set_height (List::Util::min $self->{h}, $self->{height}); |
986 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
989 | new_from_layout CFClient::Texture $self->{layout} |
987 | new_from_layout CFClient::Texture $self->{layout} |
990 | }; |
988 | }; |
991 | |
989 | |
992 | glEnable GL_BLEND; |
990 | glEnable GL_BLEND; |
993 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
991 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
… | |
… | |
999 | my $x = |
997 | my $x = |
1000 | $self->{align} < 0 ? $self->{padding} |
998 | $self->{align} < 0 ? $self->{padding} |
1001 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
999 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1002 | : ($self->{w} - $tex->{w}) * 0.5; |
1000 | : ($self->{w} - $tex->{w}) * 0.5; |
1003 | |
1001 | |
1004 | $tex->draw_quad ($x, $self->{padding}); |
1002 | glTranslate $x, $self->{padding}, 0; |
|
|
1003 | $tex->draw_quad (0, 0); |
1005 | |
1004 | |
1006 | glDisable GL_TEXTURE_2D; |
1005 | glDisable GL_TEXTURE_2D; |
1007 | glDisable GL_BLEND; |
1006 | glDisable GL_BLEND; |
1008 | } |
1007 | } |
1009 | |
1008 | |
… | |
… | |
1033 | |
1032 | |
1034 | $self->{last_activity} = $::NOW; |
1033 | $self->{last_activity} = $::NOW; |
1035 | |
1034 | |
1036 | $self->{text} = $text; |
1035 | $self->{text} = $text; |
1037 | $self->{layout}->set_width ($self->{w}); |
1036 | $self->{layout}->set_width ($self->{w}); |
|
|
1037 | $self->{layout}->set_height (List::Util::min $self->{h} - $self->{padding} * 2, $self->{height}); |
1038 | |
1038 | |
1039 | $text =~ s/./*/g if $self->{hidden}; |
1039 | $text =~ s/./*/g if $self->{hidden}; |
1040 | |
1040 | |
1041 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1041 | $self->{layout}->set_markup ($self->escape_text ($text) . " "); |
1042 | |
1042 | |
… | |
… | |
1318 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1318 | $value = int +($value - $lo) * $w / ($hi - $lo); |
1319 | |
1319 | |
1320 | $w -= $page; |
1320 | $w -= $page; |
1321 | $page &= ~1; |
1321 | $page &= ~1; |
1322 | glTranslate $page * 0.5, 0, 0; |
1322 | glTranslate $page * 0.5, 0, 0; |
|
|
1323 | $page ||= 2; |
1323 | |
1324 | |
1324 | glColor @$fg; |
1325 | glColor @$fg; |
1325 | glBegin GL_LINES; |
1326 | glBegin GL_LINES; |
1326 | glVertex 0, 0; glVertex 0, $h; |
1327 | glVertex 0, 0; glVertex 0, $h; |
1327 | glVertex $w - 1, 0; glVertex $w - 1, $h; |
1328 | glVertex $w - 1, 0; glVertex $w - 1, $h; |