From d82d30cfe68f4c031a2143f7f963190d81b462c4 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Tue, 23 Sep 2008 14:36:04 +1200 Subject: [PATCH] Get photo fading working, awesome! The droppings of moving to behaviours are in place waiting for be uncommented and made to work. --- lib/Display/Plugins/FSpot.pm | 47 +++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/lib/Display/Plugins/FSpot.pm b/lib/Display/Plugins/FSpot.pm index 9674845..fa42c9b 100644 --- a/lib/Display/Plugins/FSpot.pm +++ b/lib/Display/Plugins/FSpot.pm @@ -37,17 +37,14 @@ sub display_photo { #warn "Loading $file\n"; $self->{'new'}->set_opacity(0); $self->{'new'}->set_from_file($file); + $self->{'new'}->set_opacity(0); #$self->{'stage'}->add($self->{'new'}); +#warn "Going to show $file\n"; if ($self->{'last_file'} eq '') { fade_in(undef, $self); } else { -warn "Fade out old\n"; - my $old_effect = Clutter::EffectTemplate->new_for_duration(2000, 'main::smoothstep_dec' ); - my $old = Clutter::Effect->fade($old_effect, $self->{'new'}, 0, $self->can('fade_in'), $self); - $old->start(); - - sleep 10; + $self->fade_out(); } $self->{'last_file'} = $file; @@ -55,23 +52,50 @@ warn "Fade out old\n"; } sub fade_in { - my ($actor, $self) = @_; + my ($old_timeline, $self) = @_; -warn "Fade in new\n"; - my $new_effect = Clutter::EffectTemplate->new_for_duration(2000, 'main::smoothstep_inc'); - my $new = Clutter::Effect->fade($new_effect, $self->{'new'}, 255); + my $new_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc'); + my $new = Clutter::Effect->fade($new_effect, $self->{'new'}, 255, $self->can('post_fade_in'), $self); $new->start(); +# my $timeline = Clutter::Timeline->new_for_duration(1000); +# $timeline->signal_connect('completed', $self->can('post_fade_in'), $self); +# my $alpha = Clutter::Alpha->new($timeline, 'main::smoothstep_inc'); +# my $opacity = Clutter::Behaviour::Opacity->new($alpha, 0, 255); +# $opacity->apply($self->{'new'}); +#warn "Setup timeline, time to start it.\n"; +# $timeline->start(); +} + +sub post_fade_in { + my ($old_timeline, $self) = @_; + my $temp = $self->{'old'}; $self->{'old'} = $self->{'new'}; $self->{'new'} = $temp; } +sub fade_out { + my ($self) = @_; + + my $old_effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc' ); + my $old = Clutter::Effect->fade($old_effect, $self->{'old'}, 0, $self->can('fade_in'), $self); + $old->start(); + +# my $timeline = Clutter::Timeline->new_for_duration(1000); +# $timeline->signal_connect('completed', \&fade_in, $self); +# my $alpha = Clutter::Alpha->new($timeline, 'main::smoothstep_dec'); +# my $opacity = Clutter::Behaviour::Opacity->new($alpha, 255, 0); +# $opacity->apply($self->{'old'}); +# $timeline->start(); +} + + sub display { my $self = shift; $self->{'kernel'}->post('FSpotDB', - single => { sql => $self->{'sql'}, event => fspot_display_photo } + single => { sql => $self->{'sql'}, event => 'fspot_display_photo' } ); } @@ -108,6 +132,7 @@ LIMIT 1 $self->{'stage'}->add($self->{$age}); } +warn "Going to yield\n"; $self->{'kernel'}->yield('fspot_display'); } -- 2.30.2