banshee r3494 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView src/Libraries/Hyena.Gui/Hyena.Gui.Theming



Author: scottp
Date: Thu Mar 20 22:04:27 2008
New Revision: 3494
URL: http://svn.gnome.org/viewvc/banshee?rev=3494&view=rev

Log:
This gets rid of the 5 (count 'em: five) GdkWindows we were using
to render the ListView. We now render everything to the GdkWindow
of the ListView's parent.

* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs:
ListWindow is no more.

* src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs:
Use Style to paint the layout rather than the Drawable. This is not
ideal, but nessisary so we can clip.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs: Moved
triangle-drawing code into the Theme.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs:
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs:
* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs:
InvalidateListWindow is now InvalidateList.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs:
Replaced five input-output GdkWidows with one input-only GdkWindow.
Also improved RowsInView calculation.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs:
Changed the math to account for just one GdkWindow, got rid of
unnessisary method ShowHideHeader().

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs:
Rework of rendering. Everything draws to a single GdkWindow.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
Changed the math to account for just one GdkWindow. Split the
OnButtonPressEvent and OnButtonReleaseEvent methods into methods
specific to the header and list.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs: Clip to the
clipping box.

* src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs: Add a clip
property for the clipping box.

* src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs: Added
DrawRectangle. Split DrawFrame into DrawFrameBackground and
DrawFrameBorder.

* src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs: Added
DrawRectangle. Split DrawFrame into DrawFrameBackground and
DrawFrameBorder. Misc rendering improvements.

Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
   trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellAlbum.cs	Thu Mar 20 22:04:27 2008
@@ -106,7 +106,7 @@
             y = (int)((cellHeight - (fl_height + sl_height)) / 2);
             
             Style.PaintLayout (context.Widget.Style, context.Drawable, state, true, 
-                context.Area, context.Widget, "text",
+                context.Clip, context.Widget, "text",
                 context.Area.X + x, context.Area.Y + y, first_line_layout);
             
             if (album.ArtistName == null) {
@@ -124,11 +124,11 @@
                 gc.RgbBgColor = fgcolor;
             }
             
-            context.Drawable.DrawLayout (gc, context.Area.X + x, context.Area.Y + y + fl_height, second_line_layout);
+            // We need to clip
+            //context.Drawable.DrawLayout (gc, context.Area.X + x, context.Area.Y + y + fl_height, second_line_layout);
             
-            // Style.PaintLayout (context.Widget.Style, context.Drawable, state, true,
-            //    context.Area, context.Widget, "text",
-            //    context.Area.X + x, context.Area.Y + y + fl_height, second_line_layout);
+            Style.PaintLayout (context.Widget.Style, context.Drawable, state, true, context.Clip, context.Widget, "text",
+               context.Area.X + x, context.Area.Y + y + fl_height, second_line_layout);
         }
     }
-}
+}
\ No newline at end of file

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/TrackListView.cs	Thu Mar 20 22:04:27 2008
@@ -127,7 +127,7 @@
 
         protected override void ChildClassPostRender (Gdk.EventExpose evnt, Cairo.Context cr, Gdk.Rectangle clip)
         {
-            if (evnt.Window == ListWindow && overlay != null) {
+            if (overlay != null) {
                 overlay.Render (Theme, ListAllocation, cr, clip);
             }
         }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/CellContext.cs	Thu Mar 20 22:04:27 2008
@@ -40,9 +40,10 @@
         private Gdk.Drawable drawable;
         private Theme theme;
         private Gdk.Rectangle area;
+        private Gdk.Rectangle clip;
         
         public CellContext (Cairo.Context context, Pango.Layout layout, Gtk.Widget widget,
-            Gdk.Drawable drawable, Theme theme, Gdk.Rectangle area)
+            Gdk.Drawable drawable, Theme theme, Gdk.Rectangle area, Gdk.Rectangle clip)
         {
             this.context = context;
             this.layout = layout;
@@ -50,6 +51,7 @@
             this.drawable = drawable;
             this.theme = theme;
             this.area = area;
+            this.clip = clip;
         }
         
         public Cairo.Context Context {
@@ -75,5 +77,9 @@
         public Gdk.Rectangle Area {
             get { return area; }
         }
+        
+        public Gdk.Rectangle Clip {
+            get { return clip; }
+        }
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnCellText.cs	Thu Mar 20 22:04:27 2008
@@ -65,7 +65,7 @@
                 context.Context.Color = context.Theme.Colors.GetWidgetColor (GtkColorClass.Text, state);
                 context.Context.Fill ();
             } else {
-                Style.PaintLayout(context.Widget.Style, context.Drawable, state, true, context.Area,
+                Style.PaintLayout (context.Widget.Style, context.Drawable, state, true, context.Clip,
                     context.Widget, "text", context.Area.X + 4, context.Area.Y + (((int)cellHeight - text_height) / 2),
                     context.Layout);
             }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ColumnHeaderCellText.cs	Thu Mar 20 22:04:27 2008
@@ -50,41 +50,20 @@
                 return;
             }
             
-            context.Context.Translate (0.5, 0.5);
-
             if (!has_sort) {
                 base.Render (context, state, cellWidth - 10, cellHeight);
                 return;
             }
             
-            int w = (int)(cellHeight / 3.5);
-            int h = (int)((double)w / 1.6);
-            int x1 = (int)cellWidth - w - 10;
-            int x2 = x1 + w;
-            int x3 = x1 + w / 2;
-            int y1 = ((int)cellHeight - h) / 2;
-            int y2 = y1 + h;
+            Gdk.Rectangle alloc = new Gdk.Rectangle ();
+            alloc.Width = (int)(cellHeight / 3.5);
+            alloc.Height = (int)((double)alloc.Width / 1.6);
+            alloc.X = (int)cellWidth - alloc.Width - 10;
+            alloc.Y = ((int)cellHeight - alloc.Height) / 2;
             
-            base.Render (context, state, cellWidth - 2 * w - 10, cellHeight);
-            
-            context.Context.Translate (-0.5, -0.5);
-            
-            if (((ISortableColumn)data_handler ()).SortType == SortType.Ascending) {
-                context.Context.MoveTo (x1, y1);
-                context.Context.LineTo (x2, y1);
-                context.Context.LineTo (x3, y2);
-                context.Context.LineTo (x1, y1);
-            } else {
-                context.Context.MoveTo (x3, y1);
-                context.Context.LineTo (x2, y2);
-                context.Context.LineTo (x1, y2);
-                context.Context.LineTo (x3, y1);
-            }
-                
-            context.Context.Color = new Color (1, 1, 1, 0.4);
-            context.Context.FillPreserve ();
-            context.Context.Color = new Color (0, 0, 0, 1);
-            context.Context.Stroke ();
+            context.Theme.DrawColumnHighlight (context.Context, cellWidth, cellHeight);
+            base.Render (context, state, cellWidth - 2 * alloc.Width - 10, cellHeight);
+            context.Theme.DrawArrow (context.Context, alloc, ((ISortableColumn)data_handler ()).SortType);
         }
         
         protected override string Text {

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView.cs	Thu Mar 20 22:04:27 2008
@@ -34,7 +34,7 @@
         {
             column_layout = new Pango.Layout (PangoContext);
             CanFocus = true;
-            selection_proxy.Changed += delegate { InvalidateListWindow (); };
+            selection_proxy.Changed += delegate { InvalidateList (); };
         }
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_DragAndDrop.cs	Thu Mar 20 22:04:27 2008
@@ -123,7 +123,7 @@
                 StopDragScroll ();
                 drag_reorder_row_index = -1;
                 drag_reorder_motion_y = -1;
-                InvalidateListWindow ();
+                InvalidateList ();
                 return false;
             }
             
@@ -169,10 +169,10 @@
         
         private void DragReorderUpdateRow ()
         {
-            int row = GetRowAtY (drag_reorder_motion_y + list_alloc.Y) - 1;
+            int row = GetRowAtY (drag_reorder_motion_y) - 1;
             if (row != drag_reorder_row_index) {
                 drag_reorder_row_index = row;
-                InvalidateListWindow ();
+                InvalidateList ();
             }   
         }
     }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs	Thu Mar 20 22:04:27 2008
@@ -47,12 +47,9 @@
             public int Index;
         }
         
-        private const int COLUMN_PADDING = 1;
         private static Gdk.Cursor resize_x_cursor = new Gdk.Cursor (Gdk.CursorType.SbHDoubleArrow);
         private static Gdk.Cursor drag_cursor = new Gdk.Cursor (Gdk.CursorType.Fleur);
-        
-        private int column_text_y;
-        private int column_text_height;
+
         private int resizing_column_index = -1;
         private int pressed_column_index = -1;
         private int pressed_column_x_start = -1;
