On Wed, 23 Sep 2020 10:26:12 GMT, Jose Pereda <jper...@openjdk.org> wrote:
>> This PR fixes an issue that happens when adding new items to a `TableView` >> or any other control that uses >> `VirtualFlow`, if the scroll position is not 0: the virtual flow is slightly >> shifted down. >> For instance, let's say that a cell has a layoutY of -10.0. After adding a >> new item to the table, during the layout >> pass the new value is initially modified to -9.999999999999996 >> (`VirtualFlow::adjustByPixelAmount`) , and then, after >> calling `VirtualFlow::positionCell` (that uses `snapSizeY(position)`) the >> layoutY is modified to -9.5, causing an >> undesired positive shift of 0.5 pixels. `Region` has different snap >> methods: `snapSizeX/Y` are used to snap node >> dimension values, like width or height, by ceiling to the nearest pixel >> (which explains the -9.5 value), while >> `snapSpaceX/Y` are used to snap position values like insets, by rounding to >> the nearest pixel (this will give the >> expected -10.0). Therefore, this PR modifies `VirtualFlow::positionCell` >> to use the `snapSpaceX/Y` methods, since >> these are being used to set the layout of the cell and not its size. Test: >> A unity test has been included. It >> simulates the case of adding new items to the virtual flow after an initial >> scroll. It currently fails after adding a >> few items, and it passes with the changes of this PR. > > Jose Pereda has updated the pull request with a new target base due to a > merge or a rebase. The pull request now > contains three commits: > - Merge master > - Add test to verify the cell position remains constant when new cells are > added to the virtualFlow. > - Use correct snap method to set cell layout Marked as reviewed by aghaisas (Reviewer). ------------- PR: https://git.openjdk.java.net/jfx/pull/297