ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/UI.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/UI.pm (file contents):
Revision 1.86 by root, Wed Apr 12 15:35:54 2006 UTC vs.
Revision 1.87 by root, Wed Apr 12 17:11:02 2006 UTC

1227our @ISA = CFClient::UI::DrawBG::; 1227our @ISA = CFClient::UI::DrawBG::;
1228 1228
1229use SDL; 1229use SDL;
1230use SDL::OpenGL; 1230use SDL::OpenGL;
1231 1231
1232my @tex =
1233 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1234 qw(b1_button_active.png);
1235
1236sub new { 1232sub new {
1237 my $class = shift; 1233 my $class = shift;
1238 1234
1239 $class->SUPER::new ( 1235 $class->SUPER::new (
1240 padding => 4, 1236 padding => 2,
1241 fg => [1, 1, 1], 1237 fg => [1, 1, 1],
1242 active_fg => [1, 1, 0], 1238 active_fg => [1, 1, 0],
1243 state => 0, 1239 state => 0,
1244 @_ 1240 @_
1245 ) 1241 )
1246} 1242}
1247 1243
1244sub size_request {
1245 my ($self) = @_;
1246
1247 ($self->{padding} * 2 + 6) x 2
1248}
1249
1250sub size_allocate {
1251 my ($self, $x, $y, $w, $h) = @_;
1252
1253 $self->_size_allocate ($x, $y, $w, $h);
1254}
1255
1248sub button_down { 1256sub button_down {
1249 my ($self, $ev, $x, $y) = @_; 1257 my ($self, $ev, $x, $y) = @_;
1250 1258
1251 if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding} 1259 if ($x >= $self->{padding} && $x < $self->{w} - $self->{padding}
1252 && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) { 1260 && $y >= $self->{padding} && $y < $self->{h} - $self->{padding}) {
1253 $self->{state} = !$self->{state}; 1261 $self->{state} = !$self->{state};
1254 $self->emit ("changed"); 1262 $self->emit (changed => $self->{state});
1255 } 1263 }
1256} 1264}
1257 1265
1258sub _draw { 1266sub _draw {
1259 my ($self) = @_; 1267 my ($self) = @_;
1260 1268
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; 1269 $self->SUPER::_draw;
1270
1271 glTranslate $self->{padding} + 0.375, $self->{padding} + 0.375, 0;
1272
1273 my $s = (List::Util::min @$self{qw(w h)}) - $self->{padding} * 2;
1274
1275 glColor @{ $FOCUS == $self ? $self->{active_fg} : $self->{fg} };
1276
1277 glBegin GL_LINE_LOOP;
1278 glVertex 0 , 0;
1279 glVertex 0 , $s;
1280 glVertex $s, $s;
1281 glVertex $s, 0;
1282 glEnd;
1283
1284 if ($self->{state}) {
1285 glBegin GL_LINES;
1286 glVertex 0 , 0;
1287 glVertex $s, $s;
1288 glVertex $s, 0;
1289 glVertex 0 , $s;
1290 glEnd;
1291 }
1281} 1292}
1282 1293
1283############################################################################# 1294#############################################################################
1284 1295
1285package CFClient::UI::Slider; 1296package CFClient::UI::Slider;
1529 1540
1530 glEndList; 1541 glEndList;
1531 } 1542 }
1532 1543
1533 glCallList $self->{list}; 1544 glCallList $self->{list};
1545
1546 if ($FOCUS != $self) {
1547 glEnable GL_BLEND;
1548 glColor 0, 0, 1, 0.4;
1549 glBegin GL_QUADS;
1550 glVertex 0, 0;
1551 glVertex 0, $::HEIGHT;
1552 glVertex $::WIDTH, $::HEIGHT;
1553 glVertex $::WIDTH, 0;
1554 glEnd;
1555 glDisable GL_BLEND;
1556 }
1534} 1557}
1535 1558
1536my %DIR = ( 1559my %DIR = (
1537 SDLK_KP8, [1, "north"], 1560 SDLK_KP8, [1, "north"],
1538 SDLK_KP9, [2, "northeast"], 1561 SDLK_KP9, [2, "northeast"],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines