]> git.etc.gen.nz Git - picture-display.git/commitdiff
Lots of tweaks to make the display work and look better.
authorAndrew Ruthven <andrew@etc.gen.nz>
Sat, 20 Sep 2008 10:22:34 +0000 (22:22 +1200)
committerAndrew Ruthven <andrew@etc.gen.nz>
Sat, 20 Sep 2008 10:22:34 +0000 (22:22 +1200)
lib/Display/Plugins/MPD.pm

index 6136ff35710f71aa6daf9b28dbc7ebb95cbea57b..e9b9b08bcf9f46d3bde38c184d1f19e8350fb63b 100644 (file)
@@ -5,6 +5,8 @@ use Audio::MPD;
 use POSIX qw/strftime/;
 use base ('Display::Plugin');
 
+my $delay = 15;
+
 sub new {
   my $proto = shift;
   my $class = ref($proto) || $proto;
@@ -40,16 +42,19 @@ sub display {
     $self->{'bg'}->set_position(10, $self->{'stage'}->get_height() - 10);
 
     $self->{'status'}->set_anchor_point(1, $self->{'status'}->get_height());
-    $self->{'status'}->set_position(15, $self->{'stage'}->get_height() - 20);
+    $self->{'status'}->set_position(20, $self->{'stage'}->get_height() - 20);
 
     if (! $self->{'active'}) {
-      $self->{'stage'}->add($self->{'bg'});
-      $self->{'stage'}->add($self->{'status'});
+      $self->{'block'}->set_opacity(0);
+      $self->{'stage'}->add($self->{'block'});
+      my $effect = Clutter::EffectTemplate->new_for_duration(1000, 'main::smoothstep_inc');
+      my $timeline = Clutter::Effect->fade($effect, $self->{'block'}, 255);
+      $timeline->start();
       
-      $self->{'active'} = time() + 30;
+      $self->{'active'} = time() + $delay;
     }
 
-    Glib::Timeout->add_seconds(30, $self->can('hide_display'), $self);
+    Glib::Timeout->add_seconds($delay, $self->can('hide_display'), $self);
   }
 
   return 1;
@@ -59,8 +64,7 @@ sub hide_display {
   my $self = shift;
 
   if ($self->{'active'} <= time()) {
-    $self->{'stage'}->remove($self->{'status'});
-    $self->{'stage'}->remove($self->{'bg'});
+    $self->{'stage'}->remove($self->{'block'});
 
     $self->{'active'} = 0;
   }
@@ -71,13 +75,20 @@ sub hide_display {
 sub init {
   my $self = shift;
 
-  $self->{'status'} = Clutter::Label->new('Sans 20', "Song\nAlbum");
-  $self->{'status'}->set_color(Clutter::Color->parse('White'));
+  $self->{'block'} = Clutter::Group->new();
 
   $self->{'bg'} = Clutter::Rectangle->new(Clutter::Color->parse('Black'));
-  $self->{'bg'}->set_width($self->{'stage'}->get_width() - 40);
+  $self->{'bg'}->set_width($self->{'stage'}->get_width() - 20);
   $self->{'bg'}->set_opacity(100);
 
+  $self->{'status'} = Clutter::Label->new('Sans 20', "Song\nAlbum");
+  $self->{'status'}->set_color(Clutter::Color->parse('White'));
+  $self->{'status'}->set_ellipsize('end');
+  $self->{'status'}->set_width($self->{'bg'}->get_width() - 20);
+
+  $self->{'block'}->add($self->{'bg'});
+  $self->{'block'}->add($self->{'status'});
+
   Glib::Timeout->add_seconds(5, $self->can('display'), $self);
 }