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.135 by root, Wed Apr 19 06:21:07 2006 UTC vs.
Revision 1.137 by root, Wed Apr 19 21:38:05 2006 UTC

21 $FOCUS->key_up ($_[0]) if $FOCUS; 21 $FOCUS->key_up ($_[0]) if $FOCUS;
22} 22}
23 23
24sub feed_sdl_button_down_event { 24sub feed_sdl_button_down_event {
25 my ($ev) = @_; 25 my ($ev) = @_;
26 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 26 my ($x, $y) = ($ev->{x}, $ev->{y});
27 27
28 if (!$BUTTON_STATE) { 28 if (!$BUTTON_STATE) {
29 my $widget = $ROOT->find_widget ($x, $y); 29 my $widget = $ROOT->find_widget ($x, $y);
30 30
31 $GRAB = $widget; 31 $GRAB = $widget;
32 $GRAB->update if $GRAB; 32 $GRAB->update if $GRAB;
33 } 33 }
34 34
35 $BUTTON_STATE |= 1 << ($ev->button - 1); 35 $BUTTON_STATE |= 1 << ($ev->{button} - 1);
36 36
37 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; 37 $GRAB->button_down ($ev, $GRAB->coord2local ($x, $y)) if $GRAB;
38} 38}
39 39
40sub feed_sdl_button_up_event { 40sub feed_sdl_button_up_event {
41 my ($ev) = @_; 41 my ($ev) = @_;
42 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 42 my ($x, $y) = ($ev->{x}, $ev->{y});
43 43
44 my $widget = $GRAB || $ROOT->find_widget ($x, $y); 44 my $widget = $GRAB || $ROOT->find_widget ($x, $y);
45 45
46 $BUTTON_STATE &= ~(1 << ($ev->button - 1)); 46 $BUTTON_STATE &= ~(1 << ($ev->{button} - 1));
47 47
48 $GRAB->button_up ($ev, $GRAB->coord2local ($x, $y)) if $GRAB; 48 $GRAB->button_up ($ev, $GRAB->coord2local ($x, $y)) if $GRAB;
49 49
50 if (!$BUTTON_STATE) { 50 if (!$BUTTON_STATE) {
51 my $grab = $GRAB; undef $GRAB; 51 my $grab = $GRAB; undef $GRAB;
54 } 54 }
55} 55}
56 56
57sub feed_sdl_motion_event { 57sub feed_sdl_motion_event {
58 my ($ev) = @_; 58 my ($ev) = @_;
59 my ($x, $y) = ($ev->motion_x, $ev->motion_y); 59 my ($x, $y) = ($ev->{x}, $ev->{y});
60 60
61 my $widget = $GRAB || $ROOT->find_widget ($x, $y); 61 my $widget = $GRAB || $ROOT->find_widget ($x, $y);
62 62
63 if ($widget != $HOVER) { 63 if ($widget != $HOVER) {
64 my $hover = $HOVER; $HOVER = $widget; 64 my $hover = $HOVER; $HOVER = $widget;
1111 1111
1112package CFClient::UI::EntryBase; 1112package CFClient::UI::EntryBase;
1113 1113
1114our @ISA = CFClient::UI::Label::; 1114our @ISA = CFClient::UI::Label::;
1115 1115
1116use SDL;
1117use SDL::OpenGL; 1116use SDL::OpenGL;
1118 1117
1119sub new { 1118sub new {
1120 my $class = shift; 1119 my $class = shift;
1121 1120
1176} 1175}
1177 1176
1178sub key_down { 1177sub key_down {
1179 my ($self, $ev) = @_; 1178 my ($self, $ev) = @_;
1180 1179
1181 my $mod = $ev->key_mod; 1180 my $mod = $ev->{mod};
1182 my $sym = $ev->key_sym; 1181 my $sym = $ev->{sym};
1183
1184 my $uni = $ev->key_unicode; 1182 my $uni = $ev->{unicode};
1185 1183
1186 my $text = $self->get_text; 1184 my $text = $self->get_text;
1187 1185
1188 if ($sym == SDLK_BACKSPACE) { 1186 if ($sym == 8) {
1189 substr $text, --$self->{cursor}, 1, "" if $self->{cursor}; 1187 substr $text, --$self->{cursor}, 1, "" if $self->{cursor};
1190 } elsif ($sym == SDLK_DELETE) { 1188 } elsif ($sym == 127) {
1191 substr $text, $self->{cursor}, 1, ""; 1189 substr $text, $self->{cursor}, 1, "";
1192 } elsif ($sym == SDLK_LEFT) { 1190 } elsif ($sym == CFClient::SDLK_LEFT) {
1193 --$self->{cursor} if $self->{cursor}; 1191 --$self->{cursor} if $self->{cursor};
1194 } elsif ($sym == SDLK_RIGHT) { 1192 } elsif ($sym == CFClient::SDLK_RIGHT) {
1195 ++$self->{cursor} if $self->{cursor} < length $self->{text}; 1193 ++$self->{cursor} if $self->{cursor} < length $self->{text};
1196 } elsif ($sym == SDLK_HOME) { 1194 } elsif ($sym == CFClient::SDLK_HOME) {
1197 $self->{cursor} = 0; 1195 $self->{cursor} = 0;
1198 } elsif ($sym == SDLK_END) { 1196 } elsif ($sym == CFClient::SDLK_END) {
1199 $self->{cursor} = length $text; 1197 $self->{cursor} = length $text;
1200 } elsif ($sym == SDLK_ESCAPE) { 1198 } elsif ($sym == 27) {
1201 $self->emit ('escape'); 1199 $self->emit ('escape');
1202 } elsif ($uni) { 1200 } elsif ($uni) {
1203 substr $text, $self->{cursor}++, 0, chr $uni; 1201 substr $text, $self->{cursor}++, 0, chr $uni;
1204 } 1202 }
1205 1203
1280 1278
1281package CFClient::UI::Entry; 1279package CFClient::UI::Entry;
1282 1280
1283our @ISA = CFClient::UI::EntryBase::; 1281our @ISA = CFClient::UI::EntryBase::;
1284 1282
1285use SDL;
1286use SDL::OpenGL; 1283use SDL::OpenGL;
1287 1284
1288sub key_down { 1285sub key_down {
1289 my ($self, $ev) = @_; 1286 my ($self, $ev) = @_;
1290 1287
1291 my $sym = $ev->key_sym; 1288 my $sym = $ev->{sym};
1292 1289
1293 if ($sym == SDLK_RETURN) { 1290 if ($sym == 13) {
1294 $self->emit (activate => $self->get_text); 1291 $self->emit (activate => $self->get_text);
1295 $self->update; 1292 $self->update;
1296 1293
1297 } else { 1294 } else {
1298 $self->SUPER::key_down ($ev); 1295 $self->SUPER::key_down ($ev);
1304 1301
1305package CFClient::UI::Button; 1302package CFClient::UI::Button;
1306 1303
1307our @ISA = CFClient::UI::Label::; 1304our @ISA = CFClient::UI::Label::;
1308 1305
1309use SDL;
1310use SDL::OpenGL; 1306use SDL::OpenGL;
1311 1307
1312my @tex = 1308my @tex =
1313 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1309 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1314 qw(b1_button_active.png); 1310 qw(b1_button_active.png);
1368 1364
1369my @tex = 1365my @tex =
1370 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ } 1366 map { new_from_file CFClient::Texture CFClient::find_rcfile $_ }
1371 qw(c1_checkbox_bg.png c1_checkbox_active.png); 1367 qw(c1_checkbox_bg.png c1_checkbox_active.png);
1372 1368
1373use SDL;
1374use SDL::OpenGL; 1369use SDL::OpenGL;
1375 1370
1376sub new { 1371sub new {
1377 my $class = shift; 1372 my $class = shift;
1378 1373

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines