From 41d32941eb9720fc5d69f9bcfe410f53761d24f9 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Sat, 20 Sep 2008 22:22:34 +1200 Subject: [PATCH] Lots of tweaks to make the display work and look better. --- lib/Display/Plugins/MPD.pm | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/lib/Display/Plugins/MPD.pm b/lib/Display/Plugins/MPD.pm index 6136ff3..e9b9b08 100644 --- a/lib/Display/Plugins/MPD.pm +++ b/lib/Display/Plugins/MPD.pm @@ -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); } -- 2.30.2