Value returns the current position of the button in the scrollbar The returned value is between 0.0 and 1.0
()
| 116 | // Value returns the current position of the button in the scrollbar |
| 117 | // The returned value is between 0.0 and 1.0 |
| 118 | func (sb *ScrollBar) Value() float64 { |
| 119 | |
| 120 | if sb.vertical { |
| 121 | den := float64(sb.content.Height) - float64(sb.button.height) |
| 122 | if den == 0 { |
| 123 | return 0 |
| 124 | } |
| 125 | return float64(sb.button.Position().Y) / den |
| 126 | } |
| 127 | |
| 128 | // horizontal |
| 129 | den := float64(sb.content.Width) - float64(sb.button.width) |
| 130 | if den == 0 { |
| 131 | return 0 |
| 132 | } |
| 133 | return float64(sb.button.Position().X) / den |
| 134 | } |
| 135 | |
| 136 | // SetValue sets the position of the button of the scrollbar |
| 137 | // from 0.0 (minimum) to 1.0 (maximum). |