refactor(tracker): use built-in min & max instead of intMin & intMax

This commit is contained in:
5684185+vsariola@users.noreply.github.com
2024-10-18 23:43:27 +03:00
parent 0ba6557f65
commit 1c42a51cc6
11 changed files with 58 additions and 72 deletions

View File

@ -358,14 +358,14 @@ func between(a, b, c int) bool {
return (a <= b && b <= c) || (c <= b && b <= a)
}
func intMax(a, b int) int {
func max(a, b int) int {
if a > b {
return a
}
return b
}
func intMin(a, b int) int {
func min(a, b int) int {
if a < b {
return a
}

View File

@ -365,7 +365,7 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
}
units[i] = item
}
count := intMin(ie.unitDragList.TrackerList.Count(), 256)
count := min(ie.unitDragList.TrackerList.Count(), 256)
element := func(gtx C, i int) D {
gtx.Constraints.Max.Y = gtx.Dp(20)

View File

@ -227,7 +227,7 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
}
rowTitle := func(gtx C, j int) D {
rpp := intMax(t.RowsPerPattern().Value(), 1)
rpp := max(t.RowsPerPattern().Value(), 1)
pat := j / rpp
row := j % rpp
w := pxPatMarkWidth + pxRowMarkWidth
@ -277,7 +277,7 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
paint.FillShape(gtx.Ops, c, clip.Rect{Min: image.Pt(cx, 0), Max: image.Pt(cx+cw, gtx.Constraints.Min.Y)}.Op())
}
// draw the pattern marker
rpp := intMax(t.RowsPerPattern().Value(), 1)
rpp := max(t.RowsPerPattern().Value(), 1)
pat := y / rpp
row := y % rpp
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()

View File

@ -254,8 +254,8 @@ func (s *ScrollTable) command(gtx C, e key.Event) {
stepX := 1
stepY := 1
if e.Modifiers.Contain(key.ModAlt) {
stepX = intMax(s.ColTitleList.List.Position.Count-3, 8)
stepY = intMax(s.RowTitleList.List.Position.Count-3, 8)
stepX = max(s.ColTitleList.List.Position.Count-3, 8)
stepY = max(s.RowTitleList.List.Position.Count-3, 8)
} else if e.Modifiers.Contain(key.ModCtrl) {
stepX = 1e6
stepY = 1e6
@ -277,9 +277,9 @@ func (s *ScrollTable) command(gtx C, e key.Event) {
case key.NameRightArrow:
s.Table.MoveCursor(stepX, 0)
case key.NamePageUp:
s.Table.MoveCursor(0, -intMax(s.RowTitleList.List.Position.Count-3, 8))
s.Table.MoveCursor(0, -max(s.RowTitleList.List.Position.Count-3, 8))
case key.NamePageDown:
s.Table.MoveCursor(0, intMax(s.RowTitleList.List.Position.Count-3, 8))
s.Table.MoveCursor(0, max(s.RowTitleList.List.Position.Count-3, 8))
case key.NameHome:
s.Table.SetCursorX(0)
case key.NameEnd: