RFR: 8295078: TextField blurry when inside an TitledPane -> AnchorPane [v4]

John Hendrikx jhendrikx at openjdk.org
Fri May 12 07:51:58 UTC 2023


On Fri, 12 May 2023 07:44:04 GMT, John Hendrikx <jhendrikx at openjdk.org> wrote:

>> I wonder.
>> 
>> This might be a contrived example: what would happen if the parent containing the TitledPane is unsnapped, but TitledPane is?
>> In this case getWidth() may not be snapped since the titled pane has been laid out by an unsnapped parent.
>
> I think once there is an unsnapped parent, all children should probably also be unsnapped (ie. the property should work like the visible property; if I turn it off for one parent, all children become invisible/unsnapped).
> 
> There would otherwise be little point in setting a parent to unsnapped if one didn't also turn off snapping on all the children.
> 
> Note that we tested what happens when you put snapped content in an unsnapped container; currently this results in all children to be misaligned (not pixel aligned). I think that's the only real solution, as trying to resnap your positions when your parent container is misaligning you would otherwise need to introduce some kind of flexible border that "absorbs" some of the misalignment so the rest of the content can be snapped again...
> 
> Basically, there are three strategies for children when dealing with an unsnapped parent:
> 
> - Just do snapping as normal (JavaFX currently) and when the parent translation is added, all final positions will be shifted by an unsnapped amount resulting in all calculations (even though they used snapping logic) to be in the "wrong" positions
> - Ignore snapping when a parent is unsnapped and use standard calculations
> - Somehow try to resnap content taking the parent misalignment into account; this is going to cause visual artifacts as the parent is moved, and requires some kind of flexible border

> In this case getWidth() may not be snapped since the titled pane has been laid out by an unsnapped parent.

And when that happens, you can't do anything about it either.  If you adjust the width, you risk not covering the entire area that the parent gave you (or more if you round up), and if you use it in any calculations you need to resnap any values resulting from it, and you would still end up with some dead space that your snapped calculations can't cover...

The only real solution seems to be to treat snapping like visibility IMHO.

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

PR Review Comment: https://git.openjdk.org/jfx/pull/910#discussion_r1192030858


More information about the openjfx-dev mailing list