forked from fyne-io/fyne
/
progress.go
30 lines (24 loc) · 847 Bytes
/
progress.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package dialog
import (
"fyne.io/fyne"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
)
// ProgressDialog is a simple dialog window that displays text and a progress bar.
type ProgressDialog struct {
*dialog
bar *widget.ProgressBar
}
// SetValue updates the value of the progress bar - this should be between 0.0 and 1.0.
func (p *ProgressDialog) SetValue(v float64) {
p.bar.SetValue(v)
}
// NewProgress creates a progress dialog and returns the handle.
// Using the returned type you should call Show() and then set it's value through SetValue().
func NewProgress(title, message string, parent fyne.Window) *ProgressDialog {
d := newDialog(title, message, theme.InfoIcon(), nil /*cancel?*/, parent)
bar := widget.NewProgressBar()
bar.Resize(fyne.NewSize(200, bar.MinSize().Height))
d.setButtons(bar)
return &ProgressDialog{d, bar}
}