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

feat(tui-scrollview): add scrollbars visibility handling #45

Merged
merged 3 commits into from
Nov 23, 2024

Conversation

ulissesf
Copy link
Contributor

Add ScrollbarVisibility enum with Automatic (default), Always, and Never variants. Also add fluent setter methods horizontal_scrollbar_visibility(), vertical_scrollbar_visibility() and scrollbars_visibility() to ScrollView.

let mut sv_no_vert = ScrollView::new(Size::new(20, 20))
    .vertical_scrollbar_visibility(ScrollbarVisibility::Never);

let mut sv_allways_bars = ScrollView::new(Size::new(50, 80))
    .scrollbars_visibility(ScrollbarVisibility::Always);

Add `ScrollbarVisibility` enum with `Automatic` (default), `Always`,
and `Never` variants. Also add fluent setter methods
`horizontal_scrollbar_visibility()`, `vertical_scrollbar_visibility()`
and `scrollbars_visibility()` to `ScrollView`.

```rust
let mut sv_no_vert = ScrollView::new(Size::new(20, 20))
    .vertical_scrollbar_visibility(ScrollbarVisibility::Never);

let mut sv_allways_bars = ScrollView::new(Size::new(50, 80))
    .scrollbars_visibility(ScrollbarVisibility::Always);
```
@codecov-commenter
Copy link

codecov-commenter commented Nov 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 73 lines in your changes missing coverage. Please review.

Project coverage is 0.00%. Comparing base (e65caad) to head (e425956).

Files with missing lines Patch % Lines
tui-scrollview/src/scroll_view.rs 0.00% 73 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main     #45   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files          2       2           
  Lines        150     190   +40     
=====================================
- Misses       150     190   +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@ulissesf
Copy link
Contributor Author

@joshka Tell which part of the format checks you'd want solved. It's complaining about the tests too, but I followed the format already there in the other ones.

As for the scrollbars rendering, I kept returning the remaining area from render_scrollbars() as it does take up space and it still seemed a good approach. The code still assumes we have vertical scrollbar on the right and horizontal at the bottom (as it was before). I could add setters for that in a follow-up PR and then likely rendering_scrollbars() will need to return more information or maybe already the visible area from the scrollview's buffer and where to render it.

@joshka
Copy link
Owner

joshka commented Nov 23, 2024

I tweaked this for a bunch of nitpicks that are fairly opinionated preferences rather than problems with the code. It would have been annoying to communicate these, so easier to just do them:

  • function ordering (caller then callee)
  • changed SBV to just V
  • changes the naming a bit
  • removed the Info struct and put the vars in the main struct.
  • use less abbreviations
  • changed _fit to _space as it made more sense what this was describing
  • simplified the big else-if block

@joshka joshka merged commit 5c66f3e into joshka:main Nov 23, 2024
11 checks passed
@joshka
Copy link
Owner

joshka commented Nov 23, 2024

Thanks for the PR on this. I'll release it in a bit.

@github-actions github-actions bot mentioned this pull request Nov 23, 2024
@ulissesf
Copy link
Contributor Author

ulissesf commented Nov 23, 2024

I tweaked this for a bunch of nitpicks that are fairly opinionated preferences rather than problems with the code. It would have been annoying to communicate these, so easier to just do them:

  • function ordering (caller then callee)
  • changed SBV to just V
  • changes the naming a bit
  • removed the Info struct and put the vars in the main struct.
  • use less abbreviations
  • changed _fit to _space as it made more sense what this was describing
  • simplified the big else-if block

Thanks. Yes, it'd indeed take some more time than just doing it. You making the changes still helps me learn how you like things in case I send another PR, I appreciate it.

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