banshee r3110 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Core/Hyena.Gui src/Core/Hyena.Gui/Hyena.Gui.Theatrics
- From: abock svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3110 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Core/Hyena.Gui src/Core/Hyena.Gui/Hyena.Gui.Theatrics
- Date: Thu, 31 Jan 2008 03:56:50 +0000 (GMT)
Author: abock
Date: Thu Jan 31 03:56:50 2008
New Revision: 3110
URL: http://svn.gnome.org/viewvc/banshee?rev=3110&view=rev
Log:
2008-01-30 Aaron Bockover <abock gnome org>
* src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs:
Ported the animation/timeline code to use Hyena.Gui.Theatrics
* src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs:
A helper stage that will only have up to one actor at a time
Added:
trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp
trunk/banshee/src/Core/Hyena.Gui/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/TrackInfoDisplay.cs Thu Jan 31 03:56:50 2008
@@ -35,6 +35,7 @@
using Cairo;
using Hyena.Gui;
+using Hyena.Gui.Theatrics;
using Banshee.Base;
using Banshee.Collection;
@@ -46,8 +47,6 @@
{
public class TrackInfoDisplay : Bin
{
- private const int FADE_TIMEOUT = 1500;
-
private ArtworkManager artwork_manager;
private Gdk.Pixbuf current_pixbuf;
private Gdk.Pixbuf incoming_pixbuf;
@@ -59,11 +58,8 @@
private TrackInfo current_track;
private TrackInfo incoming_track;
-
- private DateTime transition_start;
- private double transition_percent;
- private double transition_frames;
- private uint transition_id;
+
+ private SingleActorStage stage = new SingleActorStage ();
private ArtworkPopup popup;
private uint popup_timeout_id;
@@ -72,6 +68,8 @@
public TrackInfoDisplay ()
{
+ stage.Iteration += OnStageIteration;
+
if (ServiceManager.Contains ("ArtworkManager")) {
artwork_manager = ServiceManager.Get<ArtworkManager> ("ArtworkManager");
}
@@ -244,7 +242,7 @@
Cairo.Surface ps;
Cairo.Context pcr;
- if (transition_percent >= 1.0) {
+ if (stage.Actor == null) {
// We are not in a transition, just render
RenderStage (cr, current_track, current_pixbuf);
return;
@@ -256,7 +254,7 @@
RenderStage (cr, incoming_track, incoming_pixbuf);
CairoExtensions.PopGroupToSource (cr);
- cr.PaintWithAlpha (transition_percent);
+ cr.PaintWithAlpha (stage.Actor.Percent);
return;
}
@@ -270,33 +268,33 @@
RenderCoverArt (cr, current_pixbuf);
CairoExtensions.PopGroupToSource (cr);
- cr.PaintWithAlpha (1.0 - transition_percent);
+ cr.PaintWithAlpha (1.0 - stage.Actor.Percent);
// Fade in/out the text
cr.ResetClip ();
cr.Rectangle (clip.X, clip.Y, clip.Width, clip.Height);
cr.Clip ();
- bool same_artist_album = incoming_track.ArtistAlbumEqual (current_track);
+ bool same_artist_album = incoming_track != null ? incoming_track.ArtistAlbumEqual (current_track) : false;
if (same_artist_album) {
RenderTrackInfo (cr, incoming_track, false, true);
}
- if (transition_percent <= 0.5) {
+ if (stage.Actor.Percent <= 0.5) {
// Fade out old text
CairoExtensions.PushGroup (cr);
RenderTrackInfo (cr, current_track, true, !same_artist_album);
CairoExtensions.PopGroupToSource (cr);
- cr.PaintWithAlpha (1.0 - (transition_percent * 2.0));
+ cr.PaintWithAlpha (1.0 - (stage.Actor.Percent * 2.0));
} else {
// Fade in new text
CairoExtensions.PushGroup (cr);
RenderTrackInfo (cr, incoming_track, true, !same_artist_album);
CairoExtensions.PopGroupToSource (cr);
- cr.PaintWithAlpha ((transition_percent - 0.5) * 2.0);
+ cr.PaintWithAlpha ((stage.Actor.Percent - 0.5) * 2.0);
}
}
@@ -390,53 +388,37 @@
incoming_pixbuf = pixbuf;
}
- if (transition_id == 0) {
- BeginTransition ();
+ if (stage.Actor == null) {
+ stage.Reset ();
}
}
}
- private void BeginTransition ()
+ private double last_fps = 0.0;
+
+ private void OnStageIteration (object o, EventArgs args)
{
- transition_start = DateTime.Now;
- transition_percent = 0.0;
- transition_frames = 0.0;
+ QueueDraw ();
- if (transition_id == 0) {
- transition_id = GLib.Timeout.Add (30, ComputeTransition);
+ if (stage.Actor != null) {
+ last_fps = stage.Actor.FramesPerSecond;
+ return;
}
- }
-
- private bool ComputeTransition ()
- {
- double elapsed = (DateTime.Now - transition_start).TotalMilliseconds;
- transition_percent = elapsed / FADE_TIMEOUT;
- transition_frames++;
- QueueDraw ();
+ if (ApplicationContext.Debugging) {
+ Log.DebugFormat ("TrackInfoDisplay RenderAnimation: {0:0.00} FPS", last_fps);
+ }
- if (elapsed > FADE_TIMEOUT) {
- if (ApplicationContext.Debugging) {
- Log.DebugFormat ("TrackInfoDisplay RenderAnimation: {0:0.00} FPS",
- transition_frames / ((double)FADE_TIMEOUT / 1000.0));
- }
-
- if (current_pixbuf != incoming_pixbuf && current_pixbuf != missing_pixbuf) {
- ArtworkRenderer.DisposePixbuf (current_pixbuf);
- }
-
- current_pixbuf = incoming_pixbuf;
- current_track = incoming_track;
-
- incoming_track = null;
-
- transition_id = 0;
-
- UpdatePopup ();
- return false;
+ if (current_pixbuf != incoming_pixbuf && current_pixbuf != missing_pixbuf) {
+ ArtworkRenderer.DisposePixbuf (current_pixbuf);
}
- return true;
+ current_pixbuf = incoming_pixbuf;
+ current_track = incoming_track;
+
+ incoming_track = null;
+
+ UpdatePopup ();
}
private string GetFirstLineText (TrackInfo track)
Added: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.Theatrics/SingleActorStage.cs Thu Jan 31 03:56:50 2008
@@ -0,0 +1,54 @@
+//
+// SingleActorStage.cs
+//
+// Author:
+// Aaron Bockover <abockover novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+
+namespace Hyena.Gui.Theatrics
+{
+ public class SingleActorStage : Stage<object>
+ {
+ private object target = new object ();
+
+ public SingleActorStage () : base ()
+ {
+ }
+
+ public SingleActorStage (uint actorDuration) : base (actorDuration)
+ {
+ }
+
+ public void Reset ()
+ {
+ AddOrReset (target);
+ }
+
+ public Actor<object> Actor {
+ get { return this[target]; }
+ }
+ }
+}
Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui.mdp Thu Jan 31 03:56:50 2008
@@ -32,6 +32,7 @@
<File name="Hyena.Widgets/RoundedFrame.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Gui.Theatrics/Actor.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Gui.Theatrics/Stage.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Gui.Theatrics/SingleActorStage.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/banshee/src/Core/Hyena.Gui/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Makefile.am (original)
+++ trunk/banshee/src/Core/Hyena.Gui/Makefile.am Thu Jan 31 03:56:50 2008
@@ -17,6 +17,7 @@
Hyena.Gui.Dialogs/ExceptionDialog.cs \
Hyena.Gui.Dialogs/VersionInformationDialog.cs \
Hyena.Gui.Theatrics/Actor.cs \
+ Hyena.Gui.Theatrics/SingleActorStage.cs \
Hyena.Gui.Theatrics/Stage.cs \
Hyena.Gui/CairoExtensions.cs \
Hyena.Gui/CleanRoomStartup.cs \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]