@@ -81,6 +78,10 @@
         
         private void RegenerateColumnCache ()
         {
+            if (!IsRealized) {
+                return;
+            }
+            
             InvalidateColumnCache ();
             
             if (column_controller == null) {
@@ -98,10 +99,10 @@
                 column_cache[i] = new CachedColumn ();
                 column_cache[i].Column = column;
                 
-                column_cache[i].Width = (int)Math.Round (((double)list_alloc.Width * column.Width));
+                column_cache[i].Width = (int)Math.Round (((double)header_interaction_alloc.Width * column.Width));
                 column_cache[i].X1 = i == 0 ? 0 : column_cache[i - 1].X2;
                 column_cache[i].X2 = column_cache[i].X1 + column_cache[i].Width;
-                column_cache[i].ResizeX1 = column_cache[i].X1 + column_cache[i].Width - COLUMN_PADDING;
+                column_cache[i].ResizeX1 = column_cache[i].X2;
                 column_cache[i].ResizeX2 = column_cache[i].ResizeX1 + 2;
                 column_cache[i].Index = i;
                 
@@ -143,7 +144,8 @@
             menu.ShowAll ();
             menu.Popup (null, null, delegate (Menu popup, out int pos_x, out int pos_y, out bool push_in) {
                 int win_x, win_y;
-                header_window.GetOrigin (out win_x, out win_y);
+                GdkWindow.GetOrigin (out win_x, out win_y);
+                
                 pos_x = win_x + x;
                 pos_y = win_y + y;
                 push_in = true;
@@ -173,17 +175,17 @@
 
             even_distribution /= subsequent_columns;
 
-            resizing_column.Column.Width = (resizing_column.Width + resize_delta) / (double)list_alloc.Width;
+            resizing_column.Column.Width = (resizing_column.Width + resize_delta) / (double)list_rendering_alloc.Width;
 
             for (int i = resizing_column_index + 1; i < column_cache.Length; i++) {
                 column_cache[i].Column.Width = (column_cache[i].Width - 
                     (column_cache[i].Column.Width * resize_delta) - 
-                    even_distribution) / (double)list_alloc.Width;
+                    even_distribution) / (double)list_rendering_alloc.Width;
             }
             
             RegenerateColumnCache ();
-            InvalidateHeaderWindow ();
-            InvalidateListWindow ();
+            InvalidateHeader ();
+            InvalidateList ();
         }
         
         private Column GetColumnForResizeHandle (int x)
@@ -193,8 +195,8 @@
             }
             
             foreach (CachedColumn column in column_cache) {
-                if (x >= column.ResizeX1 - 2 + left_border_alloc.Width && 
-                    x <= column.ResizeX2 + 2 + left_border_alloc.Width ) {
+                if (x >= column.ResizeX1 - 2 && 
+                    x <= column.ResizeX2 + 2) {
                     return column.Column;
                 }
             }
@@ -209,11 +211,10 @@
             }
             
             foreach (CachedColumn column in column_cache) {
-                if (x >= column.X1 + left_border_alloc.Width && x <= column.X2 + left_border_alloc.Width) {
+                if (x >= column.X1 && x <= column.X2) {
                     return column.Column;
                 }
             }
-            
             return null;
         }
         
@@ -250,35 +251,20 @@
 #endregion
 
 #region Header
- 
-        private void ShowHideHeader ()
-        {
-            if (header_window == null) {
-                return;
-            }
-            
-            if (header_visible) {
-                header_window.Show ();
-            } else {
-                header_window.Hide ();
-            }
-            
-            MoveResizeWindows (Allocation);
-        }
 
         private int header_height = 0;
         private int HeaderHeight {
             get {
                 if (!header_visible) {
-                    return InnerBorderWidth;
+                    return 0;
                 }
                 
                 if (header_height == 0) {
-                    int w_width;
+                    int w;
+                    int h;
                     column_layout.SetText ("W");
-                    column_layout.GetPixelSize (out w_width, out column_text_height);
-                    header_height = COLUMN_PADDING * 2 + column_text_height;
-                    column_text_y = (header_height / 2) - (column_text_height / 2) - 2;
+                    column_layout.GetPixelSize (out w, out h);
+                    header_height = h;
                     header_height += 10;
                 }
                 
@@ -291,7 +277,7 @@
             get { return header_visible; }
             set { 
                 header_visible = value; 
-                ShowHideHeader ();
+                MoveResize (Allocation);
             }
         }
         

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	Thu Mar 20 22:04:27 2008
@@ -109,7 +109,7 @@
             }
 
             focused_row_index = row_index;
-            InvalidateListWindow ();
+            InvalidateList ();
             return true;
         }
         
@@ -192,54 +192,82 @@
             
             return base.OnKeyPressEvent (press);
         }
+        
+        private static bool IsEventInAlloc (Gdk.EventButton evnt, Gdk.Rectangle alloc)
+        {
+            if (evnt.X < alloc.Left) {
+                return false;
+            } else if (evnt.X > alloc.Right) {
+                return false;
+            } else if (evnt.Y < alloc.Top) {
+                return false;
+            } else if (evnt.Y > alloc.Bottom) {
+                return false;
+            } else {
+                return true;
+            }
+        }
+        
+#region OnButtonPress
 
