[banshee/grid] [ArtworkRenderer] make up artwork if no image specified



commit 8bb9b8b2a70b179e1c50d2cfefe7acfe85964c23
Author: Aaron Bockover <abockover novell com>
Date:   Mon Dec 14 02:34:26 2009 -0500

    [ArtworkRenderer] make up artwork if no image specified
    
    If there's no image provided, render a random background and
    draw the Banshee lines logo over to create a nicer unknown
    album artwork effect. WIP.

 .../Banshee.Collection.Gui/ArtworkRenderer.cs      |   30 ++++++++++++++-----
 .../Banshee.Collection.Gui/ColumnCellAlbum.cs      |   12 ++++----
 .../Banshee.ThickClient/Banshee.ThickClient.csproj |   24 ++++++++++++++--
 src/Core/Banshee.ThickClient/Makefile.am           |    1 +
 4 files changed, 50 insertions(+), 17 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
index dcd0a40..91a1358 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
@@ -37,6 +37,7 @@ namespace Banshee.Collection.Gui
     {
         private static Color cover_border_light_color = new Color (1.0, 1.0, 1.0, 0.5);
         private static Color cover_border_dark_color = new Color (0.0, 0.0, 0.0, 0.65);
+        private static Random random = new Random ();
 
         public static void RenderThumbnail (Cairo.Context cr, ImageSurface image, bool dispose,
             double x, double y, double width, double height, bool drawBorder, double radius)
@@ -58,13 +59,16 @@ namespace Banshee.Collection.Gui
             bool fill, Color fillColor, CairoCorners corners)
         {
             if (image == null || image.Handle == IntPtr.Zero) {
-                return;
+                image = null;
             }
 
             double p_x = x;
             double p_y = y;
-            p_x += image.Width < width ? (width - image.Width) / 2 : 0;
-            p_y += image.Height < height ? (height - image.Height) / 2 : 0;
+
+            if (image != null) {
+                p_x += image.Width < width ? (width - image.Width) / 2 : 0;
+                p_y += image.Height < height ? (height - image.Height) / 2 : 0;
+            }
 
             cr.Antialias = Cairo.Antialias.Default;
 
@@ -74,12 +78,22 @@ namespace Banshee.Collection.Gui
                 cr.Fill();
             }
 
