fix(tracker): click on hex track low/high nibble selects that nibble

Closes #160
This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-10-15 09:37:21 +03:00
parent 5099c61705
commit 7470413ad8
3 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,8 @@
package tracker
import (
"math"
"github.com/vsariola/sointu"
"gopkg.in/yaml.v3"
)
@ -15,6 +17,7 @@ type (
Cursor2() Point
SetCursor(Point)
SetCursor2(Point)
SetCursorFloat(x, y float32)
Width() int
Height() int
MoveCursor(dx, dy int) (ok bool)
@ -178,6 +181,10 @@ func (m *Order) SetCursor2(p Point) {
m.updateCursorRows()
}
func (m *Order) SetCursorFloat(x, y float32) {
m.SetCursor(Point{int(x), int(y)})
}
func (v *Order) updateCursorRows() {
if v.Cursor() == v.Cursor2() {
v.d.Cursor.PatternRow = 0
@ -422,6 +429,11 @@ func (v *Notes) SetCursor2(p Point) {
v.d.Cursor2.SongPos = v.d.Song.Score.Clamp(sointu.SongPos{PatternRow: p.Y})
}
func (m *Notes) SetCursorFloat(x, y float32) {
m.SetCursor(Point{int(x), int(y)})
m.d.LowNibble = math.Mod(float64(x), 1.0) > 0.5
}
func (v *Notes) Width() int {
return len((*Model)(v).d.Song.Score.Tracks)
}