[banshee/a11y: 6/27] [a11y] Change ListView selection color depending on focus location.



commit f8634f43d6a0092f74ee46829622430d78f660d2
Author: Eitan Isaacson <eitan ascender com>
Date:   Wed Sep 30 10:58:48 2009 -0700

    [a11y] Change ListView selection color depending on focus location.

 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |   25 ++++++++++++-------
 .../Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs        |   12 ++++++++-
 src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs |   14 ++++++++++-
 3 files changed, 40 insertions(+), 11 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index b59bb16..88fa8bd 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -263,14 +263,20 @@ namespace Hyena.Data.Gui
                         if (Selection.Contains (ri + 1)) {
                             corners &= ~(CairoCorners.BottomLeft | CairoCorners.BottomRight);
                         }
-                        
-                        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 (HasFocus && !HeaderFocused) // Cursor out of selection.
+                            Theme.DrawRowCursor (cairo_context, single_list_alloc.X, single_list_alloc.Y,
+                                                 single_list_alloc.Width, single_list_alloc.Height,
+                                                 CairoExtensions.ColorShade(Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected), 0.85));
                     }
                     
                     if (selection_height > 0) {
-                        Theme.DrawRowSelection (cairo_context, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height);
+                        Cairo.Color selection_color = Theme.Colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected);
+                        if (!HasFocus || HeaderFocused)
+                            selection_color = CairoExtensions.ColorShade(selection_color, 1.1);
+
+                        Theme.DrawRowSelection (cairo_context, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height,
+                                                true, true, selection_color, CairoCorners.All);
                         selection_height = 0;
                     }
                     
@@ -289,10 +295,11 @@ namespace Hyena.Data.Gui
             }
             
             if (Selection != null && Selection.Count > 1 && 
-                !selected_focus_alloc.Equals (Rectangle.Zero) && HasFocus) {
-                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));
+                !selected_focus_alloc.Equals (Rectangle.Zero) &&
+                HasFocus && !HeaderFocused) { // Cursor inside selection.
+                Theme.DrawRowCursor (cairo_context, selected_focus_alloc.X, selected_focus_alloc.Y,
+                    selected_focus_alloc.Width, selected_focus_alloc.Height,
+                    Theme.Colors.GetWidgetColor (GtkColorClass.Text, StateType.Selected));
             }
             
             foreach (int ri in selected_rows) {
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
index 368a1e8..73aab20 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/GtkTheme.cs
@@ -254,7 +254,17 @@ namespace Hyena.Gui.Theming
             cr.Rectangle (alloc.X, alloc.Y, alloc.Width, alloc.Height);
             cr.Fill ();
         }
-        
+
+        public override void DrawRowCursor (Cairo.Context cr, int x, int y, int width, int height,
+                                            Cairo.Color color, CairoCorners corners)
+        {
+            cr.LineWidth = 1.25;
+            cr.Color = color;
+            CairoExtensions.RoundedRectangle (cr, x + cr.LineWidth/2.0, y + cr.LineWidth/2.0,
+                width - cr.LineWidth, height - cr.LineWidth, Context.Radius, corners, true);
+            cr.Stroke ();
+        }
+
         public override void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height,
             bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
         {
diff --git a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
index 872cc12..a34db23 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Gui.Theming/Theme.cs
@@ -160,7 +160,19 @@ namespace Hyena.Gui.Theming
         {
             DrawRowSelection (cr, x, y, width, height, filled, stroked, color, CairoCorners.All);
         }
-        
+
+        public void DrawRowCursor (Cairo.Context cr, int x, int y, int width, int height)
+        {
+            DrawRowCursor (cr, x, y, width, height, colors.GetWidgetColor (GtkColorClass.Background, StateType.Selected));
+        }
+
+        public void DrawRowCursor (Cairo.Context cr, int x, int y, int width, int height, Cairo.Color color)
+        {
+            DrawRowCursor (cr, x, y, width, height, color, CairoCorners.All);
+        }
+
+        public abstract void DrawRowCursor (Cairo.Context cr, int x, int y, int width, int height, Cairo.Color color, CairoCorners corners);
+
         public abstract void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height,
             bool filled, bool stroked, Cairo.Color color, CairoCorners corners);
         



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