-        protected override bool OnButtonPressEvent (Gdk.EventButton press)
+        protected override bool OnButtonPressEvent (Gdk.EventButton evnt)
         {
             HasFocus = true;
+            if (IsEventInAlloc (evnt, header_interaction_alloc)) {
+                return OnHeaderButtonPressEvent (evnt);
+            } else if (IsEventInAlloc (evnt, list_interaction_alloc) && model != null) {
+                return OnListButtonPressEvent (evnt);
+            }
+            return true;
+        }
+        
+        private bool OnHeaderButtonPressEvent (Gdk.EventButton evnt)
+        {
+            int x = (int)evnt.X - header_interaction_alloc.X;
+            int y = (int)evnt.Y - header_interaction_alloc.Y;
             
-            if (press.Window == header_window) {
-                if (press.Button == 3 && ColumnController.EnableColumnMenu) {
-                    Column menu_column = GetColumnAt ((int)press.X);
-                    if (menu_column != null) {
-                        OnColumnRightClicked (menu_column, (int)press.X, (int)press.Y);
-                    }
-                    return true;
-                } else if (press.Button != 1) {
-                    return true;
+            if (evnt.Button == 3 && ColumnController.EnableColumnMenu) {
+                Column menu_column = GetColumnAt (x);
+                if (menu_column != null) {
+                    OnColumnRightClicked (menu_column, x + Allocation.X, y + Allocation.Y);
                 }
-                
-                Gtk.Drag.SourceUnset (this);
-                
-                Column column = GetColumnForResizeHandle ((int)press.X);
-                if (column != null) {
-                    resizing_column_index = GetCachedColumnForColumn (column).Index;
-                } else {
-                    column = GetColumnAt ((int)press.X);
-                    if (column != null) {
-                        CachedColumn column_c = GetCachedColumnForColumn (column);
-                        pressed_column_index = column_c.Index;
-                        pressed_column_x_start = (int)press.X;
-                        pressed_column_x_offset = pressed_column_x_start - column_c.X1;
-                    }
-                }
-                
+                return true;
+            } else if (evnt.Button != 1) {
                 return true;
             }
             
-            if (press.Window != list_window || model == null) {
-                return true;
+            Gtk.Drag.SourceUnset (this);
+            
+            Column column = GetColumnForResizeHandle (x);
+            if (column != null) {
+                resizing_column_index = GetCachedColumnForColumn (column).Index;
+            } else {
+                column = GetColumnAt (x);
+                if (column != null) {
+                    CachedColumn column_c = GetCachedColumnForColumn (column);
+                    pressed_column_index = column_c.Index;
+                    pressed_column_x_start = x;
+                    pressed_column_x_offset = pressed_column_x_start - column_c.X1;
+                }
             }
             
+            return true;
+        }
+        
+        private bool OnListButtonPressEvent (Gdk.EventButton evnt)
+        {
+            int y = (int)evnt.Y - list_interaction_alloc.Y;
+            
             GrabFocus ();
             
-            int row_index = GetRowAtY ((int)press.Y);
+            int row_index = GetRowAtY (y);
 
             if (row_index >= Model.Count) {
                 return true;
             }
             
-            if (press.Button == 1 && press.Type != Gdk.EventType.TwoButtonPress && 
-                (press.State & Gdk.ModifierType.ControlMask) == 0 && Selection.Contains (row_index)) {
+            if (evnt.Button == 1 && evnt.Type != Gdk.EventType.TwoButtonPress && 
+                (evnt.State & Gdk.ModifierType.ControlMask) == 0 && Selection.Contains (row_index)) {
                 return true;
             }
 
@@ -248,23 +276,23 @@
                 return true;
             }
 
-            if (press.Button == 1 && press.Type == Gdk.EventType.TwoButtonPress && 
+            if (evnt.Button == 1 && evnt.Type == Gdk.EventType.TwoButtonPress && 
                 row_index == last_click_row_index) {
                 OnRowActivated ();
                 last_click_row_index = -1;
             } else {
-                if ((press.State & Gdk.ModifierType.ControlMask) != 0) {
-                    if (press.Button == 3) {
+                if ((evnt.State & Gdk.ModifierType.ControlMask) != 0) {
+                    if (evnt.Button == 3) {
                         if (!Selection.Contains (row_index)) {
                             Selection.Select (row_index);
                         }
                     } else {
                         Selection.ToggleSelect (row_index);
                     }
-                } else if ((press.State & Gdk.ModifierType.ShiftMask) != 0) {
+                } else if ((evnt.State & Gdk.ModifierType.ShiftMask) != 0) {
                     Selection.SelectFromFirst (row_index, true);
                 } else {
-                    if (press.Button == 3) {
+                    if (evnt.Button == 3) {
                         if (!Selection.Contains (row_index)) {
                             Selection.Clear (false);
                             Selection.Select (row_index);
@@ -277,7 +305,7 @@
 
                 FocusRow (row_index);
 
-                if (press.Button == 3) {
+                if (evnt.Button == 3) {
                     last_click_row_index = -1;
                     OnPopupMenu ();
                 } else {
@@ -285,122 +313,147 @@
                 }
             }
             
-            InvalidateListWindow ();
-            
+            InvalidateList ();
             return true;
         }
         
+#endregion
+
+#region OnButtonRelease
+        
         protected override bool OnButtonReleaseEvent (Gdk.EventButton evnt)
         {
-            if (evnt.Window == header_window) {
-                OnDragSourceSet ();
-                
-                if (resizing_column_index >= 0) {
-                    pressed_column_index = -1;
-                    resizing_column_index = -1;
-                    header_window.Cursor = null;
-                    return true;
-                }
-                
-                if (pressed_column_index >= 0 && pressed_column_is_dragging) {
-                    pressed_column_is_dragging = false;
-                    pressed_column_index = -1;
-                    header_window.Cursor = null;
-                    InvalidateHeaderWindow ();
-                    InvalidateListWindow ();
-                    return true;
-                }
+            OnDragSourceSet ();
             
-                Column column = column_cache[pressed_column_index].Column;
-                if (column != null && Model is ISortable && column is ISortableColumn) {
-                    ((ISortable)Model).Sort ((ISortableColumn)column);
-                    Model.Reload ();
-                    InvalidateHeaderWindow ();
-                }
-                
+            if (resizing_column_index >= 0) {
+                pressed_column_index = -1;
+                resizing_column_index = -1;
+                GdkWindow.Cursor = null;
+                return true;
+            }
+            
+            if (pressed_column_index >= 0 && pressed_column_is_dragging) {
+                pressed_column_is_dragging = false;
                 pressed_column_index = -1;
-            } else if (evnt.Window == list_window && model != null &&
+                GdkWindow.Cursor = null;
+                InvalidateHeader ();
+                InvalidateList ();
+                return true;
+            }
+            
+            if (IsEventInAlloc (evnt, header_interaction_alloc)) {
+                return OnHeaderButtonRelease (evnt);
+            } else if (IsEventInAlloc (evnt, list_interaction_alloc) && model != null &&
                 (evnt.State & (Gdk.ModifierType.ShiftMask | Gdk.ModifierType.ControlMask)) == 0) {
-                GrabFocus ();
-                
-                int row_index = GetRowAtY ((int)evnt.Y);
+                return OnListButtonRelease (evnt);
+            }
 
-                if (row_index >= Model.Count) {
-                    return true;
-                }
+            return true;
+        }
+        
+        private bool OnHeaderButtonRelease (Gdk.EventButton evnt)
+        {
+            Column column = column_cache[pressed_column_index].Column;
+            if (column != null && Model is ISortable && column is ISortableColumn) {
+                ((ISortable)Model).Sort ((ISortableColumn)column);
+                Model.Reload ();
+                InvalidateHeader ();
+            }
+            
+            pressed_column_index = -1;
+            return true;
+        }
+        
+        private bool OnListButtonRelease (Gdk.EventButton evnt)
+        {
+            int y = (int)evnt.Y - list_interaction_alloc.Y;
+            
+            GrabFocus ();
+            
+            int row_index = GetRowAtY (y);
 
-                object item = model[row_index];
-                if (item == null) {
-                    return true;
-                }
-                
-                if (Selection.Contains (row_index) && Selection.Count > 1) {
-                    Selection.Clear (false);
-                    Selection.Select (row_index);
-                    FocusRow (row_index);
-                    return true;
-                }
+            if (row_index >= Model.Count) {
+                return true;
             }
 
+            object item = model[row_index];
+            if (item == null) {
+                return true;
+            }
+            
+            if (Selection.Contains (row_index) && Selection.Count > 1) {
+                Selection.Clear (false);
+                Selection.Select (row_index);
+                FocusRow (row_index);
+            }
             return true;
         }
         
+#endregion
+        
         protected override bool OnMotionNotifyEvent (Gdk.EventMotion evnt)
         {
-            if (evnt.Window == header_window) {
-                if (pressed_column_index >= 0 && !pressed_column_is_dragging && 
-                    Gtk.Drag.CheckThreshold (this, pressed_column_x_start, 0, (int)evnt.X, 0)) {
-                    pressed_column_is_dragging = true;
-                    InvalidateHeaderWindow ();
-                    InvalidateListWindow ();
-                }
+            int x = (int)evnt.X - header_interaction_alloc.X;
+            
+            if (pressed_column_index >= 0 && !pressed_column_is_dragging && 
+                Gtk.Drag.CheckThreshold (this, pressed_column_x_start, 0, x, 0)) {
+                pressed_column_is_dragging = true;
+                InvalidateHeader ();
+                InvalidateList ();
+            }
+            
+            if (pressed_column_is_dragging) {
+                GdkWindow.Cursor = drag_cursor;
                 
-                if (pressed_column_is_dragging) {
-                    header_window.Cursor = drag_cursor;
-                    
-                    Column swap_column = GetColumnAt ((int)evnt.X);
+                Column swap_column = GetColumnAt (x);
+                
+                if (swap_column != null) {
+                    CachedColumn swap_column_c = GetCachedColumnForColumn (swap_column);
+                    bool reorder = false;
                     
-                    if (swap_column != null) {
-                        CachedColumn swap_column_c = GetCachedColumnForColumn (swap_column);
-                        bool reorder = false;
-                        
-                        if (swap_column_c.Index < pressed_column_index) {
-                            // Moving from right to left
-                            reorder = pressed_column_x_drag <= swap_column_c.X1 + swap_column_c.Width / 2;
-                        } else if (swap_column_c.Index > pressed_column_index) {
-                            // Moving from left to right
-                            reorder = pressed_column_x_drag + column_cache[pressed_column_index].Width >= 
-                                swap_column_c.X1 + swap_column_c.Width / 2;
-                        }
-                        
-                        if (reorder) {
-                            int actual_pressed_index = ColumnController.IndexOf (column_cache[pressed_column_index].Column);
-                            int actual_swap_index = ColumnController.IndexOf (swap_column_c.Column);
-                            ColumnController.Reorder (actual_pressed_index, actual_swap_index);
-                            pressed_column_index = swap_column_c.Index;
-                            RegenerateColumnCache ();
-                        }
+                    if (swap_column_c.Index < pressed_column_index) {
+                        // Moving from right to left
+                        reorder = pressed_column_x_drag <= swap_column_c.X1 + swap_column_c.Width / 2;
+                    } else if (swap_column_c.Index > pressed_column_index) {
+                        // Moving from left to right
+                        reorder = pressed_column_x_drag + column_cache[pressed_column_index].Width >= 
+                            swap_column_c.X1 + swap_column_c.Width / 2;
                     }
                     
-                    pressed_column_x_drag = (int)evnt.X - pressed_column_x_offset;
-                    
-                    InvalidateHeaderWindow ();
-                    InvalidateListWindow ();
-                    return true;
+                    if (reorder) {
+                        int actual_pressed_index = ColumnController.IndexOf (column_cache[pressed_column_index].Column);
+                        int actual_swap_index = ColumnController.IndexOf (swap_column_c.Column);
+                        ColumnController.Reorder (actual_pressed_index, actual_swap_index);
+                        pressed_column_index = swap_column_c.Index;
+                        RegenerateColumnCache ();
+                    }
                 }
-            
-                header_window.Cursor = resizing_column_index >= 0 || GetColumnForResizeHandle ((int)evnt.X) != null 
-                    ? resize_x_cursor 
-                    : null;
                 
-                if (resizing_column_index >= 0) {
-                    ResizeColumn (evnt.X);
-                }
+                pressed_column_x_drag = x - pressed_column_x_offset;
+                
+                InvalidateHeader ();
+                InvalidateList ();
+                return true;
+            }
+        
+            GdkWindow.Cursor = resizing_column_index >= 0 || GetColumnForResizeHandle (x) != null 
+                ? resize_x_cursor 
+                : null;
+            
+            if (resizing_column_index >= 0) {
+                ResizeColumn ((double)x);
             }
             
             return true;
         }
         
+        protected override bool OnLeaveNotifyEvent (Gdk.EventCrossing evnt)
+        {
+            GdkWindow.Cursor = null;
+            return base.OnLeaveNotifyEvent (evnt);
+        }
+
+        
         protected override bool OnFocusInEvent (Gdk.EventFocus evnt)
         {
             return base.OnFocusInEvent (evnt);
@@ -461,7 +514,7 @@
         
         private void OnAdjustmentChanged (object o, EventArgs args)
         {
-            InvalidateListWindow ();
+            InvalidateList ();
         }
         
         public void ScrollTo (double val)

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs	Thu Mar 20 22:04:27 2008
@@ -148,7 +148,7 @@
                 row_sensitive_property_info = null;
                 row_sensitive_property_invalid = false;
                 
-                InvalidateListWindow ();
+                InvalidateList ();
             }
         }
         

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs	Thu Mar 20 22:04:27 2008
@@ -30,6 +30,7 @@
 using System.Collections.Generic;
 
 using Gtk;
+using Gdk;
 using Cairo;
 
 using Hyena.Gui;
@@ -40,107 +41,76 @@
 {
     public partial class ListView<T> : Container
     {
-        private const int InnerBorderWidth = 4;
-        private const int FooterHeight = InnerBorderWidth;
-        
         private Theme theme;
         protected Theme Theme {
             get { return theme; }
         }
 
-        private Cairo.Context list_cr;
-        private Cairo.Context header_cr;
-        private Cairo.Context footer_cr;
-        private Cairo.Context left_border_cr;
-        private Cairo.Context right_border_cr;
+        private Cairo.Context cairo_context;
         
         private Pango.Layout header_pango_layout;
         private Pango.Layout list_pango_layout;
 
-        public new void QueueDraw ()
-        {
-            base.QueueDraw ();
-            
-            InvalidateHeaderWindow ();
-            InvalidateListWindow ();
-            InvalidateFooterWindow ();
-        }
-
         protected virtual void ChildClassPostRender (Gdk.EventExpose evnt, Cairo.Context cr, Gdk.Rectangle clip)
         {
         }
          
         protected override bool OnExposeEvent (Gdk.EventExpose evnt)
-        {            
+        {         
+            cairo_context = Gdk.CairoHelper.Create (evnt.Window);
+               
             foreach (Gdk.Rectangle rect in evnt.Region.GetRectangles ()) {
                 PaintRegion (evnt, rect);
             }
             
+            ((IDisposable)cairo_context.Target).Dispose ();
+            ((IDisposable)cairo_context).Dispose ();
+            
             return true;
         }
                 
         private void PaintRegion (Gdk.EventExpose evnt, Gdk.Rectangle clip)
         {
-            Cairo.Context cr = Gdk.CairoHelper.Create (evnt.Window);
-            cr.Rectangle (clip.X, clip.Y, clip.Width, clip.Height);
-            cr.Clip ();
-
-            if (evnt.Window == header_window) {
-                header_cr = cr;
-                if (header_pango_layout == null) {
-                    header_pango_layout = PangoCairoHelper.CreateLayout (header_cr);
-                }
-                PaintHeader (evnt.Area);
-            } else if (evnt.Window == footer_window) {
-                footer_cr = cr;
-                PaintFooter (evnt, clip);
-            } else if (evnt.Window == left_border_window) {
-                left_border_cr = cr;
-                PaintLeftBorder(evnt, clip);
-            } else if (evnt.Window == right_border_window) {
-                right_border_cr = cr;
-                PaintRightBorder(evnt, clip);
-            } else if (evnt.Window == list_window) {
-                list_cr = cr;
-                if (list_pango_layout == null) {
-                    list_pango_layout = PangoCairoHelper.CreateLayout (list_cr);
-                }
-                PaintList (evnt, clip);
-            }
-
-            ChildClassPostRender (evnt, cr, clip);
-            
-            ((IDisposable)cr.Target).Dispose ();
-            ((IDisposable)cr).Dispose ();
+            Theme.DrawFrameBackground (cairo_context, Allocation, true);
+            if (header_visible && column_controller != null) {
+                PaintHeader (clip);
+            }
+            PaintList (evnt, clip);
+            Theme.DrawFrameBorder (cairo_context, Allocation);
+            cairo_context.Translate (list_rendering_alloc.X, list_rendering_alloc.Y);
+            ChildClassPostRender (evnt, cairo_context, clip);
         }
         
         private void PaintHeader (Gdk.Rectangle clip)
         {
-            Theme.DrawHeaderBackground (header_cr, header_alloc, 2, header_visible);
+            clip.Intersect (header_rendering_alloc);
+            cairo_context.Rectangle (clip.X, clip.Y, clip.Width, clip.Height + Theme.BorderWidth);
+            cairo_context.Clip ();
+            
+            header_pango_layout = PangoCairoHelper.CreateLayout (cairo_context);
+            Theme.DrawHeaderBackground (cairo_context, header_rendering_alloc);
             
-            if (column_controller == null || !header_visible) {
-                return;
-            }
-                
             Gdk.Rectangle cell_area = new Gdk.Rectangle ();
-            cell_area.Y = column_text_y;
-            cell_area.Height = HeaderHeight - column_text_y;
+            cell_area.Y = header_rendering_alloc.Y;
+            cell_area.Height = header_rendering_alloc.Height;
 
             for (int ci = 0; ci < column_cache.Length; ci++) {
                 if (pressed_column_is_dragging && pressed_column_index == ci) {
                     continue;
                 }
                 
-                cell_area.X = column_cache[ci].X1 + left_border_alloc.Width;
-                cell_area.Width = column_cache[ci].Width - COLUMN_PADDING;
+                cell_area.X = column_cache[ci].X1 + Theme.TotalBorderWidth + header_rendering_alloc.X;
+                cell_area.Width = column_cache[ci].Width;
                 PaintHeaderCell (cell_area, clip, ci, false);
             }
             
             if (pressed_column_is_dragging && pressed_column_index >= 0) {
-                cell_area.X = pressed_column_x_drag + left_border_alloc.Width;
-                cell_area.Width = column_cache[pressed_column_index].Width - COLUMN_PADDING;
+                cell_area.X = pressed_column_x_drag + Allocation.X;
+                cell_area.Width = column_cache[pressed_column_index].Width;
                 PaintHeaderCell (cell_area, clip, pressed_column_index, true);
             }
+            
+            cairo_context.ResetClip ();
         }
         
         private void PaintHeaderCell (Gdk.Rectangle area, Gdk.Rectangle clip, int ci, bool dragging)
@@ -148,46 +118,38 @@
             ColumnCell cell = column_cache[ci].Column.HeaderCell;
             
             if (dragging) {
-                if (ci < column_cache.Length - 1) {
-                    Theme.DrawHeaderSeparator (header_cr, header_alloc, 
-                        column_cache[ci].ResizeX1 - 1 + left_border_alloc.Width, 2);
-                }
-            
-                Theme.DrawColumnHighlight (header_cr, area, 3, 
+                Theme.DrawColumnHighlight (cairo_context, area, 
                     CairoExtensions.ColorShade (Theme.Colors.GetWidgetColor (GtkColorClass.Dark, StateType.Normal), 0.9));
                     
                 Cairo.Color stroke_color = CairoExtensions.ColorShade (Theme.Colors.GetWidgetColor (
                     GtkColorClass.Base, StateType.Normal), 0.0);
                 stroke_color.A = 0.3;
                 
-                header_cr.Color = stroke_color;
-                header_cr.MoveTo (area.X - 1.0, area.Y + 1.0);
-                header_cr.LineTo (area.X - 1.0, area.Y + area.Height);
-                header_cr.MoveTo (area.X + area.Width, area.Y + 1.0);
-                header_cr.LineTo (area.X + area.Width, area.Y + area.Height);
-                header_cr.Stroke ();
+                cairo_context.Color = stroke_color;
+                cairo_context.MoveTo (area.X + 0.5, area.Y + 1.0);
+                cairo_context.LineTo (area.X + 0.5, area.Bottom);
+                cairo_context.MoveTo (area.Right - 0.5, area.Y + 1.0);
+                cairo_context.LineTo (area.Right - 0.5, area.Bottom);
+                cairo_context.Stroke ();
             }
             
-            if (cell is ColumnHeaderCellText && Model is ISortable) {
-                bool has_sort = ((ISortable)Model).SortColumn == column_cache[ci].Column as ISortableColumn 
-                    && column_cache[ci].Column is ISortableColumn;
-                ((ColumnHeaderCellText)cell).HasSort = has_sort;
-                if (has_sort) {
-                    Theme.DrawColumnHighlight (header_cr, area, 3);
-                }
+            ColumnHeaderCellText column_cell = cell as ColumnHeaderCellText;
+            ISortable sortable = Model as ISortable;
+            if (column_cell != null && sortable != null) {
+                ISortableColumn sort_column = column_cache[ci].Column as ISortableColumn;
+                column_cell.HasSort = sort_column != null && sortable.SortColumn == sort_column;
             }
             
             if (cell != null) {
-                header_cr.Save ();
-                header_cr.Translate (area.X, area.Y);
-                cell.Render (new CellContext (header_cr, header_pango_layout, this, header_window, 
-                    theme, area), StateType.Normal, area.Width, area.Height);
-                header_cr.Restore ();
+                cairo_context.Save ();
+                cairo_context.Translate (area.X, area.Y);
+                cell.Render (new CellContext (cairo_context, header_pango_layout, this, GdkWindow, 
+                    theme, area, clip), StateType.Normal, area.Width, area.Height);
+                cairo_context.Restore ();
             }
             
             if (!dragging && ci < column_cache.Length - 1) {
-                Theme.DrawHeaderSeparator (header_cr, header_alloc, 
-                    column_cache[ci].ResizeX1 - 1 + left_border_alloc.Width, 2);
+                Theme.DrawHeaderSeparator (cairo_context, area, area.Right);
             }
         }
 
@@ -196,6 +158,12 @@
             if (model == null) {
                 return;
             }
+            
+            clip.Intersect (list_rendering_alloc);
+            cairo_context.Rectangle (clip.X, clip.Y, clip.Width, clip.Height);
+            cairo_context.Clip ();
+            
+            list_pango_layout = PangoCairoHelper.CreateLayout (cairo_context);
 
             int vadjustment_value = (int)vadjustment.Value;
             int first_row = vadjustment_value / RowHeight;
@@ -204,10 +172,10 @@
             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.Width = list_rendering_alloc.Width;
             single_list_alloc.Height = RowHeight;
-            single_list_alloc.X = list_alloc.X;
-            single_list_alloc.Y = list_alloc.Y - vadjustment_value + (first_row * single_list_alloc.Height);
+            single_list_alloc.X = list_rendering_alloc.X;
+            single_list_alloc.Y = list_rendering_alloc.Y - vadjustment_value + (first_row * single_list_alloc.Height);
             
             int selection_height = 0;
             int selection_y = 0;
@@ -227,19 +195,19 @@
                     }
                 } else {
                     if (rules_hint && ri % 2 != 0) {
-                        Theme.DrawRowRule (list_cr, single_list_alloc.X, single_list_alloc.Y, 
+                        Theme.DrawRowRule (cairo_context, single_list_alloc.X, single_list_alloc.Y, 
                             single_list_alloc.Width, single_list_alloc.Height);
                     }
                     
                     if (ri == drag_reorder_row_index && Reorderable) {
-                        list_cr.Save ();
-                        list_cr.LineWidth = 1.0;
-                        list_cr.Antialias = Antialias.None;
-                        list_cr.MoveTo (single_list_alloc.Left, single_list_alloc.Top);
-                        list_cr.LineTo (single_list_alloc.Right, single_list_alloc.Top);
-                        list_cr.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal);
-                        list_cr.Stroke ();
-                        list_cr.Restore ();
+                        cairo_context.Save ();
+                        cairo_context.LineWidth = 1.0;
+                        cairo_context.Antialias = Antialias.None;
+                        cairo_context.MoveTo (single_list_alloc.Left, single_list_alloc.Top);
+                        cairo_context.LineTo (single_list_alloc.Right, single_list_alloc.Top);
+                        cairo_context.Color = Theme.Colors.GetWidgetColor (GtkColorClass.Text, StateType.Normal);
+                        cairo_context.Stroke ();
+                        cairo_context.Restore ();
                     }
                     
                     if (focused_row_index == ri && !Selection.Contains (ri) && HasFocus) {
@@ -253,14 +221,14 @@
                             corners ^= CairoCorners.BottomLeft | CairoCorners.BottomRight;
                         }
                         
-                        Theme.DrawRowSelection (list_cr, single_list_alloc.X, single_list_alloc.Y, 
+                        Theme.DrawRowSelection (cairo_context, single_list_alloc.X, single_list_alloc.Y, 
                             single_list_alloc.Width, single_list_alloc.Height, false, true, 
                             Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected), corners);
                     }
                     
                     if (selection_height > 0) {
                         Theme.DrawRowSelection (
-                            list_cr, list_alloc.X, list_alloc.Y + selection_y, list_alloc.Width, selection_height);
+                            cairo_context, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height);
                         selection_height = 0;
                     }
                     
@@ -271,21 +239,22 @@
             }
             
             if (selection_height > 0) {
-                Theme.DrawRowSelection (list_cr, list_alloc.X, list_alloc.Y + selection_y, 
-                    list_alloc.Width, selection_height);
+                Theme.DrawRowSelection (cairo_context, list_rendering_alloc.X, selection_y, 
+                    list_rendering_alloc.Width, selection_height);
             }
             
             if (Selection.Count > 1 && !selected_focus_alloc.Equals (Gdk.Rectangle.Zero) && HasFocus) {
-                Theme.DrawRowSelection (list_cr, selected_focus_alloc.X, selected_focus_alloc.Y, 
+                Theme.DrawRowSelection (cairo_context, selected_focus_alloc.X, selected_focus_alloc.Y, 
                     selected_focus_alloc.Width, selected_focus_alloc.Height, false, true, 
                     Theme.Colors.GetWidgetColor (GtkColorClass.Dark, StateType.Selected));
             }
             
             foreach (int ri in selected_rows) {
-                single_list_alloc.Y = ri * single_list_alloc.Height - vadjustment_value;
+                single_list_alloc.Y = list_rendering_alloc.Y + ri * single_list_alloc.Height - vadjustment_value;
                 PaintRow (ri, clip, single_list_alloc, StateType.Selected);
             }
             
+            cairo_context.ResetClip ();
             PaintDraggingColumn (evnt, clip);
         }
 
@@ -308,14 +277,14 @@
                 }
                 
                 cell_area.Width = column_cache[ci].Width;
-                cell_area.X = column_cache[ci].X1;
-                PaintCell (item, ci, row_index, cell_area, cell_area, sensitive ? state : StateType.Insensitive, false);
+                cell_area.X = column_cache[ci].X1 + area.X;
+                PaintCell (item, ci, row_index, cell_area, clip, sensitive ? state : StateType.Insensitive, false);
             }
             
-            if (pressed_column_is_dragging && pressed_column_index >= 0) {   
+            if (pressed_column_is_dragging && pressed_column_index >= 0) {
                 cell_area.Width = column_cache[pressed_column_index].Width;
-                cell_area.X = pressed_column_x_drag;
-                PaintCell (item, pressed_column_index, row_index, cell_area, cell_area, state, true);
+                cell_area.X = pressed_column_x_drag + Allocation.X;
+                PaintCell (item, pressed_column_index, row_index, cell_area, clip, state, true);
             }
         }
         
@@ -328,16 +297,16 @@
             if (dragging) {
                 Cairo.Color fill_color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
                 fill_color.A = 0.5;
-                list_cr.Color = fill_color;
-                list_cr.Rectangle (area.X, area.Y, area.Width, area.Height);
-                list_cr.Fill ();
+                cairo_context.Color = fill_color;
+                cairo_context.Rectangle (area.X, area.Y, area.Width, area.Height);
+                cairo_context.Fill ();
             }
             
-            list_cr.Save ();
-            list_cr.Translate (clip.X, clip.Y);
-            cell.Render (new CellContext (list_cr, list_pango_layout, this, list_window, theme, area), 
+            cairo_context.Save ();
+            cairo_context.Translate (area.X, area.Y);
+            cell.Render (new CellContext (cairo_context, list_pango_layout, this, GdkWindow, theme, area, clip), 
                 dragging ? StateType.Normal : state, area.Width, area.Height);
-            list_cr.Restore ();
+            cairo_context.Restore ();
         }
         
         private void PaintDraggingColumn (Gdk.EventExpose evnt, Gdk.Rectangle clip)
@@ -348,7 +317,7 @@
             
             CachedColumn column = column_cache[pressed_column_index];
             
-            int x = pressed_column_x_drag;
+            int x = pressed_column_x_drag + Allocation.X + 1;
             
             Cairo.Color fill_color = Theme.Colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal);
             fill_color.A = 0.45;
@@ -357,54 +326,34 @@
                 GtkColorClass.Base, StateType.Normal), 0.0);
             stroke_color.A = 0.3;
             
-            list_cr.Rectangle (x, list_alloc.Y, column.Width, list_alloc.Height);
-            list_cr.Color = fill_color;
-            list_cr.Fill ();
-            
-            list_cr.MoveTo (x, list_alloc.Y);
-            list_cr.LineTo (x, list_alloc.Y + list_alloc.Height - 1.0);
-            list_cr.LineTo (x + column.Width, list_alloc.Y + list_alloc.Height - 1.0);
-            list_cr.LineTo (x + column.Width, list_alloc.Y);
-            
-            list_cr.Color = stroke_color;
-            list_cr.Antialias = Cairo.Antialias.None;
-            list_cr.LineWidth = 1.0;
-            list_cr.Stroke ();
-        }
-        
-        private void PaintLeftBorder (Gdk.EventExpose evnt, Gdk.Rectangle clip)
-        {
-            Theme.DrawLeftBorder (left_border_cr, left_border_alloc);
-        }
-        
-        private void PaintRightBorder (Gdk.EventExpose evnt, Gdk.Rectangle clip)
-        {
-            Theme.DrawRightBorder (right_border_cr, right_border_alloc);
-        }
-        
-        private void PaintFooter (Gdk.EventExpose evnt, Gdk.Rectangle clip)
-        {
-            Theme.DrawFooter (footer_cr, footer_alloc);
-        }
-        
-        protected void InvalidateListWindow ()
-        {
-            if (list_window != null) {
-                list_window.InvalidateRect (list_alloc, false);
-            }
+            cairo_context.Rectangle (x, header_rendering_alloc.Bottom, column.Width,
+                list_rendering_alloc.Bottom - header_rendering_alloc.Bottom);
+            cairo_context.Color = fill_color;
+            cairo_context.Fill ();
+            
+            cairo_context.MoveTo (x - 0.5, header_rendering_alloc.Bottom + 0.5);
+            cairo_context.LineTo (x - 0.5, list_rendering_alloc.Bottom + 0.5);
+            cairo_context.LineTo (x + column.Width - 1.5, list_rendering_alloc.Bottom + 0.5);
+            cairo_context.LineTo (x + column.Width - 1.5, header_rendering_alloc.Bottom + 0.5);
+            
+            cairo_context.Color = stroke_color;
+            cairo_context.LineWidth = 1.0;
+            cairo_context.Stroke ();
         }
         
-        protected void InvalidateHeaderWindow()
+        private void InvalidateList ()
         {
-            if (header_window != null) {
-                header_window.InvalidateRect (header_alloc, false);
+            if (IsRealized) {
+                GdkWindow.InvalidateRect (list_rendering_alloc, true);
+                QueueDraw ();
             }
         }
         
-        protected void InvalidateFooterWindow ()
+        private void InvalidateHeader ()
         {
-            if (footer_window != null) {
-                footer_window.InvalidateRect (footer_alloc, false);
+            if (IsRealized) {
+                GdkWindow.InvalidateRect (header_rendering_alloc, true);
+                QueueDraw ();
             }
         }
         
@@ -413,7 +362,7 @@
             get { return rules_hint; }
             set { 
                 rules_hint = value; 
-                InvalidateListWindow();
+                QueueDraw ();
             }
         }
         

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs	Thu Mar 20 22:04:27 2008
@@ -27,6 +27,7 @@
 //
 
 using System;
+using Gdk;
 using Gtk;
 
 using Hyena.Gui.Theming;
@@ -35,143 +36,47 @@
 {
     public partial class ListView<T> : Container
     {
-        private Gdk.Window list_window;
-        private Gdk.Window header_window;
-        private Gdk.Window footer_window;
-        private Gdk.Window left_border_window;
-        private Gdk.Window right_border_window;
-
-        protected Gdk.Window ListWindow {
-            get { return list_window; }
-        }
-
-        protected Gdk.Window HeaderWindow {
-            get { return header_window; }
-        }
+        private Rectangle list_rendering_alloc;
+        private Rectangle header_rendering_alloc;
+        private Rectangle list_interaction_alloc;
+        private Rectangle header_interaction_alloc;
         
-        private Gdk.Rectangle list_alloc;
-        private Gdk.Rectangle header_alloc;
-        private Gdk.Rectangle footer_alloc;
-        private Gdk.Rectangle left_border_alloc;
-        private Gdk.Rectangle right_border_alloc;
+        private Gdk.Window event_window;
         
         protected Gdk.Rectangle ListAllocation {
-            get { return list_alloc; }
+            get { return list_rendering_alloc; }
         }
        
         protected override void OnRealized ()
         {
-            WidgetFlags |= WidgetFlags.Realized;
+            WidgetFlags |= WidgetFlags.Realized | WidgetFlags.NoWindow;
             
-            Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
+            GdkWindow = Parent.GdkWindow;
+            theme = new GtkTheme (this);
+            //graphics.RefreshColors ();
+            
+            WindowAttr attributes = new WindowAttr ();
             attributes.WindowType = Gdk.WindowType.Child;
             attributes.X = Allocation.X;
             attributes.Y = Allocation.Y;
             attributes.Width = Allocation.Width;
             attributes.Height = Allocation.Height;
-            attributes.Visual = Visual;
-            attributes.Wclass = Gdk.WindowClass.InputOutput;
-            attributes.Colormap = Colormap;
-            attributes.EventMask = (int)Gdk.EventMask.VisibilityNotifyMask;
-            
-            Gdk.WindowAttributesType attributes_mask = 
-                Gdk.WindowAttributesType.X | 
-                Gdk.WindowAttributesType.Y | 
-                Gdk.WindowAttributesType.Visual | 
-                Gdk.WindowAttributesType.Colormap;
-                
-            GdkWindow = new Gdk.Window (Parent.GdkWindow, attributes, attributes_mask);
-            GdkWindow.UserData = Handle;
-            
-            // left border window
-            attributes.X = 0;
-            attributes.Y = HeaderHeight;
-            attributes.Width = InnerBorderWidth;
-            attributes.Height = Allocation.Height - HeaderHeight - FooterHeight;
-            attributes.EventMask = (int)(
-                Gdk.EventMask.VisibilityNotifyMask |
-                Gdk.EventMask.ExposureMask);
-            
-            left_border_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
-            left_border_window.UserData = Handle;
-             
-            // right border window
-            attributes.X = Allocation.Width - 2 * InnerBorderWidth;
-            attributes.Y = HeaderHeight;
-            attributes.Width = InnerBorderWidth;
-            attributes.Height = Allocation.Height - HeaderHeight - FooterHeight;
+            attributes.Wclass = WindowClass.InputOnly;
             attributes.EventMask = (int)(
-                Gdk.EventMask.VisibilityNotifyMask |
-                Gdk.EventMask.ExposureMask);
-            
-            right_border_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
-            right_border_window.UserData = Handle;
+                GdkWindow.Events |
+                EventMask.PointerMotionMask |
+                EventMask.KeyPressMask |
+                EventMask.KeyReleaseMask |
+                EventMask.ButtonPressMask |
+                EventMask.ButtonReleaseMask |
+                EventMask.LeaveNotifyMask |
+                EventMask.ExposureMask);
             
-            // header window
-            attributes.X = 0;
-            attributes.Y = 0;
-            attributes.Width = Allocation.Width;
-            attributes.Height = HeaderHeight;
-            attributes.EventMask = (int)(
-                Gdk.EventMask.ExposureMask |
-                Gdk.EventMask.ScrollMask |
-                Gdk.EventMask.ButtonPressMask |
-                Gdk.EventMask.ButtonReleaseMask |
-                Gdk.EventMask.KeyPressMask |
-                Gdk.EventMask.KeyReleaseMask |
-                Gdk.EventMask.PointerMotionMask |
-                Events);
-                
-            header_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
-            header_window.UserData = Handle;
-            
-            // footer window
-            attributes.X = 0;
-            attributes.Y = Allocation.Height - FooterHeight - HeaderHeight;
-            attributes.Width = Allocation.Width;
-            attributes.Height = FooterHeight;
-            attributes.EventMask = (int)(
-                Gdk.EventMask.ExposureMask |
-                Events);
-                
-            footer_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
-            footer_window.UserData = Handle;
-            
-            // list window
-            attributes.X = InnerBorderWidth;
-            attributes.Y = HeaderHeight;
-            attributes.Width = Allocation.Width - 2 * InnerBorderWidth;
-            attributes.Height = Allocation.Height - HeaderHeight - FooterHeight;
-            attributes.EventMask = (int)(
-                Gdk.EventMask.ExposureMask |
-                Gdk.EventMask.ScrollMask |
-                Gdk.EventMask.PointerMotionMask |
-                Gdk.EventMask.EnterNotifyMask |
-                Gdk.EventMask.LeaveNotifyMask |
-                Gdk.EventMask.ButtonPressMask |
-                Gdk.EventMask.ButtonReleaseMask |
-                Events);
-                
-            list_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
-            list_window.UserData = Handle;
-            
-            // style and move the windows
-            Style = Style.Attach (GdkWindow);
-            GdkWindow.SetBackPixmap (null, false);
-            
-            Style.SetBackground (GdkWindow, StateType.Normal);
-            Style.SetBackground (header_window, StateType.Normal);
-            Style.SetBackground (footer_window, StateType.Normal);
-            
-            left_border_window.Background = Style.Base (State);
-            right_border_window.Background = Style.Base (State);
-            list_window.Background = Style.Base (State);
+            WindowAttributesType attributes_mask =
+                WindowAttributesType.X | WindowAttributesType.Y | WindowAttributesType.Wmclass;
             
-            MoveResizeWindows (Allocation);
-            
-            // context for drawing theme parts
-            theme = new GtkTheme (this);
-            //graphics.RefreshColors ();
+            event_window = new Gdk.Window (GdkWindow, attributes, attributes_mask);
+            event_window.UserData = Handle;
             
             OnDragSourceSet ();
         }
@@ -180,25 +85,9 @@
         {
             WidgetFlags ^= WidgetFlags.Realized;
             
-            left_border_window.UserData = IntPtr.Zero;
-            left_border_window.Destroy ();
-            left_border_window = null;
-            
-            right_border_window.UserData = IntPtr.Zero;
-            right_border_window.Destroy ();
-            right_border_window = null;
-            
-            header_window.UserData = IntPtr.Zero;
-            header_window.Destroy ();
-            header_window = null;
-            
-            footer_window.UserData = IntPtr.Zero;
-            footer_window.Destroy ();
-            footer_window = null;
-            
-            list_window.UserData = IntPtr.Zero;
-            list_window.Destroy ();
-            list_window = null;
+            event_window.UserData = IntPtr.Zero;
+            event_window.Destroy ();
+            event_window = null;
             
             base.OnUnrealized ();
         }
@@ -206,89 +95,80 @@
         protected override void OnMapped ()
         {
             WidgetFlags |= WidgetFlags.Mapped;
-            
-            left_border_window.Show ();
-            right_border_window.Show ();
-            list_window.Show ();
-            footer_window.Show ();
-            header_window.Show ();
-            GdkWindow.Show ();
+            event_window.Show ();
         }
         
         protected override void OnUnmapped ()
         {
             WidgetFlags ^= WidgetFlags.Mapped;
-            
-            left_border_window.Hide ();
-            right_border_window.Hide ();
-            list_window.Hide ();
-            footer_window.Hide ();
-            header_window.Hide ();
-            GdkWindow.Hide ();
+            event_window.Hide ();
         }
         
-        private void MoveResizeWindows (Gdk.Rectangle allocation)
+        private void MoveResize (Gdk.Rectangle allocation)
         {
-            header_alloc.Width = allocation.Width;
-            header_alloc.Height = HeaderHeight;
-            header_window.MoveResize (0, 0, header_alloc.Width, header_alloc.Height);
-            
-            footer_alloc.Width = allocation.Width;
-            footer_alloc.Height = FooterHeight;
-            footer_window.MoveResize (0, allocation.Height - footer_alloc.Height, footer_alloc.Width, footer_alloc.Height);
-            
-            left_border_alloc.Width = InnerBorderWidth;
-            left_border_alloc.Height = allocation.Height - header_alloc.Height - footer_alloc.Height; 
-            left_border_window.MoveResize (0, header_alloc.Height, left_border_alloc.Width, left_border_alloc.Height);
-            
-            right_border_alloc.Width = InnerBorderWidth;
-            right_border_alloc.Height = allocation.Height - header_alloc.Height - footer_alloc.Height;
-            right_border_window.MoveResize (allocation.Width - right_border_alloc.Width, header_alloc.Height, 
-                right_border_alloc.Width, right_border_alloc.Height);
-            
-            list_alloc.Width = allocation.Width - 2 * left_border_alloc.Width;
-            list_alloc.Height = allocation.Height - header_alloc.Height - footer_alloc.Height; 
-            list_window.MoveResize (left_border_alloc.Width, header_alloc.Height, list_alloc.Width, list_alloc.Height);
+            if (!IsRealized) {
+                return;
+            }
+            
+            header_rendering_alloc = allocation;
+            header_rendering_alloc.Height = HeaderHeight;
+            
+            list_rendering_alloc.X = header_rendering_alloc.X + Theme.TotalBorderWidth;
+            list_rendering_alloc.Y = header_rendering_alloc.Bottom + Theme.TotalBorderWidth;
+            if (header_rendering_alloc.Height > 0) {
+                //list_rendering_alloc.Y++;
+            }
+            list_rendering_alloc.Width = allocation.Width - Theme.TotalBorderWidth * 2;
+            list_rendering_alloc.Height = allocation.Height - (list_rendering_alloc.Y - allocation.Y) -
+                Theme.TotalBorderWidth;
+            
+            header_interaction_alloc = header_rendering_alloc;
+            header_interaction_alloc.X = list_rendering_alloc.X;
+            header_interaction_alloc.Width = list_rendering_alloc.Width;
+            header_interaction_alloc.Height += Theme.BorderWidth;
+            header_interaction_alloc.Offset (-allocation.X, -allocation.Y);
+            
+            list_interaction_alloc = list_rendering_alloc;
+            list_interaction_alloc.Offset (-allocation.X, -allocation.Y);
         }
         
         protected override void OnSizeRequested (ref Requisition requisition)
         {
-            requisition.Width = 0;
+            // TODO give the minimum height of the header
+            if (!IsRealized) {
+                return;
+            }
+            requisition.Width = Theme.InnerBorderWidth * 2;
             requisition.Height = HeaderHeight;
         }
         
         protected override void OnSizeAllocated (Gdk.Rectangle allocation)
         {
-            bool resized_width = Allocation.Width != allocation.Width;
-            
             base.OnSizeAllocated (allocation);
             
-            if (IsRealized) {
-                GdkWindow.MoveResize (allocation);
-                MoveResizeWindows (allocation);
+            if (!IsRealized) {
+                return;
             }
+            
+            event_window.MoveResize (allocation);
+            
+            MoveResize (allocation);
            
             if (vadjustment != null) {
-                vadjustment.PageSize = list_alloc.Height;
-                vadjustment.PageIncrement = list_alloc.Height;
+                vadjustment.PageSize = list_rendering_alloc.Height;
+                vadjustment.PageIncrement = list_rendering_alloc.Height;
                 UpdateAdjustments (null, null);
             }
             
-            if (resized_width) {
-                InvalidateHeaderWindow ();
-                InvalidateFooterWindow ();
-            }
-            
             if (Model is ICareAboutView) {
                 ((ICareAboutView)Model).RowsInView = RowsInView;
             }
             
-            InvalidateListWindow ();
             RegenerateColumnCache ();
         }
         
         private int RowsInView {
-            get { return (int) Math.Ceiling (list_alloc.Height / (double) RowHeight) + 1; }
+            get { return (int) Math.Ceiling ((list_rendering_alloc.Height + RowHeight) / (double) RowHeight); }
         }
     }
 }

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs	Thu Mar 20 22:04:27 2008
@@ -81,145 +81,116 @@
             Context.Cairo.LineWidth = Context.LineWidth;
             Context.Cairo.Stroke ();
         }
+        
+        public override void DrawArrow (Context cr, Gdk.Rectangle alloc, Hyena.Data.SortType type)
+        {
+            cr.Translate (0.5, 0.5);
+            int x1 = alloc.X;
+            int x3 = alloc.X + alloc.Width / 2;
+            int x2 = x3 + (x3 - x1);
+            int y1 = alloc.Y;
+            int y2 = alloc.Bottom;
+            
+            if (type == Hyena.Data.SortType.Ascending) {
+                cr.MoveTo (x1, y1);
+                cr.LineTo (x2, y1);
+                cr.LineTo (x3, y2);
+                cr.LineTo (x1, y1);
+            } else {
+                cr.MoveTo (x3, y1);
+                cr.LineTo (x2, y2);
+                cr.LineTo (x1, y2);
+                cr.LineTo (x3, y1);
+            }
+            
+            cr.Color = new Color (1, 1, 1, 0.4);
+            cr.FillPreserve ();
+            cr.Color = new Color (0, 0, 0, 1);
+            cr.Stroke ();
+            cr.Translate (-0.5, -0.5);
+        }
 
-        public override void DrawHeaderSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x, int bottom_offset)
+
+        public override void DrawHeaderSeparator (Cairo.Context cr, Gdk.Rectangle alloc, int x)
         {
-            Cairo.Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal);
-            Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.80);
-            Cairo.Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1);
+            Cairo.Color gtk_background_color = Colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal);
+            Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.80);
+            Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
             
-            int y_1 = alloc.Y + 2;
-            int y_2 = alloc.Y + alloc.Height - 4 - bottom_offset;
+            int y_1 = alloc.Top + 4;
+            int y_2 = alloc.Bottom - 4;
             
             cr.LineWidth = 1;
             cr.Antialias = Cairo.Antialias.None;
             
             cr.Color = dark_color;
-            cr.MoveTo(x, y_1);
-            cr.LineTo(x, y_2);
-            cr.Stroke();
+            cr.MoveTo (x, y_1);
+            cr.LineTo (x, y_2);
+            cr.Stroke ();
             
             cr.Color = light_color;
-            cr.MoveTo(x + 1, y_1);
-            cr.LineTo(x + 1, y_2);
-            cr.Stroke();
+            cr.MoveTo (x + 1, y_1);
+            cr.LineTo (x + 1, y_2);
+            cr.Stroke ();
             
             cr.Antialias = Cairo.Antialias.Default;
         }
         
-        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset, bool fill)
+        public override void DrawHeaderBackground (Cairo.Context cr, Gdk.Rectangle alloc)
         {
-            Cairo.Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal);
-            Cairo.Color gtk_base_color = Colors.GetWidgetColor(GtkColorClass.Base, StateType.Normal);
-            Cairo.Color light_color = CairoExtensions.ColorShade(gtk_background_color, 1.1);
-            Cairo.Color dark_color = CairoExtensions.ColorShade(gtk_background_color, 0.95);
+            Cairo.Color gtk_background_color = Colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal);
+            Cairo.Color light_color = CairoExtensions.ColorShade (gtk_background_color, 1.1);
+            Cairo.Color dark_color = CairoExtensions.ColorShade (gtk_background_color, 0.95);
             
             CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;
