changeset 4219:bacb30cbf1ff

RT-31469: [TreeTableView] scrollBar's bar size doesn't correspond to the size of visible data.
author jgiles
date Tue, 09 Jul 2013 13:29:34 +1200
parents 228646313e30
children 92edb54d11c7
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java
diffstat 1 files changed, 15 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Jul 09 11:59:02 2013 +1200
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Jul 09 13:29:34 2013 +1200
@@ -147,7 +147,6 @@
                     pile.clear();
                     sheetChildren.clear();
                     cells.clear();
-                    numCellsVisibleOnScreen = -1;
                     lastWidth = lastHeight = maxPrefBreadth = -1;
                     viewportBreadth = viewportLength = lastPosition = 0;
                     hbar.setValue(0);
@@ -287,13 +286,6 @@
     }
 
     /**
-     * The number of cells on the first full page. This is recomputed whenever
-     * the viewportLength changes, and is used for computing the visibleAmount
-     * of the lengthBar.
-     */
-    private int numCellsVisibleOnScreen = -1;
-
-    /**
      * The maximum preferred size in the non-virtual direction. For example,
      * if vertical, then this is the max pref width of all cells encountered.
      * <p>
@@ -812,7 +804,6 @@
             maxPrefBreadth = -1;
             lastWidth = -1;
             lastHeight = -1;
-            numCellsVisibleOnScreen = -1;
             releaseCell(accumCell);
 //            accumCell = null;
 //            accumCellParent.getChildren().clear();
@@ -1371,25 +1362,6 @@
         double flowLength = (isVertical ? getHeight() : getWidth()) -
             (breadthBar.isVisible() ? breadthBar.prefHeight(-1) : 0);
         
-        // This was changed from '== -1' to '<= 0' due to RT-29390. If this needs
-        // to change in the future there are unit tests developed against
-        // ListView, TreeView, TableView and TreeTableView, so it is hoped that
-        // RT-29390 will not be reintroduced.
-        if (numCellsVisibleOnScreen <= 0) {
-            numCellsVisibleOnScreen = 0;
-            for (int i = 0, max = cells.size(); i < max; i++) {
-                T cell = cells.get(i);
-                if (cell != null && ! cell.isEmpty()) {
-                    sumCellLength += (isVertical ? cell.getHeight() : cell.getWidth());
-                    if (sumCellLength > flowLength) {
-                        break;
-                    }
-
-                    numCellsVisibleOnScreen++;
-                }
-            }
-        }
-
         // Now position and update the scroll bars
         if (breadthBar.isVisible()) {
             /*
@@ -1432,8 +1404,22 @@
         }
 
         if (lengthBar.isVisible()) {
+            // determine how many cells there are on screen so that the scrollbar
+            // thumb can be appropriately sized
+            int numCellsVisibleOnScreen = 0;
+            for (int i = 0, max = cells.size(); i < max; i++) {
+                T cell = cells.get(i);
+                if (cell != null && ! cell.isEmpty()) {
+                    sumCellLength += (isVertical ? cell.getHeight() : cell.getWidth());
+                    if (sumCellLength > flowLength) {
+                        break;
+                    }
+
+                    numCellsVisibleOnScreen++;
+                }
+            }
+
             lengthBar.setMax(1);
-
             if (numCellsVisibleOnScreen == 0 && cellCount == 1) {
                 // special case to help resolve RT-17701 and the case where we have
                 // only a single row and it is bigger than the viewport