Skip to content

Commit

Permalink
more smooth fading when a widget is initially unbuffered
Browse files Browse the repository at this point in the history
  • Loading branch information
dk committed Aug 11, 2023
1 parent bf97e8d commit 3cea63b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion Prima/Widget/Fader.pm
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ sub fader_in_mouse_enter
my $action = $self->fader_var('action') // '';
return if $action eq 'in';

my $turn_buffering_off = !$self->buffered;
$self->buffered(1) if $turn_buffering_off;
my $turn_syncpaint_off = !$self->syncPaint;
$self->syncPaint(1) if $turn_syncpaint_off;
$self-> fader_timer_start(
action => 'callback',
callback => sub {
Expand All @@ -203,11 +207,13 @@ sub fader_in_mouse_enter
onEnd => sub {
my ( $self, $f, $ends_okay ) = @_;
$self->notify(q(FadeIn), $ends_okay);
$self->buffered(0) if $turn_buffering_off;
$self->syncPaint(0) if $turn_syncpaint_off;
},
);
$self->fader_var( current => 0.0 );
$self->fader_var( action => 'in');
$self->fader_var( test_buffering => 1 ) if $self->buffered;
$self->fader_var( test_buffering => 1 );
}

sub fader_out_mouse_leave
Expand All @@ -217,6 +223,10 @@ sub fader_out_mouse_leave
my $action = $self->fader_var('action') // '';
return if $action eq 'out';

my $turn_buffering_off = !$self->buffered;
$self->buffered(1) if $turn_buffering_off;
my $turn_syncpaint_off = !$self->syncPaint;
$self->syncPaint(1) if $turn_syncpaint_off;
$self-> fader_timer_start(
action => 'callback',
callback => sub {
Expand All @@ -227,6 +237,8 @@ sub fader_out_mouse_leave
onEnd => sub {
my ( $self, $f, $ends_okay ) = @_;
$self->notify(q(FadeOut), $ends_okay);
$self->buffered(0) if $turn_buffering_off;
$self->syncPaint(0) if $turn_syncpaint_off;
},
);
$self->fader_var( action => 'out');
Expand Down

0 comments on commit 3cea63b

Please sign in to comment.