Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #74, by forcing scroll views to scroll up until items are visible. #126

Merged
merged 2 commits into from
May 11, 2024

Conversation

DaleStan
Copy link
Collaborator

This fixes at least the object explorer (SelectObjectPanels) and the production sheet list (MainScreen.allPages), and doesn't visibly affect the production tables.

…visible.

This fixes at least the object explorer (SelectObjectPanels) and the production sheet list (MainScreen.allPages), and doesn't visibly affect the production tables.
@shpaass
Copy link
Owner

shpaass commented May 11, 2024

Thank you for the fix! I tested it, and it works.

Could you please document the purpose of the fields firstVisibleBlock and bufferRows? They are not as easy to understand as the other ones.

Since the class structure of the GUI is complicated, I would also appreciate a comment here about which call of BuildContents() this PR fixes.

@shpaass shpaass merged commit e1ca158 into shpaass:master May 11, 2024
1 check passed
@DaleStan
Copy link
Collaborator Author

The call is guiBuilder(this) at ImGuiBuilding.cs:173. The fixed delegate that's called there is created by contents = new ImGui(BuildContents, padding, clip: true); in the ScrollAreaBase constructor, when constructing a VirtualScrollList<> or one of its derived classes.

If you're asking how I found that code to fix, I started by discovering that maxScroll had the old value in scroll2d, and then that maxScroll wasn't being updated because MeasureContent was returning the old value. That was because contentSize was wrong, because lastContentRect was wrong. I think that got me close enough to DoGui and guiBuilder(this) so I could step into them and decide that it didn't make sense to have firstRow >= rowCount. (There were, of course, a lot of wrong turns too.)

@shpaass
Copy link
Owner

shpaass commented May 11, 2024

Thank you so much for the walkthrough!

@DaleStan DaleStan deleted the fix-74 branch May 12, 2024 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants