[banshee] SourceRowRenderer: Rework rendering of the cell background



commit 1fff9a12a35a1e99415e3525d8217959bdf86b27
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Sun Jun 15 17:47:25 2014 +0200

    SourceRowRenderer: Rework rendering of the cell background
    
    If the cell is selected, just let the GTK theme do the drawing.
    
    If the cell is highlighted but not selected, like when you right click
    on a non-selected cell that is not selected, draw a simple 1 pixel
    border, like we did before.
    
    The notification animation is now a simple rectangle fill, using a color
    halfway between normal and selected. We can't use the color of the
    "active" state anymore, because it now seems to be the same as the
    normal color, at least for treeviews.
    
    We should probably use GTK+ animations for that, but I still need to
    figure out how...
    
    Also update Hyena to the latest git master, to bring in all the latest
    ListView changes.

 .../Banshee.Sources.Gui/SourceRowRenderer.cs       |   44 ++++++++-----------
 src/Hyena                                          |    2 +-
 2 files changed, 20 insertions(+), 26 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs 
b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs
index 43b23fb..dfa5b20 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/SourceRowRenderer.cs
@@ -159,7 +159,7 @@ namespace Banshee.Sources.Gui
             bool selected = view != null && view.Selection.IterIsSelected (iter);
             StateFlags state = RendererStateToWidgetState (widget, flags);
 
-            RenderSelection (cr, background_area, selected, state);
+            RenderBackground (cr, background_area, selected, state);
 
             int title_layout_width = 0, title_layout_height = 0;
             int count_layout_width = 0, count_layout_height = 0;
@@ -284,7 +284,7 @@ namespace Banshee.Sources.Gui
             fd.Dispose ();
         }
 
-        private void RenderSelection (Cairo.Context cr, Gdk.Rectangle background_area,
+        private void RenderBackground (Cairo.Context cr, Gdk.Rectangle background_area,
             bool selected, StateFlags state)
         {
             if (view == null) {
@@ -292,32 +292,26 @@ namespace Banshee.Sources.Gui
             }
 
             if (selected) {
-                Gdk.Rectangle rect = background_area;
-                rect.X -= 2;
-                rect.Width += 4;
-
-                // clear the standard GTK selection and focus
-                Gdk.RGBA rgba = view.StyleContext.GetBackgroundColor (StateFlags.Normal);
-                cr.SetSourceRGBA (rgba.Red, rgba.Green, rgba.Blue, rgba.Alpha);
-                cr.Rectangle (rect.X, rect.Y, rect.Width, rect.Height);
-                cr.Fill ();
-
-                // draw the hot cairo selection
-                if (!view.EditingRow) {
-                    view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
-                        background_area.Width - 2, background_area.Height - 2);
-                }
-            } else if (!TreeIter.Zero.Equals (iter) && iter.Equals (view.HighlightedIter)) {
-                view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
-                    background_area.Width - 2, background_area.Height - 2, false);
+                // Just leave the standard GTK selection and focus
+                return;
+            }
+
+            if (!TreeIter.Zero.Equals (iter) && iter.Equals (view.HighlightedIter)) {
+                // Item is highlighted but not selected
+                view.Theme.DrawHighlightFrame (cr, background_area.X + 1, background_area.Y + 1,
+                                               background_area.Width - 2, background_area.Height - 2);
             } else if (view.NotifyStage.ActorCount > 0) {
                 if (!TreeIter.Zero.Equals (iter) && view.NotifyStage.Contains (iter)) {
+                    // Render the current step of the notification animation
                     Actor<TreeIter> actor = view.NotifyStage[iter];
-                    Cairo.Color color = CairoExtensions.GdkRGBAToCairoColor 
(view.StyleContext.GetBackgroundColor (StateFlags.Active));
-                    color.A = Math.Sin (actor.Percent * Math.PI);
-
-                    view.Theme.DrawRowSelection (cr, background_area.X + 1, background_area.Y + 1,
-                        background_area.Width - 2, background_area.Height - 2, true, true, color);
+                    Cairo.Color normal_color = CairoExtensions.GdkRGBAToCairoColor 
(view.StyleContext.GetBackgroundColor (StateFlags.Normal));
+                    Cairo.Color selected_color = CairoExtensions.GdkRGBAToCairoColor 
(view.StyleContext.GetBackgroundColor (StateFlags.Selected));
+                    Cairo.Color notify_bg_color = CairoExtensions.AlphaBlend (normal_color, selected_color, 
0.5);
+                    notify_bg_color.A = Math.Sin (actor.Percent * Math.PI);
+
+                    cr.SetSourceColor (notify_bg_color);
+                    CairoExtensions.RoundedRectangle (cr, background_area.X, background_area.Y, 
background_area.Width, background_area.Height, view.Theme.Context.Radius);
+                    cr.Fill ();
                 }
             }
         }
diff --git a/src/Hyena b/src/Hyena
index 7b464ec..ca1af04 160000
--- a/src/Hyena
+++ b/src/Hyena
@@ -1 +1 @@
-Subproject commit 7b464ecc93537314c5ddfc1fedd140cb0a25b2f1
+Subproject commit ca1af0493ac6c8a462cc2d18589c232cf7fd058c


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