-            CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
-            cr.SetSource (image, p_x, p_y);
-            cr.Fill ();
+            if (image != null) {
+                CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
+                cr.SetSource (image, p_x, p_y);
+                cr.Fill ();
+            } else {
+                CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
+                cr.Color = CairoExtensions.ColorFromHsb (random.Next (), 54 / 255.0, 102 / 255.0);
+                cr.Fill ();
+                var size = Math.Min (width, height) - 20;
+                Banshee.CairoGlyphs.BansheeLineLogo.Render (cr, x + 18, y + 12, size,
+                    CairoExtensions.RgbaToColor (0xffffff55),
+                    CairoExtensions.RgbaToColor (0xffffff88));
+            }
 
             if (!drawBorder) {
-                if (dispose) {
+                if (dispose && image != null) {
                     ((IDisposable)image).Dispose ();
                 }
 
@@ -99,7 +113,7 @@ namespace Banshee.Collection.Gui
             cr.Color = cover_border_dark_color;
             cr.Stroke ();
 
-            if (dispose) {
+            if (dispose && image != null) {
                 ((IDisposable)image).Dispose ();
             }
         }
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
index 35f790f..17c9b1c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
@@ -45,8 +45,8 @@ namespace Banshee.Collection.Gui
         private static int image_spacing = 4;
         private static int image_size = 48;
 
-        private static ImageSurface default_cover_image
-            = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (image_size, "media-optical", "browser-album-cover"));
+        // private static ImageSurface default_cover_image
+        //    = PixbufImageSurface.Create (IconThemeUtils.LoadIcon (image_size, "media-optical", "browser-album-cover"));
 
         private ArtworkManager artwork_manager;
 
@@ -84,7 +84,7 @@ namespace Banshee.Collection.Gui
 
             AlbumInfo album = (AlbumInfo)BoundObject;
 
-            bool is_default = false;
+            // bool is_default = false;
             int actual_image_size = LayoutStyle == DataViewLayoutStyle.Grid
                 ? (int)Math.Max (Math.Min (cellWidth, cellHeight) - 10, 0)
                 : image_size;
@@ -92,8 +92,8 @@ namespace Banshee.Collection.Gui
                 : artwork_manager.LookupScaleSurface (album.ArtworkId, actual_image_size, true);
 
             if (image == null) {
-                image = default_cover_image;
-                is_default = true;
+                // image = default_cover_image;
+                // is_default = true;
             }
 
             // int image_render_size = is_default ? image.Height : (int)cellHeight - 8;
@@ -104,7 +104,7 @@ namespace Banshee.Collection.Gui
             int y = ((int)cellHeight - image_render_size) / 2;
 
             ArtworkRenderer.RenderThumbnail (context.Context, image, false, x, y,
-                image_render_size, image_render_size, !is_default, context.Theme.Context.Radius);
+                image_render_size, image_render_size, /*!is_default*/ true, context.Theme.Context.Radius);
 
             if (LayoutStyle == DataViewLayoutStyle.Grid) {
                 return;
diff --git a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
index a7fb52e..3b3d6d1 100644
--- a/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
+++ b/src/Core/Banshee.ThickClient/Banshee.ThickClient.csproj
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"; ToolsVersion="3.5">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -15,6 +15,8 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
+    <ReleaseVersion>1.3</ReleaseVersion>
+    <RootNamespace>Banshee.ThickClient</RootNamespace>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -25,11 +27,17 @@
         <Command type="Execute" command="make run" workingdir="${SolutionDir}" />
       </CustomCommands>
     </CustomCommands>
+    <OutputPath>bin\Debug</OutputPath>
+    <WarningLevel>4</WarningLevel>
+    <Optimize>false</Optimize>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Windows|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <PlatformTarget>x86</PlatformTarget>
+    <OutputPath>bin\Windows</OutputPath>
+    <WarningLevel>4</WarningLevel>
+    <Optimize>false</Optimize>
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\Libraries\Hyena.Gui\Hyena.Gui.csproj">
@@ -95,10 +103,13 @@
     <Reference Include="taglib-sharp">
       <HintPath>..\..\..\winbin\taglib-sharp.dll</HintPath>
     </Reference>
+    <Reference Include="Mono.Posix" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
-    <Reference Include="Mono.Posix" />
+    <Reference Include="Mono.Posix">
+      <HintPath>..\..\..\winbin\Mono.Posix.dll</HintPath>
+    </Reference>
     <Reference Include="Mono.Cairo" />
     <Reference Include="pango-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <Reference Include="System.Xml" />
@@ -120,7 +131,9 @@
     <EmbeddedResource Include="Resources\banshee-dialogs.glade">
       <LogicalName>banshee-dialogs.glade</LogicalName>
     </EmbeddedResource>
-    <EmbeddedResource Include="Banshee.ThickClient.addin.xml" />
+    <EmbeddedResource Include="Banshee.ThickClient.addin.xml">
+      <LogicalName>Banshee.ThickClient.addin.xml</LogicalName>
+    </EmbeddedResource>
     <EmbeddedResource Include="Resources\banshee-logo.png">
       <LogicalName>banshee-logo.png</LogicalName>
     </EmbeddedResource>
@@ -278,6 +291,8 @@
     <Compile Include="Banshee.ContextPane\ContextPageManager.cs" />
     <Compile Include="Banshee.ContextPane\ContextPane.cs" />
     <Compile Include="Banshee.Query.Gui\PlaybackErrorQueryValueEntry.cs" />
+    <Compile Include="Banshee.Gui.Widgets\CoverArtDisplay.cs" />
+    <Compile Include="Banshee.CairoGlyphs\BansheeLineLogo.cs" />
   </ItemGroup>
   <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
   <ProjectExtensions>
@@ -296,4 +311,7 @@
       </Properties>
     </MonoDevelop>
   </ProjectExtensions>
+  <ItemGroup>
+    <Folder Include="Banshee.CairoGlyphs\" />
+  </ItemGroup>
 </Project>
diff --git a/src/Core/Banshee.ThickClient/Makefile.am b/src/Core/Banshee.ThickClient/Makefile.am
index 25defba..e574d1e 100644
--- a/src/Core/Banshee.ThickClient/Makefile.am
+++ b/src/Core/Banshee.ThickClient/Makefile.am
@@ -7,6 +7,7 @@ SOURCES =  \
 	Banshee.Addins.Gui/AddinDetailsDialog.cs \
 	Banshee.Addins.Gui/AddinTile.cs \
 	Banshee.Addins.Gui/AddinView.cs \
+	Banshee.CairoGlyphs/BansheeLineLogo.cs \
 	Banshee.Collection.Gui/AlbumListView.cs \
 	Banshee.Collection.Gui/ArtistListView.cs \
 	Banshee.Collection.Gui/ArtworkManager.cs \



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