diff -r 99d9d2e87bd0 javafx-ui-charts/src/javafx/scene/chart/Chart.java --- a/javafx-ui-charts/src/javafx/scene/chart/Chart.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-charts/src/javafx/scene/chart/Chart.java Tue Apr 16 23:11:38 2013 -0700 @@ -75,10 +75,10 @@ */ private final Pane chartContent = new Pane() { @Override protected void layoutChildren() { - final double top = getInsets().getTop(); - final double left = getInsets().getLeft(); - final double bottom = getInsets().getBottom(); - final double right = getInsets().getRight(); + final double top = snappedTopInset(); + final double left = snappedLeftInset(); + final double bottom = snappedBottomInset(); + final double right = snappedRightInset(); final double width = getWidth(); final double height = getHeight(); final double contentWidth = snapSize(width - (left + right)); @@ -315,10 +315,10 @@ * Invoked during the layout pass to layout this chart and all its content. */ @Override protected void layoutChildren() { - double top = getInsets().getTop(); - double left = getInsets().getLeft(); - double bottom = getInsets().getBottom(); - double right = getInsets().getRight(); + double top = snappedTopInset(); + double left = snappedLeftInset(); + double bottom = snappedBottomInset(); + double right = snappedRightInset(); final double width = getWidth(); final double height = getHeight(); // layout title diff -r 99d9d2e87bd0 javafx-ui-common/src/javafx/scene/layout/Region.java --- a/javafx-ui-common/src/javafx/scene/layout/Region.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-common/src/javafx/scene/layout/Region.java Tue Apr 16 23:11:38 2013 -0700 @@ -1354,6 +1354,52 @@ return snapPosition(value, isSnapToPixel()); } + + /** + * Utility method to get the top inset which includes padding and border + * inset. Then snapped to whole pixels if isSnapToPixel() is true. + * + * @since 8.0 + * @return Rounded up insets top + */ + public final int snappedTopInset() { + return (int)snapSize(getInsets().getTop()); + } + + /** + * Utility method to get the bottom inset which includes padding and border + * inset. Then snapped to whole pixels if isSnapToPixel() is true. + * + * @since 8.0 + * @return Rounded up insets bottom + */ + public final int snappedBottomInset() { + return (int)snapSize(getInsets().getBottom()); + } + + /** + * Utility method to get the left inset which includes padding and border + * inset. Then snapped to whole pixels if isSnapToPixel() is true. + * + * @since 8.0 + * @return Rounded up insets left + */ + public final int snappedLeftInset() { + return (int)snapSize(getInsets().getLeft()); + } + + /** + * Utility method to get the right inset which includes padding and border + * inset. Then snapped to whole pixels if isSnapToPixel() is true. + * + * @since 8.0 + * @return Rounded up insets right + */ + public final int snappedRightInset() { + return (int)snapSize(getInsets().getRight()); + } + + double computeChildMinAreaWidth(Node child, Insets margin) { return computeChildMinAreaWidth(child, margin, -1); } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/charts/Legend.java --- a/javafx-ui-controls/src/com/sun/javafx/charts/Legend.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/charts/Legend.java Tue Apr 16 23:11:38 2013 -0700 @@ -133,39 +133,39 @@ } @Override protected double computePrefWidth(double height) { - final double contentHeight = height - getInsets().getTop() - getInsets().getBottom(); + final double contentHeight = height - snappedTopInset() - snappedBottomInset(); Dimension2D tileSize = getTileSize(); if(height == -1) { - if(columns <= 1) return tileSize.getWidth() + getInsets().getLeft() + getInsets().getRight(); + if(columns <= 1) return tileSize.getWidth() + snappedLeftInset() + snappedRightInset(); } else { rows = (int) Math.floor( contentHeight / (tileSize.getHeight() + GAP) ); columns = (rows == 0) ? (int)Math.ceil(getItems().size()) : (int)Math.ceil(getItems().size() / (double)rows); } if(columns == 1) rows = Math.min(rows, getItems().size()); - return (columns*(tileSize.getWidth()+GAP)) - GAP + getInsets().getLeft() + getInsets().getRight(); + return (columns*(tileSize.getWidth()+GAP)) - GAP + snappedLeftInset() + snappedRightInset(); } @Override protected double computePrefHeight(double width) { - final double contentWidth = width - getInsets().getLeft() - getInsets().getRight(); + final double contentWidth = width - snappedLeftInset() - snappedRightInset(); Dimension2D tileSize = getTileSize(); if(width == -1) { - if(rows <= 1) return tileSize.getHeight() + getInsets().getTop() + getInsets().getBottom(); + if(rows <= 1) return tileSize.getHeight() + snappedTopInset() + snappedBottomInset(); } else { columns = (int) Math.floor( contentWidth / (tileSize.getWidth() + GAP) ); rows = (columns == 0) ? (int)Math.ceil(getItems().size()) : (int)Math.ceil(getItems().size() / (double)columns); } if(rows == 1) columns = Math.min(columns, getItems().size()); - return (rows*(tileSize.getHeight()+GAP)) - GAP + getInsets().getTop() + getInsets().getBottom(); + return (rows*(tileSize.getHeight()+GAP)) - GAP + snappedTopInset() + snappedBottomInset(); } @Override protected void layoutChildren() { Dimension2D tileSize = getTileSize(); if(isVertical()) { - double left = getInsets().getLeft(); + double left = snappedLeftInset(); outer: for (int col=0; col < columns; col++) { - double top = getInsets().getTop(); + double top = snappedTopInset(); for (int row=0; row < rows; row++) { int itemIndex = (col*rows) + row; if(itemIndex >= getItems().size()) break outer; @@ -175,9 +175,9 @@ left += tileSize.getWidth() + GAP; } } else { - double top = getInsets().getTop(); + double top = snappedTopInset(); outer: for (int row=0; row < rows; row++) { - double left = getInsets().getLeft(); + double left = snappedLeftInset(); for (int col=0; col < columns; col++) { int itemIndex = (row*columns) + col; if(itemIndex >= getItems().size()) break outer; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/AccordionSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/AccordionSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/AccordionSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -39,7 +39,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javafx.geometry.Insets; public class AccordionSkin extends BehaviorSkinBase { @@ -95,7 +94,7 @@ } } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double h = 0; for (Node child: getChildren()) { h += snapSize(child.minHeight(width)); @@ -103,7 +102,7 @@ return h; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double h = 0; if (expandedPane != null) { @@ -123,9 +122,8 @@ h += snapSize(pane.minHeight(width)); } } - - Insets insets = getSkinnable().getInsets(); - return h + snapSpace(insets.getTop()) + snapSpace(insets.getBottom()); + + return h + topInset + bottomInset; } @Override protected void layoutChildren(final double x, double y, diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/BehaviorSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/BehaviorSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/BehaviorSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -159,8 +159,6 @@ super.dispose(); } - - /*************************************************************************** * * * Public API * diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/CheckBoxSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/CheckBoxSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/CheckBoxSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -26,7 +26,6 @@ package com.sun.javafx.scene.control.skin; import javafx.geometry.HPos; -import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.geometry.VPos; import javafx.scene.control.CheckBox; @@ -61,31 +60,28 @@ } } - @Override protected double computePrefWidth(double height) { - return super.computePrefWidth(height) + snapSize(box.prefWidth(-1)); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset) + snapSize(box.prefWidth(-1)); } - @Override protected double computePrefHeight(double width) { - Insets insets = getSkinnable().getInsets(); - return Math.max(super.computePrefHeight(width - box.prefWidth(-1)), - insets.getTop() + box.prefHeight(-1) + insets.getBottom()); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return Math.max(super.computePrefHeight(width - box.prefWidth(-1), topInset, rightInset, bottomInset, leftInset), + topInset + box.prefHeight(-1) + bottomInset); } - @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { - Insets padding = getSkinnable().getInsets(); final double boxWidth = snapSize(box.prefWidth(-1)); final double boxHeight = snapSize(box.prefHeight(-1)); final double labelWidth = Math.min(getSkinnable().prefWidth(-1) - boxWidth, w - snapSize(boxWidth)); final double labelHeight = Math.min(getSkinnable().prefHeight(labelWidth), h); final double maxHeight = Math.max(boxHeight, labelHeight); - final double xOffset = Utils.computeXOffset(w, labelWidth + boxWidth, getSkinnable().getAlignment().getHpos()) + padding.getLeft(); - final double yOffset = Utils.computeYOffset(h, maxHeight, getSkinnable().getAlignment().getVpos()) + padding.getTop(); + final double xOffset = Utils.computeXOffset(w, labelWidth + boxWidth, getSkinnable().getAlignment().getHpos()) + x; + final double yOffset = Utils.computeYOffset(h, maxHeight, getSkinnable().getAlignment().getVpos()) + x; layoutLabelInArea(xOffset + boxWidth, yOffset, labelWidth, maxHeight, Pos.CENTER_LEFT); box.resize(boxWidth, boxHeight); - positionInArea(box, xOffset, yOffset, boxWidth, maxHeight, getBaselineOffset(), HPos.CENTER, VPos.CENTER); + positionInArea(box, xOffset, yOffset, boxWidth, maxHeight, 0, HPos.CENTER, VPos.CENTER); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ChoiceBoxSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ChoiceBoxSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ChoiceBoxSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -52,7 +52,6 @@ import com.sun.javafx.scene.control.behavior.ChoiceBoxBehavior; import javafx.collections.WeakListChangeListener; -import javafx.geometry.Insets; /** @@ -331,31 +330,25 @@ double obw = openButton.prefWidth(-1); ChoiceBox control = getSkinnable(); - Insets insets = control.getInsets(); - label.resizeRelocate(insets.getLeft(), insets.getTop(), w, h); + label.resizeRelocate(x, y, w, h); openButton.resize(obw, openButton.prefHeight(-1)); - positionInArea(openButton, control.getWidth() - insets.getRight() - obw, - insets.getTop(), obw, h, /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); + positionInArea(openButton, (x+w) - obw, + y, obw, h, /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final double boxWidth = label.minWidth(-1) + openButton.minWidth(-1); final double popupWidth = popup.minWidth(-1); - final Insets insets = getSkinnable().getInsets(); - return insets.getLeft() + Math.max(boxWidth, popupWidth) - + insets.getRight(); + return leftInset + Math.max(boxWidth, popupWidth) + rightInset; } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final double displayHeight = label.minHeight(-1); final double openButtonHeight = openButton.minHeight(-1); - final Insets insets = getSkinnable().getInsets(); - return insets.getTop() - + Math.max(displayHeight, openButtonHeight) - + insets.getBottom(); + return topInset + Math.max(displayHeight, openButtonHeight) + bottomInset; } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final double boxWidth = label.prefWidth(-1) + openButton.prefWidth(-1); double popupWidth = popup.prefWidth(-1); @@ -364,25 +357,23 @@ popupWidth = (new Text(((MenuItem)popup.getItems().get(0)).getText())).prefWidth(-1); } } - final Insets insets = getSkinnable().getInsets(); - return (popup.getItems().size() == 0) ? 50 : insets.getLeft() + Math.max(boxWidth, popupWidth) - + insets.getRight(); + return (popup.getItems().size() == 0) ? 50 : leftInset + Math.max(boxWidth, popupWidth) + + rightInset; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final double displayHeight = label.prefHeight(-1); final double openButtonHeight = openButton.prefHeight(-1); - final Insets insets = getSkinnable().getInsets(); - return insets.getTop() + return topInset + Math.max(displayHeight, openButtonHeight) - + insets.getBottom(); + + bottomInset; } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefWidth(height); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPickerSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPickerSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ColorPickerSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -508,12 +508,12 @@ private class PickerColorBox extends StackPane { @Override protected void layoutChildren() { - final double top = getInsets().getTop(); - final double left = getInsets().getLeft(); + final double top = snappedTopInset(); + final double left = snappedLeftInset(); final double width = getWidth(); final double height = getHeight(); - final double right = getInsets().getRight(); - final double bottom = getInsets().getBottom(); + final double right = snappedRightInset(); + final double bottom = snappedBottomInset(); colorRect.setX(snapPosition(colorRectX.get())); colorRect.setY(snapPosition(colorRectY.get())); colorRect.setWidth(snapSize(colorRectWidth.get())); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxBaseSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -145,14 +145,11 @@ if (displayNode == null) { updateDisplayArea(); } - - final Insets padding = getSkinnable().getInsets(); - final Insets arrowButtonPadding = arrowButton.getInsets(); final double arrowWidth = snapSize(arrow.prefWidth(-1)); final double arrowButtonWidth = (isButton()) ? 0 : - (snapSpace(arrowButtonPadding.getLeft()) + arrowWidth + - snapSpace(arrowButtonPadding.getRight())); + arrowButton.snappedLeftInset() + arrowWidth + + arrowButton.snappedRightInset(); if (displayNode != null) { displayNode.resizeRelocate(x, y, w - arrowButtonWidth, h); @@ -162,29 +159,27 @@ arrowButton.resize(arrowButtonWidth, h); positionInArea(arrowButton, - getSkinnable().getWidth() - padding.getRight() - arrowButtonWidth, padding.getTop(), + (x+w) - arrowButtonWidth, y, arrowButtonWidth, h, 0, HPos.CENTER, VPos.CENTER); } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (displayNode == null) { updateDisplayArea(); } - - final Insets arrowButtonPadding = arrowButton.getInsets(); + final double arrowWidth = snapSize(arrow.prefWidth(-1)); final double arrowButtonWidth = (isButton()) ? 0 : - (snapSpace(arrowButtonPadding.getLeft()) + + arrowButton.snappedLeftInset() + arrowWidth + - snapSpace(arrowButtonPadding.getRight())); + arrowButton.snappedRightInset(); final double displayNodeWidth = displayNode == null ? 0 : displayNode.prefWidth(height); final double totalWidth = displayNodeWidth + arrowButtonWidth; - final Insets padding = getSkinnable().getInsets(); - return padding.getLeft() + totalWidth + padding.getRight(); + return leftInset + totalWidth + rightInset; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { if (displayNode == null) { updateDisplayArea(); @@ -199,23 +194,21 @@ double ph; if (displayNode == null) { final int DEFAULT_HEIGHT = 21; - final Insets arrowButtonPadding = arrowButton.getInsets(); double arrowHeight = (isButton()) ? 0 : - (arrowButtonPadding.getTop() + arrow.prefHeight(-1) + arrowButtonPadding.getBottom()); + (arrowButton.snappedTopInset() + arrow.prefHeight(-1) + arrowButton.snappedBottomInset()); ph = Math.max(DEFAULT_HEIGHT, arrowHeight); } else { ph = displayNode.prefHeight(width); } - final Insets padding = getSkinnable().getInsets(); - return padding.getTop()+ ph + padding.getBottom(); + return topInset+ ph + bottomInset; } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefWidth(height); } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ComboBoxListViewSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -26,7 +26,6 @@ package com.sun.javafx.scene.control.skin; import com.sun.javafx.scene.control.behavior.ComboBoxListViewBehavior; -import java.util.Collections; import java.util.List; import javafx.application.Platform; import javafx.beans.InvalidationListener; @@ -284,8 +283,8 @@ return listView; } - @Override protected double computePrefWidth(double height) { - double superPrefWidth = super.computePrefWidth(height); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + double superPrefWidth = super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); double listViewWidth = listView.prefWidth(height); double pw = Math.max(superPrefWidth, listViewWidth); @@ -294,7 +293,7 @@ return pw; } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return 50; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ContextMenuContent.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ContextMenuContent.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ContextMenuContent.java Tue Apr 16 23:11:38 2013 -0700 @@ -287,14 +287,14 @@ @Override protected void layoutChildren() { if (itemsContainer.getChildren().size() == 0) return; - final double x = snapSpace(getInsets().getLeft()); - final double y = snapSpace(getInsets().getTop()); - final double w = snapSize(getWidth()) - (snapSpace(getInsets().getLeft()) + snapSpace(getInsets().getRight())); - final double h = snapSize(getHeight()) - (snapSpace(getInsets().getTop()) + snapSpace(getInsets().getBottom())); + final double x = snappedLeftInset(); + final double y = snappedTopInset(); + final double w = getWidth() - x - snappedRightInset(); + final double h = getHeight() - y - snappedBottomInset(); final double contentHeight = snapSize(getContentHeight()); // itemsContainer.prefHeight(-1); itemsContainer.resize(w,contentHeight); - itemsContainer.relocate(snapSpace(getInsets().getLeft()), y); + itemsContainer.relocate(x, y); if (isFirstShow && ty == 0) { upArrow.setVisible(false); @@ -335,14 +335,14 @@ if (! n.isVisible()) continue; prefWidth = Math.max(prefWidth, snapSize(n.prefWidth(-1))); } - return snapSize(getInsets().getLeft()) + snapSize(prefWidth) + snapSize(getInsets().getRight()); + return snappedLeftInset() + snapSize(prefWidth) + snappedRightInset(); } @Override protected double computePrefHeight(double width) { if (itemsContainer.getChildren().size() == 0) return 0; final double screenHeight = getScreenHeight(); final double contentHeight = getContentHeight(); // itemsContainer.prefHeight(width); - double totalHeight = snapSpace(getInsets().getTop()) + snapSize(contentHeight) + snapSpace(getInsets().getBottom()); + double totalHeight = snappedTopInset() + snapSize(contentHeight) + snappedBottomInset(); // the pref height of this menu is the smaller value of the // actual pref height and the height of the screens _visual_ bounds. double prefHeight = (screenHeight <= 0) ? (totalHeight) : (Math.min(totalHeight, screenHeight)); @@ -778,7 +778,7 @@ double getMenuYOffset(int menuIndex) { double offset = 0; if (itemsContainer.getChildren().size() > menuIndex) { - offset = getInsets().getTop(); + offset = snappedTopInset(); Node menuitem = itemsContainer.getChildren().get(menuIndex); offset += menuitem.getLayoutY() + menuitem.prefHeight(-1); } @@ -962,7 +962,7 @@ if (n.isVisible()) { final double prefHeight = snapSize(n.prefHeight(-1)); n.resize(snapSize(getWidth()), prefHeight); - n.relocate(snapSpace(getInsets().getLeft()), yOffset); + n.relocate(snappedLeftInset(), yOffset); yOffset += prefHeight; } } @@ -1014,7 +1014,7 @@ } @Override protected double computePrefHeight(double width) { - return snapSize(getInsets().getTop()) + upDownArrow.prefHeight(-1) + snapSize(getInsets().getBottom()); + return snappedTopInset() + upDownArrow.prefHeight(-1) + snappedBottomInset(); } @Override protected void layoutChildren() { @@ -1354,27 +1354,27 @@ final double prefHeight = prefHeight(-1); if (left != null) { - xOffset = getInsets().getLeft(); + xOffset = snappedLeftInset(); left.resize(left.prefWidth(-1), left.prefHeight(-1)); positionInArea(left, xOffset, 0, maxLeftWidth, prefHeight, 0, HPos.LEFT, VPos.CENTER); } if (graphic != null) { - xOffset = getInsets().getLeft() + maxLeftWidth; + xOffset = snappedLeftInset() + maxLeftWidth; graphic.resize(graphic.prefWidth(-1), graphic.prefHeight(-1)); positionInArea(graphic, xOffset, 0, maxGraphicWidth, prefHeight, 0, HPos.LEFT, VPos.CENTER); } if (label != null) { - xOffset = getInsets().getLeft() + maxLeftWidth + maxGraphicWidth; + xOffset = snappedLeftInset() + maxLeftWidth + maxGraphicWidth; label.resize(label.prefWidth(-1), label.prefHeight(-1)); positionInArea(label, xOffset, 0, maxLabelWidth, prefHeight, 0, HPos.LEFT, VPos.CENTER); } if (right != null) { - xOffset = getInsets().getLeft() + maxLeftWidth + maxGraphicWidth + maxLabelWidth; + xOffset = snappedLeftInset() + maxLeftWidth + maxGraphicWidth + maxLabelWidth; right.resize(right.prefWidth(-1), right.prefHeight(-1)); positionInArea(right, xOffset, 0, maxRightWidth, prefHeight, 0, HPos.RIGHT, VPos.CENTER); @@ -1383,13 +1383,13 @@ if ( item instanceof CustomMenuItem) { Node n = ((CustomMenuItem) item).getContent(); if (item instanceof SeparatorMenuItem) { - double width = prefWidth(-1) - (getInsets().getLeft() + maxGraphicWidth + getInsets().getRight()); + double width = prefWidth(-1) - (snappedLeftInset() + maxGraphicWidth + snappedRightInset()); n.resize(width, n.prefHeight(-1)); - positionInArea(n, getInsets().getLeft() + maxGraphicWidth, 0, prefWidth(-1), prefHeight, 0, HPos.LEFT, VPos.CENTER); + positionInArea(n, snappedLeftInset() + maxGraphicWidth, 0, prefWidth(-1), prefHeight, 0, HPos.LEFT, VPos.CENTER); } else { n.resize(n.prefWidth(-1), n.prefHeight(-1)); //the node should be left aligned - positionInArea(n, getInsets().getLeft(), 0, getWidth(), prefHeight, 0, HPos.LEFT, VPos.CENTER); + positionInArea(n, snappedLeftInset(), 0, getWidth(), prefHeight, 0, HPos.LEFT, VPos.CENTER); } } } @@ -1404,18 +1404,18 @@ prefHeight = Math.max(prefHeight, (label != null) ? label.prefHeight(-1) : 0); prefHeight = Math.max(prefHeight, (right != null) ? right.prefHeight(-1) : 0); } - return getInsets().getTop() + prefHeight + getInsets().getBottom(); + return snappedTopInset() + prefHeight + snappedBottomInset(); } @Override protected double computePrefWidth(double height) { double nodeMenuItemWidth = 0; if (item instanceof CustomMenuItem && !(item instanceof SeparatorMenuItem)) { - nodeMenuItemWidth = getInsets().getLeft() + ((CustomMenuItem) item).getContent().prefWidth(-1) + - getInsets().getRight(); + nodeMenuItemWidth = snappedLeftInset() + ((CustomMenuItem) item).getContent().prefWidth(-1) + + snappedRightInset(); } return Math.max(nodeMenuItemWidth, - getInsets().getLeft() + maxLeftWidth + maxGraphicWidth + - maxLabelWidth + maxRightWidth + getInsets().getRight()); + snappedLeftInset() + maxLeftWidth + maxGraphicWidth + + maxLabelWidth + maxRightWidth + snappedRightInset()); } // Responsible for returning a graphic (if necessary) to position in the diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/EmbeddedTextContextMenuContent.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/EmbeddedTextContextMenuContent.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/EmbeddedTextContextMenuContent.java Tue Apr 16 23:11:38 2013 -0700 @@ -108,31 +108,25 @@ } @Override protected double computePrefHeight(double width) { - double top = snapSpace(getInsets().getTop()); - double bottom = snapSpace(getInsets().getBottom()); - double pointerHeight = snapSize(pointer.prefHeight(width)); - double menuBoxHeight = snapSize(menuBox.prefHeight(width)); - - return top + pointerHeight + menuBoxHeight + bottom; + final double pointerHeight = snapSize(pointer.prefHeight(width)); + final double menuBoxHeight = snapSize(menuBox.prefHeight(width)); + return snappedTopInset() + pointerHeight + menuBoxHeight + snappedBottomInset(); } @Override protected double computePrefWidth(double height) { - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); - double menuBoxWidth = snapSize(menuBox.prefWidth(height)); - - return left + menuBoxWidth + right; + final double menuBoxWidth = snapSize(menuBox.prefWidth(height)); + return snappedLeftInset() + menuBoxWidth + snappedRightInset(); } @Override protected void layoutChildren() { - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); - double top = snapSpace(getInsets().getTop()); - double width = snapSize(getWidth() - (left + right)); - double pointerWidth = snapSize(Utils.boundedSize(pointer.prefWidth(-1), pointer.minWidth(-1), pointer.maxWidth(-1))); - double pointerHeight = snapSize(Utils.boundedSize(pointer.prefWidth(-1), pointer.minWidth(-1), pointer.maxWidth(-1))); - double menuBoxWidth = snapSize(Utils.boundedSize(menuBox.prefWidth(-1), menuBox.minWidth(-1), menuBox.maxWidth(-1))); - double menuBoxHeight = snapSize(Utils.boundedSize(menuBox.prefWidth(-1), menuBox.minWidth(-1), menuBox.maxWidth(-1))); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); + final double top = snappedTopInset(); + final double width = getWidth() - (left + right); + final double pointerWidth = snapSize(Utils.boundedSize(pointer.prefWidth(-1), pointer.minWidth(-1), pointer.maxWidth(-1))); + final double pointerHeight = snapSize(Utils.boundedSize(pointer.prefWidth(-1), pointer.minWidth(-1), pointer.maxWidth(-1))); + final double menuBoxWidth = snapSize(Utils.boundedSize(menuBox.prefWidth(-1), menuBox.minWidth(-1), menuBox.maxWidth(-1))); + final double menuBoxHeight = snapSize(Utils.boundedSize(menuBox.prefWidth(-1), menuBox.minWidth(-1), menuBox.maxWidth(-1))); double sceneX = 0; double screenX = 0; double pointerX = 0; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/FXVKSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/FXVKSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/FXVKSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -28,9 +28,6 @@ import java.lang.reflect.Field; import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; @@ -41,30 +38,17 @@ import javafx.beans.Observable; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; -import javafx.event.ActionEvent; -import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventTarget; import javafx.event.EventType; -import javafx.geometry.Bounds; -import javafx.geometry.HPos; -import javafx.geometry.Insets; -import javafx.geometry.Point2D; -import javafx.geometry.Pos; import javafx.geometry.Rectangle2D; import javafx.geometry.VPos; -import javafx.geometry.Side; -import javafx.scene.Group; import javafx.scene.Node; -import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.*; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.*; -import javafx.scene.image.*; import javafx.stage.*; import javafx.util.Duration; @@ -73,30 +57,16 @@ import com.sun.javafx.robot.impl.FXRobotHelper.FXRobotInputAccessor; import com.sun.javafx.scene.control.behavior.BehaviorBase; -import javafx.animation.Animation.Status; -import static javafx.scene.input.KeyCode.*; -import static javafx.scene.input.MouseEvent.*; import static javafx.scene.layout.Region.*; -import static com.sun.javafx.scene.control.skin.resources.EmbeddedResources.*; - import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javafx.event.EventHandler; -import javafx.event.EventType; -import javafx.geometry.Insets; -import javafx.geometry.VPos; -import javafx.scene.input.KeyCode; -import javafx.scene.input.KeyEvent; -import javafx.scene.input.MouseEvent; import javafx.scene.layout.Region; import javafx.scene.text.Text; -import com.sun.javafx.scene.control.behavior.BehaviorBase; -import java.net.URL; public class FXVKSkin extends BehaviorSkinBase> { @@ -373,15 +343,13 @@ // This skin is designed such that it gives equal widths to all columns. So // the pref width is just some hard-coded value (although I could have maybe // done it based on the pref width of a text node with the right font). - @Override protected double computePrefWidth(double height) { - final Insets insets = getSkinnable().getInsets(); - return insets.getLeft() + (56 * numCols) + insets.getRight(); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return leftInset + (56 * numCols) + rightInset; } // Pref height is just some value. This isn't overly important. - @Override protected double computePrefHeight(double width) { - final Insets insets = getSkinnable().getInsets(); - return insets.getTop() + (80 * 5) + insets.getBottom(); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return topInset + (80 * 5) + bottomInset; } // Lays the buttons comprising the current keyboard out. The first row is always @@ -445,11 +413,10 @@ public void update(boolean capsDown, boolean shiftDown) { } @Override protected void layoutChildren() { - final Insets insets = getSkinnable().getInsets(); - final double left = insets.getLeft(); - final double top = insets.getTop(); - final double width = getWidth() - left - insets.getRight(); - final double height = getHeight() - top - insets.getBottom(); + final double left = snappedLeftInset(); + final double top = snappedTopInset(); + final double width = getWidth() - left - snappedRightInset(); + final double height = getHeight() - top - snappedBottomInset(); text.setVisible(icon.getBackground() == null); double contentPrefWidth = text.prefWidth(-1); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/LabeledSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/LabeledSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/LabeledSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -25,8 +25,6 @@ package com.sun.javafx.scene.control.skin; -import com.sun.javafx.tk.Toolkit; -import com.sun.javafx.tk.FontMetrics; import javafx.application.Platform; import javafx.beans.InvalidationListener; import javafx.beans.Observable; @@ -228,34 +226,18 @@ } } - protected double topPadding() { - return snapSize(getSkinnable().getInsets().getTop()); - } - - protected double topLabelPadding() { + protected double topLabelPadding() { // TODOJASPER remove these if you can return snapSize(getSkinnable().getLabelPadding().getTop()); } - protected double bottomPadding() { - return snapSize(getSkinnable().getInsets().getBottom()); - } - protected double bottomLabelPadding() { return snapSize(getSkinnable().getLabelPadding().getBottom()); } - protected double leftPadding() { - return snapSize(getSkinnable().getInsets().getLeft()); - } - protected double leftLabelPadding() { return snapSize(getSkinnable().getLabelPadding().getLeft()); } - protected double rightPadding() { - return snapSize(getSkinnable().getInsets().getRight()); - } - protected double rightLabelPadding() { return snapSize(getSkinnable().getLabelPadding().getRight()); } @@ -475,14 +457,14 @@ (labeled.getContentDisplay() == ContentDisplay.LEFT || labeled.getContentDisplay() == ContentDisplay.RIGHT); - double availableWidth = labeled.getWidth() - leftPadding() - leftLabelPadding() - - rightPadding() - rightLabelPadding(); + double availableWidth = labeled.getWidth() - snappedLeftInset() - leftLabelPadding() - + snappedRightInset() - rightLabelPadding(); availableWidth = Math.max(availableWidth, 0); if (w == -1) { w = availableWidth; } - double minW = Math.min(computeMinWidth(-1), availableWidth); + double minW = Math.min(computeMinWidth(-1, snappedTopInset() , snappedRightInset(), snappedBottomInset(), snappedLeftInset()), availableWidth); if (horizontalPosition && !isIgnoreGraphic()) { double graphicW = (labeled.getGraphic().getLayoutBounds().getWidth() + labeled.getGraphicTextGap()); w -= graphicW; @@ -494,14 +476,14 @@ (labeled.getContentDisplay() == ContentDisplay.TOP || labeled.getContentDisplay() == ContentDisplay.BOTTOM); - double availableHeight = labeled.getHeight() - topPadding() - topLabelPadding() - - bottomPadding() - bottomLabelPadding(); + double availableHeight = labeled.getHeight() - snappedTopInset() - topLabelPadding() - + snappedBottomInset() - bottomLabelPadding(); availableHeight = Math.max(availableHeight, 0); if (h == -1) { h = availableHeight; } - double minH = Math.min(computeMinHeight(w), availableHeight); + double minH = Math.min(computeMinHeight(w, snappedTopInset() , snappedRightInset(), snappedBottomInset(), snappedLeftInset()), availableHeight); if (verticalPosition && labeled.getGraphic() != null) { double graphicH = labeled.getGraphic().getLayoutBounds().getHeight() + labeled.getGraphicTextGap(); h -= graphicH; @@ -662,7 +644,7 @@ * about a single or multiline labeled. So a multiline labeled may find that * the width of the "..." is as small as it will ever get. */ - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { // First compute the minTextWidth by checking the width of the string // 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. @@ -674,8 +656,8 @@ final boolean emptyText = string == null || string.isEmpty(); final ContentDisplay contentDisplay = labeled.getContentDisplay(); final double gap = labeled.getGraphicTextGap(); - final double widthPadding = leftPadding() + leftLabelPadding() + - rightPadding() + rightLabelPadding(); + final double widthPadding = leftInset + leftLabelPadding() + + rightInset + rightLabelPadding(); double minTextWidth = 0; if (!emptyText) { @@ -714,7 +696,7 @@ return width + widthPadding; } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final Labeled labeled = getSkinnable(); final Font font = text.getFont(); @@ -744,17 +726,17 @@ } } - return topPadding() + h + bottomPadding() + topLabelPadding() - bottomLabelPadding(); + return topInset + h + bottomInset + topLabelPadding() - bottomLabelPadding(); } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { // Get the preferred width of the text final Labeled labeled = getSkinnable(); final Font font = text.getFont(); final String string = labeled.getText(); boolean emptyText = string == null || string.isEmpty(); - double widthPadding = leftPadding() + leftLabelPadding() + - rightPadding() + rightLabelPadding(); + double widthPadding = leftInset + leftLabelPadding() + + rightInset + rightLabelPadding(); double textWidth = emptyText ? 0 : Utils.computeTextWidth(font, string, 0); @@ -772,13 +754,13 @@ } } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final Labeled labeled = getSkinnable(); final Font font = text.getFont(); final ContentDisplay contentDisplay = labeled.getContentDisplay(); final double gap = labeled.getGraphicTextGap(); - double widthPadding = leftPadding() + leftLabelPadding() + - rightPadding() + rightLabelPadding(); + double widthPadding = leftInset + leftLabelPadding() + + rightInset + rightLabelPadding(); String str = labeled.getText(); if (str != null && str.endsWith("\n")) { @@ -809,18 +791,18 @@ } } - return topPadding() + h + bottomPadding() + topLabelPadding() + bottomLabelPadding(); + return topInset + h + bottomInset + topLabelPadding() + bottomLabelPadding(); } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefWidth(height); } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } - @Override public double getBaselineOffset() { + @Override public double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { double textBaselineOffset = text.getBaselineOffset(); double h = textBaselineOffset; final Labeled labeled = getSkinnable(); @@ -834,7 +816,7 @@ } } - return topPadding() + topLabelPadding() + h; + return topInset + topLabelPadding() + h; } public TextBinding bindings; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListCellSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListCellSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListCellSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -37,19 +37,19 @@ super(control, new ListCellBehavior(control)); } - @Override protected double computePrefWidth(double height) { - double pref = super.computePrefWidth(height); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + double pref = super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); ListView listView = getSkinnable().getListView(); return listView == null ? 0 : listView.getOrientation() == Orientation.VERTICAL ? pref : Math.max(pref, getCellSize()); } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { // if (cellSizeSet) { // Added the comparison between the default cell size and the requested // cell size to prevent the issue identified in RT-19873. double cellSize = getCellSize(); - return cellSize == DEFAULT_CELL_SIZE ? super.computePrefHeight(width) : cellSize; + return cellSize == DEFAULT_CELL_SIZE ? super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset) : cellSize; // } else { // return Math.max(DEFAULT_CELL_SIZE, super.computePrefHeight(width)); // } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ListViewSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -41,7 +41,6 @@ import javafx.util.Callback; import com.sun.javafx.scene.control.behavior.ListViewBehavior; import com.sun.javafx.scene.control.skin.resources.ControlResources; -import javafx.geometry.Insets; import javafx.scene.control.Label; import javafx.scene.layout.StackPane; @@ -349,19 +348,18 @@ } } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (getItemCount() == 0) { if (placeholderRegion == null) { updatePlaceholderRegionVisibility(); } - final Insets insets = getSkinnable().getInsets(); - return placeholderRegion.prefWidth(height) + insets.getLeft() + insets.getRight(); + return placeholderRegion.prefWidth(height) + leftInset + rightInset; } else { - return computePrefHeight(-1) * 0.618033987; + return computePrefHeight(-1, topInset, rightInset, bottomInset, leftInset) * 0.618033987; } } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { // return getInsets().getTop() + flow.computePrefHeight(width) + getInsets().getBottom(); return 400; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuBarSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -922,12 +922,18 @@ // Return empty insets when "container" is empty, which happens // when using the system menu bar. - private Insets getInsets() { - if (container.getChildren().isEmpty()) { - return Insets.EMPTY; - } else { - return getSkinnable().getInsets(); - } + + @Override protected int snappedTopInset() { + return container.getChildren().isEmpty() ? 0 : super.snappedTopInset(); + } + @Override protected int snappedBottomInset() { + return container.getChildren().isEmpty() ? 0 : super.snappedBottomInset(); + } + @Override protected int snappedLeftInset() { + return container.getChildren().isEmpty() ? 0 : super.snappedLeftInset(); + } + @Override protected int snappedRightInset() { + return container.getChildren().isEmpty() ? 0 : super.snappedRightInset(); } /** @@ -940,28 +946,24 @@ container.resizeRelocate(x, y, w, h); } - @Override protected double computeMinWidth(double height) { - Insets insets = getInsets(); - return container.minWidth(height) + insets.getLeft() + insets.getRight(); + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return container.minWidth(height) + snappedLeftInset() + snappedRightInset(); } - @Override protected double computePrefWidth(double height) { - Insets insets = getInsets(); - return container.prefWidth(height) + insets.getLeft() + insets.getRight(); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return container.prefWidth(height) + snappedLeftInset() + snappedRightInset(); } - @Override protected double computeMinHeight(double width) { - Insets insets = getInsets(); - return container.minHeight(width) + insets.getTop() + insets.getBottom(); + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return container.minHeight(width) + snappedTopInset() + snappedBottomInset(); } - @Override protected double computePrefHeight(double width) { - Insets insets = getInsets(); - return container.prefHeight(width) + insets.getTop() + insets.getBottom(); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return container.prefHeight(width) + snappedTopInset() + snappedBottomInset(); } // grow horizontally, but not vertically - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(-1); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/MenuButtonSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -31,7 +31,6 @@ import javafx.event.ActionEvent; import javafx.event.Event; import javafx.event.EventHandler; -import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.CheckMenuItem; import javafx.scene.control.ContextMenu; @@ -232,26 +231,24 @@ * * **************************************************************************/ - @Override protected double computePrefWidth(double height) { - final Insets padding = getSkinnable().getInsets(); - return padding.getLeft() + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return leftInset + label.prefWidth(height) + snapSize(arrowButton.prefWidth(height)) - + padding.getRight(); + + rightInset; } - @Override protected double computePrefHeight(double width) { - final Insets padding = getSkinnable().getInsets(); - return padding.getTop() + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return topInset + Math.max(label.prefHeight(width), snapSize(arrowButton.prefHeight(-1))) - + padding.getBottom(); + + bottomInset; } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefWidth(height); } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/NestedTableColumnHeader.java Tue Apr 16 23:11:38 2013 -0700 @@ -417,19 +417,19 @@ updateColumns = false; getParent().requestLayout(); } - double w = getWidth() - getInsets().getLeft() - getInsets().getRight(); - double h = getHeight() - getInsets().getTop() - getInsets().getBottom(); + double w = getWidth() - snappedLeftInset() - snappedRightInset(); + double h = getHeight() - snappedTopInset() - snappedBottomInset(); int labelHeight = (int) label.prefHeight(-1); if (label.isVisible()) { // label gets to span whole width and sits at top label.resize(w, labelHeight); - label.relocate(getInsets().getLeft(), getInsets().getTop()); + label.relocate(snappedLeftInset(), snappedTopInset()); } // children columns need to share the total available width - double x = getInsets().getLeft(); + double x = snappedLeftInset(); int i = 0; for (TableColumnHeader n : getColumnHeaders()) { if (! n.isVisible()) continue; @@ -439,7 +439,7 @@ // position the column header in the default location... n.resize(prefWidth, snapSize(h - labelHeight)); - n.relocate(x, labelHeight + getInsets().getTop()); + n.relocate(x, labelHeight + snappedTopInset()); // // ...but, if there are no children of this column, we should ensure // // that it is resized vertically such that it goes to the very @@ -457,7 +457,7 @@ if (dragRects != null && i < dragRects.size()) { Rectangle dragRect = dragRects.get(i++); dragRect.setHeight(getHeight() - label.getHeight()); - dragRect.relocate(x - DRAG_RECT_WIDTH / 2, getInsets().getTop() + labelHeight); + dragRect.relocate(x - DRAG_RECT_WIDTH / 2, snappedTopInset() + labelHeight); } } } @@ -486,7 +486,7 @@ } } - return height + label.prefHeight(-1) + getInsets().getTop() + getInsets().getBottom(); + return height + label.prefHeight(-1) + snappedTopInset() + snappedBottomInset(); } private TableColumnHeader createColumnHeader(TableColumnBase col) { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PaginationSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PaginationSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/PaginationSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -150,7 +150,6 @@ private void initializeSwipeAndTouchHandlers() { final Pagination control = getSkinnable(); - final Insets controlPadding = control.getInsets(); getSkinnable().setOnTouchPressed(new EventHandler() { @Override public void handle(TouchEvent e) { @@ -185,7 +184,7 @@ } if (touchThresholdBroken) { - double width = control.getWidth() - (controlPadding.getLeft() + controlPadding.getRight()); + double width = control.getWidth() - (snappedLeftInset() + snappedRightInset()); double currentPaneX; double nextPaneX; @@ -267,7 +266,7 @@ final double velocity = quick ? (double)drag / time : touchVelocity; // pixels/ms // calculate distance we would travel at this speed for 500ms of travel final double distance = (velocity * 500); - final double width = control.getWidth() - (controlPadding.getLeft() + controlPadding.getRight()); + final double width = control.getWidth() - (snappedLeftInset() + snappedRightInset()); // The swipe distance travelled. final double threshold = Math.abs(distance/width); @@ -680,49 +679,34 @@ getSkinnable().requestLayout(); } - @Override protected double computeMinWidth(double height) { - Insets padding = getSkinnable().getInsets(); - double left = snapSpace(padding.getLeft()); - double right = snapSpace(padding.getRight()); + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double navigationWidth = navigation.isVisible() ? snapSize(navigation.minWidth(height)) : 0; - return left + Math.max(currentStackPane.minWidth(height), navigationWidth) + right; + return leftInset + Math.max(currentStackPane.minWidth(height), navigationWidth) + rightInset; } - @Override protected double computeMinHeight(double width) { - Insets padding = getSkinnable().getInsets(); - double top = snapSpace(padding.getTop()); - double bottom = snapSpace(padding.getBottom()); + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double navigationHeight = navigation.isVisible() ? snapSize(navigation.minHeight(width)) : 0; - return top + currentStackPane.minHeight(width) + navigationHeight + bottom; + return topInset + currentStackPane.minHeight(width) + navigationHeight + bottomInset; } - @Override protected double computePrefWidth(double height) { - Insets padding = getSkinnable().getInsets(); - double left = snapSpace(padding.getLeft()); - double right = snapSpace(padding.getRight()); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double navigationWidth = navigation.isVisible() ? snapSize(navigation.prefWidth(height)) : 0; - return left + Math.max(currentStackPane.prefWidth(height), navigationWidth) + right; + return leftInset + Math.max(currentStackPane.prefWidth(height), navigationWidth) + rightInset; } - @Override protected double computePrefHeight(double width) { - Insets padding = getSkinnable().getInsets(); - double top = snapSpace(padding.getTop()); - double bottom = snapSpace(padding.getBottom()); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(width)) : 0; - return top + currentStackPane.prefHeight(width) + navigationHeight + bottom; + return topInset + currentStackPane.prefHeight(width) + navigationHeight + bottomInset; } @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { - Insets padding = getSkinnable().getInsets(); - double left = snapSpace(padding.getLeft()); - double top = snapSpace(padding.getTop()); double navigationHeight = navigation.isVisible() ? snapSize(navigation.prefHeight(-1)) : 0; double stackPaneHeight = snapSize(h - navigationHeight); - layoutInArea(currentStackPane, left, top, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER); - layoutInArea(nextStackPane, left, top, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER); - layoutInArea(navigation, left, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER); + layoutInArea(currentStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER); + layoutInArea(nextStackPane, x, y, w, stackPaneHeight, 0, HPos.CENTER, VPos.CENTER); + layoutInArea(navigation, x, stackPaneHeight, w, navigationHeight, 0, HPos.CENTER, VPos.CENTER); } class NavigationControl extends StackPane { @@ -883,14 +867,14 @@ // Layout the maximum number of page indicators we can fit within the width. // And always show the selected indicator. private void layoutPageIndicators() { - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); - double width = snapSize(getWidth()) - (left + right); - double controlBoxleft = snapSpace(controlBox.getInsets().getLeft()); - double controlBoxRight = snapSpace(controlBox.getInsets().getRight()); - double leftArrowWidth = snapSize(Utils.boundedSize(leftArrowButton.prefWidth(-1), leftArrowButton.minWidth(-1), leftArrowButton.maxWidth(-1))); - double rightArrowWidth = snapSize(Utils.boundedSize(rightArrowButton.prefWidth(-1), rightArrowButton.minWidth(-1), rightArrowButton.maxWidth(-1))); - double spacing = snapSize(controlBox.getSpacing()); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); + final double width = snapSize(getWidth()) - (left + right); + final double controlBoxleft = controlBox.snappedLeftInset(); + final double controlBoxRight = controlBox.snappedRightInset(); + final double leftArrowWidth = snapSize(Utils.boundedSize(leftArrowButton.prefWidth(-1), leftArrowButton.minWidth(-1), leftArrowButton.maxWidth(-1))); + final double rightArrowWidth = snapSize(Utils.boundedSize(rightArrowButton.prefWidth(-1), rightArrowButton.minWidth(-1), rightArrowButton.maxWidth(-1))); + final double spacing = snapSize(controlBox.getSpacing()); double w = width - (controlBoxleft + leftArrowWidth + spacing + rightArrowWidth + controlBoxRight); if (isPageInformationVisible() && @@ -1070,8 +1054,8 @@ } @Override protected double computeMinWidth(double height) { - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); + double left = snappedLeftInset(); + double right = snappedRightInset(); double leftArrowWidth = snapSize(Utils.boundedSize(leftArrowButton.prefWidth(-1), leftArrowButton.minWidth(-1), leftArrowButton.maxWidth(-1))); double rightArrowWidth = snapSize(Utils.boundedSize(rightArrowButton.prefWidth(-1), rightArrowButton.minWidth(-1), rightArrowButton.maxWidth(-1))); double spacing = snapSize(controlBox.getSpacing()); @@ -1089,9 +1073,9 @@ } @Override protected double computePrefWidth(double height) { - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); - double controlBoxWidth = snapSize(controlBox.prefWidth(height)); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); + final double controlBoxWidth = snapSize(controlBox.prefWidth(height)); double pageInformationWidth = 0; Side side = getPageInformationAlignment(); if (Side.LEFT.equals(side) || Side.RIGHT.equals(side)) { @@ -1102,9 +1086,9 @@ } @Override protected double computePrefHeight(double width) { - double top = snapSpace(getInsets().getTop()); - double bottom = snapSpace(getInsets().getBottom()); - double boxHeight = snapSize(controlBox.prefHeight(width)); + final double top = snappedTopInset(); + final double bottom = snappedBottomInset(); + final double boxHeight = snapSize(controlBox.prefHeight(width)); double pageInformationHeight = 0; Side side = getPageInformationAlignment(); if (Side.TOP.equals(side) || Side.BOTTOM.equals(side)) { @@ -1115,16 +1099,16 @@ } @Override protected void layoutChildren() { - double top = snapSpace(getInsets().getTop()); - double bottom = snapSpace(getInsets().getBottom()); - double left = snapSpace(getInsets().getLeft()); - double right = snapSpace(getInsets().getRight()); - double width = snapSize(getWidth()) - (left + right); - double height = snapSize(getHeight()) - (top + bottom); - double controlBoxWidth = snapSize(controlBox.prefWidth(-1)); - double controlBoxHeight = snapSize(controlBox.prefHeight(-1)); - double pageInformationWidth = snapSize(pageInformation.prefWidth(-1)); - double pageInformationHeight = snapSize(pageInformation.prefHeight(-1)); + final double top = snappedTopInset(); + final double bottom = snappedBottomInset(); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); + final double width = snapSize(getWidth()) - (left + right); + final double height = snapSize(getHeight()) - (top + bottom); + final double controlBoxWidth = snapSize(controlBox.prefWidth(-1)); + final double controlBoxHeight = snapSize(controlBox.prefHeight(-1)); + final double pageInformationWidth = snapSize(pageInformation.prefWidth(-1)); + final double pageInformationHeight = snapSize(pageInformation.prefHeight(-1)); leftArrowButton.setDisable(false); rightArrowButton.setDisable(false); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressBarSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressBarSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressBarSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -263,8 +263,7 @@ control.sceneProperty().addListener(sceneListener); - final Insets padding = getSkinnable().getInsets(); - barWidth = ((int) (control.getWidth() - padding.getLeft() - padding.getRight()) * 2 * Math.min(1, Math.max(0, control.getProgress()))) / 2.0F; + barWidth = ((int) (control.getWidth() - snappedLeftInset() - snappedRightInset()) * 2 * Math.min(1, Math.max(0, control.getProgress()))) / 2.0F; InvalidationListener listener = new InvalidationListener() { @Override public void invalidated(Observable valueModel) { @@ -342,8 +341,7 @@ if (indeterminateTimeline != null) indeterminateTimeline.stop(); ProgressBar control = getSkinnable(); - Insets padding = control.getInsets(); - final double w = control.getWidth() - (padding.getLeft() + padding.getRight()); + final double w = control.getWidth() - (snappedLeftInset() + snappedRightInset()); final double startX = getIndeterminateBarEscape()? -getIndeterminateBarLength() : 0; final double endX = getIndeterminateBarEscape()? w : w - getIndeterminateBarLength(); @@ -401,15 +399,14 @@ private void updateProgress() { ProgressBar control = getSkinnable(); - Insets padding = control.getInsets(); - barWidth = ((int) (control.getWidth() - padding.getLeft() - padding.getRight()) * 2 * Math.min(1, Math.max(0, control.getProgress()))) / 2.0F; + barWidth = ((int) (control.getWidth() - snappedLeftInset() - snappedRightInset()) * 2 * Math.min(1, Math.max(0, control.getProgress()))) / 2.0F; getSkinnable().requestLayout(); } @Override - public double getBaselineOffset() { + public double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { double height = getSkinnable().getHeight(); - return getSkinnable().getInsets().getTop() + height; + return topInset + height; } @Override public void dispose() { @@ -428,22 +425,19 @@ * * **************************************************************************/ - @Override protected double computePrefWidth(double height) { - ProgressBar control = getSkinnable(); - Insets padding = control.getInsets(); - return Math.max(100, padding.getLeft() + bar.prefWidth(control.getWidth()) + padding.getRight()); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return Math.max(100, leftInset + bar.prefWidth(getSkinnable().getWidth()) + rightInset); } - @Override protected double computePrefHeight(double width) { - Insets padding = getSkinnable().getInsets(); - return padding.getTop() + bar.prefHeight(width) + padding.getBottom(); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return topInset + bar.prefHeight(width) + bottomInset; } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefWidth(height); } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } @@ -451,7 +445,6 @@ final double w, final double h) { final ProgressBar control = getSkinnable(); - final Insets padding = control.getInsets(); boolean isIndeterminate = control.isIndeterminate(); // resize clip diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -305,11 +305,10 @@ @Override protected void layoutChildren() { // Position and size the circular background double doneTextHeight = doneText.getLayoutBounds().getHeight(); - final Insets controlInsets = control.getInsets(); - final double left = snapSize(controlInsets.getLeft()); - final double right = snapSize(controlInsets.getRight()); - final double top = snapSize(controlInsets.getTop()); - final double bottom = snapSize(controlInsets.getBottom()); + final double left = control.snappedLeftInset(); + final double right = control.snappedRightInset(); + final double top = control.snappedTopInset(); + final double bottom = control.snappedBottomInset(); /* ** use the min of width, or height, keep it a circle @@ -323,11 +322,10 @@ final double centerY = snapPosition(top + radius); // find radius that fits inside radius - insetsPadding - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); + final double iLeft = indicator.snappedLeftInset(); + final double iRight = indicator.snappedRightInset(); + final double iTop = indicator.snappedTopInset(); + final double iBottom = indicator.snappedBottomInset(); final double progressRadius = snapSize(Math.min( Math.min(radius - iLeft, radius - iRight), Math.min(radius - iTop, radius - iBottom))); @@ -342,11 +340,10 @@ progress.setLayoutY(centerY); // find radius that fits inside progressRadius - progressInsets - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); + final double pLeft = progress.snappedLeftInset(); + final double pRight = progress.snappedRightInset(); + final double pTop = progress.snappedTopInset(); + final double pBottom = progress.snappedBottomInset(); final double indicatorRadius = snapSize(Math.min( Math.min(progressRadius - pLeft, progressRadius - pRight), Math.min(progressRadius - pTop, progressRadius - pBottom))); @@ -373,47 +370,39 @@ } @Override protected double computePrefWidth(double height) { - final Insets controlInsets = control.getInsets(); - final double left = snapSize(controlInsets.getLeft()); - final double right = snapSize(controlInsets.getRight()); - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); + final double left = control.snappedLeftInset(); + final double right = control.snappedRightInset(); + final double iLeft = indicator.snappedLeftInset(); + final double iRight = indicator.snappedRightInset(); + final double iTop = indicator.snappedTopInset(); + final double iBottom = indicator.snappedBottomInset(); final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); + final double pLeft = progress.snappedLeftInset(); + final double pRight = progress.snappedRightInset(); + final double pTop = progress.snappedTopInset(); + final double pBottom = progress.snappedBottomInset(); final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); - final Insets tickInsets = tick.getInsets(); - final double tLeft = snapSize(tickInsets.getLeft()); - final double tRight = snapSize(tickInsets.getRight()); + final double tLeft = tick.snappedLeftInset(); + final double tRight = tick.snappedRightInset(); final double indicatorWidth = indicatorMax + progressMax + tLeft + tRight + progressMax + indicatorMax; return left + Math.max(indicatorWidth, doneText.getLayoutBounds().getWidth()) + right; } @Override protected double computePrefHeight(double width) { - final Insets controlInsets = control.getInsets(); - final double top = snapSize(controlInsets.getTop()); - final double bottom = snapSize(controlInsets.getBottom()); - final Insets indicatorInsets = indicator.getInsets(); - final double iLeft = snapSize(indicatorInsets.getLeft()); - final double iRight = snapSize(indicatorInsets.getRight()); - final double iTop = snapSize(indicatorInsets.getTop()); - final double iBottom = snapSize(indicatorInsets.getBottom()); + final double top = control.snappedTopInset(); + final double bottom = control.snappedBottomInset(); + final double iLeft = indicator.snappedLeftInset(); + final double iRight = indicator.snappedRightInset(); + final double iTop = indicator.snappedTopInset(); + final double iBottom = indicator.snappedBottomInset(); final double indicatorMax = snapSize(Math.max(Math.max(iLeft, iRight), Math.max(iTop, iBottom))); - final Insets progressInsets = progress.getInsets(); - final double pLeft = snapSize(progressInsets.getLeft()); - final double pRight = snapSize(progressInsets.getRight()); - final double pTop = snapSize(progressInsets.getTop()); - final double pBottom = snapSize(progressInsets.getBottom()); + final double pLeft = progress.snappedLeftInset(); + final double pRight = progress.snappedRightInset(); + final double pTop = progress.snappedTopInset(); + final double pBottom = progress.snappedBottomInset(); final double progressMax = snapSize(Math.max(Math.max(pLeft, pRight), Math.max(pTop, pBottom))); - final Insets tickInsets = tick.getInsets(); - final double tTop = snapSize(tickInsets.getTop()); - final double tBottom = snapSize(tickInsets.getBottom()); + final double tTop = tick.snappedTopInset(); + final double tBottom = tick.snappedBottomInset(); final double indicatorHeight = indicatorMax + progressMax + tTop + tBottom + progressMax + indicatorMax; return top + indicatorHeight + textGap + doneText.getLayoutBounds().getHeight() + bottom; } @@ -569,9 +558,8 @@ } @Override protected void layoutChildren() { - Insets controlInsets = control.getInsets(); - final double w = control.getWidth() - controlInsets.getLeft() - controlInsets.getRight(); - final double h = control.getHeight() - controlInsets.getTop() - controlInsets.getBottom(); + final double w = control.getWidth() - control.snappedLeftInset() - control.snappedRightInset(); + final double h = control.getHeight() - control.snappedTopInset() - control.snappedBottomInset(); final double prefW = pathsG.prefWidth(-1); final double prefH = pathsG.prefHeight(-1); double scaleX = w / prefW; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/RadioButtonSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/RadioButtonSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/RadioButtonSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -78,30 +78,28 @@ * * **************************************************************************/ - @Override protected double computePrefWidth(double height) { - return super.computePrefWidth(height) + snapSize(radio.prefWidth(-1)); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset) + snapSize(radio.prefWidth(-1)); } - @Override protected double computePrefHeight(double width) { - final Insets padding = getSkinnable().getInsets(); - return Math.max(snapSize(super.computePrefHeight(width - radio.prefWidth(-1))), - padding.getTop() + radio.prefHeight(-1) + padding.getBottom()); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return Math.max(snapSize(super.computePrefHeight(width - radio.prefWidth(-1), topInset, rightInset, bottomInset, leftInset)), + topInset + radio.prefHeight(-1) + bottomInset); } @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { - Insets padding = getSkinnable().getInsets(); final double radioWidth = radio.prefWidth(-1); final double radioHeight = radio.prefHeight(-1); final double labelWidth = Math.min(getSkinnable().prefWidth(-1) - radioWidth, w - snapSize(radioWidth)); final double labelHeight = Math.min(getSkinnable().prefHeight(labelWidth), h); final double maxHeight = Math.max(radioHeight, labelHeight); - final double xOffset = Utils.computeXOffset(w, labelWidth + radioWidth, getSkinnable().getAlignment().getHpos()) + padding.getLeft(); - final double yOffset = Utils.computeYOffset(h, maxHeight, getSkinnable().getAlignment().getVpos()) + padding.getTop(); + final double xOffset = Utils.computeXOffset(w, labelWidth + radioWidth, getSkinnable().getAlignment().getHpos()) + x; + final double yOffset = Utils.computeYOffset(h, maxHeight, getSkinnable().getAlignment().getVpos()) + y; layoutLabelInArea(xOffset + radioWidth, yOffset, labelWidth, maxHeight, Pos.CENTER_LEFT); radio.resize(snapSize(radioWidth), snapSize(radioHeight)); - positionInArea(radio, xOffset, yOffset, radioWidth, maxHeight, getBaselineOffset(), HPos.CENTER, VPos.CENTER); + positionInArea(radio, xOffset, yOffset, radioWidth, maxHeight, 0, HPos.CENTER, VPos.CENTER); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollBarSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -25,7 +25,6 @@ package com.sun.javafx.scene.control.skin; -import com.sun.javafx.PlatformUtil; import javafx.application.ConditionalFeature; import javafx.event.EventHandler; import javafx.geometry.Orientation; @@ -356,20 +355,18 @@ * We should change this when we get width/height css properties. */ double getBreadth() { - final Insets padding = getSkinnable().getInsets(); - if (!PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { - return Math.max(decButton.prefWidth(-1)+padding.getLeft()+padding.getRight(), incButton.prefWidth(-1)+padding.getLeft()+padding.getRight()); + return Math.max(decButton.prefWidth(-1), incButton.prefWidth(-1)) +snappedLeftInset()+snappedRightInset(); } else { - return Math.max(decButton.prefHeight(-1)+padding.getTop()+padding.getBottom(), incButton.prefHeight(-1)+padding.getTop()+padding.getBottom()); + return Math.max(decButton.prefHeight(-1), incButton.prefHeight(-1)) +snappedTopInset()+snappedBottomInset(); } } else { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { - return Math.max(DEFAULT_EMBEDDED_SB_BREADTH+padding.getLeft()+padding.getRight(), DEFAULT_EMBEDDED_SB_BREADTH+padding.getLeft()+padding.getRight()); + return Math.max(DEFAULT_EMBEDDED_SB_BREADTH, DEFAULT_EMBEDDED_SB_BREADTH)+snappedLeftInset()+snappedRightInset(); } else { - return Math.max(DEFAULT_EMBEDDED_SB_BREADTH+padding.getTop()+padding.getBottom(), DEFAULT_EMBEDDED_SB_BREADTH+padding.getTop()+padding.getBottom()); + return Math.max(DEFAULT_EMBEDDED_SB_BREADTH, DEFAULT_EMBEDDED_SB_BREADTH)+snappedTopInset()+snappedBottomInset(); } } } @@ -388,27 +385,24 @@ * track. Minimum breadth is determined by the breadths of the * end buttons. */ - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { return getBreadth(); } else { - final Insets padding = getSkinnable().getInsets(); - if (!PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { - return decButton.minWidth(-1) + incButton.minWidth(-1) + minTrackLength()+padding.getLeft()+padding.getRight(); + return decButton.minWidth(-1) + incButton.minWidth(-1) + minTrackLength()+leftInset+rightInset; } else { - return minTrackLength()+padding.getLeft()+padding.getRight(); + return minTrackLength()+leftInset+rightInset; } } } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { if (getSkinnable().getOrientation() == Orientation.VERTICAL) { - final Insets padding = getSkinnable().getInsets(); if (!PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { - return decButton.minHeight(-1) + incButton.minHeight(-1) + minTrackLength()+padding.getTop()+padding.getBottom(); + return decButton.minHeight(-1) + incButton.minHeight(-1) + minTrackLength()+topInset+bottomInset; } else { - return minTrackLength()+padding.getTop()+padding.getBottom(); + return minTrackLength()+topInset+bottomInset; } } else { return getBreadth(); @@ -422,24 +416,22 @@ * specific length using LayoutInfo or will stretch the length * of the scrollbar to fit a container. */ - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollBar s = getSkinnable(); - final Insets padding = s.getInsets(); - return s.getOrientation() == Orientation.VERTICAL ? getBreadth() : DEFAULT_LENGTH+padding.getLeft()+padding.getRight(); + return s.getOrientation() == Orientation.VERTICAL ? getBreadth() : DEFAULT_LENGTH+leftInset+rightInset; } - @Override protected double computePrefHeight(double height) { + @Override protected double computePrefHeight(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollBar s = getSkinnable(); - final Insets padding = s.getInsets(); - return s.getOrientation() == Orientation.VERTICAL ? DEFAULT_LENGTH+padding.getTop()+padding.getBottom() : getBreadth(); + return s.getOrientation() == Orientation.VERTICAL ? DEFAULT_LENGTH+topInset+bottomInset : getBreadth(); } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollBar s = getSkinnable(); return s.getOrientation() == Orientation.VERTICAL ? s.prefWidth(-1) : Double.MAX_VALUE; } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollBar s = getSkinnable(); return s.getOrientation() == Orientation.VERTICAL ? Double.MAX_VALUE : s.prefHeight(-1); } @@ -460,9 +452,8 @@ } } - final Insets padding = s.getInsets(); - thumb.setTranslateX( snapPosition(s.getOrientation() == Orientation.VERTICAL ? padding.getLeft() : trackPos + padding.getLeft())); - thumb.setTranslateY( snapPosition(s.getOrientation() == Orientation.VERTICAL ? trackPos + padding.getTop() : padding.getTop())); + thumb.setTranslateX( snapPosition(s.getOrientation() == Orientation.VERTICAL ? snappedLeftInset() : trackPos + snappedLeftInset())); + thumb.setTranslateY( snapPosition(s.getOrientation() == Orientation.VERTICAL ? trackPos + snappedTopInset() : snappedTopInset())); } @Override protected void layoutChildren(final double x, final double y, @@ -539,9 +530,8 @@ } // things should be invisible only when well below minimum length - final Insets padding = s.getInsets(); - if (s.getOrientation() == Orientation.VERTICAL && h >= (computeMinHeight(-1) - (padding.getTop()+padding.getBottom())) || - s.getOrientation() == Orientation.HORIZONTAL && w >= (computeMinWidth(-1) - (padding.getLeft()+padding.getRight()))) { + if (s.getOrientation() == Orientation.VERTICAL && h >= (computeMinHeight(-1, (int)y , snappedRightInset(), snappedBottomInset(), (int)x) - (y+snappedBottomInset())) || + s.getOrientation() == Orientation.HORIZONTAL && w >= (computeMinWidth(-1, (int)y , snappedRightInset(), snappedBottomInset(), (int)x) - (x+snappedRightInset()))) { trackBackground.setVisible(true); track.setVisible(true); thumb.setVisible(true); @@ -588,11 +578,10 @@ } @Override protected void layoutChildren() { - final Insets insets = getInsets(); - final double top = snapSize(insets.getTop()); - final double left = snapSize(insets.getLeft()); - final double bottom = snapSize(insets.getBottom()); - final double right = snapSize(insets.getRight()); + final double top = snappedTopInset(); + final double left = snappedLeftInset(); + final double bottom = snappedBottomInset(); + final double right = snappedRightInset(); final double aw = snapSize(arrow.prefWidth(-1)); final double ah = snapSize(arrow.prefHeight(-1)); final double yPos = snapPosition((getHeight() - (top + bottom + ah)) / 2.0); @@ -609,17 +598,15 @@ } @Override protected double computePrefWidth(double height) { - final Insets insets = getInsets(); - final double left = snapSize(insets.getLeft()); - final double right = snapSize(insets.getRight()); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); final double aw = snapSize(arrow.prefWidth(-1)); return left + aw + right; } @Override protected double computePrefHeight(double width) { - final Insets insets = getInsets(); - final double top = snapSize(insets.getTop()); - final double bottom = snapSize(insets.getBottom()); + final double top = snappedTopInset(); + final double bottom = snappedBottomInset(); final double ah = snapSize(arrow.prefHeight(-1)); return top + ah + bottom; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ScrollPaneSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -55,7 +55,6 @@ import javafx.scene.layout.StackPane; import javafx.scene.shape.Rectangle; import javafx.util.Duration; -import com.sun.javafx.PlatformUtil; import com.sun.javafx.Utils; import com.sun.javafx.application.PlatformImpl; import com.sun.javafx.scene.control.behavior.ScrollPaneBehavior; @@ -162,7 +161,6 @@ */ private final ChangeListener boundsChangeListener = new ChangeListener() { @Override public void changed(ObservableValue observable, Bounds oldBounds, Bounds newBounds) { - final Insets padding = getSkinnable().getInsets(); /* ** For a height change then we want to reduce @@ -173,8 +171,8 @@ double oldHeight = oldBounds.getHeight(); double newHeight = newBounds.getHeight(); if (oldHeight != newHeight) { - double oldPositionY = (snapPosition(padding.getTop() - posY / (vsb.getMax() - vsb.getMin()) * (oldHeight - contentHeight))); - double newPositionY = (snapPosition(padding.getTop() - posY / (vsb.getMax() - vsb.getMin()) * (newHeight - contentHeight))); + double oldPositionY = (snapPosition(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (oldHeight - contentHeight))); + double newPositionY = (snapPosition(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (newHeight - contentHeight))); double newValueY = (oldPositionY/newPositionY)*vsb.getValue(); if (newValueY < 0.0) { @@ -197,8 +195,8 @@ double oldWidth = oldBounds.getWidth(); double newWidth = newBounds.getWidth(); if (oldWidth != newWidth) { - double oldPositionX = (snapPosition(padding.getLeft() - posX / (hsb.getMax() - hsb.getMin()) * (oldWidth - contentWidth))); - double newPositionX = (snapPosition(padding.getLeft() - posX / (hsb.getMax() - hsb.getMin()) * (newWidth - contentWidth))); + double oldPositionX = (snapPosition(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (oldWidth - contentWidth))); + double newPositionX = (snapPosition(snappedLeftInset() - posX / (hsb.getMax() - hsb.getMin()) * (newWidth - contentWidth))); double newValueX = (oldPositionX/newPositionX)*hsb.getValue(); if (newValueX < 0.0) { @@ -712,38 +710,36 @@ * * **************************************************************************/ - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollPane sp = getSkinnable(); if (sp.getPrefViewportWidth() > 0) { double vsbWidth = sp.getVbarPolicy() == ScrollBarPolicy.ALWAYS? vsb.prefWidth(-1) : 0; - final Insets padding = sp.getInsets(); - return (sp.getPrefViewportWidth() + vsbWidth + padding.getLeft() + padding.getRight()); + return (sp.getPrefViewportWidth() + vsbWidth + snappedLeftInset() + snappedRightInset()); } else { return DEFAULT_PREF_SIZE; } } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final ScrollPane sp = getSkinnable(); if (sp.getPrefViewportHeight() > 0) { double hsbHeight = sp.getHbarPolicy() == ScrollBarPolicy.ALWAYS? hsb.prefHeight(-1) : 0; - final Insets padding = sp.getInsets(); - return (sp.getPrefViewportHeight() + hsbHeight + padding.getTop() + padding.getBottom()); + return (sp.getPrefViewportHeight() + hsbHeight + snappedTopInset() + snappedBottomInset()); } else { return DEFAULT_PREF_SIZE; } } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double w = corner.minWidth(-1); return (w > 0) ? (3 * w) : (DEFAULT_MIN_SIZE); } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double h = corner.minHeight(-1); return (h > 0) ? (3 * h) : (DEFAULT_MIN_SIZE); } @@ -926,8 +922,7 @@ private boolean determineHorizontalSBVisible() { final ScrollPane sp = getSkinnable(); - final Insets insets = sp.getInsets(); - final double contentw = sp.getWidth() - insets.getLeft() - insets.getRight(); + final double contentw = sp.getWidth() - snappedLeftInset() - snappedRightInset(); if (PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { return (tempVisibility && (nodeWidth > contentw)); } @@ -941,8 +936,7 @@ private boolean determineVerticalSBVisible() { final ScrollPane sp = getSkinnable(); - final Insets insets = sp.getInsets(); - final double contenth = sp.getHeight() - insets.getTop() - insets.getBottom(); + final double contenth = sp.getHeight() - snappedTopInset() - snappedBottomInset(); if (PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { return (tempVisibility && (nodeHeight > contenth)); } @@ -996,7 +990,7 @@ if (nodeWidth > contentWidth) { updatePosX(); } else { - viewContent.setLayoutX(getSkinnable().getInsets().getLeft()); + viewContent.setLayoutX(snappedLeftInset()); } } } @@ -1020,7 +1014,7 @@ if (nodeHeight > contentHeight) { updatePosY(); } else { - viewContent.setLayoutY(getSkinnable().getInsets().getTop()); + viewContent.setLayoutY(snappedTopInset()); } } } @@ -1028,14 +1022,14 @@ private double updatePosX() { final ScrollPane sp = getSkinnable(); double x = isReverseNodeOrientation() ? (hsb.getMax() - (posX - hsb.getMin())) : posX; - viewContent.setLayoutX(snapPosition(sp.getInsets().getLeft() - x / (hsb.getMax() - hsb.getMin()) * (nodeWidth - contentWidth))); + viewContent.setLayoutX(snapPosition(snappedLeftInset() - x / (hsb.getMax() - hsb.getMin()) * (nodeWidth - contentWidth))); sp.setHvalue(Utils.clamp(sp.getHmin(), posX, sp.getHmax())); return posX; } private double updatePosY() { final ScrollPane sp = getSkinnable(); - viewContent.setLayoutY(snapPosition(sp.getInsets().getTop() - posY / (vsb.getMax() - vsb.getMin()) * (nodeHeight - contentHeight))); + viewContent.setLayoutY(snapPosition(snappedTopInset() - posY / (vsb.getMax() - vsb.getMin()) * (nodeHeight - contentHeight))); sp.setVvalue(Utils.clamp(sp.getVmin(), posY, sp.getVmax())); return posY; } @@ -1043,9 +1037,7 @@ private void resetClip() { clipRect.setWidth(snapSize(contentWidth)); clipRect.setHeight(snapSize(contentHeight)); - final ScrollPane sp = getSkinnable(); - Insets insets = sp.getInsets(); - clipRect.relocate(snapPosition(insets.getLeft()), snapPosition(insets.getTop())); + clipRect.relocate(snappedLeftInset(), snappedTopInset()); } Timeline sbTouchTimeline; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SeparatorSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SeparatorSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SeparatorSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -25,7 +25,6 @@ package com.sun.javafx.scene.control.skin; -import javafx.geometry.Insets; import javafx.geometry.Orientation; import javafx.scene.control.Separator; import javafx.scene.layout.Region; @@ -92,7 +91,6 @@ @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { final Separator sep = getSkinnable(); - final Insets p = sep.getInsets(); if (sep.getOrientation() == Orientation.HORIZONTAL) { // Resize to the content width, and the pref height of the line. @@ -103,29 +101,27 @@ } // Now that the line has been sized, simply position it - positionInArea(line, p.getLeft(), p.getTop(), w, h, 0, sep.getHalignment(), sep.getValignment()); + positionInArea(line, x, y, w, h, 0, sep.getHalignment(), sep.getValignment()); } - @Override protected double computePrefWidth(double h) { + @Override protected double computePrefWidth(double h, int topInset, int rightInset, int bottomInset, int leftInset) { final Separator sep = getSkinnable(); double w = sep.getOrientation() == Orientation.VERTICAL ? line.prefWidth(-1) : DEFAULT_LENGTH; - final Insets padding = sep.getInsets(); - return w + padding.getLeft() + padding.getRight(); + return w + leftInset + rightInset; } - @Override protected double computePrefHeight(double w) { + @Override protected double computePrefHeight(double w, int topInset, int rightInset, int bottomInset, int leftInset) { final Separator sep = getSkinnable(); - final Insets padding = sep.getInsets(); double h = sep.getOrientation() == Orientation.VERTICAL ? DEFAULT_LENGTH : line.prefHeight(-1); - return h + padding.getTop() + padding.getBottom(); + return h + topInset + bottomInset; } - @Override protected double computeMaxWidth(double h) { + @Override protected double computeMaxWidth(double h, int topInset, int rightInset, int bottomInset, int leftInset) { final Separator sep = getSkinnable(); return sep.getOrientation() == Orientation.VERTICAL ? sep.prefWidth(h) : Double.MAX_VALUE; } - @Override protected double computeMaxHeight(double w) { + @Override protected double computeMaxHeight(double w, int topInset, int rightInset, int bottomInset, int leftInset) { final Separator sep = getSkinnable(); return sep.getOrientation() == Orientation.VERTICAL ? Double.MAX_VALUE : sep.prefHeight(w); } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SliderSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -245,7 +245,7 @@ final double endX = (horizontal) ? trackStart + (((trackLength * ((s.getValue() - s.getMin()) / (s.getMax() - s.getMin()))) - thumbWidth/2)) : thumbLeft; final double endY = (horizontal) ? thumbTop : - s.getInsets().getTop() + trackLength - (trackLength * ((s.getValue() - s.getMin()) / + snappedTopInset() + trackLength - (trackLength * ((s.getValue() - s.getMin()) / (s.getMax() - s.getMin()))); // - thumbHeight/2 if (animate) { @@ -351,27 +351,25 @@ return 2*thumb.prefWidth(-1); } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final Slider s = getSkinnable(); - final Insets padding = s.getInsets(); if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { - return (padding.getLeft() + minTrackLength() + thumb.minWidth(-1) + padding.getRight()); + return (leftInset + minTrackLength() + thumb.minWidth(-1) + rightInset); } else { - return(padding.getLeft() + thumb.prefWidth(-1) + padding.getRight()); + return(leftInset + thumb.prefWidth(-1) + rightInset); } } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final Slider s = getSkinnable(); - final Insets padding = s.getInsets(); if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { - return(padding.getTop() + thumb.prefHeight(-1) + padding.getBottom()); + return(topInset + thumb.prefHeight(-1) + bottomInset); } else { - return(padding.getTop() + minTrackLength() + thumb.prefHeight(-1) + padding.getBottom()); + return(topInset + minTrackLength() + thumb.prefHeight(-1) + bottomInset); } } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final Slider s = getSkinnable(); if (s.getOrientation() == Orientation.HORIZONTAL) { if(showTickMarks) { @@ -380,18 +378,16 @@ return 140; } } else { - final Insets padding = s.getInsets(); - return (padding.getLeft()) + Math.max(thumb.prefWidth(-1), track.prefWidth(-1)) + - ((showTickMarks) ? (trackToTickGap+tickLine.prefWidth(-1)) : 0) + padding.getRight(); + return leftInset + Math.max(thumb.prefWidth(-1), track.prefWidth(-1)) + + ((showTickMarks) ? (trackToTickGap+tickLine.prefWidth(-1)) : 0) + rightInset; } } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final Slider s = getSkinnable(); if (s.getOrientation() == Orientation.HORIZONTAL) { - final Insets padding = s.getInsets(); - return padding.getTop() + Math.max(thumb.prefHeight(-1), track.prefHeight(-1)) + - ((showTickMarks) ? (trackToTickGap+tickLine.prefHeight(-1)) : 0) + padding.getBottom(); + return topInset + Math.max(thumb.prefHeight(-1), track.prefHeight(-1)) + + ((showTickMarks) ? (trackToTickGap+tickLine.prefHeight(-1)) : 0) + bottomInset; } else { if(showTickMarks) { return Math.max(140, tickLine.prefHeight(-1)); @@ -401,7 +397,7 @@ } } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { return Double.MAX_VALUE; } else { @@ -409,7 +405,7 @@ } } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { if (getSkinnable().getOrientation() == Orientation.HORIZONTAL) { return getSkinnable().prefHeight(width); } else { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/SplitPaneSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -351,15 +351,14 @@ private double getSize() { final SplitPane s = getSkinnable(); - final Insets padding = s.getInsets(); double size = totalMinSize(); if (horizontal) { if (s.getWidth() > size) { - size = s.getWidth() - padding.getLeft() - padding.getRight(); + size = s.getWidth() - snappedLeftInset() - snappedRightInset(); } } else { if (s.getHeight() > size) { - size = s.getHeight() - padding.getTop() - padding.getBottom(); + size = s.getHeight() - snappedTopInset() - snappedBottomInset(); } } return size; @@ -503,9 +502,9 @@ } private void layoutDividersAndContent(double width, double height) { - double paddingX = getSkinnable().getInsets().getLeft(); - double paddingY = getSkinnable().getInsets().getTop(); - double dividerWidth = contentDividers.isEmpty() ? 0 : contentDividers.get(0).prefWidth(-1); + final double paddingX = snappedLeftInset(); + final double paddingY = snappedTopInset(); + final double dividerWidth = contentDividers.isEmpty() ? 0 : contentDividers.get(0).prefWidth(-1); for (Content c: contentRegions) { // System.out.println("LAYOUT " + c.getId() + " PANELS X " + c.getX() + " Y " + c.getY() + " W " + (horizontal ? c.getArea() : width) + " H " + (horizontal ? height : c.getArea())); @@ -831,7 +830,7 @@ resize = false; } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double minWidth = 0; double maxMinWidth = 0; for (Content c: contentRegions) { @@ -841,15 +840,14 @@ for (ContentDivider d: contentDividers) { minWidth += d.prefWidth(-1); } - final Insets padding = getSkinnable().getInsets(); if (horizontal) { - return minWidth + padding.getLeft() + padding.getRight(); + return minWidth + leftInset + rightInset; } else { - return maxMinWidth + padding.getLeft() + padding.getRight(); + return maxMinWidth + leftInset + rightInset; } } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double minHeight = 0; double maxMinHeight = 0; for (Content c: contentRegions) { @@ -859,15 +857,14 @@ for (ContentDivider d: contentDividers) { minHeight += d.prefWidth(-1); } - final Insets padding = getSkinnable().getInsets(); if (horizontal) { - return maxMinHeight + padding.getTop() + padding.getBottom(); + return maxMinHeight + topInset + bottomInset; } else { - return minHeight + padding.getTop() + padding.getBottom(); + return minHeight + topInset + bottomInset; } } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double prefWidth = 0; double prefMaxWidth = 0; for (Content c: contentRegions) { @@ -877,15 +874,14 @@ for (ContentDivider d: contentDividers) { prefWidth += d.prefWidth(-1); } - final Insets padding = getSkinnable().getInsets(); if (horizontal) { - return prefWidth + padding.getLeft() + padding.getRight(); + return prefWidth + leftInset + rightInset; } else { - return prefMaxWidth + padding.getLeft() + padding.getRight(); + return prefMaxWidth + leftInset + rightInset; } } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double prefHeight = 0; double maxPrefHeight = 0; for (Content c: contentRegions) { @@ -895,11 +891,10 @@ for (ContentDivider d: contentDividers) { prefHeight += d.prefWidth(-1); } - final Insets padding = getSkinnable().getInsets(); if (horizontal) { - return maxPrefHeight + padding.getTop() + padding.getBottom(); + return maxPrefHeight + topInset + bottomInset; } else { - return prefHeight + padding.getTop() + padding.getBottom(); + return prefHeight + topInset + bottomInset; } } @@ -954,11 +949,11 @@ } @Override protected double computePrefWidth(double height) { - return getInsets().getLeft() + getInsets().getRight(); + return snappedLeftInset() + snappedRightInset(); } @Override protected double computePrefHeight(double width) { - return getInsets().getTop() + getInsets().getBottom(); + return snappedTopInset() + snappedBottomInset(); } @Override protected double computeMaxWidth(double height) { @@ -1047,11 +1042,11 @@ } @Override protected double computePrefWidth(double height) { - return snapSpace(getInsets().getLeft()) + snapSpace(getInsets().getRight()); + return snappedLeftInset() + snappedRightInset(); } @Override protected double computePrefHeight(double width) { - return snapSpace(getInsets().getTop()) + snapSpace(getInsets().getBottom()); + return snappedTopInset() + snappedBottomInset(); } @Override protected double computeMaxWidth(double height) { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TabPaneSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TabPaneSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TabPaneSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -25,7 +25,6 @@ package com.sun.javafx.scene.control.skin; -import com.sun.javafx.PlatformUtil; import javafx.application.ConditionalFeature; import javafx.css.CssMetaData; import javafx.css.PseudoClass; @@ -419,30 +418,28 @@ // } private double maxw = 0.0d; - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { // The TabPane can only be as wide as it widest content width. for (TabContentRegion contentRegion: tabContentRegions) { maxw = Math.max(maxw, snapSize(contentRegion.prefWidth(-1))); } double prefwidth = isHorizontal() ? maxw : maxw + snapSize(tabHeaderArea.prefHeight(-1)); - final Insets padding = getSkinnable().getInsets(); - return snapSize(prefwidth) + snapSize(padding.getRight()) + snapSize(padding.getLeft()); + return snapSize(prefwidth) + rightInset + leftInset; } private double maxh = 0.0d; - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { // The TabPane can only be as high as it highest content height. for (TabContentRegion contentRegion: tabContentRegions) { maxh = Math.max(maxh, snapSize(contentRegion.prefHeight(-1))); } double prefheight = isHorizontal()? maxh + snapSize(tabHeaderArea.prefHeight(-1)) : maxh; - final Insets padding = getSkinnable().getInsets(); - return snapSize(prefheight) + snapSize(padding.getTop()) + snapSize(padding.getBottom()); + return snapSize(prefheight) + topInset + bottomInset; } - @Override public double getBaselineOffset() { + @Override public double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { return tabHeaderArea.getBaselineOffset() + tabHeaderArea.getLayoutY(); } @@ -649,7 +646,7 @@ width += tabHeaderSkin.prefWidth(height); } } - return snapSize(width) + snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); + return snapSize(width) + snappedLeftInset() + snappedRightInset(); } @Override protected double computePrefHeight(double width) { @@ -658,7 +655,7 @@ TabHeaderSkin tabHeaderSkin = (TabHeaderSkin)child; height = Math.max(height, tabHeaderSkin.prefHeight(width)); } - return snapSize(height) + snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + return snapSize(height) + snappedTopInset() + snappedBottomInset(); } @Override protected void layoutChildren() { @@ -732,7 +729,7 @@ // This ensures that the tabs are located in the correct position // when there are tabs of differing heights. double startY = tabPosition.equals(Side.BOTTOM) ? - 0 : tabBackgroundHeight - tabHeaderPrefHeight - snapSize(getInsets().getBottom()); + 0 : tabBackgroundHeight - tabHeaderPrefHeight - snappedBottomInset(); if (tabPosition.equals(Side.LEFT) || tabPosition.equals(Side.BOTTOM)) { // build from the right tabX -= tabHeaderPrefWidth; @@ -900,10 +897,10 @@ switch (getSkinnable().getSide()) { case TOP: case BOTTOM: - return snapSize(getInsets().getLeft()); + return snappedLeftInset(); case RIGHT: case LEFT: - return snapSize(getInsets().getTop()); + return snappedTopInset(); default: return 0; } @@ -911,15 +908,15 @@ @Override protected double computePrefWidth(double height) { double padding = isHorizontal() ? - snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()) : - snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + snappedLeftInset() + snappedRightInset() : + snappedTopInset() + snappedBottomInset(); return snapSize(headersRegion.prefWidth(-1)) + padding; } @Override protected double computePrefHeight(double width) { double padding = isHorizontal() ? - snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()) : - snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); + snappedTopInset() + snappedBottomInset() : + snappedLeftInset() + snappedRightInset(); return snapSize(headersRegion.prefHeight(-1)) + padding; } @@ -928,12 +925,14 @@ } @Override protected void layoutChildren() { - TabPane tabPane = getSkinnable(); - Insets padding = getInsets(); + final double leftInset = snappedLeftInset(); + final double rightInset = snappedRightInset(); + final double topInset = snappedTopInset(); + final double bottomInset = snappedBottomInset(); double w = snapSize(getWidth()) - (isHorizontal() ? - snapSize(padding.getLeft()) + snapSize(padding.getRight()) : snapSize(padding.getTop()) + snapSize(padding.getBottom())); + leftInset + rightInset : topInset + bottomInset); double h = snapSize(getHeight()) - (isHorizontal() ? - snapSize(padding.getTop()) + snapSize(padding.getBottom()) : snapSize(padding.getLeft()) + snapSize(padding.getRight())); + topInset + bottomInset : leftInset + rightInset); double tabBackgroundHeight = snapSize(prefHeight(-1)); double headersPrefWidth = snapSize(headersRegion.prefWidth(-1)); double headersPrefHeight = snapSize(headersRegion.prefHeight(-1)); @@ -966,25 +965,25 @@ Side tabPosition = getSkinnable().getSide(); if (tabPosition.equals(Side.TOP)) { - startX = snapSize(padding.getLeft()); - startY = tabBackgroundHeight - headersPrefHeight - snapSize(padding.getBottom()); - controlStartX = w - btnWidth + snapSize(padding.getLeft()); - controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - snapSize(padding.getBottom()); + startX = leftInset; + startY = tabBackgroundHeight - headersPrefHeight - bottomInset; + controlStartX = w - btnWidth + leftInset; + controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - bottomInset; } else if (tabPosition.equals(Side.RIGHT)) { - startX = snapSize(padding.getTop()); - startY = tabBackgroundHeight - headersPrefHeight - snapSize(padding.getLeft()); - controlStartX = w - btnWidth + snapSize(padding.getTop()); - controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - snapSize(padding.getLeft()); + startX = topInset; + startY = tabBackgroundHeight - headersPrefHeight - leftInset; + controlStartX = w - btnWidth + topInset; + controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - leftInset; } else if (tabPosition.equals(Side.BOTTOM)) { - startX = snapSize(getWidth()) - headersPrefWidth - snapSize(getInsets().getLeft()); - startY = tabBackgroundHeight - headersPrefHeight - snapSize(padding.getTop()); - controlStartX = snapSize(padding.getRight()); - controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - snapSize(padding.getTop()); + startX = snapSize(getWidth()) - headersPrefWidth - leftInset; + startY = tabBackgroundHeight - headersPrefHeight - topInset; + controlStartX = rightInset; + controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - topInset; } else if (tabPosition.equals(Side.LEFT)) { - startX = snapSize(getWidth()) - headersPrefWidth - snapSize(getInsets().getTop()); - startY = tabBackgroundHeight - headersPrefHeight - snapSize(padding.getRight()); - controlStartX = snapSize(padding.getLeft()); - controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - snapSize(padding.getRight()); + startX = snapSize(getWidth()) - headersPrefWidth - topInset; + startY = tabBackgroundHeight - headersPrefHeight - rightInset; + controlStartX = leftInset; + controlStartY = snapSize(getHeight()) - controlButtons.getControlTabHeight() - rightInset; } if (headerBackground.isVisible()) { positionInArea(headerBackground, 0, 0, @@ -1075,13 +1074,12 @@ inner = new StackPane() { @Override protected void layoutChildren() { - final Insets insets = getInsets(); final TabPane skinnable = getSkinnable(); - final double paddingTop = snapSize(insets.getTop()); - final double paddingRight = snapSize(insets.getRight()); - final double paddingBottom = snapSize(insets.getBottom()); - final double paddingLeft = snapSize(insets.getLeft()); + final double paddingTop = snappedTopInset(); + final double paddingRight = snappedRightInset(); + final double paddingBottom = snappedBottomInset(); + final double paddingLeft = snappedLeftInset(); final double w = getWidth() - (paddingLeft + paddingRight); final double h = getHeight() - (paddingTop + paddingBottom); @@ -1334,8 +1332,8 @@ } double minWidth = snapSize(getSkinnable().getTabMinWidth()); double maxWidth = snapSize(getSkinnable().getTabMaxWidth()); - double paddingRight = snapSize(getInsets().getRight()); - double paddingLeft = snapSize(getInsets().getLeft()); + double paddingRight = snappedRightInset(); + double paddingLeft = snappedLeftInset(); double tmpPrefWidth = snapSize(label.prefWidth(-1)); // only include the close button width if it is relevant @@ -1356,8 +1354,8 @@ @Override protected double computePrefHeight(double width) { double minHeight = snapSize(getSkinnable().getTabMinHeight()); double maxHeight = snapSize(getSkinnable().getTabMaxHeight()); - double paddingTop = snapSize(getInsets().getTop()); - double paddingBottom = snapSize(getInsets().getBottom()); + double paddingTop = snappedTopInset(); + double paddingBottom = snappedBottomInset(); double tmpPrefHeight = snapSize(label.prefHeight(width)); if (tmpPrefHeight > maxHeight) { @@ -1371,11 +1369,10 @@ private Runnable animateNewTab = null; - @Override protected void layoutChildren() { - Insets padding = getInsets(); - inner.resize(snapSize(getWidth()) - snapSize(padding.getRight()) - snapSize(padding.getLeft()), - snapSize(getHeight()) - snapSize(padding.getTop()) - snapSize(padding.getBottom())); - inner.relocate(snapSize(padding.getLeft()), snapSize(padding.getTop())); + @Override protected void layoutChildren() { + inner.resize(snapSize(getWidth()) - snappedRightInset() - snappedLeftInset(), + snapSize(getHeight()) - snappedTopInset() - snappedBottomInset()); + inner.relocate(snappedLeftInset(), snappedTopInset()); if (animateNewTab != null) { animateNewTab.run(); @@ -1550,7 +1547,7 @@ pw += maxArrowWidth; } if (pw > 0) { - pw += snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); + pw += snappedLeftInset() + snappedRightInset(); } return pw; } @@ -1561,7 +1558,7 @@ height = Math.max(height, snapSize(downArrowBtn.prefHeight(width))); } if (height > 0) { - height += snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + height += snappedTopInset() + snappedBottomInset(); } return height; } @@ -1570,8 +1567,8 @@ Side tabPosition = getSkinnable().getSide(); double x = 0.0F; //padding.left; - double y = snapSize(getInsets().getTop()); - double h = snapSize(getHeight()) - snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + double y = snappedTopInset(); + double h = snapSize(getHeight()) - y + snappedBottomInset(); // when on the left or bottom, we need to position the tabs controls // button such that it is the furtherest button away from the tabs. if (tabPosition.equals(Side.BOTTOM) || tabPosition.equals(Side.LEFT)) { @@ -1599,9 +1596,9 @@ double arrowWidth = snapSize(arrow.prefWidth(-1)); double arrowHeight = snapSize(arrow.prefHeight(-1)); arrow.resize(arrowWidth, arrowHeight); - positionInArea(arrow, snapSize(btn.getInsets().getLeft()), snapSize(btn.getInsets().getTop()), - width - snapSize(btn.getInsets().getLeft()) - snapSize(btn.getInsets().getRight()), - height - snapSize(btn.getInsets().getTop()) - snapSize(btn.getInsets().getBottom()), + positionInArea(arrow, btn.snappedLeftInset(), btn.snappedTopInset(), + width - btn.snappedLeftInset() - btn.snappedRightInset(), + height - btn.snappedTopInset() - btn.snappedBottomInset(), /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); } }; @@ -1691,21 +1688,21 @@ private double getActualPrefWidth(double height) { double pw = snapSize(inner.prefWidth(height)); if (pw > 0) { - pw += snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); + pw += snappedLeftInset() + snappedRightInset(); } return pw; } @Override protected double computePrefHeight(double width) { return Math.max(getSkinnable().getTabMinHeight(), snapSize(inner.prefHeight(width))) + - snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + snappedTopInset() + snappedBottomInset(); } @Override protected void layoutChildren() { - double x = snapSize(getInsets().getLeft()); - double y = snapSize(getInsets().getTop()); - double w = snapSize(getWidth()) - snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); - double h = snapSize(getHeight()) - snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + double x = snappedLeftInset(); + double y = snappedTopInset(); + double w = snapSize(getWidth()) - x + snappedRightInset(); + double h = snapSize(getHeight()) - y + snappedBottomInset(); if (showControlButtons) { showControlButtons(); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableCellSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableCellSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableCellSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -111,9 +111,9 @@ layoutLabelInArea(x, y, w, h - getSkinnable().getPadding().getBottom()); } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (isDeferToParentForPrefWidth) { - return super.computePrefWidth(height); + return super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); } return columnWidthProperty().get(); } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableColumnHeader.java Tue Apr 16 23:11:38 2013 -0700 @@ -668,8 +668,8 @@ } double sortWidth = 0; - double w = snapSize(getWidth()) - (snapSpace(getInsets().getLeft()) + snapSpace(getInsets().getRight())); - double h = getHeight() - getInsets().getTop() + getInsets().getBottom(); + double w = snapSize(getWidth()) - (snappedLeftInset() + snappedRightInset()); + double h = getHeight() - (snappedTopInset() + snappedBottomInset()); double x = w; // a bit hacky, but we REALLY don't want the arrow shape to fluctuate @@ -682,13 +682,13 @@ sortWidth = sortArrow.prefWidth(-1); x -= sortWidth; sortArrow.resize(sortWidth, sortArrow.prefHeight(-1)); - positionInArea(sortArrow, x, getInsets().getTop(), + positionInArea(sortArrow, x, snappedTopInset(), sortWidth, h, 0, HPos.CENTER, VPos.CENTER); } if (label != null) { double labelWidth = w - sortWidth; - label.resizeRelocate(getInsets().getLeft(), 0, labelWidth, getHeight()); + label.resizeRelocate(snappedLeftInset(), 0, labelWidth, getHeight()); } } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableHeaderRow.java Tue Apr 16 23:11:38 2013 -0700 @@ -243,9 +243,8 @@ image.getStyleClass().setAll("show-hide-column-image"); cornerRegion = new StackPane() { @Override protected void layoutChildren() { - Insets padding = image.getInsets(); - double imageWidth = padding.getLeft() + padding.getRight(); - double imageHeight = padding.getTop() + padding.getBottom(); + double imageWidth = image.snappedLeftInset() + image.snappedRightInset(); + double imageHeight = image.snappedTopInset() + image.snappedBottomInset(); image.resize(imageWidth, imageHeight); positionInArea(image, 0, 0, getWidth(), getHeight() - 3, @@ -393,11 +392,11 @@ @Override protected void layoutChildren() { double x = scrollX; double headerWidth = snapSize(header.prefWidth(-1)); - double prefHeight = getHeight() - getInsets().getTop() - getInsets().getBottom(); + double prefHeight = getHeight() - snappedTopInset() - snappedBottomInset(); double cornerWidth = snapSize(flow.getVbar().prefWidth(-1)); // position the main nested header - header.resizeRelocate(x, getInsets().getTop(), headerWidth, prefHeight); + header.resizeRelocate(x, snappedTopInset(), headerWidth, prefHeight); // position the filler region double border = filler.getBoundsInLocal().getWidth() - filler.getLayoutBounds().getWidth(); @@ -405,11 +404,11 @@ fillerWidth -= tableSkin.tableMenuButtonVisibleProperty().get() ? cornerWidth : 0; filler.setVisible(fillerWidth > 0); if (fillerWidth > 0) { - filler.resizeRelocate(x + headerWidth, getInsets().getTop(), fillerWidth, prefHeight); + filler.resizeRelocate(x + headerWidth, snappedTopInset(), fillerWidth, prefHeight); } // position the top-right rectangle (which sits above the scrollbar) - cornerRegion.resizeRelocate(tableWidth - cornerWidth, getInsets().getTop(), cornerWidth, prefHeight); + cornerRegion.resizeRelocate(tableWidth - cornerWidth, snappedTopInset(), cornerWidth, prefHeight); } @Override protected double computePrefWidth(double height) { @@ -421,7 +420,7 @@ } @Override protected double computePrefHeight(double width) { - return getInsets().getTop() + header.prefHeight(width) + getInsets().getBottom(); + return snappedTopInset() + header.prefHeight(width) + snappedBottomInset(); } // public function isColumnFullyVisible(col:TableColumn):Number { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableRowSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -428,10 +428,8 @@ double width; double height; - Insets insets = getSkinnable().getInsets(); - - double verticalPadding = insets.getTop() + insets.getBottom(); - double horizontalPadding = insets.getLeft() + insets.getRight(); + double verticalPadding = snappedTopInset() + snappedBottomInset(); + double horizontalPadding = snappedLeftInset() + snappedRightInset(); /** * RT-26743:TreeTableView: Vertical Line looks unfinished. @@ -572,7 +570,7 @@ // /////////////////////////////////////////// tableCell.resize(width, height); - tableCell.relocate(x, insets.getTop()); + tableCell.relocate(x, snappedTopInset()); // Request layout is here as (partial) fix for RT-28684 tableCell.requestLayout(); @@ -686,7 +684,7 @@ return cell; } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double prefWidth = 0.0F; List*/> visibleLeafColumns = getVisibleLeafColumns(); @@ -698,7 +696,7 @@ return prefWidth; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { if (fixedCellLengthEnabled) { return fixedCellLength; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -234,7 +234,7 @@ Node n = cell.getSkin() == null ? null : cell.getSkin().getNode(); if (n instanceof Region) { Region r = (Region) n; - padding = r.getInsets().getLeft() + r.getInsets().getRight(); + padding = r.snappedLeftInset() + r.snappedRightInset(); } int rows = maxRows == -1 ? items.size() : Math.min(items.size(), maxRows); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TableViewSkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -448,21 +448,20 @@ private static final double GOLDEN_RATIO_MULTIPLIER = 0.618033987; - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return 400; } /** {@inheritDoc} */ - @Override protected double computePrefWidth(double height) { - double prefHeight = computePrefHeight(-1); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + double prefHeight = computePrefHeight(-1, topInset, rightInset, bottomInset, leftInset); List cols = getVisibleLeafColumns(); if (cols == null || cols.isEmpty()) { return prefHeight * GOLDEN_RATIO_MULTIPLIER; } - - final Insets padding = getSkinnable().getInsets(); - double pw = padding.getLeft() + padding.getRight(); + + double pw = leftInset + rightInset; for (int i = 0, max = cols.size(); i < max; i++) { TableColumnBase tc = cols.get(i); pw += Math.max(tc.getPrefWidth(), tc.getMinWidth()); @@ -556,10 +555,9 @@ } // paint the reorder line as well - Insets rp = columnReorderLine.getInsets(); - double cw = rp.getLeft() + rp.getRight(); + double cw = columnReorderLine.snappedLeftInset() + columnReorderLine.snappedRightInset(); double lineHeight = h - (flow.getHbar().isVisible() ? flow.getHbar().getHeight() - 1 : 0); - columnReorderLine.resizeRelocate(0, rp.getTop(), cw, lineHeight); + columnReorderLine.resizeRelocate(0, columnReorderLine.snappedTopInset(), cw, lineHeight); } columnReorderLine.setVisible(tableHeaderRow.isReordering()); @@ -667,8 +665,7 @@ if (contentWidth <= 0) { // Fix for RT-14855 when there is no content in the TableView. Control c = getSkinnable(); - Insets padding = c.getInsets(); - contentWidth = c.getWidth() - (padding.getLeft() + padding.getRight()); + contentWidth = c.getWidth() - (snappedLeftInset() + snappedRightInset()); } // FIXME this isn't perfect, but it prevents RT-14885, which results in @@ -762,7 +759,6 @@ if (col == null || !col.isVisible()) return; final Control control = getSkinnable(); - final Insets padding = control.getInsets(); // work out where this column header is, and it's width (start -> end) double start = 0;//scrollX; @@ -773,7 +769,7 @@ double end = start + col.getWidth(); // determine the visible width of the table - double headerWidth = control.getWidth() - padding.getLeft() + padding.getRight(); + double headerWidth = control.getWidth() - snappedLeftInset() - snappedRightInset(); // determine by how much we need to translate the table to ensure that // the start position of this column lines up with the left edge of the diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextAreaSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextAreaSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextAreaSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -63,7 +63,6 @@ import javafx.scene.text.Text; import javafx.scene.text.TextBoundsType; import javafx.util.Duration; -import com.sun.javafx.PlatformUtil; import com.sun.javafx.application.PlatformImpl; import com.sun.javafx.scene.control.behavior.TextAreaBehavior; import com.sun.javafx.scene.text.HitInfo; @@ -138,7 +137,7 @@ paragraphNode.getText(), 0)); } - prefWidth += leftPadding() + rightPadding(); + prefWidth += snappedLeftInset() + snappedRightInset(); Bounds viewPortBounds = scrollPane.getViewportBounds(); computedPrefWidth = Math.max(prefWidth, (viewPortBounds != null) ? viewPortBounds.getWidth() : 0); @@ -158,7 +157,7 @@ if (width == -1) { wrappingWidth = 0; } else { - wrappingWidth = Math.max(width - (leftPadding() + rightPadding()), 0); + wrappingWidth = Math.max(width - (snappedLeftInset() + snappedRightInset()), 0); } double prefHeight = 0; @@ -172,7 +171,7 @@ paragraphNode.getBoundsType()); } - prefHeight += topPadding() + bottomPadding(); + prefHeight += snappedTopInset() + snappedBottomInset(); Bounds viewPortBounds = scrollPane.getViewportBounds(); computedPrefHeight = Math.max(prefHeight, (viewPortBounds != null) ? viewPortBounds.getHeight() : 0); @@ -182,7 +181,7 @@ @Override protected double computeMinWidth(double height) { if (computedMinWidth < 0) { - double hInsets = leftPadding() + rightPadding(); + double hInsets = snappedLeftInset() + snappedRightInset(); computedMinWidth = Math.min(characterWidth + hInsets, computePrefWidth(height)); } return computedMinWidth; @@ -190,38 +189,22 @@ @Override protected double computeMinHeight(double width) { if (computedMinHeight < 0) { - double vInsets = topPadding() + bottomPadding(); + double vInsets = snappedTopInset() + snappedBottomInset(); computedMinHeight = Math.min(lineHeight + vInsets, computePrefHeight(width)); } return computedMinHeight; } - private final double topPadding() { - return snapSize(getInsets().getTop()); - } - - private final double bottomPadding() { - return snapSize(getInsets().getBottom()); - } - - private final double leftPadding() { - return snapSize(getInsets().getLeft()); - } - - private final double rightPadding() { - return snapSize(getInsets().getRight()); - } - @Override public void layoutChildren() { TextArea textArea = getSkinnable(); double width = getWidth(); // Lay out paragraphs - final double topPadding = topPadding(); - final double leftPadding = leftPadding(); + final double topPadding = snappedTopInset(); + final double leftPadding = snappedLeftInset(); - double wrappingWidth = Math.max(width - (leftPadding + rightPadding()), 0); + double wrappingWidth = Math.max(width - (leftPadding + snappedRightInset()), 0); double y = topPadding; @@ -820,10 +803,10 @@ } @Override - public double getBaselineOffset() { + public double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { Text firstParagraph = (Text) paragraphNodes.getChildren().get(0); return Utils.getAscent(getSkinnable().getFont(),firstParagraph.getBoundsType()) - + contentView.getInsets().getTop() + textArea.getInsets().getTop(); + + contentView.snappedTopInset() + textArea.snappedTopInset(); } @Override @@ -858,13 +841,11 @@ int index = -1; if (n > 0) { - Insets padding = contentView.getInsets(); - - if (y < padding.getTop()) { + if (y < contentView.snappedTopInset()) { // Select the character at x in the first row Text paragraphNode = (Text)paragraphNodes.getChildren().get(0); index = getNextInsertionPoint(paragraphNode, x, -1, VerticalDirection.DOWN); - } else if (y > padding.getTop() + contentView.getHeight()) { + } else if (y > contentView.snappedTopInset() + contentView.getHeight()) { // Select the character at x in the last row int lastParagraphIndex = n - 1; Text lastParagraphView = (Text)paragraphNodes.getChildren().get(lastParagraphIndex); @@ -1032,7 +1013,6 @@ private void scrollBoundsToVisible(Rectangle2D bounds) { TextArea textArea = getSkinnable(); Bounds viewportBounds = scrollPane.getViewportBounds(); - Insets padding = contentView.getInsets(); double viewportWidth = viewportBounds.getWidth(); double viewportHeight = viewportBounds.getHeight(); @@ -1042,13 +1022,13 @@ if (bounds.getMinY() < 0) { double y = scrollTop + bounds.getMinY(); - if (y <= padding.getTop()) { + if (y <= contentView.snappedTopInset()) { y = 0; } textArea.setScrollTop(y); - } else if (padding.getTop() + bounds.getMaxY() > viewportHeight) { - double y = scrollTop + padding.getTop() + bounds.getMaxY() - viewportHeight; - if (y >= getScrollTopMax() - padding.getBottom()) { + } else if (contentView.snappedTopInset() + bounds.getMaxY() > viewportHeight) { + double y = scrollTop + contentView.snappedTopInset() + bounds.getMaxY() - viewportHeight; + if (y >= getScrollTopMax() - contentView.snappedBottomInset()) { y = getScrollTopMax(); } textArea.setScrollTop(y); @@ -1057,13 +1037,13 @@ if (bounds.getMinX() < 0) { double x = scrollLeft + bounds.getMinX() - slop; - if (x <= padding.getLeft() + slop) { + if (x <= contentView.snappedLeftInset() + slop) { x = 0; } textArea.setScrollLeft(x); - } else if (padding.getLeft() + bounds.getMaxX() > viewportWidth) { - double x = scrollLeft + padding.getLeft() + bounds.getMaxX() - viewportWidth + slop; - if (x >= getScrollLeftMax() - padding.getRight() - slop) { + } else if (contentView.snappedLeftInset() + bounds.getMaxX() > viewportWidth) { + double x = scrollLeft + contentView.snappedLeftInset() + bounds.getMaxX() - viewportWidth + slop; + if (x >= getScrollLeftMax() - contentView.snappedRightInset() - slop) { x = getScrollLeftMax(); } textArea.setScrollLeft(x); @@ -1072,14 +1052,12 @@ private void updatePrefViewportWidth() { int columnCount = getSkinnable().getPrefColumnCount(); - Insets contentPadding = contentView.getInsets(); - scrollPane.setPrefViewportWidth(columnCount * characterWidth + contentPadding.getLeft() + contentPadding.getRight()); + scrollPane.setPrefViewportWidth(columnCount * characterWidth + contentView.snappedLeftInset() + contentView.snappedRightInset()); } private void updatePrefViewportHeight() { int rowCount = getSkinnable().getPrefRowCount(); - Insets contentPadding = contentView.getInsets(); - scrollPane.setPrefViewportHeight(rowCount * lineHeight + contentPadding.getTop() + contentPadding.getBottom()); + scrollPane.setPrefViewportHeight(rowCount * lineHeight + contentView.snappedTopInset() + contentView.snappedBottomInset()); } private void updateFontMetrics() { @@ -1113,11 +1091,11 @@ // Callbacks from Behavior class private double getTextTranslateX() { - return contentView.getInsets().getLeft(); + return contentView.snappedLeftInset(); } private double getTextTranslateY() { - return contentView.getInsets().getTop(); + return contentView.snappedTopInset(); } private double getTextLeft() { @@ -1389,9 +1367,8 @@ contentView.layoutChildren(); Point2D p = super.getMenuPosition(); if (p != null) { - Insets padding = contentView.getInsets(); - p = new Point2D(Math.max(0, p.getX() - padding.getLeft() - getSkinnable().getScrollLeft()), - Math.max(0, p.getY() - padding.getTop() - getSkinnable().getScrollTop())); + p = new Point2D(Math.max(0, p.getX() - contentView.snappedLeftInset() - getSkinnable().getScrollLeft()), + Math.max(0, p.getY() - contentView.snappedTopInset() - getSkinnable().getScrollTop())); } return p; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextFieldSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextFieldSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TextFieldSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -42,7 +42,6 @@ import javafx.event.EventHandler; import javafx.geometry.Bounds; import javafx.geometry.HPos; -import javafx.geometry.Insets; import javafx.geometry.Point2D; import javafx.geometry.Rectangle2D; import javafx.scene.Group; @@ -57,7 +56,6 @@ import javafx.scene.shape.PathElement; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; -import com.sun.javafx.PlatformUtil; import com.sun.javafx.application.PlatformImpl; import com.sun.javafx.scene.control.behavior.TextFieldBehavior; import com.sun.javafx.scene.text.HitInfo; @@ -460,42 +458,26 @@ } @Override - protected double computePrefWidth(double height) { + protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { TextField textField = getSkinnable(); double characterWidth = fontMetrics.get().computeStringWidth("W"); int columnCount = textField.getPrefColumnCount(); - return columnCount * characterWidth + (leftPadding() + rightPadding()); + return columnCount * characterWidth + leftInset + rightInset; } - @Override protected double computePrefHeight(double width) { - return topPadding() + textNode.getLayoutBounds().getHeight() + bottomPadding(); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + return topInset + textNode.getLayoutBounds().getHeight() + bottomInset; } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().prefHeight(width); } - private final double topPadding() { - return snapSize(getSkinnable().getInsets().getTop()); - } - - private final double bottomPadding() { - return snapSize(getSkinnable().getInsets().getBottom()); - } - - private final double leftPadding() { - return snapSize(getSkinnable().getInsets().getLeft()); - } - - private final double rightPadding() { - return snapSize(getSkinnable().getInsets().getRight()); - } - - @Override public double getBaselineOffset() { - return topPadding() + textNode.getBaselineOffset(); + @Override public double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { + return topInset + textNode.getBaselineOffset(); } private void updateTextPos() { @@ -648,11 +630,10 @@ public HitInfo getIndex(MouseEvent e) { // adjust the event to be in the same coordinate space as the // text content of the textInputControl - Insets insets = getSkinnable().getInsets(); Point2D p; - p = new Point2D(e.getX() - textTranslateX.get() - insets.getLeft(), - e.getY() - insets.getTop()); + p = new Point2D(e.getX() - textTranslateX.get() - snappedLeftInset(), + e.getY() - snappedTopInset()); return textNode.impl_hitTestChar(translateCaretPosition(p)); } @@ -775,8 +756,8 @@ } if (PlatformImpl.isSupported(ConditionalFeature.INPUT_TOUCH)) { - handleGroup.setLayoutX(leftPadding()); - handleGroup.setLayoutY(topPadding()); + handleGroup.setLayoutX(x); + handleGroup.setLayoutY(y); // Resize handles for caret and anchor. // IndexRange selection = textField.getSelection(); @@ -803,8 +784,8 @@ @Override public Point2D getMenuPosition() { Point2D p = super.getMenuPosition(); if (p != null) { - p = new Point2D(Math.max(0, p.getX() - textNode.getLayoutX() - leftPadding() + textTranslateX.get()), - Math.max(0, p.getY() - textNode.getLayoutY() - topPadding())); + p = new Point2D(Math.max(0, p.getX() - textNode.getLayoutX() - snappedLeftInset() + textTranslateX.get()), + Math.max(0, p.getY() - textNode.getLayoutY() - snappedTopInset())); } return p; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TitledPaneSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TitledPaneSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TitledPaneSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -51,8 +51,6 @@ import com.sun.javafx.scene.traversal.Direction; import com.sun.javafx.scene.traversal.TraversalEngine; import com.sun.javafx.scene.traversal.TraverseListener; -import javafx.beans.binding.Binding; -import javafx.beans.binding.Bindings; import javafx.beans.binding.DoubleBinding; import javafx.geometry.Insets; import javafx.scene.control.Accordion; @@ -205,13 +203,12 @@ @Override protected void layoutChildren(final double x, double y, final double w, final double h) { - final Insets padding = getSkinnable().getInsets(); // header double headerHeight = Math.max(MIN_HEADER_HEIGHT, snapSize(titleRegion.prefHeight(-1))); titleRegion.resize(w, headerHeight); - positionInArea(titleRegion, snapSize(padding.getLeft()), snapSize(padding.getTop()), + positionInArea(titleRegion, x, y, w, headerHeight, 0, HPos.LEFT, VPos.CENTER); // content @@ -223,38 +220,36 @@ } } - y = snapSize(padding.getTop()) + snapSize(headerHeight) - (contentHeight * (1 - getTransition())); + y = y + snapSize(headerHeight) - (contentHeight * (1 - getTransition())); double clipY = contentHeight * (1 - getTransition()); ((Rectangle)contentContainer.getClip()).setY(clipY); contentContainer.resize(contentWidth, contentHeight); - positionInArea(contentContainer, snapSize(padding.getLeft()), y, + positionInArea(contentContainer, x, y, w, contentHeight, /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); } - @Override protected double computeMinWidth(double height) { - return computePrefWidth(height); + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return Math.max(MIN_HEADER_HEIGHT, snapSize(titleRegion.prefHeight(-1))); } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double titleWidth = snapSize(titleRegion.prefWidth(height)); double contentWidth = snapSize(contentContainer.prefWidth(height)); - final Insets padding = getSkinnable().getInsets(); - return Math.max(titleWidth, contentWidth) + snapSize(padding.getLeft()) + snapSize(padding.getRight()); + return Math.max(titleWidth, contentWidth) + leftInset + rightInset; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double headerHeight = Math.max(MIN_HEADER_HEIGHT, snapSize(titleRegion.prefHeight(-1))); double contentHeight = contentContainer.prefHeight(-1) * getTransition(); - final Insets padding = getSkinnable().getInsets(); - return headerHeight + snapSize(contentHeight) + snapSize(padding.getTop()) + snapSize(padding.getBottom()); + return headerHeight + snapSize(contentHeight) + topInset + bottomInset; } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return Double.MAX_VALUE; } @@ -266,8 +261,7 @@ double getTitledPaneHeightForAccordion() { double headerHeight = Math.max(MIN_HEADER_HEIGHT, snapSize(titleRegion.prefHeight(-1))); double contentHeight = (prefHeightFromAccordion - headerHeight) * getTransition(); - final Insets padding = getSkinnable().getInsets(); - return headerHeight + snapSize(contentHeight) + snapSize(padding.getTop()) + snapSize(padding.getBottom()); + return headerHeight + snapSize(contentHeight) + snappedTopInset() + snappedBottomInset(); } private void doAnimationTransition() { @@ -420,9 +414,8 @@ } @Override protected double computePrefWidth(double height) { - final Insets padding = getInsets(); - double left = snapSize(padding.getLeft()); - double right = snapSize(padding.getRight()); + double left = snappedLeftInset(); + double right = snappedRightInset(); double arrowWidth = 0; double labelPrefWidth = labelPrefWidth(height); @@ -434,9 +427,8 @@ } @Override protected double computePrefHeight(double width) { - final Insets padding = getInsets(); - double top = snapSize(padding.getTop()); - double bottom = snapSize(padding.getBottom()); + double top = snappedTopInset(); + double bottom = snappedBottomInset(); double arrowHeight = 0; double labelPrefHeight = labelPrefHeight(width); @@ -448,11 +440,10 @@ } @Override protected void layoutChildren() { - final Insets padding = getInsets(); - double top = snapSize(padding.getTop()); - double bottom = snapSize(padding.getBottom()); - double left = snapSize(padding.getLeft()); - double right = snapSize(padding.getRight()); + final double top = snappedTopInset(); + final double bottom = snappedBottomInset(); + final double left = snappedLeftInset(); + final double right = snappedRightInset(); double width = getWidth() - (left + right); double height = getHeight() - (top + bottom); double arrowWidth = snapSize(arrowRegion.prefWidth(-1)); @@ -507,9 +498,8 @@ final Font font = text.getFont(); final ContentDisplay contentDisplay = labeled.getContentDisplay(); final double gap = labeled.getGraphicTextGap(); - final Insets padding = labeled.getInsets(); final Insets labelPadding = labeled.getLabelPadding(); - final double widthPadding = padding.getLeft() + padding.getRight() + labelPadding.getLeft() + labelPadding.getRight(); + final double widthPadding = snappedLeftInset() + snappedRightInset() + labelPadding.getLeft() + labelPadding.getRight(); String str = labeled.getText(); if (str != null && str.endsWith("\n")) { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ToolBarSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ToolBarSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/ToolBarSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -71,7 +71,6 @@ import com.sun.javafx.scene.traversal.TraversalEngine; import com.sun.javafx.scene.traversal.TraverseListener; import javafx.css.Styleable; -import javafx.geometry.Insets; public class ToolBarSkin extends BehaviorSkinBase implements TraverseListener { @@ -232,26 +231,23 @@ } } - @Override protected double computeMinWidth(double height) { + @Override protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); return toolbar.getOrientation() == Orientation.VERTICAL ? - computePrefWidth(-1) : - snapSize(overflowMenu.prefWidth(-1)) + snapSpace(padding.getLeft()) + snapSpace(padding.getRight()); + computePrefWidth(-1, topInset, rightInset, bottomInset, leftInset) : + snapSize(overflowMenu.prefWidth(-1)) + leftInset + rightInset; } - @Override protected double computeMinHeight(double width) { + @Override protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); return toolbar.getOrientation() == Orientation.VERTICAL? - snapSize(overflowMenu.prefHeight(-1)) + snapSpace(padding.getTop()) + snapSpace(padding.getBottom()) : - computePrefHeight(-1); + snapSize(overflowMenu.prefHeight(-1)) + topInset + bottomInset : + computePrefHeight(-1, topInset, rightInset, bottomInset, leftInset); } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double prefWidth = 0; final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); if (toolbar.getOrientation() == Orientation.HORIZONTAL) { for (Node node : toolbar.getItems()) { @@ -268,13 +264,12 @@ prefWidth = savedPrefWidth; } } - return snapSpace(padding.getLeft()) + prefWidth + snapSpace(padding.getRight()); + return leftInset + prefWidth + rightInset; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double prefHeight = 0; final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); if(toolbar.getOrientation() == Orientation.VERTICAL) { for (Node node: toolbar.getItems()) { @@ -291,24 +286,23 @@ prefHeight = savedPrefHeight; } } - return snapSpace(padding.getTop()) + prefHeight + snapSpace(padding.getBottom()); + return topInset + prefHeight + bottomInset; } - @Override protected double computeMaxWidth(double height) { + @Override protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().getOrientation() == Orientation.VERTICAL ? snapSize(getSkinnable().prefWidth(-1)) : Double.MAX_VALUE; } - @Override protected double computeMaxHeight(double width) { + @Override protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return getSkinnable().getOrientation() == Orientation.VERTICAL ? Double.MAX_VALUE : snapSize(getSkinnable().prefHeight(-1)); } - @Override protected void layoutChildren(double x, double y, + @Override protected void layoutChildren(final double x,final double y, final double w, final double h) { // super.layoutChildren(); final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); if (toolbar.getOrientation() == Orientation.VERTICAL) { if (snapSize(toolbar.getHeight()) != previousHeight || needsUpdate) { @@ -327,8 +321,8 @@ } needsUpdate = false; - double toolbarWidth = snapSize(toolbar.getWidth()) - (snapSpace(padding.getLeft()) + snapSpace(padding.getRight())); - double toolbarHeight = snapSize(toolbar.getHeight()) - (snapSpace(padding.getTop()) + snapSpace(padding.getBottom())); + double toolbarWidth = w; + double toolbarHeight = h; if (getSkinnable().getOrientation() == Orientation.VERTICAL) { toolbarHeight -= (overflow ? snapSize(overflowMenu.prefHeight(-1)) : 0); @@ -337,13 +331,15 @@ } box.resize(toolbarWidth, toolbarHeight); - positionInArea(box, snapSpace(padding.getLeft()), snapSpace(padding.getTop()), + positionInArea(box, x, y, toolbarWidth, toolbarHeight, /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); // If popup menu is not null show the overflowControl if (overflow) { double overflowMenuWidth = snapSize(overflowMenu.prefWidth(-1)); double overflowMenuHeight = snapSize(overflowMenu.prefHeight(-1)); + double overflowX = x; + double overflowY = x; if (getSkinnable().getOrientation() == Orientation.VERTICAL) { // This is to prevent the overflow menu from moving when there // are no items in the toolbar. @@ -352,17 +348,16 @@ } HPos pos = ((VBox)box).getAlignment().getHpos(); if (HPos.LEFT.equals(pos)) { - x = snapSpace(padding.getLeft()) + - Math.abs((toolbarWidth - overflowMenuWidth)/2); + overflowX = x + Math.abs((toolbarWidth - overflowMenuWidth)/2); } else if (HPos.RIGHT.equals(pos)) { - x = (snapSize(toolbar.getWidth()) - snapSpace(padding.getRight()) - toolbarWidth) + + overflowX = (snapSize(toolbar.getWidth()) - snappedRightInset() - toolbarWidth) + Math.abs((toolbarWidth - overflowMenuWidth)/2); } else { - x = snapSpace(padding.getLeft()) + - Math.abs((snapSize(toolbar.getWidth()) - (snapSpace(padding.getLeft()) + - snapSpace(padding.getRight())) - overflowMenuWidth)/2); + overflowX = x + + Math.abs((snapSize(toolbar.getWidth()) - (x) + + snappedRightInset() - overflowMenuWidth)/2); } - y = snapSize(toolbar.getHeight()) - overflowMenuHeight - snapSpace(padding.getTop()); + overflowY = snapSize(toolbar.getHeight()) - overflowMenuHeight - y; } else { // This is to prevent the overflow menu from moving when there // are no items in the toolbar. @@ -371,20 +366,18 @@ } VPos pos = ((HBox)box).getAlignment().getVpos(); if (VPos.TOP.equals(pos)) { - y = snapSpace(padding.getTop()) + + overflowY = y + Math.abs((toolbarHeight - overflowMenuHeight)/2); } else if (VPos.BOTTOM.equals(pos)) { - y = (snapSize(toolbar.getHeight()) - snapSpace(padding.getBottom()) - toolbarHeight) + + overflowY = (snapSize(toolbar.getHeight()) - snappedBottomInset() - toolbarHeight) + Math.abs((toolbarHeight - overflowMenuHeight)/2); } else { - y = snapSpace(padding.getTop()) + - Math.abs((snapSize(toolbar.getHeight()) - (snapSpace(padding.getTop()) + - snapSpace(padding.getBottom())) - overflowMenuHeight)/2); + overflowY = y + Math.abs((toolbarHeight - overflowMenuHeight)/2); } - x = snapSize(toolbar.getWidth()) - overflowMenuWidth - snapSpace(padding.getRight()); + overflowX = snapSize(toolbar.getWidth()) - overflowMenuWidth - snappedRightInset(); } overflowMenu.resize(overflowMenuWidth, overflowMenuHeight); - positionInArea(overflowMenu, x, y, overflowMenuWidth, overflowMenuHeight, /*baseline ignored*/0, + positionInArea(overflowMenu, overflowX, overflowY, overflowMenuWidth, overflowMenuHeight, /*baseline ignored*/0, HPos.CENTER, VPos.CENTER); } } @@ -415,12 +408,11 @@ private void addNodesToToolBar() { final ToolBar toolbar = getSkinnable(); - final Insets padding = toolbar.getInsets(); double length = 0; if (getSkinnable().getOrientation() == Orientation.VERTICAL) { - length = snapSize(toolbar.getHeight()) - (snapSpace(padding.getTop()) + snapSpace(padding.getBottom())) + getSpacing(); + length = snapSize(toolbar.getHeight()) - snappedTopInset() - snappedBottomInset() + getSpacing(); } else { - length = snapSize(toolbar.getWidth()) - (snapSpace(padding.getLeft()) + snapSpace(padding.getRight())) + getSpacing(); + length = snapSize(toolbar.getWidth()) - snappedLeftInset() - snappedRightInset() + getSpacing(); } // Is there overflow ? @@ -608,11 +600,11 @@ } @Override protected double computePrefWidth(double height) { - return snapSize(getInsets().getLeft()) + snapSize(getInsets().getRight()); + return snappedLeftInset() + snappedRightInset(); } @Override protected double computePrefHeight(double width) { - return snapSize(getInsets().getTop()) + snapSize(getInsets().getBottom()); + return snappedTopInset() + snappedBottomInset(); } @Override protected void layoutChildren() { diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeCellSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeCellSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeCellSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -45,14 +45,9 @@ import com.sun.javafx.css.converters.SizeConverter; import com.sun.javafx.scene.control.MultiplePropertyChangeListenerHandler; import com.sun.javafx.scene.control.behavior.TreeCellBehavior; -import javafx.animation.RotateTransition; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.beans.value.WeakChangeListener; import javafx.css.Styleable; import javafx.geometry.Insets; import javafx.util.Callback; -import javafx.util.Duration; public class TreeCellSkin extends CellSkinBase, TreeCellBehavior> { @@ -253,17 +248,16 @@ layoutLabelInArea(x, y, w, h); } - @Override protected double computePrefHeight(double width) { - double pref = super.computePrefHeight(width); + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { + double pref = super.computePrefHeight(width, topInset, rightInset, bottomInset, leftInset); Node d = getSkinnable().getDisclosureNode(); return (d == null) ? pref : Math.max(d.prefHeight(-1), pref); } - @Override protected double computePrefWidth(double height) { - double labelWidth = super.computePrefWidth(height); + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + double labelWidth = super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); - final Insets padding = getSkinnable().getInsets(); - double pw = padding.getLeft() + padding.getRight(); + double pw = snappedLeftInset() + snappedRightInset(); TreeView tree = getSkinnable().getTreeView(); if (tree == null) return pw; diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableCellSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableCellSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableCellSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -110,11 +110,11 @@ return leftPadding; } - @Override protected double computePrefWidth(double height) { + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { if (isDeferToParentForPrefWidth) { // RT-27167: we must take into account the disclosure node and the // indentation (which is not taken into account by the LabeledSkinBase. - return super.computePrefWidth(height); + return super.computePrefWidth(height, topInset, rightInset, bottomInset, leftInset); } return columnWidthProperty().get(); } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeTableViewSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -336,7 +336,7 @@ Node n = cell.getSkin() == null ? null : cell.getSkin().getNode(); if (n instanceof Region) { Region r = (Region) n; - padding = r.getInsets().getLeft() + r.getInsets().getRight(); + padding = r.snappedLeftInset() + r.snappedRightInset(); } TreeTableRow treeTableRow = new TreeTableRow(); diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/TreeViewSkin.java Tue Apr 16 23:11:38 2013 -0700 @@ -27,7 +27,6 @@ import javafx.event.EventHandler; import javafx.scene.Node; -import javafx.scene.control.IndexedCell; import javafx.scene.control.TreeCell; import javafx.scene.control.TreeItem; import javafx.scene.control.TreeItem.TreeModificationEvent; @@ -339,11 +338,11 @@ }; } - @Override protected double computePrefWidth(double height) { - return computePrefHeight(-1) * 0.618033987; + @Override protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { + return computePrefHeight(-1, topInset, rightInset, bottomInset, leftInset) * 0.618033987; } - @Override protected double computePrefHeight(double width) { + @Override protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return 400; } diff -r 99d9d2e87bd0 javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualContainerBase.java --- a/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualContainerBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/VirtualContainerBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -88,8 +88,7 @@ protected abstract void updateRowCount(); double getMaxCellWidth(int rowsToCount) { - final Insets padding = getSkinnable().getInsets(); - return padding.getLeft() + flow.getMaxCellWidth(rowsToCount) + padding.getRight(); + return snappedLeftInset() + flow.getMaxCellWidth(rowsToCount) + snappedRightInset(); } double getVirtualFlowPreferredHeight(int rows) { @@ -98,9 +97,8 @@ for (int i = 0; i < rows && i < getItemCount(); i++) { height += flow.getCellLength(i); } - - final Insets padding = getSkinnable().getInsets(); - return height + padding.getTop() + padding.getBottom(); + + return height + snappedTopInset() + snappedBottomInset(); } @Override protected void layoutChildren(double x, double y, double w, double h) { diff -r 99d9d2e87bd0 javafx-ui-controls/src/javafx/scene/control/Control.java --- a/javafx-ui-controls/src/javafx/scene/control/Control.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/javafx/scene/control/Control.java Tue Apr 16 23:11:38 2013 -0700 @@ -455,7 +455,7 @@ */ @Override protected double computeMinWidth(final double height) { if (skinBase != null) { - return skinBase.computeMinWidth(height); + return skinBase.computeMinWidth(height, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.minWidth(height); @@ -474,7 +474,7 @@ */ @Override protected double computeMinHeight(final double width) { if (skinBase != null) { - return skinBase.computeMinHeight(width); + return skinBase.computeMinHeight(width, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.minHeight(width); @@ -493,7 +493,7 @@ */ @Override protected double computeMaxWidth(double height) { if (skinBase != null) { - return skinBase.computeMaxWidth(height); + return skinBase.computeMaxWidth(height, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.maxWidth(height); @@ -512,7 +512,7 @@ */ @Override protected double computeMaxHeight(double width) { if (skinBase != null) { - return skinBase.computeMaxHeight(width); + return skinBase.computeMaxHeight(width, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.maxHeight(width); @@ -522,7 +522,7 @@ /** {@inheritDoc} */ @Override protected double computePrefWidth(double height) { if (skinBase != null) { - return skinBase.computePrefWidth(height); + return skinBase.computePrefWidth(height, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.prefWidth(height); @@ -531,8 +531,8 @@ /** {@inheritDoc} */ @Override protected double computePrefHeight(double width) { - if (skinBase != null) { - return skinBase.computePrefHeight(width); + if (skinBase != null) { + return skinBase.computePrefHeight(width, snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.prefHeight(width); @@ -542,7 +542,7 @@ /** {@inheritDoc} */ @Override public double getBaselineOffset() { if (skinBase != null) { - return skinBase.getBaselineOffset(); + return skinBase.computeBaselineOffset(snappedTopInset(), snappedRightInset(), snappedBottomInset(), snappedLeftInset()); } else { final Node skinNode = getSkinNode(); return skinNode == null ? 0 : skinNode.getBaselineOffset(); @@ -559,11 +559,10 @@ /** {@inheritDoc} */ @Override protected void layoutChildren() { if (skinBase != null) { - final Insets padding = getInsets(); - final double x = snapSize(padding.getLeft()); - final double y = snapSize(padding.getTop()); - final double w = snapSize(getWidth()) - snapSize(padding.getLeft()) - snapSize(padding.getRight()); - final double h = snapSize(getHeight()) - snapSize(padding.getTop()) - snapSize(padding.getBottom()); + final double x = snappedLeftInset(); + final double y = snappedTopInset(); + final double w = snapSize(getWidth()) - x - snappedRightInset(); + final double h = snapSize(getHeight()) - y - snappedBottomInset(); skinBase.layoutChildren(x, y, w, h); } else { Node n = getSkinNode(); diff -r 99d9d2e87bd0 javafx-ui-controls/src/javafx/scene/control/SkinBase.java --- a/javafx-ui-controls/src/javafx/scene/control/SkinBase.java Tue Apr 16 16:40:55 2013 -0700 +++ b/javafx-ui-controls/src/javafx/scene/control/SkinBase.java Tue Apr 16 23:11:38 2013 -0700 @@ -197,48 +197,64 @@ /** * Computes the minimum allowable width of the Skin, based on the provided * height. - * + * * @param height The height of the Skin, in case this value might dictate * the minimum width. + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return A double representing the minimum width of this Skin. */ - protected double computeMinWidth(double height) { + protected double computeMinWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return control.prefWidth(height); } /** * Computes the minimum allowable height of the Skin, based on the provided * width. - * + * * @param width The width of the Skin, in case this value might dictate * the minimum height. + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return A double representing the minimum height of this Skin. */ - protected double computeMinHeight(double width) { + protected double computeMinHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return control.prefHeight(width); } /** * Computes the maximum allowable width of the Skin, based on the provided * height. - * + * * @param height The height of the Skin, in case this value might dictate * the maximum width. + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return A double representing the maximum width of this Skin. */ - protected double computeMaxWidth(double height) { + protected double computeMaxWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { return Double.MAX_VALUE; } /** * Computes the maximum allowable height of the Skin, based on the provided * width. - * + * * @param width The width of the Skin, in case this value might dictate * the maximum height. + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return A double representing the maximum height of this Skin. */ - protected double computeMaxHeight(double width) { + protected double computeMaxHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { return Double.MAX_VALUE; } @@ -249,11 +265,14 @@ * by its managed children when they are positioned at their * current positions at their preferred widths. * - * @param height the height that should be used if preferred width depends - * on it + * @param height the height that should be used if preferred width depends on it + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return the calculated preferred width */ - protected double computePrefWidth(double height) { + protected double computePrefWidth(double height, int topInset, int rightInset, int bottomInset, int leftInset) { double minX = 0; double maxX = 0; for (int i = 0; i < children.size(); i++) { @@ -274,11 +293,14 @@ * by its managed children when they are positioned at their current * positions at their preferred heights. * - * @param width the width that should be used if preferred height depends - * on it + * @param width the width that should be used if preferred height depends on it + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return the calculated preferred height */ - protected double computePrefHeight(double width) { + protected double computePrefHeight(double width, int topInset, int rightInset, int bottomInset, int leftInset) { double minY = 0; double maxY = 0; for (int i = 0; i < children.size(); i++) { @@ -296,9 +318,13 @@ * Calculates the baseline offset based on the first managed child. If there * is no such child, returns {@link Node#getBaselineOffset()}. * + * @param topInset the pixel snapped top inset + * @param rightInset the pixel snapped right inset + * @param bottomInset the pixel snapped bottom inset + * @param leftInset the pixel snapped left inset * @return baseline offset */ - public double getBaselineOffset() { + protected double computeBaselineOffset(int topInset, int rightInset, int bottomInset, int leftInset) { int size = children.size(); for (int i = 0; i < size; ++i) { Node child = children.get(i); @@ -308,15 +334,54 @@ } return control.getLayoutBounds().getHeight(); } - - + /*************************************************************************** * * * (Mostly ugly) Skin -> Control forwarding API * * * - **************************************************************************/ - + **************************************************************************/ + + /** + * Utility method to get the top inset which includes padding and border + * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. + * + * @return Rounded up insets top + */ + protected int snappedTopInset() { + return control.snappedTopInset(); + } + + /** + * Utility method to get the bottom inset which includes padding and border + * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. + * + * @return Rounded up insets bottom + */ + protected int snappedBottomInset() { + return control.snappedBottomInset(); + } + + /** + * Utility method to get the left inset which includes padding and border + * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. + * + * @return Rounded up insets left + */ + protected int snappedLeftInset() { + return control.snappedLeftInset(); + } + + /** + * Utility method to get the right inset which includes padding and border + * inset. Then snapped to whole pixels if getSkinnable().isSnapToPixel() is true. + * + * @return Rounded up insets right + */ + protected int snappedRightInset() { + return control.snappedRightInset(); + } + /** * If this region's snapToPixel property is true, returns a value rounded * to the nearest pixel, else returns the same value.