… | |
… | |
448 | |
448 | |
449 | # translate global coordinates to local coordinate system |
449 | # translate global coordinates to local coordinate system |
450 | sub coord2local { |
450 | sub coord2local { |
451 | my ($self, $x, $y) = @_; |
451 | my ($self, $x, $y) = @_; |
452 | |
452 | |
453 | Carp::confess unless $self->{parent};#d# |
453 | return (undef, undef) unless $self->{parent}; |
454 | |
454 | |
455 | $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y}) |
455 | $self->{parent}->coord2local ($x - $self->{x}, $y - $self->{y}) |
456 | } |
456 | } |
457 | |
457 | |
458 | # translate local coordinates to global coordinate system |
458 | # translate local coordinates to global coordinate system |
459 | sub coord2global { |
459 | sub coord2global { |
460 | my ($self, $x, $y) = @_; |
460 | my ($self, $x, $y) = @_; |
461 | |
461 | |
462 | Carp::confess unless $self->{parent};#d# |
462 | return (undef, undef) unless $self->{parent}; |
463 | |
463 | |
464 | $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y}) |
464 | $self->{parent}->coord2global ($x + $self->{x}, $y + $self->{y}) |
465 | } |
465 | } |
466 | |
466 | |
467 | sub invoke_focus_in { |
467 | sub invoke_focus_in { |
… | |
… | |
3673 | ); |
3673 | ); |
3674 | |
3674 | |
3675 | if ($self->{anim} && $self->{animspeed}) { |
3675 | if ($self->{anim} && $self->{animspeed}) { |
3676 | CFPlus::weaken (my $widget = $self); |
3676 | CFPlus::weaken (my $widget = $self); |
3677 | |
3677 | |
3678 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3678 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
3679 | $widget->{anim_start} = $self->{animspeed} * int EV::now / $self->{animspeed}; |
3679 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
3680 | $self->{timer} = EV::timer_ns 0, 0, sub { |
|
|
3681 | return unless $::CONN; |
3680 | return unless $::CONN; |
3682 | |
3681 | |
3683 | my $w = $widget |
3682 | my $w = $widget |
3684 | or return; |
3683 | or return; |
3685 | |
3684 | |
… | |
… | |
3702 | my ($self) = @_; |
3701 | my ($self) = @_; |
3703 | |
3702 | |
3704 | return unless $self->{timer}; |
3703 | return unless $self->{timer}; |
3705 | |
3704 | |
3706 | if ($self->{visible}) { |
3705 | if ($self->{visible}) { |
3707 | $self->{timer}->set ( |
|
|
3708 | $self->{anim_start} |
|
|
3709 | + $self->{animspeed} |
|
|
3710 | * int 1.5 + (EV::now - $self->{anim_start}) / $self->{animspeed} |
|
|
3711 | ); |
|
|
3712 | $self->{timer}->start; |
3706 | $self->{timer}->start; |
3713 | } else { |
3707 | } else { |
3714 | $self->{timer}->stop; |
3708 | $self->{timer}->stop; |
3715 | } |
3709 | } |
3716 | } |
3710 | } |