changeset 6556:7d3f955a9729

RT-36166 [Layout] ListCell and FlowPane, minHeight issue Reviewed by: jgiles
author Martin Sladecek <martin.sladecek@oracle.com>
date Tue, 25 Mar 2014 10:09:11 +0100
parents e530f77a64a4
children baf51881af79
files modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListCellSkin.java modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java
diffstat 3 files changed, 21 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java	Tue Mar 25 10:34:57 2014 +0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/LabeledSkinBase.java	Tue Mar 25 10:09:11 2014 +0100
@@ -693,17 +693,16 @@
         // made by the ellipsis "...", and then by checking the width of the
         // string made up by labeled.text. We want the smaller of the two.
         final Labeled labeled = getSkinnable();
+        final ContentDisplay contentDisplay = labeled.getContentDisplay();
+        final double gap = labeled.getGraphicTextGap();
+        double minTextWidth = 0;
+
         final Font font = text.getFont();
         OverrunStyle truncationStyle = labeled.getTextOverrun();
         String ellipsisString = labeled.getEllipsisString();
         final String string = labeled.getText();
         final boolean emptyText = string == null || string.isEmpty();
-        final ContentDisplay contentDisplay = labeled.getContentDisplay();
-        final double gap = labeled.getGraphicTextGap();
-        final double widthPadding = leftInset + leftLabelPadding() +
-                                    rightInset + rightLabelPadding();
 
-        double minTextWidth = 0;
         if (!emptyText) {
             // We only want to recompute the full text width if the font or text changed
             if (truncationStyle == CLIP) {
@@ -737,7 +736,8 @@
             width = Math.max(minTextWidth, graphic.minWidth(-1));
         }
 
-        return width + widthPadding;
+        return width + leftInset + leftLabelPadding() +
+                rightInset + rightLabelPadding();
     }
 
     @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
@@ -768,9 +768,9 @@
             final Node graphic = labeled.getGraphic();
             if (labeled.getContentDisplay() == ContentDisplay.TOP
                 || labeled.getContentDisplay() == ContentDisplay.BOTTOM) {
-                h = graphic.minHeight(-1) + labeled.getGraphicTextGap() + textHeight;
+                h = graphic.minHeight(width) + labeled.getGraphicTextGap() + textHeight;
             } else {
-                h = Math.max(textHeight, graphic.minHeight(-1));
+                h = Math.max(textHeight, graphic.minHeight(width));
             }
         }
 
@@ -807,8 +807,8 @@
         final Font font = text.getFont();
         final ContentDisplay contentDisplay = labeled.getContentDisplay();
         final double gap = labeled.getGraphicTextGap();
-        double widthPadding = leftInset + leftLabelPadding() +
-                              rightInset + rightLabelPadding();
+        width -= leftInset + leftLabelPadding() +
+                rightInset + rightLabelPadding();
 
         String str = labeled.getText();
         if (str != null && str.endsWith("\n")) {
@@ -816,16 +816,15 @@
             str = str.substring(0, str.length() - 1);
         }
 
+        double textWidth = width;
         if (!isIgnoreGraphic() &&
             (contentDisplay == LEFT || contentDisplay == RIGHT)) {
-            width -= (graphic.prefWidth(-1) + gap);
+            textWidth -= (graphic.prefWidth(-1) + gap);
         }
 
-        width -= widthPadding;
-
         // TODO figure out how to cache this effectively.
         final double textHeight = Utils.computeTextHeight(font, str,
-                                                          labeled.isWrapText() ? width : 0,
+                                                          labeled.isWrapText() ? textWidth : 0,
                                                           labeled.getLineSpacing(), text.getBoundsType());
 
         // Now we want to add on the graphic if necessary!
@@ -833,9 +832,9 @@
         if (!isIgnoreGraphic()) {
             final Node graphic = labeled.getGraphic();
             if (contentDisplay == TOP || contentDisplay == BOTTOM) {
-                h = graphic.prefHeight(-1) + gap + textHeight;
+                h = graphic.prefHeight(width) + gap + textHeight;
             } else {
-                h = Math.max(textHeight, graphic.prefHeight(-1));
+                h = Math.max(textHeight, graphic.prefHeight(width));
             }
         }
 
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListCellSkin.java	Tue Mar 25 10:34:57 2014 +0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ListCellSkin.java	Tue Mar 25 10:09:11 2014 +0100
@@ -69,10 +69,7 @@
         // cell size to prevent the issue identified in RT-19873.
         final double cellSize = getCellSize();
         final double prefHeight = cellSize == DEFAULT_CELL_SIZE ? super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset) : cellSize;
-        
-        // RT-30212: ListCell does not honor minSize of cells
-        final ListCell<T> cell = getSkinnable();
-        return Math.max(cell.getMinHeight(), prefHeight);
+        return prefHeight;
     }
 
     @Override protected double computeMinHeight(double width, double topInset, double rightInset, double bottomInset, double leftInset) {
--- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Mar 25 10:34:57 2014 +0400
+++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/VirtualFlow.java	Tue Mar 25 10:09:11 2014 +0100
@@ -1299,7 +1299,7 @@
 
         // Assign the hbar and vbar to the breadthBar and lengthBar so as
         // to make some subsequent calculations easier.
-        VirtualScrollBar breadthBar = isVertical ? hbar : vbar;
+        VirtualScrollBar breadthBar = isVertical ? hba  r : vbar;
         VirtualScrollBar lengthBar = isVertical ? vbar : hbar;
         double breadthBarLength = snapSize(isVertical ? hbar.prefHeight(-1) : vbar.prefWidth(-1));
         double lengthBarBreadth = snapSize(isVertical ? vbar.prefWidth(-1) : hbar.prefHeight(-1));
@@ -1785,11 +1785,11 @@
         if (cell == null) return;
         
         if (isVertical()) {
-            double width = cell.getWidth();
-            cell.resize(width, fixedCellSizeEnabled ? fixedCellSize : cell.prefHeight(width));
+            double width = Math.max(getMaxPrefBreadth(), getViewportBreadth());
+            cell.resize(width, fixedCellSizeEnabled ? fixedCellSize : Utils.boundedSize(cell.prefHeight(width), cell.minHeight(width), cell.maxHeight(width)));
         } else {
-            double height = cell.getHeight();
-            cell.resize(fixedCellSizeEnabled ? fixedCellSize : cell.prefWidth(height), height);
+            double height = Math.max(getMaxPrefBreadth(), getViewportBreadth());
+            cell.resize(fixedCellSizeEnabled ? fixedCellSize : Utils.boundedSize(cell.prefWidth(height), cell.minWidth(height), cell.maxWidth(height)), height);
         }
     }