/
progress.go
39 lines (32 loc) · 1.12 KB
/
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
31
32
33
34
35
36
37
38
39
package dialog
import (
"image/color"
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
// ProgressDialog is a simple dialog window that displays text and a progress bar.
//
// Deprecated: Create a new custom dialog with a widget.ProgressBar() inside.
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 its value through SetValue().
//
// Deprecated: Create a new custom dialog with a widget.ProgressBar() inside.
func NewProgress(title, message string, parent fyne.Window) *ProgressDialog {
d := newDialog(title, message, theme.InfoIcon(), nil /*cancel?*/, parent)
bar := widget.NewProgressBar()
rect := canvas.NewRectangle(color.Transparent)
rect.SetMinSize(fyne.NewSize(200, 0))
d.setButtons(container.NewMax(rect, bar))
return &ProgressDialog{d, bar}
}