Fix scrollbar wrongly displayed bug #487
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes these scrollbar bugs
Change 1
Resets scroll_top to zero if
dialog.pointer == nil
. It will be nil whendialog_render_info.contents
changed.Originally, reset is done at
dialog.scroll_top = dialog.contents.size - height
that I deleted in change2.Change 2
The original code unintentionally resets dialog.scroll_top to zero because
dialog.contents.size - height
is always zero.This will wrongly calculates scroll_top when
scroll_top >= height
.I think the purpose of the original code is to satisfy the condition
0 <= scroll_top and scroll_top + height <= dialog_render_info.contents.size
when the content shrinks.After I add
dialog.scroll_top = 0
in change1, the condition seems to be always satisfied.Change 3
+ bar_height = 1 if bar_height.zero?
If the dialog content is too long, calculated bar_height will be zero.
Since most scrollbar in GUI apps has a minimum hight, I set the minimum hight to 1.
Change 4
The condition I deleted is for optimization to skip re-rendering scrollbar.
When pointer moved or dialog contents changed, scrollbar needs to be re-rendered. This is almost always, so I deleted the optimization condition.