[banshee/grid] Mostly done with new unknown artwork rendering



commit 1887c29fb5716d64520da23cc77e718a60a9ac48
Author: Aaron Bockover <abockover novell com>
Date:   Tue Dec 15 19:27:42 2009 -0500

    Mostly done with new unknown artwork rendering
    
    - Added 90 as a valid artwork cache size
    - Tweaked look and feel of the unknown artwork
    - Added 3 new properties to CellContext: ViewRowIndex,
      ViewColumnIndex, and ModelRowIndex; also made all the
      properties in CellContext use automatic getter/setters
    - Set the three new CellContext properties when doing
      rendering
    - Set the global GTK theme radius to 0, just seeing if
      I like this; getting tired of rounded

 .../Banshee.Collection.Gui/ArtworkManager.cs       |    1 +
 .../Banshee.Collection.Gui/ArtworkRenderer.cs      |   31 +++++----
 .../Banshee.Collection.Gui/ColumnCellAlbum.cs      |   12 +---
 .../Hyena.Gui/Hyena.Data.Gui/CellContext.cs        |   71 +++++---------------
 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |    8 ++
 .../Hyena.Gui/Hyena.Gui.Theming/ThemeContext.cs    |    2 +-
 6 files changed, 45 insertions(+), 80 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
index 90b5577..d67e314 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkManager.cs
@@ -70,6 +70,7 @@ namespace Banshee.Collection.Gui
             AddCachedSize (42);
             AddCachedSize (48);
             AddCachedSize (64);
+            AddCachedSize (90);
             AddCachedSize (300);
 
             try {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
index 47e2780..f1ce05c 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ArtworkRenderer.cs
@@ -37,7 +37,6 @@ 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)
@@ -72,30 +71,32 @@ namespace Banshee.Collection.Gui
 
             cr.Antialias = Cairo.Antialias.Default;
 
-            if (fill) {
-                cr.Rectangle (x, y, width, height);
-                cr.Color = fillColor;
-                cr.Fill();
-            }
-
             if (image != null) {
+                if (fill) {
+                    CairoExtensions.RoundedRectangle (cr, x, y, width, height, radius, corners);
+                    cr.Color = fillColor;
+                    cr.Fill ();
+                }
+
                 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);
 
