changeset 118:be35b718a109

RT-17754 : [ProgressIndicator] Size is not updated dynamicaly
author mickf
date Wed, 07 Dec 2011 13:13:35 +0000
parents 1145eb73b1b1
children 4c0d75c08ba5 1426b6d5b791
files javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java	Tue Dec 06 15:47:29 2011 -0800
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java	Wed Dec 07 13:13:35 2011 +0000
@@ -325,8 +325,22 @@
             tick.setLayoutY(indicator.getLayoutY() + (indicator.getHeight() / 2) - (tick.getHeight() / 2));
             tick.setVisible(control.getProgress() >= 1);
 
-            text.setLayoutY(y + indicator.getHeight() + textGap);
-            text.setLayoutX(indicator.getLayoutX() + (indicator.getWidth() - text.getLayoutBounds().getWidth()) / 2);
+            /*
+            ** if the % text can't fit anywhere in the bounds then don't display it
+            */
+            if (control.getWidth() >= com.sun.javafx.scene.control.skin.Utils.computeTextWidth(font, text.getText(), 0.0) &&
+                control.getHeight() >= com.sun.javafx.scene.control.skin.Utils.computeTextHeight(font, text.getText(), 0.0)) {
+                if (!text.isVisible()) {
+                    text.setVisible(true);
+                }
+                text.setLayoutY(y + indicator.getHeight() + textGap);
+                text.setLayoutX(indicator.getLayoutX() + (indicator.getWidth() - text.getLayoutBounds().getWidth()) / 2);
+            }
+            else {
+                if (text.isVisible()) {
+                    text.setVisible(false);
+                }
+            }
         }
 
         @Override protected double computePrefWidth(double height) {