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.167 by elmex, Mon Apr 24 08:44:23 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;
1469 1484
1470 if ($sym == 13) { 1485 if ($sym == 13) {
1471 unshift @{$self->{history}}, 1486 unshift @{$self->{history}},
1472 my $txt = $self->get_text; 1487 my $txt = $self->get_text;
1473 $self->{history_pointer} = -1; 1488 $self->{history_pointer} = -1;
1489 $self->{history_saveback} = '';
1474 $self->emit (activate => $txt); 1490 $self->emit (activate => $txt);
1475 $self->update; 1491 $self->update;
1476 1492
1477 } elsif ($sym == CFClient::SDLK_UP) { 1493 } elsif ($sym == CFClient::SDLK_UP) {
1478 if ($self->{history_pointer} < 0) { 1494 if ($self->{history_pointer} < 0) {
1479 $self->{history_saveback} = $self->get_text; 1495 $self->{history_saveback} = $self->get_text;
1480 } 1496 }
1497 if (@{$self->{history} || []} > 0) {
1481 $self->{history_pointer}++; 1498 $self->{history_pointer}++;
1482 if ($self->{history_pointer} >= @{$self->{history}}) { 1499 if ($self->{history_pointer} >= @{$self->{history} || []}) {
1483 $self->{history_pointer} = @{$self->{history}} - 1; 1500 $self->{history_pointer} = @{$self->{history} || []} - 1;
1501 }
1502 $self->set_text ($self->{history}->[$self->{history_pointer}]);
1484 } 1503 }
1485 $self->set_text ($self->{history}->[$self->{history_pointer}]);
1486 1504
1487 } elsif ($sym == CFClient::SDLK_DOWN) { 1505 } elsif ($sym == CFClient::SDLK_DOWN) {
1488 $self->{history_pointer}--; 1506 $self->{history_pointer}--;
1489 $self->{history_pointer} = -1 if $self->{history_pointer} < 0; 1507 $self->{history_pointer} = -1 if $self->{history_pointer} < 0;
1490 1508
1821 1839
1822sub new { 1840sub new {
1823 my ($class, %arg) = @_; 1841 my ($class, %arg) = @_;
1824 1842
1825 my $self = $class->SUPER::new ( 1843 my $self = $class->SUPER::new (
1826 tooltip => $arg{type}, 1844 tooltip => $arg{type},
1827 can_hover => 1, 1845 can_hover => 1,
1846 can_events => 1,
1828 %arg, 1847 %arg,
1829 ); 1848 );
1830 1849
1831 $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");
1832 $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);
2147 my ($self) = @_; 2166 my ($self) = @_;
2148 2167
2149 if ($self->{texture}) { 2168 if ($self->{texture}) {
2150 glEnable GL_TEXTURE_2D; 2169 glEnable GL_TEXTURE_2D;
2151 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;
2152 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h}); 2172 $self->{texture}->draw_quad (0, 0, $self->{w}, $self->{h});
2153 glDisable GL_TEXTURE_2D; 2173 glDisable GL_TEXTURE_2D;
2154 } 2174 }
2155 2175
2156 $self->{children}[1]->draw; 2176 $self->{children}[1]->draw;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines