feat(scrollbar): initial implementation of scrollbars #849
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.
Describe your changes
Initial exploratory work for a scrollbar implementation.
scrollbar
component, which is similar to paginator, where you could just use it for logic, or for rendering.scrollbar
component itself only supports 1 direction, so for higher-level components, they would have 2 scrollbar components, 1 for horizontal and 1 for vertical.I've attempted to add scrollbars (just vertical) to textarea, however, the textarea component is kind of a mess when it comes to state tracking for scroll state due to it using viewport under the hood (and doing so in kind of a hacky way), I'd like to remove viewport altogether to simplify things a bit, however, I'd like to wait until #844 is merged. It isn't too difficult to wrap textarea in a scrollbar right now, however,
LineCount()
on textarea doesn't include virtual lines, so would have to exposeVirtualLineCount()
or similar to get accurate reporting. Could also just use viewports scrollbars, however, I still have to explore the implications of that, given how textarea <-> viewport interact is kind of odd.I've also explored creating a scrollbar container that wraps any generic model, however, using generics (to not obfuscate the model we're wrapping, so you can still call methods like normal) is challenging due to the mix of pointer and non-pointer methods on other models. I may still explore that if there is enough desire to make it easier to wrap models, rather than directly implementing sidebar logic in every single model.
Related issue/discussion
n/a
Examples & Screenshots
Most of the examples below will use viewport. Worth noting that I think the horizontal scrollbar usually doesn't look as nice due to how large the characters are and the space it takes up. So, with viewport, most users probably want soft wrapping + vertical (which it will automatically turn off horizontal bars when softwrap is enabled)
Viewport with slim bars for both X & Y:
Also automatically turns off scrollbars when not required (& doesn't use extra space):
Viewport with slim circles bar
Viewport with slim dotted bar
Viewport with dotted bar
Viewport with block bar
Viewport with ASCII bar
Wrapping a component in a custom scrollbar
Wrapping viewport, but not using viewports internal scrollbars. Uses soft wrapping, so just a vertical scrollbar is required.
code
Checklist before requesting a review
CONTRIBUTING.md
Reviewer Notes