… | |
… | |
801 | } |
801 | } |
802 | |
802 | |
803 | sub size_allocate { |
803 | sub size_allocate { |
804 | my ($self, $x, $y, $w, $h) = @_; |
804 | my ($self, $x, $y, $w, $h) = @_; |
805 | |
805 | |
806 | $self->_size_allocate ($x, $y, $w, $h) or return; |
806 | $self->_size_allocate ($x, $y, $w, $h); |
807 | |
|
|
808 | return unless $self->{w}; |
|
|
809 | |
807 | |
810 | ($h, $w) = ($w, $h); |
808 | ($h, $w) = ($w, $h); |
811 | |
809 | |
812 | my $children = $self->{children}; |
810 | my $children = $self->{children}; |
813 | |
811 | |
… | |
… | |
861 | } |
859 | } |
862 | |
860 | |
863 | sub size_allocate { |
861 | sub size_allocate { |
864 | my ($self, $x, $y, $w, $h) = @_; |
862 | my ($self, $x, $y, $w, $h) = @_; |
865 | |
863 | |
866 | $self->_size_allocate ($x, $y, $w, $h) or return; |
864 | $self->_size_allocate ($x, $y, $w, $h); |
867 | |
|
|
868 | return unless $self->{h}; |
|
|
869 | |
865 | |
870 | my $children = $self->{children}; |
866 | my $children = $self->{children}; |
871 | |
867 | |
872 | my @h = map +($_->size_request)[1], @$children; |
868 | my @h = map +($_->size_request)[1], @$children; |
873 | |
869 | |
… | |
… | |
1224 | $self->SUPER::_draw; |
1220 | $self->SUPER::_draw; |
1225 | } |
1221 | } |
1226 | |
1222 | |
1227 | ############################################################################# |
1223 | ############################################################################# |
1228 | |
1224 | |
|
|
1225 | package CFClient::UI::CheckBox; |
|
|
1226 | |
|
|
1227 | our @ISA = CFClient::UI::DrawBG::; |
|
|
1228 | |
|
|
1229 | use SDL; |
|
|
1230 | use SDL::OpenGL; |
|
|
1231 | |
|
|
1232 | my @tex = |
|
|
1233 | map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } |
|
|
1234 | qw(b1_button_active.png); |
|
|
1235 | |
|
|
1236 | sub new { |
|
|
1237 | my $class = shift; |
|
|
1238 | |
|
|
1239 | $class->SUPER::new ( |
|
|
1240 | padding => 4, |
|
|
1241 | fg => [1, 1, 1], |
|
|
1242 | active_fg => [1, 1, 0], |
|
|
1243 | state => 0, |
|
|
1244 | @_ |
|
|
1245 | ) |
|
|
1246 | } |
|
|
1247 | |
|
|
1248 | sub button_down { |
|
|
1249 | my ($self, $ev, $x, $y) = @_; |
|
|
1250 | |
|
|
1251 | if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} |
|
|
1252 | && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { |
|
|
1253 | $self->{state} = !$self->{state}; |
|
|
1254 | $self->emit ("changed"); |
|
|
1255 | } |
|
|
1256 | } |
|
|
1257 | |
|
|
1258 | sub _draw { |
|
|
1259 | my ($self) = @_; |
|
|
1260 | |
|
|
1261 | local $self->{fg} = $self->{fg}; |
|
|
1262 | my $tex = $tex[0]; |
|
|
1263 | |
|
|
1264 | glEnable GL_BLEND; |
|
|
1265 | glEnable GL_TEXTURE_2D; |
|
|
1266 | glBlendFunc GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA; |
|
|
1267 | |
|
|
1268 | if ($GRAB == $self) { |
|
|
1269 | $self->{fg} = $self->{active_fg}; |
|
|
1270 | } |
|
|
1271 | |
|
|
1272 | glBindTexture GL_TEXTURE_2D, $tex->{name}; |
|
|
1273 | glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; |
|
|
1274 | |
|
|
1275 | $tex->draw_quad (0, 0, $self->{w}, $self->{h}); |
|
|
1276 | |
|
|
1277 | glDisable GL_TEXTURE_2D; |
|
|
1278 | glDisable GL_BLEND; |
|
|
1279 | |
|
|
1280 | $self->SUPER::_draw; |
|
|
1281 | } |
|
|
1282 | |
|
|
1283 | ############################################################################# |
|
|
1284 | |
1229 | package CFClient::UI::Slider; |
1285 | package CFClient::UI::Slider; |
1230 | |
1286 | |
1231 | use strict; |
1287 | use strict; |
1232 | |
1288 | |
1233 | use SDL::OpenGL; |
1289 | use SDL::OpenGL; |