-                var grad = new LinearGradient (x, y, x, y + height);
-                grad.AddColorStop (0, CairoExtensions.ColorFromHsb (random.Next (), random.Next (50, 150) / 255.0, 0.75));
-                grad.AddColorStop (1, CairoExtensions.ColorFromHsb (random.Next (), random.Next (50, 150) / 255.0, 0.15));
-                cr.Pattern = grad;
-                cr.Fill ();
-                grad.Destroy ();
+                if (fill) {
+                    var grad = new LinearGradient (x, y, x, y + height);
+                    grad.AddColorStop (0, fillColor);
+                    grad.AddColorStop (1, CairoExtensions.ColorShade (fillColor, 1.3));
+                    cr.Pattern = grad;
+                    cr.Fill ();
+                    grad.Destroy ();
+                }
 
                 Banshee.CairoGlyphs.BansheeLineLogo.Render (cr,
                     new Rectangle (x + 15, y + 15, width - 30, height - 30),
-                    CairoExtensions.RgbaToColor (0xffffff55),
-                    CairoExtensions.RgbaToColor (0xffffff88));
+                    CairoExtensions.RgbaToColor (0x00000044),
+                    CairoExtensions.RgbaToColor (0x00000055));
             }
 
             if (!drawBorder) {
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
index 17c9b1c..b9cce0e 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
@@ -45,9 +45,6 @@ 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 ArtworkManager artwork_manager;
 
         public ColumnCellAlbum () : base (null, true)
@@ -84,18 +81,12 @@ namespace Banshee.Collection.Gui
 
             AlbumInfo album = (AlbumInfo)BoundObject;
 
-            // bool is_default = false;
             int actual_image_size = LayoutStyle == DataViewLayoutStyle.Grid
                 ? (int)Math.Max (Math.Min (cellWidth, cellHeight) - 10, 0)
                 : image_size;
             ImageSurface image = artwork_manager == null ? null
                 : artwork_manager.LookupScaleSurface (album.ArtworkId, actual_image_size, true);
 
-            if (image == null) {
-                // image = default_cover_image;
-                // is_default = true;
-            }
-
             // int image_render_size = is_default ? image.Height : (int)cellHeight - 8;
             int image_render_size = actual_image_size;
             int x = LayoutStyle == DataViewLayoutStyle.Grid
@@ -104,7 +95,8 @@ 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*/ true, context.Theme.Context.Radius);
+                image_render_size, image_render_size, true, context.Theme.Context.Radius,
+                image == null, new Color (0.8, 0.8, 0.8));
 
             if (LayoutStyle == DataViewLayoutStyle.Grid) {
                 return;
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
index f25ec0d..253d5b2 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
@@ -34,59 +34,22 @@ namespace Hyena.Data.Gui
 {
     public class CellContext
     {
-        private Cairo.Context context;
-        private Pango.Layout layout;
-        private Gtk.Widget widget;
-        private Gdk.Drawable drawable;
-        private Theme theme;
-        private Gdk.Rectangle area;
-        private Gdk.Rectangle clip;
-        private bool text_as_foreground = false;
-        private bool opaque = true;
-
-        public Cairo.Context Context {
-            get { return context; }
-            set { context = value; }
-        }
-
-        public Pango.Layout Layout {
-            get { return layout; }
-            set { layout = value; }
-        }
-
-        public Gtk.Widget Widget {
-            get { return widget; }
-            set { widget = value; }
-        }
-
-        public Gdk.Drawable Drawable {
-            get { return drawable; }
-            set { drawable = value; }
-        }
-
-        public Theme Theme {
-            get { return theme; }
-            set { theme = value; }
-        }
-
-        public Gdk.Rectangle Area {
-            get { return area; }
-            set { area = value; }
-        }
-
-        public Gdk.Rectangle Clip {
-            get { return clip; }
-            set { clip = value; }
-        }
-
-        public bool TextAsForeground {
-            get { return text_as_foreground; }
-            set { text_as_foreground = value; }
-        }
-
-        public bool Opaque {
-            get { return opaque; }
-            set { opaque = value; }
-        }
+        public CellContext ()
+        {
+            Opaque = true;
+        }
+
+        public Cairo.Context Context { get; set; }
+        public Pango.Layout Layout { get; set; }
+        public Gtk.Widget Widget { get; set; }
+        public Gdk.Drawable Drawable { get; set; }
+        public Theme Theme { get; set; }
+        public Gdk.Rectangle Area { get; set; }
+        public Gdk.Rectangle Clip { get; set; }
+        public bool TextAsForeground { get; set; }
+        public bool Opaque { get; set; }
+        public int ViewRowIndex { get; set; }
+        public int ViewColumnIndex { get; set; }
+        public int ModelRowIndex { get; set; }
     }
 }
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 26f698b..9aba3a7 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -353,7 +353,11 @@ namespace Hyena.Data.Gui
             cell_area.Height = RowHeight;
             cell_area.Y = area.Y;
 
+            cell_context.ViewRowIndex = cell_context.ModelRowIndex = row_index;
+
             for (int ci = 0; ci < column_cache.Length; ci++) {
+                cell_context.ViewColumnIndex = ci;
+
                 if (pressed_column_is_dragging && pressed_column_index == ci) {
                     continue;
                 }
@@ -483,6 +487,10 @@ namespace Hyena.Data.Gui
                         true, true, selection_color, CairoCorners.All);
                 }
 
+                cell_context.ModelRowIndex = model_row_index;
+                cell_context.ViewRowIndex = view_row_index;
+                cell_context.ViewColumnIndex = view_column_index;
+
                 var item = model[model_row_index];
                 PaintCell (item, 0, model_row_index, grid_cell_alloc,
                     IsRowOpaque (item), IsRowBold (item), StateType.Normal, false);
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeContext.cs b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeContext.cs
index 0f8ea97..5c7b6af 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeContext.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/ThemeContext.cs
@@ -33,7 +33,7 @@ namespace Hyena.Gui.Theming
 {
     public class ThemeContext
     {
-        private double radius = 3.0;
+        private double radius = 0.0;
         public double Radius {
             get { return radius; }
             set { radius = value; }



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