All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.factoryfx.javafx.editor.data.BreadCrumbBarWidthFixed Maven / Gradle / Ivy

package de.factoryfx.javafx.editor.data;

import impl.org.controlsfx.skin.BreadCrumbBarSkin;
import javafx.scene.Node;
import javafx.scene.control.Skin;
import org.controlsfx.control.BreadCrumbBar;

public class BreadCrumbBarWidthFixed extends BreadCrumbBar {
    /**
     * {@inheritDoc}
     */
    @Override
    protected Skin createDefaultSkin() {
        return new BreadCrumbBarSkin(this) {

            @Override
            protected double computePrefWidth(double height, double topInset, double rightInset, double bottomInset, double leftInset) {
                double width = 0;
                for (Node node : getChildren()) {
                    if (node instanceof BreadCrumbButton) {
                        width = width - ((BreadCrumbButton) node).getArrowWidth();
                    }
                    width += node.prefWidth(-1);
                }
                if (!getChildren().isEmpty()){
                    width = width + ((BreadCrumbButton) getChildren().get(0)).getArrowWidth();
                }
                return width;
            }

        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy