mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-23 07:24:47 -04:00
feat: introduce "cache" for derived model information
This commit is contained in:
@ -220,12 +220,11 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
pxRowMarkWidth := gtx.Dp(trackRowMarkWidth)
|
||||
|
||||
colTitle := func(gtx C, i int) D {
|
||||
h := gtx.Dp(unit.Dp(trackColTitleHeight))
|
||||
title := ((*tracker.Order)(t.Model)).Title(i)
|
||||
h := gtx.Dp(trackColTitleHeight)
|
||||
gtx.Constraints = layout.Exact(image.Pt(pxWidth, h))
|
||||
LabelStyle{
|
||||
Alignment: layout.N,
|
||||
Text: title,
|
||||
Text: t.Model.TrackTitle(i),
|
||||
FontSize: unit.Sp(12),
|
||||
Color: mediumEmphasisTextColor,
|
||||
Shaper: t.Theme.Shaper,
|
||||
@ -294,7 +293,7 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
}
|
||||
// draw the corresponding "fake cursors" for instrument-track-groups (for polyphony)
|
||||
if hasTrackMidiIn {
|
||||
for trackIndex := range ((*tracker.Order)(t.Model)).TrackIndicesForCurrentInstrument() {
|
||||
for trackIndex := range t.Model.TracksWithSameInstrumentAsCurrent() {
|
||||
if x == trackIndex && y == cursor.Y {
|
||||
te.paintColumnCell(gtx, x, t, cursorNeighborForTrackMidiInColor)
|
||||
}
|
||||
@ -414,7 +413,7 @@ func (te *NoteEditor) HandleMidiInput(t *Tracker) {
|
||||
return
|
||||
}
|
||||
te.scrollTable.Table.SetCursor2(te.scrollTable.Table.Cursor())
|
||||
remaining := (*tracker.Order)(t.Model).CountNextTracksForCurrentInstrument()
|
||||
remaining := t.Model.CountNextTracksForCurrentInstrument()
|
||||
for i, note := range t.MidiNotePlaying {
|
||||
t.Model.Notes().Table().Set(note)
|
||||
te.scrollTable.Table.MoveCursor(1, 0)
|
||||
|
@ -68,8 +68,13 @@ func (oe *OrderEditor) Layout(gtx C, t *Tracker) D {
|
||||
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()
|
||||
defer op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), -90*math.Pi/180).Offset(f32.Point{X: 0, Y: float32(h)})).Push(gtx.Ops).Pop()
|
||||
gtx.Constraints = layout.Exact(image.Pt(1e6, 1e6))
|
||||
title := t.Model.Order().Title(i)
|
||||
LabelStyle{Alignment: layout.NW, Text: title, FontSize: unit.Sp(12), Color: mediumEmphasisTextColor, Shaper: t.Theme.Shaper}.Layout(gtx)
|
||||
LabelStyle{
|
||||
Alignment: layout.NW,
|
||||
Text: t.Model.TrackTitle(i),
|
||||
FontSize: unit.Sp(12),
|
||||
Color: mediumEmphasisTextColor,
|
||||
Shaper: t.Theme.Shaper,
|
||||
}.Layout(gtx)
|
||||
return D{Size: image.Pt(gtx.Dp(patternCellWidth), h)}
|
||||
}
|
||||
|
||||
|
@ -247,20 +247,26 @@ type ParameterWidget struct {
|
||||
}
|
||||
|
||||
type ParameterStyle struct {
|
||||
tracker *Tracker
|
||||
w *ParameterWidget
|
||||
Theme *material.Theme
|
||||
Focus bool
|
||||
sends []sointu.Unit
|
||||
tracker *Tracker
|
||||
w *ParameterWidget
|
||||
Theme *material.Theme
|
||||
SendTargetTheme *material.Theme
|
||||
Focus bool
|
||||
sends []sointu.Unit
|
||||
}
|
||||
|
||||
func (t *Tracker) ParamStyle(th *material.Theme, paramWidget *ParameterWidget) ParameterStyle {
|
||||
sends := slices.Collect(t.Model.CollectSendsTo(paramWidget.Parameter))
|
||||
sendTargetTheme := th.WithPalette(material.Palette{
|
||||
Bg: th.Bg,
|
||||
Fg: paramIsSendTargetColor,
|
||||
ContrastBg: th.ContrastBg,
|
||||
ContrastFg: th.ContrastFg,
|
||||
})
|
||||
return ParameterStyle{
|
||||
tracker: t, // TODO: we need this to pull the instrument names for ID style parameters, find out another way
|
||||
Theme: th,
|
||||
w: paramWidget,
|
||||
sends: sends,
|
||||
tracker: t, // TODO: we need this to pull the instrument names for ID style parameters, find out another way
|
||||
Theme: th,
|
||||
SendTargetTheme: &sendTargetTheme,
|
||||
w: paramWidget,
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,7 +302,6 @@ func (p ParameterStyle) Layout(gtx C) D {
|
||||
}
|
||||
sliderStyle := material.Slider(p.Theme, &p.w.floatWidget)
|
||||
sliderStyle.Color = p.Theme.Fg
|
||||
|
||||
if len(sends) > 0 {
|
||||
sliderStyle.Color = paramIsSendTargetColor
|
||||
}
|
||||
@ -374,11 +379,11 @@ func (p ParameterStyle) Layout(gtx C) D {
|
||||
layout.Rigid(func(gtx C) D {
|
||||
if p.w.Parameter.Type() != tracker.IDParameter {
|
||||
label := Label(p.w.Parameter.Hint(), white, p.tracker.Theme.Shaper)
|
||||
info := p.buildTooltip(sends)
|
||||
info := p.buildSendTargetTooltip(sends)
|
||||
if info == "" {
|
||||
return label(gtx)
|
||||
}
|
||||
tooltip := component.PlatformTooltip(p.Theme, info)
|
||||
tooltip := component.PlatformTooltip(p.SendTargetTheme, info)
|
||||
return p.w.tipArea.Layout(gtx, tooltip, label)
|
||||
}
|
||||
return D{}
|
||||
@ -413,7 +418,7 @@ func (p ParameterStyle) findSends() iter.Seq[sointu.Unit] {
|
||||
}
|
||||
}
|
||||
|
||||
func (p ParameterStyle) buildTooltip(sends []sointu.Unit) string {
|
||||
func (p ParameterStyle) buildSendTargetTooltip(sends []sointu.Unit) string {
|
||||
if len(sends) == 0 {
|
||||
return ""
|
||||
}
|
||||
@ -424,7 +429,7 @@ func (p ParameterStyle) buildTooltip(sends []sointu.Unit) string {
|
||||
sourceInstr := p.tracker.Model.InstrumentForUnit(sends[0].ID)
|
||||
sourceInfo := ""
|
||||
if sourceInstr != targetInstr {
|
||||
sourceInfo = fmt.Sprintf(" (%s)", sourceInstr.Name)
|
||||
sourceInfo = fmt.Sprintf(" from \"%s\"", sourceInstr.Name)
|
||||
}
|
||||
if amounts == "" {
|
||||
amounts = fmt.Sprintf("x %d%s", sends[i].Parameters["amount"], sourceInfo)
|
||||
|
Reference in New Issue
Block a user