changeset 7203:b229352490bb

RT-37408: [ScrollPane] incorrect preferred size when viewport pref size is specified and bar is present Reviewed by: martin
author David Grieve<david.grieve@oracle.com>
date Fri, 06 Jun 2014 09:17:55 -0400
parents ce8f5e176a92
children 7368fff13097
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java
diffstat 1 files changed, 10 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Fri Jun 06 13:39:12 2014 +0300
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java	Fri Jun 06 09:17:55 2014 -0400
@@ -710,7 +710,11 @@
     @Override protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
         final ScrollPane sp = getSkinnable();
 
-        double vsbWidth = sp.getVbarPolicy() == ScrollBarPolicy.ALWAYS ? vsb.prefWidth(ScrollBar.USE_COMPUTED_SIZE) : 0;
+        double vsbWidth =
+                ((sp.getVbarPolicy() == ScrollBarPolicy.ALWAYS) ||
+                 (sp.getVbarPolicy() == ScrollBarPolicy.AS_NEEDED && sp.getPrefViewportWidth() > 0))
+                ? vsb.prefWidth(ScrollBar.USE_COMPUTED_SIZE)
+                : 0;
         double minWidth = vsbWidth + snappedLeftInset() + snappedRightInset();
 
         if (sp.getPrefViewportWidth() > 0) {
@@ -727,7 +731,11 @@
     @Override protected double computePrefHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
         final ScrollPane sp = getSkinnable();
 
-        double hsbHeight = sp.getHbarPolicy() == ScrollBarPolicy.ALWAYS ? hsb.prefHeight(ScrollBar.USE_COMPUTED_SIZE) : 0;
+        double hsbHeight =
+                ((sp.getHbarPolicy() == ScrollBarPolicy.ALWAYS) ||
+                 (sp.getHbarPolicy() == ScrollBarPolicy.AS_NEEDED && sp.getPrefViewportHeight() > 0))
+                ? hsb.prefHeight(ScrollBar.USE_COMPUTED_SIZE)
+                : 0;
         double minHeight = hsbHeight + snappedTopInset() + snappedBottomInset();
 
         if (sp.getPrefViewportHeight() > 0) {