changeset 1808:988f6f79107b

Fix for RT-25049: SplitMenuButton have gap. As near as I can tell, they have a gap going back a long way. In fact, the gap is still there with Region caching disabled (in fact with region caching turned on, you don't get this gap at all, so I think this error came from some time in the past). The MenuButtonSkinBase layout was incorrect, along with the CSS.
author rbair
date Wed, 10 Oct 2012 11:30:25 -0700
parents ea00b638cdd6
children 32ed56155a53
files javafx-ui-common/src/javafx/scene/layout/CornerRadii.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css
diffstat 3 files changed, 42 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/javafx-ui-common/src/javafx/scene/layout/CornerRadii.java	Tue Oct 09 13:07:14 2012 -0700
+++ b/javafx-ui-common/src/javafx/scene/layout/CornerRadii.java	Wed Oct 10 11:30:25 2012 -0700
@@ -371,4 +371,39 @@
     @Override public int hashCode() {
         return hash;
     }
+
+    @Override public String toString() {
+        if (isUniform()) {
+            return "CornerRadii [uniform radius = " + topLeftHorizontalRadius + "]";
+        }
+
+        return "CornerRadii [" +
+                (topLeftHorizontalRadius == topLeftVerticalRadius ?
+                    "topLeft=" + topLeftHorizontalRadius :
+                    "topLeftHorizontalRadius=" + topLeftHorizontalRadius +
+                    ", topLeftVerticalRadius=" + topLeftVerticalRadius) +
+                (topRightHorizontalRadius == topRightVerticalRadius ?
+                    ", topRight=" + topRightHorizontalRadius :
+                    ", topRightVerticalRadius=" + topRightVerticalRadius +
+                    ", topRightHorizontalRadius=" + topRightHorizontalRadius) +
+                (bottomRightHorizontalRadius == bottomRightVerticalRadius ?
+                    ", bottomRight=" + bottomRightHorizontalRadius :
+                    ", bottomRightHorizontalRadius=" + bottomRightHorizontalRadius +
+                    ", bottomRightVerticalRadius=" + bottomRightVerticalRadius) +
+                (bottomLeftHorizontalRadius == bottomLeftVerticalRadius ?
+                    ", bottomLeft=" + bottomLeftHorizontalRadius :
+                    ", bottomLeftVerticalRadius=" + bottomLeftVerticalRadius +
+                    ", bottomLeftHorizontalRadius=" + bottomLeftHorizontalRadius) +
+//                ", topLeftHorizontalRadiusAsPercentage=" + topLeftHorizontalRadiusAsPercentage +
+//                ", topLeftVerticalRadiusAsPercentage=" + topLeftVerticalRadiusAsPercentage +
+//                ", topRightVerticalRadiusAsPercentage=" + topRightVerticalRadiusAsPercentage +
+//                ", topRightHorizontalRadiusAsPercentage=" + topRightHorizontalRadiusAsPercentage +
+//                ", bottomRightHorizontalRadiusAsPercentage=" + bottomRightHorizontalRadiusAsPercentage +
+//                ", bottomRightVerticalRadiusAsPercentage=" + bottomRightVerticalRadiusAsPercentage +
+//                ", bottomLeftVerticalRadiusAsPercentage=" + bottomLeftVerticalRadiusAsPercentage +
+//                ", bottomLeftHorizontalRadiusAsPercentage=" + bottomLeftHorizontalRadiusAsPercentage +
+//                ", hasPercentBasedRadii=" + hasPercentBasedRadii +
+//                ", uniform=" + uniform +
+                ']';
+    }
 }
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java	Tue Oct 09 13:07:14 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java	Wed Oct 10 11:30:25 2012 -0700
@@ -29,24 +29,19 @@
 import javafx.beans.value.ObservableValue;
 import javafx.collections.ListChangeListener;
 import javafx.event.ActionEvent;
+import javafx.event.Event;
 import javafx.event.EventHandler;
-import javafx.geometry.HPos;
 import javafx.geometry.Insets;
-import javafx.geometry.VPos;
 import javafx.scene.Scene;
 import javafx.scene.control.ContextMenu;
+import javafx.scene.control.Menu;
 import javafx.scene.control.MenuButton;
 import javafx.scene.control.MenuItem;
 import javafx.scene.control.SkinBase;
 import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.Region;
 import javafx.scene.layout.StackPane;
-
 import com.sun.javafx.scene.control.behavior.MenuButtonBehaviorBase;
-import javafx.event.Event;
-import javafx.event.Event;
-import javafx.event.EventType;
-import javafx.scene.control.Menu;
-import javafx.scene.layout.Region;
 
 /**
  * Base class for MenuButtonSkin and SplitMenuButtonSkin. It consists of the
@@ -266,20 +261,9 @@
 
     @Override protected void layoutChildren(final double x, final double y,
             final double w, final double h) {
-        final Insets padding = getInsets();
-        final Insets arrowButtonPadding = arrowButton.getInsets();
-
-        final double arrowWidth = arrow.prefWidth(-1);
-        final double arrowButtonWidth = arrowButtonPadding.getLeft() + arrowWidth + arrowButtonPadding.getRight();
-
+        final double arrowButtonWidth = Math.ceil(arrowButton.prefWidth(-1));
         label.resizeRelocate(x, y, w - arrowButtonWidth, h);
-
-        arrowButton.resize(arrowButtonWidth, h);
-        positionInArea(arrowButton, getWidth() - padding.getRight() - arrowButtonWidth, y, arrowButtonWidth, h,
-                /*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
-
-        // size popup to its pref size
-//        popup.autosize();
+        arrowButton.resizeRelocate(x+(w-arrowButtonWidth), y, arrowButtonWidth, h);
     }
 
     private void addAccelerators(javafx.collections.ObservableList<javafx.scene.control.MenuItem> mItems) {
--- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Tue Oct 09 13:07:14 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/caspian/caspian.css	Wed Oct 10 11:30:25 2012 -0700
@@ -1834,7 +1834,7 @@
 /* The SplitMenuButton skin uses an inner Label part */
 .split-menu-button > .label {
     -fx-background-color:  -fx-outer-border, -fx-inner-border, -fx-body-color;
-    -fx-background-insets: 0, 1, 2;
+    -fx-background-insets: 0, 1 0 1 1, 2 1 2 2;
     -fx-background-radius: 5 0 0 5, 4 0 0 4, 3 0 0 3;
     -fx-padding: 0.166667em 1.5em 0.25em 0.833333em; /* 2 18 3 10 */
 }
@@ -1850,7 +1850,7 @@
     -fx-color: -fx-hover-base;
 }
 
-.split-menu-button > .arrow-button:armed {
+.split-menu-button > .arrow-button:pressed {
     -fx-color: -fx-pressed-base;
 }