summaryrefslogtreecommitdiff
path: root/durationSlider.go
diff options
context:
space:
mode:
Diffstat (limited to 'durationSlider.go')
-rw-r--r--durationSlider.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/durationSlider.go b/durationSlider.go
index cceb65b..0824b63 100644
--- a/durationSlider.go
+++ b/durationSlider.go
@@ -4,34 +4,34 @@
package gadgets
-import (
+import (
"fmt"
"time"
+ "go.wit.com/gui"
"go.wit.com/log"
- "go.wit.com/gui/gui"
)
type Duration struct {
- p *gui.Node // parent widget
- l *gui.Node // label widget
- s *gui.Node // slider widget
+ p *gui.Node // parent widget
+ l *gui.Node // label widget
+ s *gui.Node // slider widget
- Label string
- Low time.Duration
- High time.Duration
- Duration time.Duration
+ Label string
+ Low time.Duration
+ High time.Duration
+ Duration time.Duration
- Custom func()
+ Custom func()
}
func (n *Duration) Set(d time.Duration) {
var timeRange, step, offset time.Duration
- if (d > n.High) {
+ if d > n.High {
d = n.High
}
- if (d < n.Low) {
+ if d < n.Low {
d = n.Low
}
@@ -41,7 +41,7 @@ func (n *Duration) Set(d time.Duration) {
// figure out the integer offset for the Slider GUI Widget
timeRange = n.High - n.Low
step = timeRange / 1000
- if (step == 0) {
+ if step == 0 {
log.Log(INFO, "duration.Set() division by step == 0", n.Low, n.High, timeRange, step)
n.s.Set(0)
return
@@ -55,22 +55,22 @@ func (n *Duration) Set(d time.Duration) {
}
func NewDurationSlider(n *gui.Node, label string, low time.Duration, high time.Duration) *Duration {
- d := Duration {
- p: n,
+ d := Duration{
+ p: n,
Label: label,
- High: high,
- Low: low,
+ High: high,
+ Low: low,
}
// various timeout settings
d.l = n.NewLabel(label)
d.s = n.NewSlider(label, 0, 1000)
- d.s.Custom = func () {
- d.Duration = low + (high - low) * time.Duration(d.s.Int()) / 1000
+ d.s.Custom = func() {
+ d.Duration = low + (high-low)*time.Duration(d.s.Int())/1000
log.Println("d.Duration =", d.Duration)
s := fmt.Sprintf("%s (%v)", d.Label, d.Duration)
d.l.SetText(s)
- if (d.Custom != nil) {
+ if d.Custom != nil {
d.Custom()
}
}