+
+            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom);
+            grad.AddColorStop (0, light_color);
+            grad.AddColorStop (0.75, dark_color);
+            grad.AddColorStop (0, light_color);
+        
+            cr.Pattern = grad;
+            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
+            cr.Fill ();
             
-            if(fill) {
-                LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
-                grad.AddColorStop(0, light_color);
-                grad.AddColorStop(0.75, dark_color);
-                grad.AddColorStop(0, light_color);
-            
-                cr.Pattern = grad;
-                CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, 
-                alloc.Height - bottom_offset, Context.Radius, corners);
-                cr.Fill();
-            
-                cr.Color = gtk_base_color;
-                cr.Rectangle(alloc.X, alloc.Y + alloc.Height - bottom_offset, alloc.Width, bottom_offset);
-                cr.Fill();
-            } else {
-                cr.Color = gtk_base_color;
-                CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
-                cr.Fill();
-            }
-            
-            cr.LineWidth = 1.0;
-            cr.Translate(alloc.X + 0.5, alloc.Y + 0.5);
             cr.Color = border_color;
-            CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width - 1, 
-                alloc.Height + 4, Context.Radius, corners);
-            cr.Stroke();
-            
-            if(fill) {
-                cr.LineWidth = 1;
-                cr.Antialias = Cairo.Antialias.None;
-                cr.MoveTo(alloc.X + 1, alloc.Y + alloc.Height - 1 - bottom_offset);
-                cr.LineTo(alloc.X + alloc.Width - 1, alloc.Y + alloc.Height - 1 - bottom_offset);
-                cr.Stroke();
-                cr.Antialias = Cairo.Antialias.Default;
-            }
+            cr.Rectangle (alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
+            cr.Fill ();
         }
         
