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.166 by root, Mon Apr 24 08:38:36 2006 UTC vs.
Revision 1.172 by root, Tue Apr 25 09:52:04 2006 UTC

236 236
237sub size_allocate { 237sub size_allocate {
238 # nothing to be done 238 # nothing to be done
239} 239}
240 240
241sub children {
242}
243
241sub set_max_size { 244sub set_max_size {
242 my ($self, $w, $h) = @_; 245 my ($self, $w, $h) = @_;
243 246
244 delete $self->{max_w}; $self->{max_w} = $w if $w; 247 delete $self->{max_w}; $self->{max_w} = $w if $w;
245 delete $self->{max_h}; $self->{max_h} = $h if $h; 248 delete $self->{max_h}; $self->{max_h} = $h if $h;
246} 249}
247 250
248# return top left coordinates 251# return top left coordinates
249sub _topleft { 252sub _topleft {
250 my ($self, $x, $y) = @_; 253 my ($self, $x, $y) = @_;
254
255 $self->{parent}
256 or Carp::confess "no parent widget in _topleft\n";#d#
251 257
252 $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y}); 258 $self->{parent}->_topleft ($x + $self->{x}, $y + $self->{y});
253} 259}
254 260
255# translate global coordinates to local coordinate system 261# translate global coordinates to local coordinate system
517 ]; 523 ];
518 524
519 $child->check_size; 525 $child->check_size;
520} 526}
521 527
528sub children {
529 @{ $_[0]{children} }
530}
531
522sub remove { 532sub remove {
523 my ($self, $child) = @_; 533 my ($self, $child) = @_;
524 534
525 delete $child->{parent}; 535 delete $child->{parent};
526 $child->hide; 536 $child->hide;
912 $self->{children}[$y][$x] = $child; 922 $self->{children}[$y][$x] = $child;
913 923
914 $child->check_size; 924 $child->check_size;
915} 925}
916 926
927sub children {
928 grep $_, map @$_, grep $_, @{ $_[0]{children} }
929}
930
917# TODO: move to container class maybe? send childs a signal on removal? 931# TODO: move to container class maybe? send childs a signal on removal?
918sub clear { 932sub clear {
919 my ($self) = @_; 933 my ($self) = @_;
920 934
921 my $children = delete $self->{children}; 935 my @children = $self->children;
936 delete $self->{children};
922 937
923 for (grep $_, map @$_, grep $_, @$children) { 938 for (@children) {
924 delete $_->{parent}; 939 delete $_->{parent};
925 $_->hide; 940 $_->hide;
926 } 941 }
927 942
928 $self->update; 943 $self->update;
1466 my ($self, $ev) = @_; 1481 my ($self, $ev) = @_;
1467 1482
1468 my $sym = $ev->{sym}; 1483 my $sym = $ev->{sym};
1469 1484
1470 if ($sym == 13) { 1485 if ($sym == 13) {
1486 unshift @{$self->{history}},
1487 my $txt = $self->get_text;
1488 $self->{history_pointer} = -1;
1489 $self->{history_saveback} = '';
1471 $self->emit (activate => $self->get_text); 1490 $self->emit (activate => $txt);
1472 $self->update; 1491 $self->update;
1492
1493 } elsif ($sym == CFClient::SDLK_UP) {
1494 if ($self->{history_pointer} < 0) {
1495 $self->{history_saveback} = $self->get_text;
1496 }
1497 if (@{$self->{history} || []} > 0) {
1498 $self->{history_pointer}++;
1499 if ($self->{history_pointer} >= @{$self->{history} || []}) {
1500 $self->{history_pointer} = @{$self->{history} || []} - 1;
1501 }
1502 $self->set_text ($self->{history}->[$self->{history_pointer}]);
1503 }
1504
1505 } elsif ($sym == CFClient::SDLK_DOWN) {
1506 $self->{history_pointer}--;
1507 $self->{history_pointer} = -1 if $self->{history_pointer} < 0;
1508
1509 if ($self->{history_pointer} >= 0) {
1510 $self->set_text ($self->{history}->[$self->{history_pointer}]);
1511 } else {
1512 $self->set_text ($self->{history_saveback});
1513 }
1473 1514
1474 } else { 1515 } else {
1475 $self->SUPER::key_down ($ev); 1516 $self->SUPER::key_down ($ev);
1476 } 1517 }
1477 1518
1798 1839
1799sub new { 1840sub new {
1800 my ($class, %arg) = @_; 1841 my ($class, %arg) = @_;
1801 1842
1802 my $self = $class->SUPER::new ( 1843 my $self = $class->SUPER::new (
1803 tooltip => $arg{type}, 1844 tooltip => $arg{type},
1804 can_hover => 1, 1845 can_hover => 1,
1846 can_events => 1,
1805 %arg, 1847 %arg,
1806 ); 1848 );
1807 1849
1808 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999"); 1850 $self->add ($self->{value} = new CFClient::UI::Label valign => +1, align => 0, template => "999");
1809 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1); 1851 $self->add ($self->{gauge} = new CFClient::UI::VGauge type => $self->{type}, expand => 1, can_hover => 1);
2124 my ($self) = @_; 2166 my ($self) = @_;
2125 2167
2126 if ($self->{texture}) { 2168 if ($self->{texture}) {
2127 glEnable GL_TEXTURE_2D; 2169 glEnable GL_TEXTURE_2D;
2128 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE; 2170 glTexEnv GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE;
2171 glColor 1, 1, 1, 1;
2129 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); 2172 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
2130 glDisable GL_TEXTURE_2D; 2173 glDisable GL_TEXTURE_2D;
2131 } 2174 }
2132 2175
2133 $self->{children}[1]->draw; 2176 $self->{children}[1]->draw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines