changeset 282:31e367e93df8

RT-18805: Additional fixes for SplitPane divider issues.
author Kinsley Wong
date Thu, 19 Jan 2012 14:27:56 -0800
parents dc3023f562bc
children 3492c5356f79
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java
diffstat 1 files changed, 22 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java	Thu Jan 19 14:26:07 2012 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java	Thu Jan 19 14:27:56 2012 -0800
@@ -693,7 +693,7 @@
                         extraSpace += (c.getArea() - c.getResizableWithParentArea());
                     } else {
                         // We are making the SplitPane smaller and will need to
-                        // find distribute the space requested.
+                        // distribute the space requested.
                         spaceRequested += (c.getResizableWithParentArea() - c.getArea());
                     }
                     c.setAvailable(0);
@@ -713,13 +713,23 @@
             }
 
             if (extraSpace > 0) {
-                double space = distributeTo(storageList, extraSpace);
-                if (space == 0) {
-                    spaceRequested -= extraSpace;
-                } else {
-                    spaceRequested -= space;
+                extraSpace = distributeTo(storageList, extraSpace);
+                // After distributing add any panels that may still need space to the
+                // spaceRequestor list.
+                spaceRequested = 0;
+                spaceRequestor.clear();
+                available = 0;
+                availableList.clear();
+                for (Content c: contentRegions) {
+                    if (c.getAvailable() < 0) {
+                        spaceRequested += c.getAvailable();
+                        spaceRequestor.add(c);
+                    } else {
+                        available += c.getAvailable();
+                        availableList.add(c);
+                    }
                 }
-                extraSpace = space;
+                spaceRequested = Math.abs(spaceRequested);
             }
 
             if (available >= spaceRequested) {
@@ -728,15 +738,15 @@
                     requestor.setArea(min);
                     requestor.setAvailable(0);
                 }
-                // We have some space requested but it is not from the space requestors.
-                // This is probably from resizing the SplitPane lets add this to
-                // extraSpace and try and redistribute it.
+                // After setting all the space requestors to their min we have to
+                // redistribute the space requested to any panel that still
+                // has available space.
                 if (spaceRequested > 0 && !spaceRequestor.isEmpty()) {
                     distributeFrom(spaceRequested, availableList);
                 }
 
-                // Only for resizing.  At this point we should have all the
-                // area available computed.  We can total them up and see
+                // Only for resizing.  We should have all the panel areas
+                // available computed.  We can total them up and see
                 // how much space we have left or went over and redistribute.
                 if (resize) {
                     double total = 0;