On Sat, 29 Nov 2025 20:51:38 GMT, John Hendrikx <[email protected]> wrote:

>> This fixes a long standing bug with `GridPane` where unmanaged nodes would 
>> still result in gaps being added between rows/columns even though nothing is 
>> rendered there.  Take the following grid where dashes and pipes represent 
>> the vgaps and hgaps:
>> 
>> |            |0| |1|
>> |--------|---|---|---|
>> |0  |A|||B|
>> |    |-|||-|
>> |1  |C|||D|
>> |    |-|||-|
>> |2  |E|||F|
>> 
>> Now, when both C and D are set to unmanaged (and invisible) the grid will 
>> **still** render the gaps:
>> 
>> |            |0| |1|
>> |--------|---|---|---|
>> |0  |A|||B|
>> |    |-|||-|
>> |1  |||||
>> |    |-|||-|
>> |2  |E|||F|
>> 
>> Instead it should collapse the gap between row 0 and 2:
>> 
>> |            |0| |1|
>> |--------|---|---|---|
>> |0  |A|||B|
>> |    |-|||-|
>> |2  |E|||F|
>> 
>> There are at least two relevant issues in JBS:
>> - A request to let the user show and hide rows and columns: 
>> https://bugs.openjdk.org/browse/JDK-8136901
>>   - This can now be done by setting the relevant row/columns items to 
>> unmanaged without having to restructure the grid (assuming the complaint was 
>> that otherwise there'd be visible extra gaps for each hidden row)
>> - A request for another mode to skip gaps when entire rows/columns are 
>> unmanaged: https://bugs.openjdk.org/browse/JDK-8092379
>>   - This should not be a mode, but the standard, as unmanaged nodes should 
>> not affect the outcome of the grid layout
>> 
>> Screenshots
>> 
>> Simple application which can hide row 3:
>> 
>> <img width="443" height="491" alt="image" 
>> src="https://github.com/user-attachments/assets/0342dba3-cd1c-4d9e-9451-e9c8c628b2e2";
>>  />
>> 
>> Correct behavior when row 3 is hidden:
>> 
>> <img width="443" height="408" alt="image" 
>> src="https://github.com/user-attachments/assets/c7c54414-6a03-43e4-b733-21d0b251d729";
>>  />
>> 
>> Behavior before this fix (note the double gap **and** extra grid line):
>> 
>> <img width="443" height="453" alt="image" 
>> src="https://github.com/user-attachments/assets/f357e68a-e950-42e7-890b-91a78e194dd0";
>>  />
>
> John Hendrikx has refreshed the contents of this pull request, and previous 
> commits have been removed. The incremental views will show differences 
> compared to the previous content of the PR. The pull request contains one new 
> commit since the last revision:
> 
>   When all nodes starting in a row or column are unmanaged, skip gap

Looks good.

I've updated the standalone Monkey Tester to add a couple of layout scenarios 
to the GridPane page.

modules/javafx.graphics/src/main/java/javafx/scene/layout/GridPane.java line 
2635:

> 2633: 
> 2634:         private void setMaxSize(int position, double size) {
> 2635:             singleSizes[position] = Math.max(singleSizes[position], 
> size);

I don't know why github shows this as a change.
Unused `setMultiSize()` has been removed which is ok.

modules/javafx.graphics/src/main/java/javafx/scene/layout/GridPane.java line 
2640:

> 2638:         private Iterable<Entry<Interval, Double>> multiSizes() {
> 2639:             if (multiSizes == null) {
> 2640:                 return Collections.emptyList();

unrelated change, and probably gets inlined anyway.

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

Marked as reviewed by angorya (Reviewer).

PR Review: https://git.openjdk.org/jfx/pull/1990#pullrequestreview-3526569032
PR Review Comment: https://git.openjdk.org/jfx/pull/1990#discussion_r2578295713
PR Review Comment: https://git.openjdk.org/jfx/pull/1990#discussion_r2578297744

Reply via email to