feat(sointu, tracker,...): restructure domain & tracker models

send targets are now by ID and Song has "Score" part, which is the notes for it. also, moved the model part separate of the actual gioui dependend stuff.

sorry to my future self about the code bomb; ended up too far and did not find an easy way to rewrite the history to make the steps smaller, so in the end, just squashed everything.
This commit is contained in:
vsariola
2021-02-23 23:55:42 +02:00
parent fd1d018e82
commit adcf3ebce8
155 changed files with 5520 additions and 4914 deletions

51
tracker/gioui/surface.go Normal file
View File

@ -0,0 +1,51 @@
package gioui
import (
"image/color"
"gioui.org/layout"
"gioui.org/op/clip"
"gioui.org/op/paint"
)
type Surface struct {
Gray int
Inset layout.Inset
FitSize bool
Focus bool
}
func (s Surface) Layout(gtx C, widget layout.Widget) D {
bg := func(gtx C) D {
grayInt := s.Gray
if s.Focus {
grayInt += 8
}
var grayUint8 uint8
if grayInt < 0 {
grayUint8 = 0
} else if grayInt > 255 {
grayUint8 = 255
} else {
grayUint8 = uint8(grayInt)
}
color := color.NRGBA{R: grayUint8, G: grayUint8, B: grayUint8, A: 255}
paint.FillShape(gtx.Ops, color, clip.Rect{
Max: gtx.Constraints.Min,
}.Op())
return D{Size: gtx.Constraints.Min}
}
fg := func(gtx C) D {
return s.Inset.Layout(gtx, widget)
}
if s.FitSize {
return layout.Stack{}.Layout(gtx,
layout.Expanded(bg),
layout.Stacked(fg),
)
}
gtxbg := gtx
gtxbg.Constraints.Min = gtxbg.Constraints.Max
bg(gtxbg)
return fg(gtx)
}