banshee r3170 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui src/Core/Hyena.Gui/Hyena.Data.Gui/ListView src/Core/Hyena.Gui/Hyena.Gui



Author: abock
Date: Fri Feb  8 00:47:13 2008
New Revision: 3170
URL: http://svn.gnome.org/viewvc/banshee?rev=3170&view=rev

Log:
2008-02-07  Aaron Bockover  <abock gnome org>

    * src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
    Draw the focus row again, make it really sexy by merging it into the
    selection if it borders one

    * src/Core/Hyena.Gui/Hyena.Gui/CairoExtensions.cs:
    * src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs: Support drawing
    selections/rounded rectangles that fall through to others



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui/CairoExtensions.cs

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	Fri Feb  8 00:47:13 2008
@@ -32,6 +32,8 @@
 using Gtk;
 using Cairo;
 
+using Hyena.Gui;
+
 namespace Hyena.Data.Gui
 {
     public partial class ListView<T> : Container
@@ -153,7 +155,9 @@
             int first_row = vadjustment_value / RowHeight;
             int last_row = Math.Min (model.Count, first_row + RowsInView);     
 
+            Gdk.Rectangle selected_focus_alloc = Gdk.Rectangle.Zero;;
             Gdk.Rectangle single_list_alloc = new Gdk.Rectangle ();
+            
             single_list_alloc.Width = list_alloc.Width;
             single_list_alloc.Height = RowHeight;
             single_list_alloc.X = list_alloc.X;
@@ -168,20 +172,41 @@
                     if (selection_height == 0) {
                         selection_y = single_list_alloc.Y;
                     }
+                    
                     selection_height += single_list_alloc.Height;
                     selected_rows.Add (ri);
+                    
+                    if (focused_row_index == ri) {
+                        selected_focus_alloc = single_list_alloc;
+                    }
                 } else {
+                    if (rules_hint && ri % 2 != 0) {
+                        graphics.DrawRowRule (list_cr, single_list_alloc.X, single_list_alloc.Y, 
+                            single_list_alloc.Width, single_list_alloc.Height);
+                    }
+                    
+                    if (focused_row_index == ri && !Selection.Contains (ri)) {
+                        CairoCorners corners = CairoCorners.All;
+                        
+                        if (Selection.Contains (ri - 1)) {
+                            corners ^= CairoCorners.TopLeft | CairoCorners.TopRight;
+                        }
+                        
+                        if (Selection.Contains (ri + 1)) {
+                            corners ^= CairoCorners.BottomLeft | CairoCorners.BottomRight;
+                        }
+                        
+                        graphics.DrawRowSelection (list_cr, single_list_alloc.X, single_list_alloc.Y, 
+                            single_list_alloc.Width, single_list_alloc.Height, false, true, 
+                            graphics.GetWidgetColor (GtkColorClass.Background, StateType.Selected), corners);
+                    }
+                    
                     if (selection_height > 0) {
                         graphics.DrawRowSelection (
                             list_cr, list_alloc.X, list_alloc.Y + selection_y, list_alloc.Width, selection_height);
                         selection_height = 0;
                     }
                     
-                    if (rules_hint && ri % 2 != 0) {
-                        graphics.DrawRowRule (list_cr, single_list_alloc.X, single_list_alloc.Y, 
-                            single_list_alloc.Width, single_list_alloc.Height);
-                    }
-                    
                     PaintRow (ri, clip, single_list_alloc, StateType.Normal);
                 }
                 
@@ -189,8 +214,14 @@
             }
             
             if (selection_height > 0) {
-                graphics.DrawRowSelection(
-                    list_cr, list_alloc.X, list_alloc.Y + selection_y, list_alloc.Width, selection_height);
+                graphics.DrawRowSelection (list_cr, list_alloc.X, list_alloc.Y + selection_y, 
+                    list_alloc.Width, selection_height);
+            }
+            
+            if (Selection.Count > 1 && !selected_focus_alloc.Equals (Gdk.Rectangle.Zero)) {
+                graphics.DrawRowSelection (list_cr, selected_focus_alloc.X, selected_focus_alloc.Y, 
+                    selected_focus_alloc.Width, selected_focus_alloc.Height, false, true, 
+                    graphics.GetWidgetColor (GtkColorClass.Dark, StateType.Selected));
             }
             
             foreach (int ri in selected_rows) {

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListViewGraphics.cs	Fri Feb  8 00:47:13 2008
@@ -285,12 +285,18 @@
         public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height, bool filled)
         {
             DrawRowSelection(cr, x, y, width, height, filled, true, 
-                GetWidgetColor(GtkColorClass.Background, StateType.Selected));
+                GetWidgetColor(GtkColorClass.Background, StateType.Selected), CairoCorners.All);
         }
         
