… | |
… | |
2653 | can_events => 1, |
2653 | can_events => 1, |
2654 | @_ |
2654 | @_ |
2655 | ); |
2655 | ); |
2656 | } |
2656 | } |
2657 | |
2657 | |
|
|
2658 | sub invoke_button_down { |
|
|
2659 | my ($self, $ev, $x, $y) = @_; |
|
|
2660 | |
|
|
2661 | 1 |
|
|
2662 | } |
|
|
2663 | |
2658 | sub invoke_button_up { |
2664 | sub invoke_button_up { |
2659 | my ($self, $ev, $x, $y) = @_; |
2665 | my ($self, $ev, $x, $y) = @_; |
2660 | |
2666 | |
2661 | $self->emit ("activate") |
2667 | $self->emit ("activate") |
2662 | if $x >= 0 && $x < $self->{w} |
2668 | if $x >= 0 && $x < $self->{w} |
… | |
… | |
3549 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3555 | $widget->{animspeed} = List::Util::max 0.05, $widget->{animspeed}; |
3550 | $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; |
3556 | $widget->{anim_start} = $self->{animspeed} * int Event::time / $self->{animspeed}; |
3551 | $self->{timer} = Event->timer ( |
3557 | $self->{timer} = Event->timer ( |
3552 | parked => 1, |
3558 | parked => 1, |
3553 | cb => sub { |
3559 | cb => sub { |
3554 | return unless $::CONN && $widget; |
3560 | return unless $::CONN; |
3555 | |
3561 | |
|
|
3562 | my $w = $widget |
|
|
3563 | or return; |
|
|
3564 | |
3556 | ++$widget->{frame}; |
3565 | ++$w->{frame}; |
3557 | $widget->update_face; |
3566 | $w->update_face; |
|
|
3567 | |
|
|
3568 | # somehow, $widget can go away |
3558 | $widget->update; |
3569 | $w->update; |
3559 | |
|
|
3560 | $widget->update_timer; |
3570 | $w->update_timer; |
3561 | }, |
3571 | }, |
3562 | ); |
3572 | ); |
3563 | |
3573 | |
3564 | $self->update_face; |
3574 | $self->update_face; |
3565 | $self->update_timer; |
3575 | $self->update_timer; |
… | |
… | |
3586 | } |
3596 | } |
3587 | |
3597 | |
3588 | sub update_face { |
3598 | sub update_face { |
3589 | my ($self) = @_; |
3599 | my ($self) = @_; |
3590 | |
3600 | |
3591 | return unless $::CONN; |
3601 | if ($::CONN) { |
3592 | |
|
|
3593 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3602 | if (my $anim = $::CONN->{anim}[$self->{anim}]) { |
3594 | if ($anim && @$anim) { |
3603 | if ($anim && @$anim) { |
3595 | delete $self->{wait_face}; |
|
|
3596 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
3604 | $self->{face} = $anim->[ $self->{frame} % @$anim ]; |
|
|
3605 | delete $self->{face_change_cb}; |
|
|
3606 | |
3597 | if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{faceid}[$self->{face}] ]) { |
3607 | if (my $tex = $self->{tex} = $::CONN->{texture}[ $::CONN->{face}[$self->{face}]{id} ]) { |
3598 | unless ($tex->{name} || $tex->{loading}) { |
3608 | unless ($tex->{name} || $tex->{loading}) { |
3599 | $tex->upload (sub { $self->reconfigure }); |
3609 | $tex->upload (sub { $self->reconfigure }); |
|
|
3610 | } |
3600 | } |
3611 | } |
3601 | } |
3612 | } |
3602 | } |
3613 | } |
3603 | } |
3614 | } |
3604 | } |
3615 | } |
3605 | |
3616 | |
3606 | sub size_request { |
3617 | sub size_request { |
3607 | my ($self) = @_; |
3618 | my ($self) = @_; |
3608 | |
3619 | |
3609 | if ($::CONN) { |
3620 | if ($::CONN) { |
3610 | if (my $faceid = $::CONN->{faceid}[$self->{face}]) { |
3621 | if (my $faceid = $::CONN->{face}[$self->{face}]{id}) { |
3611 | if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) { |
3622 | if (my $tex = $self->{tex} = $::CONN->{texture}[$faceid]) { |
3612 | if ($tex->{name}) { |
3623 | if ($tex->{name}) { |
3613 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3624 | return ($self->{size_w} || $tex->{w}, $self->{size_h} || $tex->{h}); |
3614 | } elsif (!$tex->{loading}) { |
3625 | } elsif (!$tex->{loading}) { |
3615 | $tex->upload (sub { $self->reconfigure }); |
3626 | $tex->upload (sub { $self->reconfigure }); |
3616 | } |
3627 | } |
3617 | } else { |
|
|
3618 | $self->{wait_face} ||= $::CONN->connect_face_update ($faceid, sub { |
|
|
3619 | $self->reconfigure; |
|
|
3620 | }); |
|
|
3621 | } |
3628 | } |
|
|
3629 | |
|
|
3630 | $self->{face_change_cb} ||= $::CONN->on_face_change ($self->{face}, sub { $self->reconfigure }); |
3622 | } |
3631 | } |
3623 | } |
3632 | } |
3624 | |
3633 | |
3625 | ($self->{size_w} || 8, $self->{size_h} || 8) |
3634 | ($self->{size_w} || 8, $self->{size_h} || 8) |
3626 | } |
3635 | } |