banshee r3415 - in trunk/banshee: . src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView



Author: gburt
Date: Tue Mar 11 04:10:28 2008
New Revision: 3415
URL: http://svn.gnome.org/viewvc/banshee?rev=3415&view=rev

Log:
2008-03-10  Gabriel Burt  <gabriel burt gmail com>

	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
	* src/Libraries/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Model.cs: Fix
	scrolling to jump to the first selected item only if a selected item is
	not already in view.  If the model count < the visible rows, scroll to the
	top.


Modified:
   trunk/banshee/ChangeLog
   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

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	Tue Mar 11 04:10:28 2008
@@ -466,7 +466,7 @@
         
         public void ScrollTo (double val)
         {
-            vadjustment.Value = Math.Min (val, vadjustment.Upper - vadjustment.PageSize);
+            vadjustment.Value = Math.Max (0.0, Math.Min (val, vadjustment.Upper - vadjustment.PageSize));
         }
 
         public void ScrollToRow (int row_index)

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	Tue Mar 11 04:10:28 2008
@@ -74,8 +74,21 @@
             if (vpos != null) {
                 ScrollTo ((double) vpos);
             } else {
-                if (Selection.Count > 0) {
-                    ScrollToRow (Selection.Ranges[0].Start + 1 - RowsInView/2);
+                if (Model.Count <= RowsInView) {
+                    ScrollTo (0.0);
+                } else if (Selection.Count > 0) {
+                    bool selection_in_view = false;
+                    int first_row = GetRowAtY (0);
+                    for (int i = 0; i < RowsInView; i++) {
+                        if (Selection.Contains (first_row + i)) {
+                            selection_in_view = true;
+                            break;
+                        }
+                    }
+
+                    if (!selection_in_view) {
+                        ScrollToRow (Selection.Ranges[0].Start + 1 - RowsInView/2);
+                    }
                 } else {
                     ScrollTo (vadjustment.Value);
                 }



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