Alexey-T / CudaText

Cross-platform text editor, written in Free Pascal
Mozilla Public License 2.0
2.47k stars 171 forks source link

Viewer: scrollbar thumb has wrong size and position #5598

Closed pintassilgo closed 2 months ago

pintassilgo commented 2 months ago

At least on KDE Plasma (or Cuda Qt5).

  1. If you open a file whose content has scrollable content, scrollbar thumb is displayed in its minimal size, what should only happen when document is long.

  2. Using the same small, but scrollable file in Viewer, scrolling all the way down should have scrollbar thumb at the bottom, but this doesn't happen. Example:

image

The percentage in status is also wrong. It means the relative position of current view in the whole document, right? It should display 100% in the screenshot, not 6%, because there's no way to scroll down more.

Just for comparison, this is the proper scrollbar thumb and position when I open the same file in normal editor:

image

Alexey-T commented 2 months ago

improved it now. it is not ideal correct pos, but now it shows 100% when scrolled to end. I have limitation: max int for OS scrollbar lazarus API is MaxShort (16bit), so for big files result is not ok.

Alexey-T commented 2 months ago

thumb size is not fixed yet.

beta cudatext.xz.zip

pintassilgo commented 2 months ago

Thanks, but this new version seems worse.

Now it's simply impossible for the thumb to be at the top. Look, I'm at the top of the document:

image

There should be no gap above thumb, since first visible line is 1st line of the file.

This happens the same in giant files, for which there was no such issue. The only issue for big file still remain: when I scroll to the bottom of the file, status still shows 99%, not 100%.

pintassilgo commented 2 months ago

In summary: new version fixed status percentage for small file, but for the other cases or issues it's now worse or still not fixed.

Alexey-T commented 2 months ago

reverted v-scrollbar pos. (percent display is kept).

Alexey-T commented 2 months ago

thumb size cannot be fixed IN TEXT (+UNICODE) mode. because in these modes, 'page size' depends on scroll pos, it is number of chars on visible area, it changes on scroll. but can we change thumb size on scroll? no. it is bad UI.

viewer don't have 'number of visible lines' + 'total lines' calculation (for small files: yes, for big: no).

pintassilgo commented 2 months ago

viewer don't have 'number of visible lines' + 'total lines' calculation (for small files: yes, for big: no).

Well, for big files thumb size can be the minimum as it already is. For big file, big scrollable area, small thumb, it's correct. If you think you can fix thumb size for small files, it would probably fix everything related to thumb size.

Alexey-T commented 2 months ago

I don't have idea how to calculate (easily) the 'total lines' and 'current visible lines', so no, cannot fix it. let's decline this fix.

pintassilgo commented 2 months ago

OK, thumb size is not important. But thumb position I believe it is. Do you think it's fixable? If I'm seeing first line, thumb should be touching the top limit of scrollbar. If I'm seeing last line, thumb should be touching the bottom limit of scrollbar.

pintassilgo commented 2 months ago

And it would be good if status can display 100% if I can't scroll down i.e. last line is visible.

Alexey-T commented 2 months ago

If I'm seeing first line, thumb should be touching the top limit of scrollbar.

now it works.

cudatext.xz.zip

If I'm seeing last line, thumb should be touching the bottom limit of scrollbar.

this will be auto OK if I fix the 'page size of scrollbar' but I won't change it - 'page size' means 'count of chars in visible area' so pagesize will change on scrolling - bad ui. so won't fix.

pintassilgo commented 2 months ago

Thanks.

What if you make thumb position to follow status percentage? With the single exception of when first line is visible.

So if percentage is 50%, thumb will be at the center of scrollbar. If percentage is 100%, thumb will be at the bottom.

I guess this would be a better UI compared to current (look at the first image of this issue, thumb is near the top but I can't scroll down, last line is visible).

Edit: with last beta, now status shows 100% when I see the last line of the giant file, which is correct. Thanks. So I just stand with my suggestion above and I think we're done.

Alexey-T commented 2 months ago

this will lead to:

pintassilgo commented 2 months ago

Yes, what you described is caused by the first reported issue here, the bad size of the thumb, hard to fix as you said.

I think this needing to do big drag to scroll in small file with only a couple of scrollable lines is better than current incomprehensible case of thumb being at the top with giant gap below it while document is already fully scrolled, with last line visible.

Needing to drag to the bottom of scrollbar to see last lines of the document at least makes sense for everyone. The giant gap below the thumb when there's nothing more to scroll down, doesn't.

But if you're sure of your decision, I think you can close this one as wontfix.

Alexey-T commented 2 months ago

i don't like the idea - show thumb on top for scroll=0, and show thumb for bottom-pos for scroll != 0. it makes thumb jump on scroll, as i said.

it also makes code heavier.