… | |
… | |
3726 | aspect => 1, |
3726 | aspect => 1, |
3727 | can_events => 0, |
3727 | can_events => 0, |
3728 | @_, |
3728 | @_, |
3729 | ); |
3729 | ); |
3730 | |
3730 | |
3731 | if ($self->{anim} && $self->{animspeed}) { |
|
|
3732 | DC::weaken (my $widget = $self); |
|
|
3733 | |
|
|
3734 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
|
|
3735 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
|
|
3736 | return unless $::CONN; |
|
|
3737 | |
|
|
3738 | my $w = $widget |
|
|
3739 | or return; |
|
|
3740 | |
|
|
3741 | ++$w->{frame}; |
|
|
3742 | $w->update_face; |
|
|
3743 | |
|
|
3744 | # somehow, $widget can go away |
|
|
3745 | $w->update; |
|
|
3746 | $w->update_timer; |
|
|
3747 | }; |
|
|
3748 | |
|
|
3749 | $self->update_face; |
|
|
3750 | $self->update_timer; |
3731 | $self->update_anim; |
3751 | } |
|
|
3752 | |
3732 | |
3753 | $self |
3733 | $self |
3754 | } |
3734 | } |
3755 | |
3735 | |
3756 | sub update_timer { |
3736 | sub update_timer { |
… | |
… | |
3779 | $tex->upload (sub { $self->reconfigure }); |
3759 | $tex->upload (sub { $self->reconfigure }); |
3780 | } |
3760 | } |
3781 | } |
3761 | } |
3782 | } |
3762 | } |
3783 | } |
3763 | } |
|
|
3764 | } |
|
|
3765 | } |
|
|
3766 | |
|
|
3767 | sub update_anim { |
|
|
3768 | my ($self) = @_; |
|
|
3769 | |
|
|
3770 | if ($self->{anim} && $self->{animspeed}) { |
|
|
3771 | DC::weaken (my $widget = $self); |
|
|
3772 | |
|
|
3773 | $self->{animspeed} = List::Util::max 0.05, $self->{animspeed}; |
|
|
3774 | $self->{timer} = EV::periodic_ns 0, $self->{animspeed}, undef, sub { |
|
|
3775 | return unless $::CONN; |
|
|
3776 | |
|
|
3777 | my $w = $widget |
|
|
3778 | or return; |
|
|
3779 | |
|
|
3780 | ++$w->{frame}; |
|
|
3781 | $w->update_face; |
|
|
3782 | |
|
|
3783 | # somehow, $widget can go away |
|
|
3784 | $w->update; |
|
|
3785 | $w->update_timer; |
|
|
3786 | }; |
|
|
3787 | |
|
|
3788 | $self->update_face; |
|
|
3789 | $self->update_timer; |
|
|
3790 | } else { |
|
|
3791 | delete $self->{timer}; |
3784 | } |
3792 | } |
3785 | } |
3793 | } |
3786 | |
3794 | |
3787 | sub size_request { |
3795 | sub size_request { |
3788 | my ($self) = @_; |
3796 | my ($self) = @_; |
… | |
… | |
3808 | my ($self) = @_; |
3816 | my ($self) = @_; |
3809 | |
3817 | |
3810 | return unless $self->{visible}; |
3818 | return unless $self->{visible}; |
3811 | |
3819 | |
3812 | $self->SUPER::update; |
3820 | $self->SUPER::update; |
|
|
3821 | } |
|
|
3822 | |
|
|
3823 | sub set_face { |
|
|
3824 | my ($self, $face) = @_; |
|
|
3825 | |
|
|
3826 | $self->{face} = $face; |
|
|
3827 | $self->reconfigure; |
|
|
3828 | } |
|
|
3829 | |
|
|
3830 | sub set_anim { |
|
|
3831 | my ($self, $anim) = @_; |
|
|
3832 | |
|
|
3833 | $self->{anim} = $anim; |
|
|
3834 | $self->update_anim; |
|
|
3835 | } |
|
|
3836 | |
|
|
3837 | sub set_animspeed { |
|
|
3838 | my ($self, $animspeed) = @_; |
|
|
3839 | |
|
|
3840 | $self->{animspeed} = $animspeed; |
|
|
3841 | $self->update_anim; |
3813 | } |
3842 | } |
3814 | |
3843 | |
3815 | sub invoke_visibility_change { |
3844 | sub invoke_visibility_change { |
3816 | my ($self) = @_; |
3845 | my ($self) = @_; |
3817 | |
3846 | |