MCPcopy Index your code
hub / github.com/g3n/engine / SetValue

Method SetValue

gui/scrollbar.go:138–148  ·  view source on GitHub ↗

SetValue sets the position of the button of the scrollbar from 0.0 (minimum) to 1.0 (maximum).

(v float32)

Source from the content-addressed store, hash-verified

136// SetValue sets the position of the button of the scrollbar
137// from 0.0 (minimum) to 1.0 (maximum).
138func (sb *ScrollBar) SetValue(v float32) {
139
140 v = math32.Clamp(v, 0.0, 1.0)
141 if sb.vertical {
142 pos := v * (float32(sb.content.Height) - float32(sb.button.height))
143 sb.button.SetPositionY(pos)
144 } else {
145 pos := v * (float32(sb.content.Width) - float32(sb.button.width))
146 sb.button.SetPositionX(pos)
147 }
148}
149
150// onMouse receives subscribed mouse events over the scrollbar outer panel
151func (sb *ScrollBar) onMouse(evname string, ev interface{}) {

Callers

nothing calls this directly

Calls 3

ClampFunction · 0.92
SetPositionYMethod · 0.65
SetPositionXMethod · 0.65

Tested by

no test coverage detected