… | |
… | |
741 | |
741 | |
742 | my $x = 0; |
742 | my $x = 0; |
743 | my $row_h = $hs->[$r]; |
743 | my $row_h = $hs->[$r]; |
744 | |
744 | |
745 | for my $c (0 .. $#$row) { |
745 | for my $c (0 .. $#$row) { |
746 | my $widget = $row->[$c] |
|
|
747 | or next; |
|
|
748 | |
|
|
749 | my $col_w = $ws->[$c]; |
746 | my $col_w = $ws->[$c]; |
750 | |
747 | |
|
|
748 | if (my $widget = $row->[$c]) { |
751 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
749 | $widget->size_allocate ($x, $y, $col_w, $row_h); |
|
|
750 | } |
752 | |
751 | |
753 | $x += $col_w; |
752 | $x += $col_w; |
754 | } |
753 | } |
755 | |
754 | |
756 | $y += $row_h; |
755 | $y += $row_h; |
… | |
… | |
998 | my $x = |
997 | my $x = |
999 | $self->{align} < 0 ? $self->{padding} |
998 | $self->{align} < 0 ? $self->{padding} |
1000 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
999 | : $self->{align} > 0 ? $self->{w} - $tex->{w} - $self->{padding} |
1001 | : ($self->{w} - $tex->{w}) * 0.5; |
1000 | : ($self->{w} - $tex->{w}) * 0.5; |
1002 | |
1001 | |
1003 | glTranslate $x, $self->{padding}, 0; |
1002 | glTranslate $x, ($self->{h} - $tex->{h}) * 0.5, 0; |
1004 | $tex->draw_quad (0, 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 | } |
… | |
… | |
1171 | our @ISA = CFClient::UI::Label::; |
1170 | our @ISA = CFClient::UI::Label::; |
1172 | |
1171 | |
1173 | use SDL; |
1172 | use SDL; |
1174 | use SDL::OpenGL; |
1173 | use SDL::OpenGL; |
1175 | |
1174 | |
|
|
1175 | my @tex = |
|
|
1176 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1177 | qw(b1_button_active.png); |
|
|
1178 | |
1176 | sub new { |
1179 | sub new { |
1177 | my $class = shift; |
1180 | my $class = shift; |
1178 | |
1181 | |
1179 | $class->SUPER::new ( |
1182 | $class->SUPER::new ( |
1180 | padding => 4, |
1183 | padding => 4, |
1181 | fg => [1, 1, 1], |
1184 | fg => [1, 1, 1], |
1182 | bg => [1, 1, 1, 0.2], |
1185 | bg => [1, 1, 1, 0.2], |
1183 | active_bg => [0, 0, 0, 0.5], |
|
|
1184 | active_fg => [1, 1, 0], |
1186 | active_fg => [1, 1, 0], |
|
|
1187 | # active_bg => [0, 0, 0, 0.5], |
1185 | border_fg => [1, 1, 0], |
1188 | # border_fg => [1, 1, 0], |
1186 | @_ |
1189 | @_ |
1187 | ) |
1190 | ) |
1188 | } |
1191 | } |
1189 | |
1192 | |
1190 | sub button_up { |
1193 | sub button_up { |
… | |
… | |
1198 | |
1201 | |
1199 | sub _draw { |
1202 | sub _draw { |
1200 | my ($self) = @_; |
1203 | my ($self) = @_; |
1201 | |
1204 | |
1202 | local $self->{fg} = $self->{fg}; |
1205 | local $self->{fg} = $self->{fg}; |
|
|
1206 | my $tex = $tex[0]; |
1203 | |
1207 | |
1204 | glEnable GL_BLEND; |
1208 | glEnable GL_BLEND; |
|
|
1209 | glEnable GL_TEXTURE_2D; |
1205 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1210 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
1206 | |
1211 | |
1207 | glTranslate 0.375, 0.375, 0; # make line and polyogon coordinates behave similarly |
|
|
1208 | |
|
|
1209 | glBegin GL_LINE_LOOP; |
|
|
1210 | glColor @{$self->{border_fg}}; |
|
|
1211 | glVertex 1 , 1; |
|
|
1212 | glVertex 1 , $self->{h} - 2; |
|
|
1213 | glVertex $self->{w} - 2, $self->{h} - 2; |
|
|
1214 | glVertex $self->{w} - 2, 1; |
|
|
1215 | glEnd; |
|
|
1216 | |
|
|
1217 | if ($GRAB == $self) { |
1212 | if ($GRAB == $self) { |
1218 | glColor @{$self->{active_bg}}; |
|
|
1219 | $self->{fg} = $self->{active_fg}; |
1213 | $self->{fg} = $self->{active_fg}; |
1220 | } else { |
|
|
1221 | glColor @{$self->{bg}}; |
|
|
1222 | } |
1214 | } |
1223 | |
1215 | |
1224 | glBegin GL_QUADS; |
1216 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
1225 | glVertex 2 , 2; |
1217 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
1226 | glVertex 2 , $self->{h} - 2; |
1218 | |
1227 | glVertex $self->{w} - 2, $self->{h} - 2; |
1219 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
1228 | glVertex $self->{w} - 2, 2; |
1220 | |
1229 | glEnd; |
1221 | glDisable GL_TEXTURE_2D; |
1230 | glDisable GL_BLEND; |
1222 | glDisable GL_BLEND; |
1231 | |
1223 | |
1232 | $self->SUPER::_draw; |
1224 | $self->SUPER::_draw; |
1233 | } |
1225 | } |
1234 | |
1226 | |
… | |
… | |
1507 | my $mod = $ev->key_mod; |
1499 | my $mod = $ev->key_mod; |
1508 | my $sym = $ev->key_sym; |
1500 | my $sym = $ev->key_sym; |
1509 | |
1501 | |
1510 | if ($sym == SDLK_KP5) { |
1502 | if ($sym == SDLK_KP5) { |
1511 | $::CONN->send ("command stay fire"); |
1503 | $::CONN->send ("command stay fire"); |
|
|
1504 | } elsif ($sym == SDLK_a) { |
|
|
1505 | $::CONN->send ("command apply"); |
1512 | } elsif (exists $DIR{$sym}) { |
1506 | } elsif (exists $DIR{$sym}) { |
1513 | if ($mod & KMOD_SHIFT) { |
1507 | if ($mod & KMOD_SHIFT) { |
1514 | $self->{shft}++; |
1508 | $self->{shft}++; |
1515 | $::CONN->send ("command fire $DIR{$sym}[0]"); |
1509 | $::CONN->send ("command fire $DIR{$sym}[0]"); |
1516 | } elsif ($mod & KMOD_CTRL) { |
1510 | } elsif ($mod & KMOD_CTRL) { |