On Tue, 25 Mar 2025 17:08:02 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> This PR will forward more Label calculations to LabeledSkinBase, as they are >> quite complex, especially when a Graphic is involved which is a full-fledged >> `Node`. More specifically, this solves issues with TitledPane when the >> graphic is resizable (ie. an HBox is placed as Graphic in the titled pane's >> title area). Before, the calculations would only look at the preferred size >> of the graphic, and use these regardless of available space, even if the >> maximum size allowed for the graphic to be larger. After this fix, the more >> extensive LabeledSkinBase calculations are used. >> >> This PR also simplifies the layout calculation. Instead of manually >> calculating where the label should be positioned (according to alignment), >> this is left to `layoutLabelInArea` which will do this automatically when >> its provided with the available space for the label instead of the label's >> width. >> >> See the ticket for a sample program; take a look at the graphic-only case >> where an HBox is used to put a label + gap + button as the graphic of the >> titled pane. > > modules/javafx.controls/src/main/java/javafx/scene/control/skin/TitledPaneSkin.java > line 160: > >> 158: registerChangeListener(titleRegion.alignmentProperty(), e -> >> pos = titleRegion.getAlignment()); >> 159: >> 160: // NOTE: Listening to two different alignment properties, and >> using the last value of either is likely a bug! > > I agree: it is definitely a bug. I think we should remove it along with the > possibility of specifying conflicting alignment via CSS. The control must be > in control. Yeah, the reason I was hesitant to change this is that currently you can set the alignment from CSS in two ways: .titled-pane { -fx-alignment: RIGHT; } Or: .titled-pane > .title { -fx-alignment: RIGHT; } Both will work at the moment. I'm not sure which one is more correct. A titled pane naturally has two major regions; its title area, and its content area. The top level alignment could apply to either or none in theory. The top level alignment setting is "inherited" from being a Labeled control, which only has a single alignment to worry about (this also shows using this kind of inheritance is just a bad idea). It would have been much more clear to have a `titleAlignment` and `contentAlignment` property. At the "top" level there is nothing to align, since a titled pane always fill its width. ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1742#discussion_r2014914945