Example #1
0
File: ui.go Project: num5/steven
func (sl *slider) hover(x, y float64, w, h int) {
	if sl.sliding {
		ox, _, ok := ui.Intersects(sl.back, x, y, w, h)
		if ok {
			ww, _ := sl.back.Size()
			v := math.Min(ww-10, math.Max(10, ox)) - 10
			sl.Value = v / (ww - 20)
			sl.update()
		}
	}
}
Example #2
0
File: ui.go Project: num5/steven
func (sl *slider) click(down bool, x, y float64, w, h int) {
	if !down {
		if sl.sliding {
			sl.sliding = false
		}
		return
	}
	_, _, ok := ui.Intersects(sl.slider, x, y, w, h)
	if ok {
		sl.sliding = true
	} else {
		ox, _, ok := ui.Intersects(sl.back, x, y, w, h)
		if ok {
			ww, _ := sl.back.Size()
			v := math.Min(ww-10, math.Max(10, ox)) - 10
			sl.Value = v / (ww - 20)
			sl.update()
		}
	}
}