-        public override void DrawFrame (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
+        public override void DrawFrameBackground (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
         {
-            CairoCorners corners = CairoCorners.All;
-        
             color.A = Context.FillAlpha;
             cr.Color = color;
-            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
+            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.All);
             cr.Fill ();
-            
-            if (!Context.ShowStroke) {
-                return;
-            }
-            
-            cr.LineWidth = 1.0;
-            cr.Translate (0.5, 0.5);
-            cr.Color = border_color;
-            CairoExtensions.RoundedRectangle (cr, alloc.X, alloc.Y, alloc.Width - 1, alloc.Height - 1, Context.Radius, corners);
-            cr.Stroke();
-        }
-
-        public override void DrawColumnHighlight(Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset, Cairo.Color color)
-        {
-            Cairo.Color light_color = CairoExtensions.ColorShade(color, 1.6);
-            Cairo.Color dark_color = CairoExtensions.ColorShade(color, 1.3);
-            
-            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y + 2, alloc.X, alloc.Y + alloc.Height - 3 - bottom_offset);
-            grad.AddColorStop(0, light_color);
-            grad.AddColorStop(1, dark_color);
-            
-            cr.Pattern = grad;
-            cr.Rectangle(alloc.X, alloc.Y + 2, alloc.Width - 1, alloc.Height - 3 - bottom_offset);
-            cr.Fill();
         }
         
