banshee r3179 - in trunk/banshee: . src/Core/Hyena.Gui/Hyena.Data.Gui/ListView



Author: abock
Date: Sat Feb  9 05:39:12 2008
New Revision: 3179
URL: http://svn.gnome.org/viewvc/banshee?rev=3179&view=rev

Log:
2008-02-09  Aaron Bockover  <abock gnome org>

    * src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs:
    * src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs:
    Finished actual column reordering



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
   trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Header.cs	Sat Feb  9 05:39:12 2008
@@ -55,6 +55,7 @@
         private int resizing_column_index = -1;
         private int pressed_column_index = -1;
         private int pressed_column_x_start = -1;
+        private int pressed_column_x_offset = -1;
         private int pressed_column_x_drag = -1;
         private bool pressed_column_is_dragging = false;
         

Modified: trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs
==============================================================================
--- trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	(original)
+++ trunk/banshee/src/Core/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Interaction.cs	Sat Feb  9 05:39:12 2008
@@ -206,8 +206,10 @@
                 } else {
                     column = GetColumnAt ((int)press.X);
                     if (column != null) {
-                        pressed_column_index = GetCachedColumnForColumn (column).Index;
+                        CachedColumn column_c = GetCachedColumnForColumn (column);
+                        pressed_column_index = column_c.Index;
                         pressed_column_x_start = (int)press.X;
+                        pressed_column_x_offset = pressed_column_x_start - column_c.X1;
                     }
                 }
                 
@@ -220,7 +222,7 @@
             
             GrabFocus ();
             
-            int row_index = GetRowAtY ((int) press.Y);
+            int row_index = GetRowAtY ((int)press.Y);
             
             if (press.Button == 1 && press.Type != Gdk.EventType.TwoButtonPress && 
                 (press.State & Gdk.ModifierType.ControlMask) == 0 && Selection.Contains (row_index)) {
@@ -243,7 +245,7 @@
                             Selection.Select (row_index);
                         }
                     } else {
-                        Selection.ToggleSelect(row_index);
+                        Selection.ToggleSelect (row_index);
                     }
                 } else if ((press.State & Gdk.ModifierType.ShiftMask) != 0) {
                     Selection.SelectFromFirst (row_index, true);
@@ -337,16 +339,30 @@
                 if (pressed_column_is_dragging) {
                     header_window.Cursor = drag_cursor;
                     
-                    /*Column swap_column = GetColumnAt ((int)evnt.X);
+                    Column swap_column = GetColumnAt ((int)evnt.X);
+                    bool x_drag_updated = false;
+                    
                     if (swap_column != null) {
-                        int index = GetCachedColumnForColumn (swap_column).Index;
-                        ColumnController.Reorder (pressed_column_index, index);
-                        pressed_column_index = index;
-                        RegenerateColumnCache ();
-                    }*/
+                        CachedColumn swap_column_c = GetCachedColumnForColumn (swap_column);
+                        bool reorder = false;
+                        
+                        if (swap_column_c.Index < pressed_column_index) {
+                            // Moving from right to left
+                            reorder = pressed_column_x_drag <= swap_column_c.X1 + swap_column_c.Width / 2;
+                        } else if (swap_column_c.Index > pressed_column_index) {
+                            // Moving from left to right
+                            reorder = pressed_column_x_drag + column_cache[pressed_column_index].Width >= 
+                                swap_column_c.X1 + swap_column_c.Width / 2;
+                        }
+                        
+                        if (reorder) {
+                            ColumnController.Reorder (pressed_column_index, swap_column_c.Index);
+                            pressed_column_index = swap_column_c.Index;
+                            RegenerateColumnCache ();
+                        }
+                    }
                     
-                    pressed_column_x_drag = (int)evnt.X - pressed_column_x_start + 
-                        column_cache[pressed_column_index].X1;
+                    pressed_column_x_drag = (int)evnt.X - pressed_column_x_offset;
                     
                     InvalidateHeaderWindow ();
                     InvalidateListWindow ();



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