diff options
| author | Jeff Carr <[email protected]> | 2024-01-18 05:04:18 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-18 05:04:18 -0600 |
| commit | a8d95fef8d0879a3e3ecdac76ab4df4fee658fcf (patch) | |
| tree | d870cdb3147828e2a93bb99a84925b07b719216d /durationSlider.go | |
| parent | 76d6da5505900c50b72e3c84e86a521d9bcbc6bd (diff) | |
lots of syntax changesv0.12.8
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'durationSlider.go')
| -rw-r--r-- | durationSlider.go | 40 |
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() } } |