-        public override void DrawFooter(Cairo.Context cr, Gdk.Rectangle alloc)
+        public override void DrawFrameBorder (Cairo.Context cr, Gdk.Rectangle alloc)
         {
-            Cairo.Color gtk_base_color = Colors.GetWidgetColor(GtkColorClass.Base, StateType.Normal);
-            CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;
-            
-            cr.Color = gtk_base_color;
-            CairoExtensions.RoundedRectangle(cr, alloc.X , alloc.Y, alloc.Width, 
-                alloc.Height, Context.Radius, corners);
-            cr.Fill();
-            
-            cr.LineWidth = 1.0;
-            cr.Translate(alloc.Y + 0.5, alloc.Y + 0.5);
-            
+            cr.LineWidth = BorderWidth;
             cr.Color = border_color;
-            CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y - 4, alloc.Width - 1, 
-                alloc.Height + 3, Context.Radius, corners);
+            double offset = (double)BorderWidth / 2.0;
+            CairoExtensions.RoundedRectangle (cr, alloc.X + offset, alloc.Y + offset,
+                alloc.Width - BorderWidth, alloc.Height - BorderWidth, Context.Radius, CairoCorners.All);
             cr.Stroke();
         }
-        
-        protected override void DrawLeftOrRightBorder(Cairo.Context cr, int x, Gdk.Rectangle alloc)
+
+        public override void DrawColumnHighlight (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
         {
-            cr.LineWidth = 1.0;
-            cr.Antialias = Cairo.Antialias.None;
+            Cairo.Color light_color = CairoExtensions.ColorShade (color, 1.6);
+            Cairo.Color dark_color = CairoExtensions.ColorShade (color, 1.3);
             
-            cr.Color = border_color;
-            cr.MoveTo(x, alloc.Y);
-            cr.LineTo(x, alloc.Y + alloc.Height);
-            cr.Stroke();
+            LinearGradient grad = new LinearGradient (alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);
+            grad.AddColorStop (0, light_color);
+            grad.AddColorStop (1, dark_color);
             
-            cr.Antialias = Cairo.Antialias.Default;
+            cr.Pattern = grad;
+            cr.Rectangle (alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
+            cr.Fill();
         }
         
-        public override void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
+        public override 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;
@@ -227,19 +198,19 @@
             selection_stroke.A = color.A;
             
             if (filled) {
-                Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.1);
-                Cairo.Color selection_fill_dark = CairoExtensions.ColorShade(selection_color, 0.90);
+                Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.1);
+                Cairo.Color selection_fill_dark = CairoExtensions.ColorShade (selection_color, 0.90);
                 
                 selection_fill_light.A = color.A;
                 selection_fill_dark.A = color.A;
                 
-                LinearGradient grad = new LinearGradient(x, y, x, y + height);
-                grad.AddColorStop(0, selection_fill_light);
-                grad.AddColorStop(1, selection_fill_dark);
+                LinearGradient grad = new LinearGradient (x, y, x, y + height);
+                grad.AddColorStop (0, selection_fill_light);
+                grad.AddColorStop (1, selection_fill_dark);
                 
                 cr.Pattern = grad;
-                CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true);
-                cr.Fill();
+                CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
+                cr.Fill ();
             }
             
             if (stroked) {
@@ -257,4 +228,4 @@
             cr.Fill ();
         }
     }
