Added indeterminate ProgressBars to the portable frontend and fixed up ProgressBar's documentation.
This commit is contained in:
parent
6be3c2835f
commit
bf093d534c
|
@ -6,7 +6,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// A ProgressBar is a horizontal rectangle that fills up from left to right to indicate the progress of a long-running task.
|
// A ProgressBar is a horizontal rectangle that fills up from left to right to indicate the progress of a long-running task.
|
||||||
// This progress is typically a percentage, so within the range [0,100].
|
// This progress is represented by an integer within the range [0,100], representing a percentage.
|
||||||
|
// Alternatively, a progressbar can show an animation indicating that progress is being made but how much is indeterminate.
|
||||||
|
// Newly-created ProgressBars default to showing 0% progress.
|
||||||
type ProgressBar struct {
|
type ProgressBar struct {
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
created bool
|
created bool
|
||||||
|
@ -21,13 +23,16 @@ func NewProgressBar() *ProgressBar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetProgress sets the currently indicated progress amount on the ProgressBar. If this amount is outside the range [0,100] (ideally -1), the function will panic (TODO make it indeterminate).
|
// SetProgress sets the currently indicated progress amount on the ProgressBar.
|
||||||
|
// If percent is in the range [0,100], the progressBar shows that much percent complete.
|
||||||
|
// If percent is -1, the ProgressBar is made indeterminate.
|
||||||
|
// Otherwise, SetProgress panics.
|
||||||
func (p *ProgressBar) SetProgress(percent int) {
|
func (p *ProgressBar) SetProgress(percent int) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
|
|
||||||
if percent < 0 || percent > 100 {
|
if percent < -1 || percent > 100 {
|
||||||
panic("invalid percent") // TODO
|
panic("percent value out of range")
|
||||||
}
|
}
|
||||||
if p.created {
|
if p.created {
|
||||||
p.sysData.setProgress(percent)
|
p.sysData.setProgress(percent)
|
||||||
|
|
Loading…
Reference in New Issue