[hyena] Add ItemsInView property to ListView



commit 31825dfb1a45373c4cbcd18ab36335a6e75df7f6
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Wed Mar 10 21:04:29 2010 -0800

    Add ItemsInView property to ListView
    
    And use it for CenterOn, IsRowVisible, and scrolling to if the model is
    reloaded with fewer items than in view.

 .../ListView/ListView_Interaction.cs               |    4 ++--
 .../Hyena.Data.Gui/ListView/ListView_Model.cs      |    2 +-
 .../Hyena.Data.Gui/ListView/ListView_Windowing.cs  |    8 ++++++++
 3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
index afaf78b..1734250 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
+++ b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
@@ -982,7 +982,7 @@ namespace Hyena.Data.Gui
 
         public void CenterOn (int index)
         {
-            ScrollTo (index - RowsInView / 2 + 1);
+            ScrollTo (index - ItemsInView / 2 + 1);
         }
 
         public bool IsRowVisible (int index)
@@ -996,7 +996,7 @@ namespace Hyena.Data.Gui
             if (Selection != null && Selection.Count > 0 && !Selection.AllSelected) {
                 bool selection_in_view = false;
                 int first_row = GetModelRowAt (0, 0);
-                for (int i = 0; i < RowsInView; i++) {
+                for (int i = 0; i < ItemsInView; i++) {
                     if (Selection.Contains (first_row + i)) {
                         selection_in_view = true;
                         break;
diff --git a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
index 715eac8..60409fd 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
+++ b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs
@@ -102,7 +102,7 @@ namespace Hyena.Data.Gui
 
             if (vpos != null) {
                 ScrollToY ((double) vpos);
-            } else if (Model.Count <= RowsInView) {
+            } else if (Model.Count <= ItemsInView) {
                 // If our view fits all rows at once, make sure we're scrolled to the top
                 ScrollToY (0.0);
             } else if (vadjustment != null) {
diff --git a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
index 804cb3e..8a6a5a1 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
+++ b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
@@ -184,6 +184,14 @@ namespace Hyena.Data.Gui
             }
         }
 
+        protected int ItemsInView {
+            get {
+                // FIXME hardcoded grid
+                int columns = ViewLayout == null ? 1 : (ViewLayout as DataViewLayoutGrid).Columns;
+                return RowsInView * columns;
+            }
+        }
+
         // FIXME: obsolete
         protected int RowsInView {
             get {



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