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.243 by root, Sat May 27 20:46:54 2006 UTC vs.
Revision 1.245 by elmex, Sat May 27 21:15:57 2006 UTC

223 } 223 }
224 224
225 $self 225 $self
226} 226}
227 227
228sub toggle_visibility {
229 my ($self) = @_;
230
231 if ($self->{visible}) {
232 $self->hide;
233 } else {
234 $self->show;
235 }
236}
237
228sub destroy { 238sub destroy {
229 my ($self) = @_; 239 my ($self) = @_;
230 240
231 $self->hide; 241 $self->hide;
232 %$self = (); 242 %$self = ();
253} 263}
254 264
255sub set_invisible { 265sub set_invisible {
256 my ($self) = @_; 266 my ($self) = @_;
257 267
268 return unless $self->{visible};
269
258 # broken show/hide model 270 # broken show/hide model
259 271
260 delete $self->{root}; 272 delete $self->{root};
261 delete $self->{visible}; 273 delete $self->{visible};
262 274
265 277
266 CFClient::UI::check_tooltip 278 CFClient::UI::check_tooltip
267 if $CFClient::UI::TOOLTIP->{owner} == $self; 279 if $CFClient::UI::TOOLTIP->{owner} == $self;
268 280
269 $self->focus_out; 281 $self->focus_out;
282
283 $self->emit (visibility_change => 0);
270} 284}
271 285
272sub hide { 286sub hide {
273 my ($self) = @_; 287 my ($self) = @_;
274 288
486sub set_parent { 500sub set_parent {
487 my ($self, $parent) = @_; 501 my ($self, $parent) = @_;
488 502
489 Scalar::Util::weaken ($self->{parent} = $parent); 503 Scalar::Util::weaken ($self->{parent} = $parent);
490 504
505 if ($parent->{visible} || 1) {
491 $self->{root} = $parent->{root}; 506 $self->{root} = $parent->{root};
492 $self->{visible} = $parent->{visible} + 1; 507 $self->{visible} = $parent->{visible} + 1;
508
509 $self->emit (visibility_change => 1)
510 unless $self->{parent}{visible};
511 }
493 512
494 # TODO: req_w _does_change after ->reconfigure 513 # TODO: req_w _does_change after ->reconfigure
495 $self->check_size 514 $self->check_size
496 unless exists $self->{req_w}; 515 unless exists $self->{req_w};
497 516
527sub emit { 546sub emit {
528 my ($self, $signal, @args) = @_; 547 my ($self, $signal, @args) = @_;
529 548
530 $self->_emit ($signal, @args) 549 $self->_emit ($signal, @args)
531 || $self->$signal (@args); 550 || $self->$signal (@args);
551}
552
553sub visibility_change {
554 #my ($self, $visible) = @_;
532} 555}
533 556
534sub DESTROY { 557sub DESTROY {
535 my ($self) = @_; 558 my ($self) = @_;
536 559
2579 state => 0, 2602 state => 0,
2580 on_activate => \&toggle_flopper, 2603 on_activate => \&toggle_flopper,
2581 @_ 2604 @_
2582 ); 2605 );
2583 2606
2584 if ($self->{state}) {
2585 $self->{state} = 0;
2586 $self->toggle_flopper;
2587 }
2588
2589 $self 2607 $self
2590} 2608}
2591 2609
2592sub toggle_flopper { 2610sub toggle_flopper {
2593 my ($self) = @_; 2611 my ($self) = @_;
2594 2612
2595 # TODO: use animation 2613 $self->{other}->toggle_visibility;
2596 if ($self->{state} = !$self->{state}) {
2597 $CFClient::UI::ROOT->add ($self->{other});
2598 $self->{other}->move ($self->coord2global (0, $self->{h}));
2599 $self->_emit ("open");
2600 } else {
2601 $CFClient::UI::ROOT->remove ($self->{other});
2602 $self->_emit ("close");
2603 }
2604
2605 $self->_emit (changed => $self->{state});
2606} 2614}
2607 2615
2608############################################################################# 2616#############################################################################
2609 2617
2610package CFClient::UI::Tooltip; 2618package CFClient::UI::Tooltip;
3032 if exists $child->{req_x}; 3040 if exists $child->{req_x};
3033 3041
3034 $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1 3042 $Y = $child->{req_y} > 0 ? $child->{req_y} : $h - $H - $child->{req_y} + 1
3035 if exists $child->{req_y}; 3043 if exists $child->{req_y};
3036 3044
3045 $X = $self->{user_x} if exists $self->{user_x};
3046 $Y = $self->{user_y} if exists $self->{user_y};
3047
3037 $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5; 3048 $X = List::Util::max 0, List::Util::min $w - $W, int $X + 0.5;
3038 $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5; 3049 $Y = List::Util::max 0, List::Util::min $h - $H, int $Y + 0.5;
3039 3050
3040 $child->configure ($X, $Y, $W, $H); 3051 $child->configure ($X, $Y, $W, $H);
3041 } 3052 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines