Skip to content

Commit

Permalink
max_steps is now required
Browse files Browse the repository at this point in the history
  • Loading branch information
dod38fr committed May 17, 2012
1 parent 82c6665 commit d1b7f73
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/SDLx/SlideShow/Any.pm
Expand Up @@ -15,7 +15,7 @@ use Any::Moose;
use Any::Moose '::Util::TypeConstraints' ;
# use Any::Moose '::Meta::Attribute::Native::Trait::Array' ;

has max_steps => ( is => 'rw', isa => 'Int', default => 26 );
has max_steps => ( is => 'rw', isa => 'Int', required => 1 );

# tick method will draw on this surface
has surface => (
Expand All @@ -37,6 +37,7 @@ has image => (

# step = 0 -> idle
# step > 0 and < max_steps -> transitioning
# internal
has step => (
traits => ['Counter'],
is => 'rw',
Expand All @@ -61,11 +62,13 @@ sub busy {
return 0 ;
}

#internal
sub progress {
my ($self,$value) = @_;
return int($self->step * $value / $self->max_steps ) ;
}

#internal
sub regress {
my ($self,$value) = @_;
return int(($self->max_steps - $self->step) * $value / $self->max_steps) ;
Expand Down

0 comments on commit d1b7f73

Please sign in to comment.