Added ProgressBar and implemented it on GTK+.
This commit is contained in:
parent
4333a1221b
commit
47600ec087
|
@ -147,7 +147,6 @@ func NewTextbox() Textbox {
|
|||
// - TODO set page step?
|
||||
// - TODO wrapping
|
||||
// - TODO negative values
|
||||
// - TODO ensuring values entered in text box stay within bounds (OS X seems to take care of this automatically; not sure about Windows or GTK+...)
|
||||
type Spinbox interface {
|
||||
Control
|
||||
|
||||
|
@ -170,3 +169,19 @@ func NewSpinbox(min int, max int) Spinbox {
|
|||
}
|
||||
return newSpinbox(min, max)
|
||||
}
|
||||
|
||||
// ProgressBar is a Control that displays a horizontal bar which shows the level of completion of an operation.
|
||||
type ProgressBar interface {
|
||||
Control
|
||||
|
||||
// Percent and SetPrecent get and set the current percentage indicated by the ProgressBar, respectively.
|
||||
// This value must be between 0 and 100; all other values cause SetPercent to panic.
|
||||
Percent() int
|
||||
SetPercent(percent int)
|
||||
}
|
||||
|
||||
// NewProgressBar creates a new ProgressBar.
|
||||
// It will initially show a progress of 0%.
|
||||
func NewProgressBar() ProgressBar {
|
||||
return newProgressBar()
|
||||
}
|
||||
|
|
|
@ -150,11 +150,11 @@ func (tw *testwin) addfe() {
|
|||
tw.festack.SetStretchy(4)
|
||||
tw.festack.SetStretchy(6)
|
||||
sb := NewSpinbox(0, 100)
|
||||
sl := NewLabel("")
|
||||
sp := NewProgressBar()
|
||||
sb.OnChanged(func() {
|
||||
sl.SetText(fmt.Sprintf("%d", sb.Value()))
|
||||
sp.SetPercent(sb.Value())
|
||||
})
|
||||
tw.festack2 = newVerticalStack(sb, sl, Space(), Space(), NewTextbox())
|
||||
tw.festack2 = newVerticalStack(sb, sp, Space(), Space(), NewTextbox())
|
||||
tw.festack2.SetStretchy(3)
|
||||
tw.festack2.SetStretchy(4)
|
||||
tw.festack = newHorizontalStack(tw.festack, tw.festack2)
|
||||
|
|
Loading…
Reference in New Issue