Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@mat007
Copy link
Contributor

@mat007 mat007 commented Aug 20, 2023

This pull requests adds two features to the progress bar:

  • vertical progress bars with widget.ProgressBarOpts.Direction(widget.DirectionVertical), the default being horizontal
  • inverted progress bars with widget.ProgressBarOpts.Inverted(true), the default being obviously not inverted

As you can guess I had a need for a vertical progress bar filling from bottom to top 😄

I’m happy to add anything to the examples if deemed needed, or to try to come up with a progressbar_test.go file, even!

Comment on lines +74 to +82
func (o ProgressBarOptions) Inverted(inverted bool) ProgressBarOpt {
return func(s *ProgressBar) {
s.inverted = inverted
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just noticed some other somewhat similar functions in the library that do not take an argument, e.g.

func (o DragAndDropOptions) DisableDrag() DragAndDropOpt {
	return func(t *DragAndDrop) {
		t.dragDisabled = true
	}
}

Maybe this would be better if it were similar, i.e.

Suggested change
func (o ProgressBarOptions) Inverted(inverted bool) ProgressBarOpt {
return func(s *ProgressBar) {
s.inverted = inverted
}
}
func (o ProgressBarOptions) Invert() ProgressBarOpt {
return func(s *ProgressBar) {
s.inverted = true
}
}

?

Copy link
Collaborator

Choose a reason for hiding this comment

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

We have examples of both in the codebase. I prefer the way you currently have it. There are times when its cleaner to pass a variable in rather than call the method or not.

@mat007 mat007 force-pushed the progress-bar-direction branch from 8e9ae74 to 34b52b5 Compare August 23, 2023 06:45
@CLAassistant
Copy link

CLAassistant commented Aug 23, 2023

CLA assistant check
All committers have signed the CLA.

@mat007 mat007 force-pushed the progress-bar-direction branch from 34b52b5 to 353e56c Compare August 23, 2023 06:48
Copy link
Collaborator

@mcarpenter622 mcarpenter622 left a comment

Choose a reason for hiding this comment

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

Overall this looks great! I have one minor request. Could you update the progressbar example to show a vertical progressbar as well? and possibly add some comments to describe the two new functions.

Comment on lines +74 to +82
func (o ProgressBarOptions) Inverted(inverted bool) ProgressBarOpt {
return func(s *ProgressBar) {
s.inverted = inverted
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have examples of both in the codebase. I prefer the way you currently have it. There are times when its cleaner to pass a variable in rather than call the method or not.

@mat007 mat007 force-pushed the progress-bar-direction branch from 353e56c to 8fa41d6 Compare August 24, 2023 05:41
@mat007
Copy link
Contributor Author

mat007 commented Aug 24, 2023

Could you update the progressbar example to show a vertical progressbar as well? and possibly add some comments to describe the two new functions.

Done, both!

For the example, feel free to suggest some simpler way to lace up the containers, as I had to add one to center the progress bars somewhat.

image

Also I ended up changing most of the comments (my IDE keeps adding a space on the right of the comment start //, because it says «it’s the Go way» 🤷). I can revert these if you want!

@mat007 mat007 requested a review from mcarpenter622 August 24, 2023 05:46
@mcarpenter622
Copy link
Collaborator

No worries about the comments formatting. Also the layering of containers is the proper way to handle layouts in this library. You did it right! =)

@mcarpenter622 mcarpenter622 merged commit 011fa05 into ebitenui:master Aug 25, 2023
@mcarpenter622
Copy link
Collaborator

Thank you for the PR. Nicely done!. I did make one minor tweak just for my own personal style choice: c4e3c27

@mcarpenter622
Copy link
Collaborator

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants