mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
layout,gesture: add option to handle vertical scroll on horizontal list
Previously, it was impossible to scroll a Axis == Horizontal using ordinary mouse-wheel. Now, it's possible to set ScrollAnyAxis == True, which combine scrolling from any direction. That makes possible to scroll Horizontal lists with vertical mouse-wheel. By default this option is false, keeping the old behaviour. Signed-off-by: inkeliz <inkeliz@inkeliz.com>
This commit is contained in:
+9
-2
@@ -322,6 +322,8 @@ func (s *Scroll) Update(cfg unit.Metric, q input.Source, t time.Time, axis Axis,
|
||||
s.scroll += e.Scroll.X
|
||||
case Vertical:
|
||||
s.scroll += e.Scroll.Y
|
||||
case Both:
|
||||
s.scroll += e.Scroll.X + e.Scroll.Y
|
||||
}
|
||||
iscroll := int(s.scroll)
|
||||
s.scroll -= float32(iscroll)
|
||||
@@ -353,10 +355,15 @@ func (s *Scroll) Update(cfg unit.Metric, q input.Source, t time.Time, axis Axis,
|
||||
}
|
||||
|
||||
func (s *Scroll) val(axis Axis, p f32.Point) float32 {
|
||||
if axis == Horizontal {
|
||||
switch axis {
|
||||
case Horizontal:
|
||||
return p.X
|
||||
} else {
|
||||
case Vertical:
|
||||
return p.Y
|
||||
case Both:
|
||||
return p.X + p.Y
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user