-}
+}
\ No newline at end of file

Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs	(original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs	Thu Mar 20 22:04:27 2008
@@ -77,40 +77,50 @@
 #region Drawing
 
         public abstract void DrawPie (double fraction);
+        
+        public abstract void DrawArrow (Cairo.Context cr, Gdk.Rectangle alloc, Hyena.Data.SortType type);
 
-        public abstract void DrawHeaderSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x, int bottom_offset);
+        public abstract void DrawHeaderSeparator(Cairo.Context cr, Gdk.Rectangle alloc, int x);
         
-        public abstract void DrawHeaderBackground (Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset, bool fill);
+        public abstract void DrawHeaderBackground (Cairo.Context cr, Gdk.Rectangle alloc);
         
         public void DrawFrame (Cairo.Context cr, Gdk.Rectangle alloc, bool baseColor)
         {
-            DrawFrame (cr, alloc,  baseColor 
-                ? colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal)
-                : colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal));
+            DrawFrameBackground (cr, alloc, baseColor);
+            DrawFrameBorder (cr, alloc);
         }
         
-        public abstract void DrawFrame (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color);
+        public void DrawFrame (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color)
+        {
+            DrawFrameBackground (cr, alloc, color);
+            DrawFrameBorder (cr, alloc);
+        }
         
-        public void DrawColumnHighlight (Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset)
+        public void DrawFrameBackground (Cairo.Context cr, Gdk.Rectangle alloc, bool baseColor)
         {
-            DrawColumnHighlight (cr, alloc, bottom_offset, colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected));
+            DrawFrameBackground (cr, alloc,  baseColor 
+                ? colors.GetWidgetColor (GtkColorClass.Base, StateType.Normal)
+                : colors.GetWidgetColor (GtkColorClass.Background, StateType.Normal));
         }
         
