Fixed vertical slider
This commit is contained in:
parent
98bf754282
commit
05b6490095
13
slider.go
13
slider.go
@ -74,18 +74,24 @@ func (this *Slider) OnValueChange (callback func ()) event.Cookie {
|
||||
}
|
||||
|
||||
func (this *Slider) handleKeyDown (key input.Key, numpad bool) {
|
||||
var increment float64; if this.layout.vertical {
|
||||
increment = -0.05
|
||||
} else {
|
||||
increment = 0.05
|
||||
}
|
||||
|
||||
switch key {
|
||||
case input.KeyUp, input.KeyLeft:
|
||||
if this.Modifiers().Alt {
|
||||
this.SetValue(0)
|
||||
} else {
|
||||
this.SetValue(this.Value() - 0.05)
|
||||
this.SetValue(this.Value() - increment)
|
||||
}
|
||||
case input.KeyDown, input.KeyRight:
|
||||
if this.Modifiers().Alt {
|
||||
this.SetValue(1)
|
||||
} else {
|
||||
this.SetValue(this.Value() + 0.05)
|
||||
this.SetValue(this.Value() + increment)
|
||||
}
|
||||
case input.KeyHome:
|
||||
this.SetValue(0)
|
||||
@ -152,6 +158,7 @@ func (this *Slider) drag () {
|
||||
|
||||
if this.layout.vertical {
|
||||
this.SetValue (
|
||||
1 -
|
||||
float64(pointer.Y) /
|
||||
float64(gutter.Dy() - handle.Dy()))
|
||||
} else {
|
||||
@ -188,7 +195,7 @@ func (this sliderLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
||||
|
||||
if this.vertical {
|
||||
height := gutter.Dy() - handle.Dy()
|
||||
offset := int(float64(height) * this.value)
|
||||
offset := int(float64(height) * (1 - this.value))
|
||||
handle.Max.X = gutter.Dx()
|
||||
boxes[0].SetBounds (
|
||||
handle.
|
||||
|
Loading…
Reference in New Issue
Block a user