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.221 by root, Mon May 22 03:48:50 2006 UTC vs.
Revision 1.223 by elmex, Tue May 23 18:10:51 2006 UTC

206 %$self = (); 206 %$self = ();
207} 207}
208 208
209sub show { 209sub show {
210 my ($self) = @_; 210 my ($self) = @_;
211
212 for (my @w = $self; @w; ) {
213 my $w = pop @w;
214 push @w, $w->children;
215 $w->{visible} = 1;
216 }
217
218 return if $self->{parent}; 211 return if $self->{parent};
219 212
220 $CFClient::UI::ROOT->add ($self); 213 $CFClient::UI::ROOT->add ($self);
221} 214}
222 215
216sub show_centered {
217 my ($self) = @_;
218 return if $self->{parent};
219
220 $self->show;
221
222 $CFClient::UI::ROOT->on_post_alloc (
223 "centered $self" => sub {
224 $self->move (($::WIDTH - $self->{w}) * 0.5, ($::HEIGHT - $self->{h}) * 0.5);
225 },
226 );
227}
228
223sub hide { 229sub hide {
224 my ($self) = @_; 230 my ($self) = @_;
225
226 for (my @w = $self; @w; ) {
227 my $w = pop @w;
228 push @w, $w->children;
229 $w->{visible} = 1;
230 }
231 231
232 undef $GRAB if $GRAB == $self; 232 undef $GRAB if $GRAB == $self;
233 undef $HOVER if $HOVER == $self; 233 undef $HOVER if $HOVER == $self;
234 234
235 $self->{parent}->remove ($self) 235 $self->{parent}->remove ($self)
2539 $self 2539 $self
2540} 2540}
2541 2541
2542sub size_request { 2542sub size_request {
2543 (32, 8) 2543 (32, 8)
2544}
2545
2546sub update {
2547 my ($self) = @_;
2548
2549 return unless $self->{visible};
2550
2551 $self->SUPER::update;
2544} 2552}
2545 2553
2546sub _draw { 2554sub _draw {
2547 my ($self) = @_; 2555 my ($self) = @_;
2548 2556
3002 $child->{x} = int $child->{x}; 3010 $child->{x} = int $child->{x};
3003 $child->{y} = int $child->{y}; 3011 $child->{y} = int $child->{y};
3004 } 3012 }
3005 3013
3006 $self->SUPER::add (@children); 3014 $self->SUPER::add (@children);
3015
3016 while (@children) {
3017 my $w = pop @children;
3018 push @children, $w->children;
3019 $w->{visible} = 1;
3020 }
3021}
3022
3023sub remove {
3024 my ($self, @children) = @_;
3025
3026 $self->SUPER::remove (@children);
3027
3028 while (@children) {
3029 my $w = pop @children;
3030 push @children, $w->children;
3031 delete $w->{visible};
3032 }
3007} 3033}
3008 3034
3009sub on_refresh { 3035sub on_refresh {
3010 my ($self, $id, $cb) = @_; 3036 my ($self, $id, $cb) = @_;
3011 3037

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines