mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
fix(tracker/gioui): scroll bars move in sync with the cursor
This commit is contained in:
parent
b772940b1f
commit
9073adadb3
@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
options
|
||||
|
||||
### Fixed
|
||||
- The scroll bars move in sync with the cursor.
|
||||
- The stereo version of delay in the go virtual machine (executables / plugins
|
||||
not ending with -native) applied the left delay taps on the right channel, and
|
||||
the right delay taps on the left channel.
|
||||
|
@ -50,6 +50,9 @@ func (s *ScrollBar) Layout(gtx C, width unit.Dp, numItems int, pos *layout.Posit
|
||||
totalPixelsEstimate = float32(gtx.Constraints.Min.X+pos.Offset-pos.OffsetLast) * float32(numItems) / float32(pos.Count)
|
||||
scrollBarRelLength = float32(gtx.Constraints.Min.X) / float32(totalPixelsEstimate)
|
||||
}
|
||||
if scrollBarRelLength < 1e-2 {
|
||||
scrollBarRelLength = 1e-2 // make sure it doesn't disappear completely
|
||||
}
|
||||
|
||||
scrollBarRelStart := (float32(pos.First)*totalPixelsEstimate/float32(numItems) + float32(pos.Offset)) / totalPixelsEstimate
|
||||
scrWidth := gtx.Dp(width)
|
||||
@ -97,10 +100,10 @@ func (s *ScrollBar) Layout(gtx C, width unit.Dp, numItems int, pos *layout.Posit
|
||||
}
|
||||
case pointer.Drag:
|
||||
if s.Axis == layout.Horizontal {
|
||||
pos.Offset += int(e.Position.X - s.dragStart + 0.5)
|
||||
pos.Offset += int((e.Position.X-s.dragStart)/scrollBarRelLength + 0.5)
|
||||
s.dragStart = e.Position.X
|
||||
} else {
|
||||
pos.Offset += int(e.Position.Y - s.dragStart + 0.5)
|
||||
pos.Offset += int((e.Position.Y-s.dragStart)/scrollBarRelLength + 0.5)
|
||||
s.dragStart = e.Position.Y
|
||||
}
|
||||
case pointer.Release, pointer.Cancel:
|
||||
|
Loading…
Reference in New Issue
Block a user