Separate css rules for separators of one splitPane
I have the following css class in a css file
.split-pane > .split-pane-divider {
-fx-background-insets: 0;
-fx-padding: 0 0 0 0;
-fx-background-color: red;
}
And I have a splitPane with two delimiters and I have a link to those delimiters as Node (!). I mean
Node leftDivider;
Node rightDivider;
I get a link to them this way
List<Node> nodes=getDividerNodes(splitPane);
leftDivider=nodes.get(0);
rightDivider=nodes.get(1);
...
public static List<Node> getDividerNodes(SplitPane splitPane){
Map<Double,Node> sortedMap=new TreeMap<>();
if (splitPane.getOrientation()==Orientation.HORIZONTAL){
splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> {
if (div.getParent()==splitPane){
sortedMap.put(div.getLayoutX(), div);
}
});
}else{
splitPane.lookupAll(".split-pane-divider").stream().forEach(div -> {
if (div.getParent()==splitPane){
sortedMap.put(div.getLayoutY(), div);
}
});
}
return new ArrayList<>(sortedMap.values());
}
Now I will not display leftDivider, but not display rightDivider. I do
leftDivider.setStyle("-fx-padding: 0 5 0 0;");
However, I see both left and right separators. Also, if I only want to see the correct divisor and I do
rightDivider.setStyle("-fx-padding: 0 5 0 0;");
I don't see any separators.
It seems to me that separate control over the dividers within a single split panel is not possible. If I am wrong, please tell me how can I only show one of the two delimiters?
source to share
This looks like a bug. In particular, the class SplitPaneSkin
contains the following method:
private void layoutDividersAndContent(double width, double height) {
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()));
if (horizontal) {
c.setClipSize(c.getArea(), height);
layoutInArea(c, c.getX() + paddingX, c.getY() + paddingY, c.getArea(), height,
0/*baseline*/,HPos.CENTER, VPos.CENTER);
} else {
c.setClipSize(width, c.getArea());
layoutInArea(c, c.getX() + paddingX, c.getY() + paddingY, width, c.getArea(),
0/*baseline*/,HPos.CENTER, VPos.CENTER);
}
}
for (ContentDivider c: contentDividers) {
// System.out.println("LAYOUT DIVIDERS X " + c.getX() + " Y " + c.getY() + " W " + (horizontal ? dividerWidth : width) + " H " + (horizontal ? height : dividerWidth));
if (horizontal) {
c.resize(dividerWidth, height);
positionInArea(c, c.getX() + paddingX, c.getY() + paddingY, dividerWidth, height,
/*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
} else {
c.resize(width, dividerWidth);
positionInArea(c, c.getX() + paddingX, c.getY() + paddingY, width, dividerWidth,
/*baseline ignored*/0, HPos.CENTER, VPos.CENTER);
}
}
}
As you can see, it is dividerWidth
calculated for one separator and the same value is used in the layout of all separators. Hence, all dividers are the same size regardless of the different styles they may have.
I recommend you search if this has already been reported (I did a quick search and found nothing) and report if not.
source to share