-
Enhancement
-
Resolution: Unresolved
-
P4
-
8
-
JavaFX 8b113
No matter what I do (playing with -fx-indent, setting DisclosureNode to null, or an empty Rectangle), the default TreeCellSkin implementation will reserve 18 pixels for the disclosure node.
This is despite the fact that the TreeCellSkin code determined that the node is not visible already:
boolean disclosureVisible = disclosureNode != null && treeItem != null && ! treeItem.isLeaf();
It will still calculate the disclosureWidth:
final double defaultDisclosureWidth = maxDisclosureWidthMap.containsKey(tree) ?
maxDisclosureWidthMap.get(tree) : 18; //RT-19656: default width of default disclosure node
double disclosureWidth = defaultDisclosureWidth;
And then use it in its calculation of where to layout the label/graphic of the cell node:
// determine starting point of the graphic or cell node, and the
// remaining width available to them
final int padding = treeItem != null && treeItem.getGraphic() == null ? 0 : 3;
x += disclosureWidth + padding;
w -= (leftMargin + disclosureWidth + padding);
layoutLabelInArea(x, y, w, h);
From what I can see, the disclosureVisible boolean is there as an indication of whether a disclosure node should be rendered or not but does not control whether space should be reserved for it or not. I think an additional check needs to be added that collapses the default 18 pixels to 0 pixels if disclosureNode == null.
I think the code should be rewritten as:
boolean disclosureVisible = treeItem != null && ! treeItem.isLeaf();
final double defaultDisclosureWidth = disclosureNode == null ? 0 : maxDisclosureWidthMap.containsKey(tree) ?
maxDisclosureWidthMap.get(tree) : 18; //RT-19656: default width of default disclosure node
double disclosureWidth = defaultDisclosureWidth;
if (disclosureVisible && disclosureNode != null) {
This also makes clear that there is a slight logic error inside the if block, where disclosureNode is tested against null twice -- however since this was already taken into account in the disclosureVisible boolean, those checks are redundant.
I'm also a bit worried about the 3 pixels of padding getting added when treeItem != null && treeItem.getGraphic() == null... when controlling the TreeCells precisely (especially when it is set to GRAPHIC_ONLY) I apparently still get 3 free pixels of padding.
This is despite the fact that the TreeCellSkin code determined that the node is not visible already:
boolean disclosureVisible = disclosureNode != null && treeItem != null && ! treeItem.isLeaf();
It will still calculate the disclosureWidth:
final double defaultDisclosureWidth = maxDisclosureWidthMap.containsKey(tree) ?
maxDisclosureWidthMap.get(tree) : 18; //
double disclosureWidth = defaultDisclosureWidth;
And then use it in its calculation of where to layout the label/graphic of the cell node:
// determine starting point of the graphic or cell node, and the
// remaining width available to them
final int padding = treeItem != null && treeItem.getGraphic() == null ? 0 : 3;
x += disclosureWidth + padding;
w -= (leftMargin + disclosureWidth + padding);
layoutLabelInArea(x, y, w, h);
From what I can see, the disclosureVisible boolean is there as an indication of whether a disclosure node should be rendered or not but does not control whether space should be reserved for it or not. I think an additional check needs to be added that collapses the default 18 pixels to 0 pixels if disclosureNode == null.
I think the code should be rewritten as:
boolean disclosureVisible = treeItem != null && ! treeItem.isLeaf();
final double defaultDisclosureWidth = disclosureNode == null ? 0 : maxDisclosureWidthMap.containsKey(tree) ?
maxDisclosureWidthMap.get(tree) : 18; //
double disclosureWidth = defaultDisclosureWidth;
if (disclosureVisible && disclosureNode != null) {
This also makes clear that there is a slight logic error inside the if block, where disclosureNode is tested against null twice -- however since this was already taken into account in the disclosureVisible boolean, those checks are redundant.
I'm also a bit worried about the 3 pixels of padding getting added when treeItem != null && treeItem.getGraphic() == null... when controlling the TreeCells precisely (especially when it is set to GRAPHIC_ONLY) I apparently still get 3 free pixels of padding.
- relates to
-
JDK-8180646 TreeView renders TreeCells with superfluous indentation if disclosure node is not visible or smaller than 18px in width
- Open