CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.66k stars 4.18k forks source link

Scroll bars display incorrectly #54285

Open J-Fields opened 2 years ago

J-Fields commented 2 years ago

Describe the bug

Scroll bars are just broken - they don't correctly convey the information they're supposed to.

Steps to reproduce

Easiest way to repro is to spawn in, go to crafting > food and hit j. At least with my screen dimensions, the scrollbar moves but the list doesn't scroll. Thus it looks like there are items hidden above the first listed item, but there aren't.

Expected behavior

A scrollbar should:

Screenshots

image

Versions and configuration

Latest experimental, but this isn't a new bug

Additional context

I've got a branch fixing this that just needs a bit of polish & testing, so feel free to assign me

PatrikLundell commented 2 years ago

Are you sure the scroll bars are broken, rather than inappropriately applied (the first being a problem with the scrollbar functionality itself, while the latter is a problem local to individual usages, such as the crafting menu)?

If I remember correctly, I had that issue with one menu where the scroll bar checks were against the size of the window, rather than the size of the area allocated to entries (i.e. the "hidden items" in you case could be the header part). In my case the logic also checked against the number of items in the list to be displayed, rather than the number of lines required (some entries required multiple lines), compounding the issue.

J-Fields commented 2 years ago

Based on my reading of the code yesterday, I'm pretty sure the implementation is simply wrong, but later today I'll take another look and put a PR up which we can discuss.

J-Fields commented 2 years ago

If I remember correctly, I had that issue with one menu where the scroll bar checks were against the size of the window, rather than the size of the area allocated to entries

Finally got back to this and looks like you're right (or something very similar, at least). draw_scrollbar expects to be given how fat it should be scrolled, but some usages give the currently selected index.