diff options
Diffstat (limited to 'src/MTools/Anim/MOpacity.pm')
-rw-r--r-- | src/MTools/Anim/MOpacity.pm | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/src/MTools/Anim/MOpacity.pm b/src/MTools/Anim/MOpacity.pm index 19c2108..00b4450 100644 --- a/src/MTools/Anim/MOpacity.pm +++ b/src/MTools/Anim/MOpacity.pm @@ -38,9 +38,8 @@ use strict; use MTools; use MTools::MObjet; -use Anim; -use Anim::Pacing::Linear; -use Anim::Path::Rectilinear; +use Tk::Anim; +Tk::Anim::synchronous(25.0); use vars qw /@ISA/; @@ -83,29 +82,29 @@ sub new { sub start { my ($self) = @_; - my $pacing = new Anim::Pacing::Linear (-duration => $self -> mget ('duration')); $self -> {__opacitydep} = my $opacitydep = $self -> mget ('from_opacity'); - my $animationpath = new Anim::Path::Rectilinear ( - -xdep => 0, - -ydep => 0, - -xdest => $self -> mget ('to_opacity') - $opacitydep, - -ydest => 0, - ); $self -> {__opacity} = $opacitydep; - $self -> {__animation} = my $animation = new Anim ( - -pacing => $pacing, - -resources => [ - $animationpath, - -command => sub { $self -> __event (@_)}, - -endcommand => sub {$self -> {__animation} = undef; - $self -> notify ('ANIMATION_END');}, - ], - -stopcommand => sub {$self -> {__animation} = undef; - $self -> notify ('ANIMATION_ABORD', $self -> {__opacity});}, - -loop => $self -> mget ('loop'), + $self -> {__animation} = my $animation = $zinc->Anim ( + -pacing => 'linear', + -duration => $self -> mget ('duration') * 1000, + -command => sub { $self -> __event (@{$_[0]})}, ); - $animation -> start (); + $animation->addresource('number', + -path => [0, $self -> mget ('to_opacity') - $opacitydep]); + my $loop = $self -> mget ('loop'); + if ($loop != 0) { + $self -> {__animation} = $animation -> repeat (); + } + $self -> {__animation} -> whenterminated (sub { + $self -> {__animation} = undef; + $self -> notify ('ANIMATION_END'); + }); + $self -> {__animation} -> wheninterrupted (sub { + $self -> {__animation} = undef; + $self -> notify ('ANIMATION_ABORD', $self -> {__opacity}); + }); + $self -> {__animation} -> start (); } sub stop { |