[Muine] Magic Spooky Cover Image Patch



Wooooooo

So, I was bored tonight and thought I'd port something from my
top-sekrit project to my personal version of Muine
(imuine...geddit????!), then I realised it applied cleanly to the
official version of Muine, so here I submit to you

*********************************************
The Magic Spooky Cover Image Patch!!!!!
*********************************************

Not telling you what it does, apply it and see.

iain
Index: CoverImage.cs
===================================================================
RCS file: /cvs/gnome/muine/src/CoverImage.cs,v
retrieving revision 1.25
diff -U2 -r1.25 CoverImage.cs
--- CoverImage.cs	15 Mar 2005 11:25:47 -0000	1.25
+++ CoverImage.cs	31 Jan 2006 00:15:14 -0000
@@ -125,5 +125,5 @@
 
 		// Objects
-		private Gtk.Image image;
+		private MagicCoverImage image;
 		private Song song;
 		
@@ -134,5 +134,5 @@
 		public CoverImage () : base ()
 		{
-			image = new Gtk.Image ();	
+			image = new MagicCoverImage ();	
 			image.SetSizeRequest (CoverDatabase.CoverSize, 
 					      CoverDatabase.CoverSize);
@@ -184,8 +184,8 @@
 			// Image
 			if (song != null && song.CoverImage != null) {
-				image.FromPixbuf = song.CoverImage;
+				image.ChangePixbuf (song.CoverImage);
 
 			} else if (song != null && Global.CoverDB.Loading) {
-				image.FromPixbuf = Global.CoverDB.DownloadingPixbuf;
+				image.ChangePixbuf (Global.CoverDB.DownloadingPixbuf);
 
 			} else {
Index: MagicCoverImage.cs
===================================================================
RCS file: MagicCoverImage.cs
diff -N MagicCoverImage.cs
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MagicCoverImage.cs	31 Jan 2006 00:15:14 -0000
@@ -0,0 +1,85 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Authors: Iain Holmes <iain gnome org>
+ *
+ *  Copyright 2006 Iain Holmes
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of version 2 of the GNU General Public License as 
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+using System;
+
+using Gtk;
+using Gdk;
+
+namespace Muine
+{
+        public class MagicCoverImage : Gtk.Image {
+		private Pixbuf current;
+		private Pixbuf next;
+
+		private TimeSpan start;
+
+		const double FADE_DURATION = 3000.0;
+
+		public MagicCoverImage () {
+			current = null;
+			next = null;
+		}
+
+		public void ChangePixbuf (Pixbuf pb) {
+			if (current == null) {
+				this.FromPixbuf = pb;
+				current = pb;
+			} else {
+				next = pb;
+				start_fade ();
+			}
+		}
+
+		private void start_fade () {
+			start = DateTime.Now.TimeOfDay;
+
+			GLib.Idle.Add (new GLib.IdleHandler (do_fade));
+		}
+
+		private bool do_fade () {
+			TimeSpan now = DateTime.Now.TimeOfDay;
+			double elapsed = now.TotalMilliseconds - start.TotalMilliseconds;
+			double percent = elapsed / FADE_DURATION;
+			
+			this.FromPixbuf = make_frame (percent);
+			if (elapsed > FADE_DURATION) {
+				current = next;
+				return false;
+			} else {
+				return true;
+			}
+		}
+
+		private Pixbuf make_frame (double percent) {
+			if (percent > 1.0) {
+				percent = 1.0;
+			}
+
+			Pixbuf frame = current.Copy ();
+			next.Composite (frame, 0, 0, next.Width, next.Height,
+					0, 0, 1.0, 1.0, InterpType.Nearest, 
+					(int) (percent * 255));
+
+			return frame;
+		}
+	}
+}
Index: Makefile.am
===================================================================
RCS file: /cvs/gnome/muine/src/Makefile.am,v
retrieving revision 1.78
diff -U2 -r1.78 Makefile.am
--- Makefile.am	11 Jan 2006 04:23:58 -0000	1.78
+++ Makefile.am	31 Jan 2006 00:15:14 -0000
@@ -49,5 +49,6 @@
 	$(srcdir)/ImportDialog.cs		\
 	$(srcdir)/OpenDialog.cs			\
-	$(srcdir)/SaveDialog.cs
+	$(srcdir)/SaveDialog.cs			\
+	$(srcdir)/MagicCoverImage.cs
 
 MUINE_GENERATED_CSFILES =			\


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]