Skip to content

Commit

Permalink
fix(tracker): click on hex track low/high nibble selects that nibble
Browse files Browse the repository at this point in the history
Closes #160
  • Loading branch information
vsariola committed Oct 15, 2024
1 parent 5099c61 commit 7470413
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
the command line tools.

### Fixed
- Clicking on low nibble or high nibble of a hex track selects that nibble
([#160][i160])
- If units have useless parameters in their parameter maps, from bugs or from a
malformed yaml file, they are removed and user is warned about it
- Pressing a or 1 when editing note values in hex mode created a note off line
Expand Down Expand Up @@ -257,5 +259,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
[i151]: https://github.com/vsariola/sointu/issues/151
[i154]: https://github.com/vsariola/sointu/issues/154
[i158]: https://github.com/vsariola/sointu/issues/158
[i160]: https://github.com/vsariola/sointu/issues/160
[i162]: https://github.com/vsariola/sointu/issues/162
[i166]: https://github.com/vsariola/sointu/issues/166
12 changes: 5 additions & 7 deletions tracker/gioui/scroll_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,11 @@ func (s *ScrollTableStyle) handleEvents(gtx layout.Context, p image.Point) {
if e.Kind == pointer.Press {
gtx.Execute(key.FocusCmd{Tag: s.ScrollTable})
}
dx := (int(e.Position.X) + s.ScrollTable.ColTitleList.List.Position.Offset) / gtx.Dp(s.CellWidth)
dy := (int(e.Position.Y) + s.ScrollTable.RowTitleList.List.Position.Offset) / gtx.Dp(s.CellHeight)
x := dx + s.ScrollTable.ColTitleList.List.Position.First
y := dy + s.ScrollTable.RowTitleList.List.Position.First
s.ScrollTable.Table.SetCursor(
tracker.Point{X: x, Y: y},
)
dx := (e.Position.X + float32(s.ScrollTable.ColTitleList.List.Position.Offset)) / float32(gtx.Dp(s.CellWidth))
dy := (e.Position.Y + float32(s.ScrollTable.RowTitleList.List.Position.Offset)) / float32(gtx.Dp(s.CellHeight))
x := dx + float32(s.ScrollTable.ColTitleList.List.Position.First)
y := dy + float32(s.ScrollTable.RowTitleList.List.Position.First)
s.ScrollTable.Table.SetCursorFloat(x, y)
if !e.Modifiers.Contain(key.ModShift) {
s.ScrollTable.Table.SetCursor2(s.ScrollTable.Table.Cursor())
}
Expand Down
12 changes: 12 additions & 0 deletions tracker/table.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package tracker

import (
"math"

"github.com/vsariola/sointu"
"gopkg.in/yaml.v3"
)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 7470413

Please sign in to comment.