JDK-8117641 : [CheckBox, RadioButton] Layout regression (was: Text Overrun incorrect work in CheckBox and RadioButton)
Type:Bug
Component:javafx
Sub-Component:controls
Affected Version:8
Priority:P3
Status:Closed
Resolution:Fixed
Submitted:2012-09-12
Updated:2015-06-17
Resolved:2013-08-29
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
I see that now and will investigate. Let's not reopen this again. Can you file a new issue?
05-09-2013
at least some of them (simple ellipsis for instance - 2nd row of controls) have possibility to have more characters before ellipsis using.. it looks like a trouble of different size options : LayoutSize single_line_layout = new LayoutSize(150, 20, 115, 20, 115, 20);
05-09-2013
Do you mean all of them have too much space on the right? Some of the truncated ones just didn't have room for another character, but others look good to me.
05-09-2013
Question on the fix: why is there so much left space on the right side inside the labeled control, between the right end of the text, and the right side of the control?
Patch appears to work well, and I can't see any obvious regressions. Leif - were you intending to push this?
29-08-2013
Attached proposed patch.
29-08-2013
The previous fix was undone by the fix for RT-29739, which added the width of the check/radio mark to the minimum width.
As I explained earlier, the "Labeled" part of the skin needs its own minWidth calculation. I will need to separate out that with a new private method in LabeledSkinBase, like computeLabeledPartMinWidth().
29-08-2013
I don't think it was the fix for RT-29641 because LabeledSkinBase.computeMinWidth() doesn't call super. It has to think for itself. :)
29-08-2013
Perhaps this is due to:
Changeset: 3345 (09430770080f) RT-29641: Regression : size issue with many controls
User: jgiles
Date: 2013-04-23 11:24:49 +1200 (4 months)
29-08-2013
Did I mention that this is unbelievably complex, and that the previous fix was prone to new bugs going forward?
Changeset: http://hg.openjdk.java.net/openjfx/8/controls/rt/rev/43d9c4d3f5b4
Changed the calls to compute the label minWidth and minHeight per above. We will probably revisit the need to make the Label a separate node.
18-09-2012
This is unbelievably complex, so bear with me.
Once upon a time (early builds of 2.0) we had CheckBoxSkin and RadioButtonSkin simply contain a Label, which managed its own layout constraints for the text and graphic parts (not including the check/radio node). The CSS was simple too, as the Label part could have its own padding, etc. There was order in the universe.
Then we had RT-15076 which made the skins extend LabeledSkinBase instead of containing a Label. We introduced the method LabeledSkinBase.layoutLabelInArea() as well as the new CSS property -fx-label-padding. This was a bit of a kludge, but worked fine. The skin was still a separate node (StackPane) and had its own minWidth() separate from that of the control node. The method layoutLabelInArea() called updateDisplayedText(w, h), which called minWidth(), which in turn called LabeledSkinBase.computeMinWidth() to deal with the text/graphic parts only.
Now, with the fix for RT-23459, the skin is no longer a node and updateDisplayedText() has been changed to call getSkinnable().minWidth(). This fails for CheckBoxSkin/RadioButtonSkin, because their computeMinWidth() methods include the width of the check/radio node.
One way to solve this would be to go back to having CheckBoxSkin/RadioButtonSkin contain a Label again. It would add a node for these two controls, but would simplify the code (and the understanding of the code) immensely. We would then deprecate the -fx-label-padding property while still honoring it if set.
Otherwise, we have to do something like the following patch. It preserves the node hierarchy, but loses the benefit of caching of the minWidth value and is probably more prone to new bugs going forward.
diff -r e76f959dbc62 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 Fri Sep 14 10:20:59 2012 -0700
+++ b/javafx-ui-controls/src/com/sun/javafx/scene/control/skin/LabeledSkinBase.java Fri Sep 14 12:15:03 2012 -0700
@@ -467,7 +467,7 @@
if (w == -1) {
w = availableWidth;
}
- double minW = Math.min(getSkinnable().minWidth(-1), availableWidth);
+ double minW = Math.min(computeMinWidth(-1), availableWidth);
if (horizontalPosition && !isIgnoreGraphic()) {
double graphicW = (labeled.getGraphic().getLayoutBounds().getWidth() + labeled.getGraphicTextGap());
w -= graphicW;
@@ -486,7 +486,7 @@
if (h == -1) {
h = availableHeight;
}
- double minH = Math.min(getSkinnable().minHeight(w), availableHeight);
+ double minH = Math.min(computeMinHeight(w), availableHeight);
if (verticalPosition && labeled.getGraphic() != null) {
double graphicH = labeled.getGraphic().getLayoutBounds().getHeight() + labeled.getGraphicTextGap();
h -= graphicH;
14-09-2012
This is not a bug in the overrun code, but a regression caused by fix for RT-23459 where the minWidth for the whole CheckBox/RadioButton now wins over the smaller width that is passed to LabeledSkinBase.layoutLabelInArea().