On Mon, 7 Sep 2020 17:54:31 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. This pull request has now been integrated. Changeset: 205e4b95 Author: Jose Pereda <jper...@openjdk.org> URL: https://git.openjdk.java.net/jfx/commit/205e4b95 Stats: 24 lines in 2 files changed: 22 ins; 0 del; 2 mod 8178297: TableView scrolls slightly when adding new elements Reviewed-by: kcr, aghaisas ------------- PR: https://git.openjdk.java.net/jfx/pull/297