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(LineGauge): allow LineGauge background styles #565

Merged
merged 3 commits into from
May 24, 2024

Conversation

nowNick
Copy link
Contributor

@nowNick nowNick commented Oct 6, 2023

Description

LineGauge can be styled with regard to the line itself. There was no option to style the background behind the line. There was a community issue request to add such a feature.

This PR deprecates gauge_style in favor of filled_style and unfilled_style which can have it's foreground and background styled.

Demo

cargo run --example=line_gauge --features=crossterm

Demo

line_gauge_demo.mov

Issue link

Implements ratatui-org#424

src/widgets/gauge.rs Outdated Show resolved Hide resolved
src/widgets/gauge.rs Outdated Show resolved Hide resolved
@Fabus1184
Copy link

Very nice, I too think the name gauge_background_style is still confusing because of the word "background" which does not clearly indicate that this refers to the "unfilled" area of the gauge, it would be better to have LineGauge::filled_style and LineGauge::unfilled_style or some similar term. IMO because of compatibility LineGauge::gauge_style can be left and just sets the Style::fg field of the LineGauge::filled_style and the Style::bg field of the LineGauge::unfilled_style so it won't alter the behavior.

@nowNick
Copy link
Contributor Author

nowNick commented Oct 9, 2023

Oh I like that! We can mark LineGauge::gauge_style as deprecated and introduce LineGauge::filled_style and LineGauge::unfilled_style with proper fg and bg. Then in future we can remove LineGauge::gauge_style

@nowNick nowNick force-pushed the feat/line-gauge-background-styles branch from 329a487 to ff3a293 Compare November 3, 2023 15:39
@nowNick nowNick marked this pull request as draft November 3, 2023 16:22
@TieWay59
Copy link
Contributor

TieWay59 commented Dec 8, 2023

LineGauge::filled_style is neat. I'm always confused by the bg/fg somehow, I favor this wording.

And saw your screenshot above, it's great. Hope the new API design did not slow you down, it is always hard to give backward compatibility.

@joshka
Copy link
Member

joshka commented Dec 17, 2023

Another +1 to filled / unfilled from me.

The remaining tasks on this are something like:

  • Fix the end of line spacing in doc comments (replace with multiple new lines to break the paragraphs)
  • Update to use filled_style and unfilled_style
  • Mark gauge style as deprecated with a message to use filled and unfilled
  • Write / update tests
  • Create a small demo and VHS tape file

@nowNick nowNick force-pushed the feat/line-gauge-background-styles branch from ff3a293 to 38635d1 Compare February 2, 2024 16:01
Copy link

github-actions bot commented Feb 2, 2024

Thank you for opening this pull request!

We require commits to be signed and it looks like this PR contains unsigned commits.

Get help in the CONTRIBUTING.md
or on Github doc.

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.3%. Comparing base (257db62) to head (33d8c40).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #565   +/-   ##
=====================================
  Coverage   94.3%   94.3%           
=====================================
  Files         61      61           
  Lines      14767   14777   +10     
=====================================
+ Hits       13926   13937   +11     
+ Misses       841     840    -1     

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

@nowNick nowNick force-pushed the feat/line-gauge-background-styles branch 3 times, most recently from af6f43b to eb1fd2c Compare March 2, 2024 11:25
@nowNick nowNick force-pushed the feat/line-gauge-background-styles branch from eb1fd2c to e28be44 Compare March 2, 2024 11:47
@nowNick nowNick marked this pull request as ready for review March 2, 2024 12:06
@nowNick
Copy link
Contributor Author

nowNick commented Mar 2, 2024

Hey all! :)

It took me some time but finally I got around to wrapping everything up. I tried to check all of the boxes on the todo list you provided @joshka

[x] Fix the end of line spacing in doc comments (replace with multiple new lines to break the paragraphs)
[x] Update to use filled_style and unfilled_style
[x] Mark gauge style as deprecated with a message to use filled and unfilled
[x] Write / update tests
[x] Create a small demo and VHS tape file


I'm not 100% if vhs demo will be recorded on the main branch in the repository itself or should I do it from my computer and somehow upload it?
Also I couldn't quite run the vhs tape file according to the instructions in the comments.
They all say something like:

# To run this script, install vhs and run `vhs ./examples/paragraph.tape`

and I don't think that the path is quite right. Shouldn't it be vhs ./examples/vhs/paragraph.tape ?

src/widgets/gauge.rs Outdated Show resolved Hide resolved
examples/README.md Show resolved Hide resolved
examples/README.md Show resolved Hide resolved
@joshka
Copy link
Member

joshka commented May 24, 2024

ugh - Figured I'd try hitting the "Sync Changes" button in VSCode to let it push things - that was a mistake! What a useless button.

@joshka joshka force-pushed the feat/line-gauge-background-styles branch from 70a4db6 to 7815c5d Compare May 24, 2024 18:24
nowNick and others added 2 commits May 24, 2024 11:28
LineGauge can be styled with regard to the line itself.
There was no option to style the background behind the line.
This commit adds this feature by adding two fields:
filled_style and unfilled style. The filled style has an
ability to define foreground color (the line itself) as well
background color (the background behind the filled line).
unfilled_style works accordingly.
gauge_style was left intact to maintain backwards compatiblity

Implements ratatui-org#424
@joshka joshka force-pushed the feat/line-gauge-background-styles branch from 7815c5d to 7be7dc8 Compare May 24, 2024 18:28
@joshka joshka merged commit eef1afe into ratatui:main May 24, 2024
33 checks passed
@nowNick
Copy link
Contributor Author

nowNick commented Jun 10, 2024

So happy it got merged! 🎉
Thanks for everybody's help! Especially @joshka for pushing it over the last hump 🙇

@nowNick nowNick deleted the feat/line-gauge-background-styles branch June 10, 2024 09:58
orhun added a commit that referenced this pull request Jun 24, 2024
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.

6 participants