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 horizontal scrollbar #161

Merged
merged 8 commits into from
Jun 19, 2024
Merged

Conversation

veger
Copy link
Collaborator

@veger veger commented Jun 17, 2024

I figured out that clicking the horizontal scrollbar was not possible because the 'click test' area did not match the actual drawn rectangle. This got fixed by d9f8151.

In order to figure this out, I did some major documenting/cleanup to get an understanding of what Scrollable class was (intending) to do.

I hope that all new variable/field names make more sense now, if not let me know and we can figure out how to further improve them.

While I was at it I found some other 'oddities' that I fixed/improved:

I assume it would be easiest to review ecah commit separately, as the cleanup shuffled/renames quite come code. Which is much more apparent when reviewing the separate commits.

@veger veger requested review from DaleStan and shpaass June 17, 2024 15:40
Yafc.UI/ImGui/ScrollArea.cs Outdated Show resolved Hide resolved
Now they actually reflect what they are about
* Get rid of misleading height property
  (a visible area height is needed instead)
* MeasureContent only uses width, so replace Rect param
* Rename Scrollbar Rects to make their purpose more clear
* Document code blocks to clarify a little better what happens
rect.Heigth does not need the correction for the ScrollbarSize when not
building. It does not have the correction when it is building. So with
this fix both the building and not building states use the same
rect.Height.
Possible since last fix
The height of the horizontal scrollbar is already taken care of by
Scrollable. So it sohuld not be part of the height calculation.

The calculation got messed up, when ScrollbarSize != 1 indicating the
old calculations were wrong already.
It does not 'de-highlight' and it was only active for the Summary view
(making it more consistent with the rest of YAFC)
@veger veger marked this pull request as ready for review June 18, 2024 22:12
@DaleStan
Copy link
Collaborator

DaleStan commented Jun 19, 2024

I'm still seeing a .5f vertical offset in the hit testing for both scrollbars. Is that just a me thing?

Good work on all the documentation and renaming

@veger
Copy link
Collaborator Author

veger commented Jun 19, 2024

I cannot reproduce the .5f offset. I tried with both a 1f and a 4f scrollbar sizes, and with either size clicks that are just outside of the 'scroller' are not registered and you cannot drag it.

I see only two (visual) glitches:

  1. Sometimes the scrollbars are drawn in the wrong place, triggering a UI (re)build (by clicking something for example) puts the bars to the correct places. I think it is because the UI contents is repositioned by the Scrollable cause the scrollarea dimensions to change. A followup rebuild uses the new dimensions, causing the bars to move to the correct places. (Fixing this would mean a complete overhaul of the UI system, as there is no way to find the bottom (height)/right (width) of the 'left over' area where the scrollable component needs to be placed. (The UI is 'fluid' and is build from the top/left)
  2. The vertical scrollbar is one ScrollbarSize from the window border. This is because the MainScreen is also has a scrollable (vertical only) for pages/tabs whose content does not fit. The UI system reserves this space for a scrollbar, even if it is hidden.

@DaleStan DaleStan dismissed their stale review June 19, 2024 21:22

Veger can't reproduce issue I'm seeing, and it's minor.

Copy link
Collaborator

@DaleStan DaleStan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I can't explain where the 0.5f vertical offset issue comes from, and veger can't reproduce it, so I'm going to ignore it.

@DaleStan DaleStan merged commit 3889a6a into shpaass:master Jun 19, 2024
1 check passed
@veger veger deleted the fix-horizontal-scrollbar branch June 19, 2024 21:45
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.

3 participants