VirtualizedFX icon indicating copy to clipboard operation
VirtualizedFX copied to clipboard

Wrong bar height/width calculation

Open UrosBajc opened this issue 1 year ago • 1 comments

Wanted Usage

I want to use VirtualFlow with VirtualScrollPane which can be scrolled only in one dimension (horizontally). That's why I want to hide the vertical scroll bar. I used the following code:

final VirtualScrollPane scrollPane = flow.wrap();
scrollPane.setVBarPolicy(ScrollPaneEnums.ScrollBarPolicy.NEVER);

The Problem

However, there's a problem - the horizontal scrollbar is not stretching the whole width, and there is an empty space on the right, as seen in the image below. image

The issue is with the following code which in this case subtracts vBarW from the hBarW (the problem is the same for the vertical scrollbar).

https://github.com/palexdev/VirtualizedFX/blob/83fe3ee84ea7b6587c1fa2dff1e95672955ef835/src/main/java/io/github/palexdev/virtualizedfx/controls/skins/VirtualScrollPaneSkin.java#L526-L534

Proposed Solution

I think the subtraction should not be done every time we use LayoutMode.DEFAULT mode and should also only be done when scrollbar is visible. So if I am not missing something I think it should be done like this:

if (hBarPolicy != ScrollBarPolicy.NEVER && hBar.isVisible())
	vBarH -= hBarH;

if (vBarPolicy != ScrollBarPolicy.NEVER && vBar.isVisible())
	hBarW -= vBarW;

UrosBajc avatar Jan 10 '24 12:01 UrosBajc

Nice catch, I'll investigate asap

palexdev avatar Jan 10 '24 13:01 palexdev

Fixed on the new version, sorry it took so long, I wanted to full focus on the rewrite

palexdev avatar May 28 '24 15:05 palexdev