]> git.etc.gen.nz Git - picture-display.git/commitdiff
Get photo fading working, awesome!
authorAndrew Ruthven <puck@catalyst.net.nz>
Tue, 23 Sep 2008 02:36:04 +0000 (14:36 +1200)
committerAndrew Ruthven <puck@dirk.wgtn.cat-it.co.nz>
Tue, 23 Sep 2008 02:36:04 +0000 (14:36 +1200)
The droppings of moving to behaviours are in place waiting for be
uncommented and made to work.

lib/Display/Plugins/FSpot.pm

index 96748457c04a49f8ce911fe203b78803e7c38aec..fa42c9bdcfd87a2c025a6bc1f43375543d063a13 100644 (file)
@@ -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');
 }