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) {
|
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 {
|
switch key {
|
||||||
case input.KeyUp, input.KeyLeft:
|
case input.KeyUp, input.KeyLeft:
|
||||||
if this.Modifiers().Alt {
|
if this.Modifiers().Alt {
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() - 0.05)
|
this.SetValue(this.Value() - increment)
|
||||||
}
|
}
|
||||||
case input.KeyDown, input.KeyRight:
|
case input.KeyDown, input.KeyRight:
|
||||||
if this.Modifiers().Alt {
|
if this.Modifiers().Alt {
|
||||||
this.SetValue(1)
|
this.SetValue(1)
|
||||||
} else {
|
} else {
|
||||||
this.SetValue(this.Value() + 0.05)
|
this.SetValue(this.Value() + increment)
|
||||||
}
|
}
|
||||||
case input.KeyHome:
|
case input.KeyHome:
|
||||||
this.SetValue(0)
|
this.SetValue(0)
|
||||||
@ -152,6 +158,7 @@ func (this *Slider) drag () {
|
|||||||
|
|
||||||
if this.layout.vertical {
|
if this.layout.vertical {
|
||||||
this.SetValue (
|
this.SetValue (
|
||||||
|
1 -
|
||||||
float64(pointer.Y) /
|
float64(pointer.Y) /
|
||||||
float64(gutter.Dy() - handle.Dy()))
|
float64(gutter.Dy() - handle.Dy()))
|
||||||
} else {
|
} else {
|
||||||
@ -188,7 +195,7 @@ func (this sliderLayout) Arrange (hints tomo.LayoutHints, boxes []tomo.Box) {
|
|||||||
|
|
||||||
if this.vertical {
|
if this.vertical {
|
||||||
height := gutter.Dy() - handle.Dy()
|
height := gutter.Dy() - handle.Dy()
|
||||||
offset := int(float64(height) * this.value)
|
offset := int(float64(height) * (1 - this.value))
|
||||||
handle.Max.X = gutter.Dx()
|
handle.Max.X = gutter.Dx()
|
||||||
boxes[0].SetBounds (
|
boxes[0].SetBounds (
|
||||||
handle.
|
handle.
|
||||||
|
Loading…
Reference in New Issue
Block a user