… | |
… | |
206 | %$self = (); |
206 | %$self = (); |
207 | } |
207 | } |
208 | |
208 | |
209 | sub show { |
209 | sub 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 | |
|
|
216 | sub 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 | |
223 | sub hide { |
229 | sub 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 | |
2542 | sub size_request { |
2542 | sub size_request { |
2543 | (32, 8) |
2543 | (32, 8) |
|
|
2544 | } |
|
|
2545 | |
|
|
2546 | sub update { |
|
|
2547 | my ($self) = @_; |
|
|
2548 | |
|
|
2549 | return unless $self->{visible}; |
|
|
2550 | |
|
|
2551 | $self->SUPER::update; |
2544 | } |
2552 | } |
2545 | |
2553 | |
2546 | sub _draw { |
2554 | sub _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 | |
|
|
3023 | sub 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 | |
3009 | sub on_refresh { |
3035 | sub on_refresh { |
3010 | my ($self, $id, $cb) = @_; |
3036 | my ($self, $id, $cb) = @_; |
3011 | |
3037 | |