Search in sources :

Example 1 with Side

use of javafx.geometry.Side in project Gargoyle by callakrsos.

the class DockTabPaneSkin method layoutChildren.

@Override
protected void layoutChildren(final double x, final double y, final double w, final double h) {
    DockTabPane tabPane = getSkinnable();
    Side tabPosition = tabPane.getSide();
    double headerHeight = snapSize(tabHeaderArea.prefHeight(-1));
    double tabsStartX = tabPosition.equals(Side.RIGHT) ? x + w - headerHeight : x;
    double tabsStartY = tabPosition.equals(Side.BOTTOM) ? y + h - headerHeight : y;
    if (tabPosition == Side.TOP) {
        tabHeaderArea.resize(w, headerHeight);
        tabHeaderArea.relocate(tabsStartX, tabsStartY);
        tabHeaderArea.getTransforms().clear();
        tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.TOP)));
    } else if (tabPosition == Side.BOTTOM) {
        tabHeaderArea.resize(w, headerHeight);
        tabHeaderArea.relocate(w, tabsStartY - headerHeight);
        tabHeaderArea.getTransforms().clear();
        tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.BOTTOM), 0, headerHeight));
    } else if (tabPosition == Side.LEFT) {
        tabHeaderArea.resize(h, headerHeight);
        tabHeaderArea.relocate(tabsStartX + headerHeight, h - headerHeight);
        tabHeaderArea.getTransforms().clear();
        tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.LEFT), 0, headerHeight));
    } else if (tabPosition == Side.RIGHT) {
        tabHeaderArea.resize(h, headerHeight);
        tabHeaderArea.relocate(tabsStartX, y - headerHeight);
        tabHeaderArea.getTransforms().clear();
        tabHeaderArea.getTransforms().add(new Rotate(getRotation(Side.RIGHT), 0, headerHeight));
    }
    tabHeaderAreaClipRect.setX(0);
    tabHeaderAreaClipRect.setY(0);
    if (isHorizontal()) {
        tabHeaderAreaClipRect.setWidth(w);
    } else {
        tabHeaderAreaClipRect.setWidth(h);
    }
    tabHeaderAreaClipRect.setHeight(headerHeight);
    // ==================================
    // position the tab content for the selected tab only
    // ==================================
    // if the tabs are on the left, the content needs to be indented
    double contentStartX = 0;
    double contentStartY = 0;
    if (tabPosition == Side.TOP) {
        contentStartX = x;
        contentStartY = y + headerHeight;
        if (isFloatingStyleClass()) {
            // This is to hide the top border content
            contentStartY -= 1;
        }
    } else if (tabPosition == Side.BOTTOM) {
        contentStartX = x;
        contentStartY = y;
        if (isFloatingStyleClass()) {
            // This is to hide the bottom border content
            contentStartY = 1;
        }
    } else if (tabPosition == Side.LEFT) {
        contentStartX = x + headerHeight;
        contentStartY = y;
        if (isFloatingStyleClass()) {
            // This is to hide the left border content
            contentStartX -= 1;
        }
    } else if (tabPosition == Side.RIGHT) {
        contentStartX = x;
        contentStartY = y;
        if (isFloatingStyleClass()) {
            // This is to hide the right border content
            contentStartX = 1;
        }
    }
    double contentWidth = w - (isHorizontal() ? 0 : headerHeight);
    double contentHeight = h - (isHorizontal() ? headerHeight : 0);
    for (int i = 0, max = tabContentRegions.size(); i < max; i++) {
        TabContentRegion tabContent = tabContentRegions.get(i);
        tabContent.setAlignment(Pos.TOP_LEFT);
        if (tabContent.getClip() != null) {
            ((Rectangle) tabContent.getClip()).setWidth(contentWidth);
            ((Rectangle) tabContent.getClip()).setHeight(contentHeight);
        }
        // we need to size all tabs, even if they aren't visible. For example,
        // see RT-29167
        tabContent.resize(contentWidth, contentHeight);
        tabContent.relocate(contentStartX, contentStartY);
    }
}
Also used : Side(javafx.geometry.Side) Rotate(javafx.scene.transform.Rotate) Rectangle(javafx.scene.shape.Rectangle)

Aggregations

Side (javafx.geometry.Side)1 Rectangle (javafx.scene.shape.Rectangle)1 Rotate (javafx.scene.transform.Rotate)1