On Wed, 5 Aug 2026 20:32:53 GMT, Andy Goryachev <[email protected]> wrote:

>> I think it is a bug; other containers (including the "big" ones like 
>> HBox/VBox) do snap these.
>> 
>> I think it would lead to subtle issue when mixing snapped/unsnapped content 
>> as well: for an unsnapped container, you can provide unsnapped sizes, but a 
>> snapped one should include the space it needs to do correct snapping (and 
>> not rely on the parent container to also be snapped which is why this 
>> problem is hidden usually now).
>> 
>> So if a `StackPane` has a child of 50 pixels wide, and insets of 0.6 then 
>> `minWidth(-1)` should return:
>> - 0.6 + 50 + 0.6 = 51.2 (unsnapped)
>> - 1 + 50 + 1 = 52.0 (snapped)
>> 
>> When placed inside a snapped container, both will `ceil()` to 52, but if 
>> `StackPane` is snapped and its container isn't, it would get only 51.2 
>> pixels assigned to it, but it will still try to place things at pixel 
>> offsets, meaning 0.8 pixels of space (or border decoration) would get 
>> clipped.
>> 
>> Also I think that if you use a `StackPane` as root for a `Scene` (quite 
>> common) which doesn't do snapping of its own, and give it insets (not  
>> uncommon) you may find that the `Window` is one pixel too small (in either 
>> or both directions). Usually this is unnoticable as it just crops one pixel 
>> of empty space, but it could show up as a subtle difference between the 
>> left/top and right/bottom spacing.
>
> makes sense.  
> 
> so the rule should be - if the value comes from a property it can (and 
> should) not be snapped (because set == get == property.get), but if there is 
> one or more entities involved then we better snap each constituent.

Yeah, the user can set whatever value they want. So if they spacing to `0.7` or 
`Insets` to some non-aligned values, that should be returned as well. 

In calculations though they need to follow the snapping rules (snapSpace in 
this case). Some containers will even cache these values (in a separate field, 
not the property) to avoid snapping each time, or calculate them once at the 
start of `layoutChildren`.

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/2241#discussion_r3723898238

Reply via email to