changeset 5621:6054bd8a3a5a

RT-31123: Fixed TreeTableView cells position after expanding an item while scrolled to bottom. Reviewed-by: Jonathan
author Pavel Safrata <pavel.safrata@oracle.com>
date Mon, 04 Nov 2013 08:38:45 +0000
parents 4a8fba6d5627
children bf5672724141
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java
diffstat 1 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Mon Nov 04 08:17:47 2013 +0100
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Mon Nov 04 08:38:45 2013 +0000
@@ -1365,7 +1365,39 @@
         
         double breadthBarLength = snapSize(isVertical ? hbar.prefHeight(-1) : vbar.prefWidth(-1));
         double lengthBarBreadth = snapSize(isVertical ? vbar.prefWidth(-1) : hbar.prefHeight(-1));
-        
+
+        // Update cell positions.
+        // When rebuilding the cells, we add the cells and along the way compute
+        // the maxPrefBreadth. Based on the computed value, we may add
+        // the breadth scrollbar which changes viewport length, so we need
+        // to re-position the cells.
+        if (!cells.isEmpty()) {
+            final double currOffset = -computeViewportOffset(getPosition());
+            final int currIndex = computeCurrentIndex() - cells.getFirst().getIndex();
+            final int size = cells.size();
+
+            // position leading cells
+            double offset = currOffset;
+            boolean first = true;
+            for (int i = currIndex; i >= 0 && i < size; i--) {
+                final T cell = cells.get(i);
+
+                offset -= first ? 0.0 : getCellLength(cell);
+                first = false;
+
+                positionCell(cell, offset);
+            }
+
+            // position trailing cells
+            offset = currOffset;
+            for (int i = currIndex; i >= 0 && i < size; i++) {
+                final T cell = cells.get(i);
+                positionCell(cell, offset);
+
+                offset += getCellLength(cell);
+            }
+        }
+
         // Now that we've laid out the cells, we may need to adjust the scroll
         // bars and update the viewport dimensions based on the bars
         // We have to do the following work twice because the first pass