[hyena] Fixed some grid rendering math bugs



commit ffc971ec3dd58e224bdf6e0cad9ee6bdb96df1ad
Author: Aaron Bockover <abockover novell com>
Date:   Thu Dec 3 12:05:39 2009 +0800

    Fixed some grid rendering math bugs
    
    The grid now renders properly with any vertical adjustment
    and the off-by-one row popping is fixed.
    
    There is still an issue seemingly surrounding computation
    of the number of grid rows or the vadjustment in general.

 .../Hyena.Data.Gui/ListView/ListView_Rendering.cs  |   11 ++++-------
 .../Hyena.Data.Gui/ListView/ListView_Windowing.cs  |    2 +-
 2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
index 7ac908d..ccef280 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
+++ b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Rendering.cs
@@ -453,9 +453,9 @@ namespace Hyena.Data.Gui
                 columns_in_view * GridCellWidth) / columns_in_view);
             int vadjustment_value = VadjustmentValue;
 
-            int first_model_row = vadjustment_value / (row_height * columns_in_view);
-            int last_model_row = Math.Min (model.Count, first_model_row + rows_in_view * columns_in_view);
-            int offset = list_rendering_alloc.Y - vadjustment_value % row_height;
+            int offset = list_rendering_alloc.Y - vadjustment_value % RowHeight;
+            int first_model_row = (int)Math.Floor (vadjustment_value / (double)RowHeight) * columns_in_view;
+            int last_model_row = Math.Min (model.Count, first_model_row + rows_in_view * columns_in_view) - 1;
 
             var grid_cell_alloc = new Rectangle () {
                 X = list_rendering_alloc.X,
@@ -464,11 +464,8 @@ namespace Hyena.Data.Gui
                 Height = GridCellHeight
             };
 
-            Console.WriteLine ("FIRST = {0}, LAST = {1}", first_model_row, last_model_row);
-
             for (int model_row_index = first_model_row, view_row_index = 0, view_column_index = 0;
-                model_row_index < last_model_row; model_row_index++) {
-
+                model_row_index <= last_model_row; model_row_index++) {
                 var item = model[model_row_index];
                 PaintCell (item, 0, model_row_index, grid_cell_alloc,
                     IsRowOpaque (item), IsRowBold (item), StateType.Normal, false);
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 ddb3b8e..b1ee8a0 100644
--- a/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
+++ b/src/Hyena.Gui/Hyena.Data.Gui/ListView/ListView_Windowing.cs
@@ -180,7 +180,7 @@ namespace Hyena.Data.Gui
         }
 
         protected int RowsInView {
-            get { return (int) Math.Ceiling ((list_rendering_alloc.Height + RowHeight) / (double) RowHeight); }
+            get { return (int)Math.Ceiling ((list_rendering_alloc.Height + RowHeight) / (double)RowHeight); }
         }
 
         protected int GridColumnsInView {



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