-        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height, 
+        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
             bool filled, bool stroked, Cairo.Color color)
         {
+            DrawRowSelection(cr, x, y, width, height, filled, stroked, color, CairoCorners.All);
+        }
+        
+        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
+            bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
+        {
             Cairo.Color selection_color = color;
             Cairo.Color selection_stroke = CairoExtensions.ColorShade(selection_color, 0.85);
             selection_stroke.A = color.A;
@@ -307,14 +313,14 @@
                 grad.AddColorStop(1, selection_fill_dark);
                 
                 cr.Pattern = grad;
-                CairoExtensions.RoundedRectangle(cr, x, y, width, height, BorderRadius);
+                CairoExtensions.RoundedRectangle(cr, x, y, width, height, BorderRadius, corners, true);
                 cr.Fill();
             }
             
             if (stroked) {
                 cr.LineWidth = 1.0;
                 cr.Color = selection_stroke;
-                CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1, BorderRadius);
+                CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1, BorderRadius, corners, true);
                 cr.Stroke();
             }
         }

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui/CairoExtensions.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui/CairoExtensions.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Gui/CairoExtensions.cs	Fri Feb  8 00:47:13 2008
@@ -191,45 +191,71 @@
 
         public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h, double r)
         {
-            RoundedRectangle(cr, x, y, w, h, r, CairoCorners.All);
+            RoundedRectangle(cr, x, y, w, h, r, CairoCorners.All, false);
         }
         
-        public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h, 
+        public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
             double r, CairoCorners corners)
         {
-            if(r < 0.0001 || corners == CairoCorners.None) {
+            RoundedRectangle(cr, x, y, w, h, r, corners, false);
+        }
+        
+        public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
+            double r, CairoCorners corners, bool topBottomFallsThrough)
+        {
+            if(topBottomFallsThrough && corners == CairoCorners.None) {
+                cr.MoveTo(x, y - r);
+                cr.LineTo(x, y + h + r);
+                cr.MoveTo(x + w, y - r);
+                cr.LineTo(x + w, y + h + r);
+                return;
+            } else if(r < 0.0001 || corners == CairoCorners.None) {
                 cr.Rectangle(x, y, w, h);
                 return;
             }
             
-            if((corners & CairoCorners.TopLeft) != 0) {
-                cr.MoveTo(x + r, y);
+            if((corners & (CairoCorners.TopLeft | CairoCorners.TopRight)) == 0 && topBottomFallsThrough) {
+                y -= r;
+                h += r;
+                cr.MoveTo(x + w, y);
             } else {
-                cr.MoveTo(x, y);
-            }
+                if((corners & CairoCorners.TopLeft) != 0) {
+                    cr.MoveTo(x + r, y);
+                } else {
+                    cr.MoveTo(x, y);
+                }
             
-            if((corners & CairoCorners.TopRight) != 0) {
-                cr.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
-            } else {
-                cr.LineTo(x + w, y);
+                if((corners & CairoCorners.TopRight) != 0) {
+                    cr.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
+                } else {
+                    cr.LineTo(x + w, y);
+                }
             }
             
-            if((corners & CairoCorners.BottomRight) != 0) {
-                cr.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
-            } else {
+            if((corners & (CairoCorners.BottomLeft | CairoCorners.BottomRight)) == 0 && topBottomFallsThrough) {
+                h += r;
                 cr.LineTo(x + w, y + h);
-            }
-            
-            if((corners & CairoCorners.BottomLeft) != 0) {
-                cr.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
-            } else {
-                cr.LineTo(x, y + h);
-            }
-            
-            if((corners & CairoCorners.TopLeft) != 0) {
+                cr.MoveTo(x, y + h);
+                cr.LineTo(x, y + r);
                 cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
             } else {
-                cr.LineTo(x, y);
+                if((corners & CairoCorners.BottomRight) != 0) {
+                    cr.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
+                } else {
+                    cr.LineTo(x + w, y + h);
+                }
+                
+                if((corners & CairoCorners.BottomLeft) != 0) {
+                    cr.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
+                } else {
+                    cr.LineTo(x, y + h);
+                }
+                
+                if((corners & CairoCorners.TopLeft) != 0) {
+                    cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
+                } else {
+                    cr.LineTo(x, y);
+                }
             }
         }
 



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