[banshee/grid] [grid] Utility methods for finding layout children



commit 0b61fbeb36c8db668cc4b7601e056322164b2a8a
Author: Aaron Bockover <abockover novell com>
Date:   Wed Jan 20 20:47:59 2010 -0500

    [grid] Utility methods for finding layout children
    
    - Implemented FindChildAtPoint(x,y) and FindChildAtModelRowIndex(i)
    - Implemented GetChildVirtualAllocation, added the concept of
      VirtualAllocation to children, but I'm not sure this is sound...
      I've already confused myself with the concept

 .../Hyena.Gui/Hyena.Data.Gui/DataViewLayout.cs     |   22 ++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayout.cs b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayout.cs
index 1cc3ae2..842ef5e 100644
--- a/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayout.cs
+++ b/src/Libraries/Hyena.Gui/Hyena.Data.Gui/DataViewLayout.cs
@@ -36,6 +36,7 @@ namespace Hyena.Data.Gui
         public class Child
         {
             public Gdk.Rectangle Allocation { get; set; }
+            public Gdk.Rectangle VirtualAllocation { get; set; }
             public int ModelRowIndex { get; set; }
         }
 
@@ -83,6 +84,17 @@ namespace Hyena.Data.Gui
             InvalidateChildLayout ();
         }
 
+        public virtual Child FindChildAtPoint (int x, int y)
+        {
+            return Children.Find (child => child.Allocation.Contains (
+                ActualAllocation.X + x, ActualAllocation.Y + y));
+        }
+
+        public virtual Child FindChildAtModelRowIndex (int modelRowIndex)
+        {
+            return Children.Find (child => child.ModelRowIndex == modelRowIndex);
+        }
+
         protected abstract void InvalidateChildSize ();
         protected abstract void InvalidateVirtualSize ();
         protected abstract void InvalidateChildCollection ();
@@ -99,5 +111,15 @@ namespace Hyena.Data.Gui
                 }
             }
         }
+
+        protected Gdk.Rectangle GetChildVirtualAllocation (Gdk.Rectangle childAllocation)
+        {
+            return new Gdk.Rectangle () {
+                X = childAllocation.X - ActualAllocation.X,
+                Y = childAllocation.Y - ActualAllocation.Y,
+                Width = childAllocation.Width,
+                Height = childAllocation.Height
+            };
+        }
     }
 }



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