-        public abstract void DrawColumnHighlight (Cairo.Context cr, Gdk.Rectangle alloc, int bottom_offset, Cairo.Color color);
+        public abstract void DrawFrameBackground (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color);
         
-        public abstract void DrawFooter (Cairo.Context cr, Gdk.Rectangle alloc);
+        public abstract void DrawFrameBorder (Cairo.Context cr, Gdk.Rectangle alloc);
         
-        public void DrawLeftBorder (Cairo.Context cr, Gdk.Rectangle alloc)
+        public void DrawColumnHighlight (Cairo.Context cr, double cellWidth, double cellHeight)
         {
-            DrawLeftOrRightBorder (cr, alloc.X + 1, alloc);
+            Gdk.Rectangle alloc = new Gdk.Rectangle ();
+            alloc.Width = (int)cellWidth;
+            alloc.Height = (int)cellHeight;
+            DrawColumnHighlight (cr, alloc);
         }
         
-        public void DrawRightBorder (Cairo.Context cr, Gdk.Rectangle alloc)
+        public void DrawColumnHighlight (Cairo.Context cr, Gdk.Rectangle alloc)
         {
-            DrawLeftOrRightBorder (cr, alloc.X + alloc.Width, alloc);   
+            DrawColumnHighlight (cr, alloc, colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected));
         }
         
-        protected abstract void DrawLeftOrRightBorder (Cairo.Context cr, int x, Gdk.Rectangle alloc);
+        public abstract void DrawColumnHighlight (Cairo.Context cr, Gdk.Rectangle alloc, Cairo.Color color);
         
         public void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height)
         {
@@ -149,6 +159,18 @@
         public Cairo.Color SelectionStroke {
             get { return selection_stroke; }
         }
+        
+        public virtual int BorderWidth {
+            get { return 1; }
+        }
+        
+        public virtual int InnerBorderWidth {
+            get { return 4; }
+        }
+        
+        public int TotalBorderWidth {
+            get { return BorderWidth + InnerBorderWidth; }
+        }
 
 #endregion
 



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