Alt-Tickit-Widgets-ObjectPad

 view release on metacpan or  search on metacpan

lib/Tickit/Widget/Spinner.pm  view on Meta::CPAN

}

method cols
{
   return $_cols;
}

=head2 $spinner->start

Starts the animation effect.

=cut

method start
{
   return if $_running;
   $_running = 1;
   $self->tick;
}

=head2 $spinner->stop

Stops the animation effect.

=cut

method stop
{
   $_running = 0;
}

method window_gained
{
   $self->SUPER::window_gained( @_ );
   $self->start;
}

# precache position
method reshape
{
   my $win = $self->window or return;

   ( $_x, $_y ) = map int($_ / 2), $win->cols - $self->cols, $win->lines - $self->lines;

   $_rect = Tickit::Rect->new(
      top   => $_y,
      left  => $_x,
      lines => $self->lines,
      cols  => $self->cols,
   );
}

method tick
{
   return unless $_running;

   my $state = $_state++;
   $_state %= @_chars;

   if( my $win = $self->window ) {
      $win->tickit->timer( after => $_interval => sub { $self->tick } );
      $win->expose( $_rect );
   }
}

method render_to_rb
{
   my ( $rb, $rect ) = @_;

   $rb->eraserect( $rect );

   $rb->text_at( $_y, $_x, $_chars[$_state] );
}

=head1 AUTHOR

Paul Evans <leonerd@leonerd.org.uk>

=cut

0x55AA;



( run in 1.260 second using v1.01-cache-2.11-cpan-39bf76dae61 )