mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-19 13:34:34 -04:00
refactor(tracker): make Bool have separate BoolValue and Enabler
This commit is contained in:
parent
036cb1f34d
commit
fb3a0da3ed
@ -82,12 +82,12 @@ func init() {
|
||||
go detector.Run()
|
||||
|
||||
t := gioui.NewTracker(model)
|
||||
model.InstrEnlarged().Bool().Set(true)
|
||||
model.InstrEnlarged().SetValue(true)
|
||||
// since the VST is usually working without any regard for the tracks
|
||||
// until recording, disable the Instrument-Track linking by default
|
||||
// because it might just confuse the user why instrument cannot be
|
||||
// swapped/added etc.
|
||||
model.LinkInstrTrack().Bool().Set(false)
|
||||
model.LinkInstrTrack().SetValue(false)
|
||||
go t.Main()
|
||||
context := VSTIProcessContext{host: h}
|
||||
buf := make(sointu.AudioBuffer, 1024)
|
||||
|
134
tracker/bool.go
134
tracker/bool.go
@ -2,13 +2,13 @@ package tracker
|
||||
|
||||
type (
|
||||
Bool struct {
|
||||
BoolData
|
||||
value BoolValue
|
||||
enabler Enabler
|
||||
}
|
||||
|
||||
BoolData interface {
|
||||
BoolValue interface {
|
||||
Value() bool
|
||||
Enabled() bool
|
||||
setValue(bool)
|
||||
SetValue(bool)
|
||||
}
|
||||
|
||||
Panic Model
|
||||
@ -29,60 +29,66 @@ type (
|
||||
Oversampling Model
|
||||
)
|
||||
|
||||
func (v Bool) Toggle() {
|
||||
v.Set(!v.Value())
|
||||
func MakeBool(valueEnabler interface {
|
||||
BoolValue
|
||||
Enabler
|
||||
}) Bool {
|
||||
return Bool{value: valueEnabler, enabler: valueEnabler}
|
||||
}
|
||||
|
||||
func (v Bool) Set(value bool) {
|
||||
func MakeEnabledBool(value BoolValue) Bool {
|
||||
return Bool{value: value, enabler: nil}
|
||||
}
|
||||
|
||||
func (v Bool) Toggle() {
|
||||
v.SetValue(!v.Value())
|
||||
}
|
||||
|
||||
func (v Bool) SetValue(value bool) {
|
||||
if v.Enabled() && v.Value() != value {
|
||||
v.setValue(value)
|
||||
v.value.SetValue(value)
|
||||
}
|
||||
}
|
||||
|
||||
func (v Bool) Value() bool {
|
||||
if v.value == nil {
|
||||
return false
|
||||
}
|
||||
return v.value.Value()
|
||||
}
|
||||
|
||||
func (v Bool) Enabled() bool {
|
||||
if v.enabler == nil {
|
||||
return true
|
||||
}
|
||||
return v.enabler.Enabled()
|
||||
}
|
||||
|
||||
// Model methods
|
||||
|
||||
func (m *Model) Panic() *Panic { return (*Panic)(m) }
|
||||
func (m *Model) IsRecording() *IsRecording { return (*IsRecording)(m) }
|
||||
func (m *Model) Playing() *Playing { return (*Playing)(m) }
|
||||
func (m *Model) InstrEnlarged() *InstrEnlarged { return (*InstrEnlarged)(m) }
|
||||
func (m *Model) Effect() *Effect { return (*Effect)(m) }
|
||||
func (m *Model) TrackMidiIn() *TrackMidiIn { return (*TrackMidiIn)(m) }
|
||||
func (m *Model) CommentExpanded() *CommentExpanded { return (*CommentExpanded)(m) }
|
||||
func (m *Model) Follow() *Follow { return (*Follow)(m) }
|
||||
func (m *Model) UnitSearching() *UnitSearching { return (*UnitSearching)(m) }
|
||||
func (m *Model) UnitDisabled() *UnitDisabled { return (*UnitDisabled)(m) }
|
||||
func (m *Model) LoopToggle() *LoopToggle { return (*LoopToggle)(m) }
|
||||
func (m *Model) UniquePatterns() *UniquePatterns { return (*UniquePatterns)(m) }
|
||||
func (m *Model) Mute() *Mute { return (*Mute)(m) }
|
||||
func (m *Model) Solo() *Solo { return (*Solo)(m) }
|
||||
func (m *Model) LinkInstrTrack() *LinkInstrTrack { return (*LinkInstrTrack)(m) }
|
||||
func (m *Model) Oversampling() *Oversampling { return (*Oversampling)(m) }
|
||||
|
||||
// Panic methods
|
||||
|
||||
func (m *Panic) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Panic() Bool { return MakeEnabledBool((*Panic)(m)) }
|
||||
func (m *Panic) Value() bool { return m.panic }
|
||||
func (m *Panic) setValue(val bool) {
|
||||
func (m *Panic) SetValue(val bool) {
|
||||
(*Model)(m).setPanic(val)
|
||||
}
|
||||
func (m *Panic) Enabled() bool { return true }
|
||||
|
||||
// IsRecording methods
|
||||
|
||||
func (m *IsRecording) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) IsRecording() Bool { return MakeEnabledBool((*IsRecording)(m)) }
|
||||
func (m *IsRecording) Value() bool { return (*Model)(m).recording }
|
||||
func (m *IsRecording) setValue(val bool) {
|
||||
func (m *IsRecording) SetValue(val bool) {
|
||||
m.recording = val
|
||||
m.instrEnlarged = val
|
||||
TrySend(m.broker.ToPlayer, any(RecordingMsg{val}))
|
||||
}
|
||||
func (m *IsRecording) Enabled() bool { return true }
|
||||
|
||||
// Playing methods
|
||||
|
||||
func (m *Playing) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Playing() Bool { return MakeBool((*Playing)(m)) }
|
||||
func (m *Playing) Value() bool { return m.playing }
|
||||
func (m *Playing) setValue(val bool) {
|
||||
func (m *Playing) SetValue(val bool) {
|
||||
m.playing = val
|
||||
if m.playing {
|
||||
(*Model)(m).setPanic(false)
|
||||
@ -95,64 +101,59 @@ func (m *Playing) Enabled() bool { return m.playing || !m.instrEnlarged }
|
||||
|
||||
// InstrEnlarged methods
|
||||
|
||||
func (m *InstrEnlarged) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) InstrEnlarged() Bool { return MakeEnabledBool((*InstrEnlarged)(m)) }
|
||||
func (m *InstrEnlarged) Value() bool { return m.instrEnlarged }
|
||||
func (m *InstrEnlarged) setValue(val bool) { m.instrEnlarged = val }
|
||||
func (m *InstrEnlarged) Enabled() bool { return true }
|
||||
func (m *InstrEnlarged) SetValue(val bool) { m.instrEnlarged = val }
|
||||
|
||||
// CommentExpanded methods
|
||||
|
||||
func (m *CommentExpanded) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) CommentExpanded() Bool { return MakeEnabledBool((*CommentExpanded)(m)) }
|
||||
func (m *CommentExpanded) Value() bool { return m.commentExpanded }
|
||||
func (m *CommentExpanded) setValue(val bool) { m.commentExpanded = val }
|
||||
func (m *CommentExpanded) Enabled() bool { return true }
|
||||
func (m *CommentExpanded) SetValue(val bool) { m.commentExpanded = val }
|
||||
|
||||
// Follow methods
|
||||
|
||||
func (m *Follow) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Follow() Bool { return MakeEnabledBool((*Follow)(m)) }
|
||||
func (m *Follow) Value() bool { return m.follow }
|
||||
func (m *Follow) setValue(val bool) { m.follow = val }
|
||||
func (m *Follow) Enabled() bool { return true }
|
||||
func (m *Follow) SetValue(val bool) { m.follow = val }
|
||||
|
||||
// TrackMidiIn (Midi Input for notes in the tracks)
|
||||
|
||||
func (m *TrackMidiIn) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) TrackMidiIn() Bool { return MakeBool((*TrackMidiIn)(m)) }
|
||||
func (m *TrackMidiIn) Value() bool { return m.trackMidiIn }
|
||||
func (m *TrackMidiIn) setValue(val bool) { m.trackMidiIn = val }
|
||||
func (m *TrackMidiIn) SetValue(val bool) { m.trackMidiIn = val }
|
||||
func (m *TrackMidiIn) Enabled() bool { return m.MIDI.HasDeviceOpen() }
|
||||
|
||||
// Effect methods
|
||||
|
||||
func (m *Effect) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Effect() Bool { return MakeEnabledBool((*Effect)(m)) }
|
||||
func (m *Effect) Value() bool {
|
||||
if m.d.Cursor.Track < 0 || m.d.Cursor.Track >= len(m.d.Song.Score.Tracks) {
|
||||
return false
|
||||
}
|
||||
return m.d.Song.Score.Tracks[m.d.Cursor.Track].Effect
|
||||
}
|
||||
func (m *Effect) setValue(val bool) {
|
||||
func (m *Effect) SetValue(val bool) {
|
||||
if m.d.Cursor.Track < 0 || m.d.Cursor.Track >= len(m.d.Song.Score.Tracks) {
|
||||
return
|
||||
}
|
||||
m.d.Song.Score.Tracks[m.d.Cursor.Track].Effect = val
|
||||
}
|
||||
func (m *Effect) Enabled() bool { return true }
|
||||
|
||||
// Oversampling methods
|
||||
|
||||
func (m *Oversampling) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Oversampling() Bool { return MakeEnabledBool((*Oversampling)(m)) }
|
||||
func (m *Oversampling) Value() bool { return m.oversampling }
|
||||
func (m *Oversampling) setValue(val bool) {
|
||||
func (m *Oversampling) SetValue(val bool) {
|
||||
m.oversampling = val
|
||||
TrySend(m.broker.ToDetector, MsgToDetector{HasOversampling: true, Oversampling: val})
|
||||
}
|
||||
func (m *Oversampling) Enabled() bool { return true }
|
||||
|
||||
// UnitSearching methods
|
||||
|
||||
func (m *UnitSearching) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) UnitSearching() Bool { return MakeEnabledBool((*UnitSearching)(m)) }
|
||||
func (m *UnitSearching) Value() bool { return m.d.UnitSearching }
|
||||
func (m *UnitSearching) setValue(val bool) {
|
||||
func (m *UnitSearching) SetValue(val bool) {
|
||||
m.d.UnitSearching = val
|
||||
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
|
||||
m.d.UnitSearchString = ""
|
||||
@ -164,11 +165,10 @@ func (m *UnitSearching) setValue(val bool) {
|
||||
}
|
||||
m.d.UnitSearchString = m.d.Song.Patch[m.d.InstrIndex].Units[m.d.UnitIndex].Type
|
||||
}
|
||||
func (m *UnitSearching) Enabled() bool { return true }
|
||||
|
||||
// UnitDisabled methods
|
||||
|
||||
func (m *UnitDisabled) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) UnitDisabled() Bool { return MakeBool((*UnitDisabled)(m)) }
|
||||
func (m *UnitDisabled) Value() bool {
|
||||
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
|
||||
return false
|
||||
@ -178,7 +178,7 @@ func (m *UnitDisabled) Value() bool {
|
||||
}
|
||||
return m.d.Song.Patch[m.d.InstrIndex].Units[m.d.UnitIndex].Disabled
|
||||
}
|
||||
func (m *UnitDisabled) setValue(val bool) {
|
||||
func (m *UnitDisabled) SetValue(val bool) {
|
||||
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
|
||||
return
|
||||
}
|
||||
@ -201,9 +201,9 @@ func (m *UnitDisabled) Enabled() bool {
|
||||
|
||||
// LoopToggle methods
|
||||
|
||||
func (m *LoopToggle) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) LoopToggle() Bool { return MakeEnabledBool((*LoopToggle)(m)) }
|
||||
func (m *LoopToggle) Value() bool { return m.loop.Length > 0 }
|
||||
func (t *LoopToggle) setValue(val bool) {
|
||||
func (t *LoopToggle) SetValue(val bool) {
|
||||
m := (*Model)(t)
|
||||
newLoop := Loop{}
|
||||
if val {
|
||||
@ -213,25 +213,22 @@ func (t *LoopToggle) setValue(val bool) {
|
||||
}
|
||||
m.setLoop(newLoop)
|
||||
}
|
||||
func (m *LoopToggle) Enabled() bool { return true }
|
||||
|
||||
// UniquePatterns methods
|
||||
|
||||
func (m *UniquePatterns) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) UniquePatterns() Bool { return MakeEnabledBool((*UniquePatterns)(m)) }
|
||||
func (m *UniquePatterns) Value() bool { return m.uniquePatterns }
|
||||
func (m *UniquePatterns) setValue(val bool) { m.uniquePatterns = val }
|
||||
func (m *UniquePatterns) Enabled() bool { return true }
|
||||
func (m *UniquePatterns) SetValue(val bool) { m.uniquePatterns = val }
|
||||
|
||||
// Mute methods
|
||||
|
||||
func (m *Mute) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Mute() Bool { return MakeBool((*Mute)(m)) }
|
||||
func (m *Mute) Value() bool {
|
||||
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
|
||||
return false
|
||||
}
|
||||
return m.d.Song.Patch[m.d.InstrIndex].Mute
|
||||
}
|
||||
func (m *Mute) setValue(val bool) {
|
||||
func (m *Mute) SetValue(val bool) {
|
||||
if m.d.InstrIndex < 0 || m.d.InstrIndex >= len(m.d.Song.Patch) {
|
||||
return
|
||||
}
|
||||
@ -248,7 +245,7 @@ func (m *Mute) Enabled() bool { return m.d.InstrIndex >= 0 && m.d.InstrIndex < l
|
||||
|
||||
// Solo methods
|
||||
|
||||
func (m *Solo) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) Solo() Bool { return MakeBool((*Solo)(m)) }
|
||||
func (m *Solo) Value() bool {
|
||||
a, b := min(m.d.InstrIndex, m.d.InstrIndex2), max(m.d.InstrIndex, m.d.InstrIndex2)
|
||||
for i := range m.d.Song.Patch {
|
||||
@ -261,7 +258,7 @@ func (m *Solo) Value() bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *Solo) setValue(val bool) {
|
||||
func (m *Solo) SetValue(val bool) {
|
||||
defer (*Model)(m).change("Solo", PatchChange, MinorChange)()
|
||||
a, b := min(m.d.InstrIndex, m.d.InstrIndex2), max(m.d.InstrIndex, m.d.InstrIndex2)
|
||||
for i := range m.d.Song.Patch {
|
||||
@ -275,7 +272,6 @@ func (m *Solo) Enabled() bool { return m.d.InstrIndex >= 0 && m.d.InstrIndex < l
|
||||
|
||||
// LinkInstrTrack methods
|
||||
|
||||
func (m *LinkInstrTrack) Bool() Bool { return Bool{m} }
|
||||
func (m *Model) LinkInstrTrack() Bool { return MakeEnabledBool((*LinkInstrTrack)(m)) }
|
||||
func (m *LinkInstrTrack) Value() bool { return m.linkInstrTrack }
|
||||
func (m *LinkInstrTrack) setValue(val bool) { m.linkInstrTrack = val }
|
||||
func (m *LinkInstrTrack) Enabled() bool { return true }
|
||||
func (m *LinkInstrTrack) SetValue(val bool) { m.linkInstrTrack = val }
|
||||
|
@ -70,17 +70,17 @@ type (
|
||||
func NewInstrumentEditor(model *tracker.Model) *InstrumentEditor {
|
||||
ret := &InstrumentEditor{
|
||||
newInstrumentBtn: NewActionClickable(model.AddInstrument()),
|
||||
enlargeBtn: NewBoolClickable(model.InstrEnlarged().Bool()),
|
||||
enlargeBtn: NewBoolClickable(model.InstrEnlarged()),
|
||||
deleteInstrumentBtn: NewActionClickable(model.DeleteInstrument()),
|
||||
linkInstrTrackBtn: NewBoolClickable(model.LinkInstrTrack().Bool()),
|
||||
linkInstrTrackBtn: NewBoolClickable(model.LinkInstrTrack()),
|
||||
splitInstrumentBtn: NewActionClickable(model.SplitInstrument()),
|
||||
copyInstrumentBtn: new(TipClickable),
|
||||
saveInstrumentBtn: new(TipClickable),
|
||||
loadInstrumentBtn: new(TipClickable),
|
||||
commentExpandBtn: NewBoolClickable(model.CommentExpanded().Bool()),
|
||||
commentExpandBtn: NewBoolClickable(model.CommentExpanded()),
|
||||
presetMenuBtn: new(TipClickable),
|
||||
soloBtn: NewBoolClickable(model.Solo().Bool()),
|
||||
muteBtn: NewBoolClickable(model.Mute().Bool()),
|
||||
soloBtn: NewBoolClickable(model.Solo()),
|
||||
muteBtn: NewBoolClickable(model.Mute()),
|
||||
commentEditor: NewEditor(widget.Editor{}),
|
||||
nameEditor: NewEditor(widget.Editor{SingleLine: true, Submit: true, Alignment: text.Middle}),
|
||||
searchEditor: NewEditor(widget.Editor{SingleLine: true, Submit: true, Alignment: text.Start}),
|
||||
@ -429,11 +429,11 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
}
|
||||
}
|
||||
}
|
||||
t.UnitSearching().Bool().Set(false)
|
||||
t.UnitSearching().SetValue(false)
|
||||
ie.searchEditor.SetText(str.Value())
|
||||
}
|
||||
for ie.searchEditor.Cancelled(gtx) {
|
||||
t.UnitSearching().Bool().Set(false)
|
||||
t.UnitSearching().SetValue(false)
|
||||
ie.searchEditor.SetText(str.Value())
|
||||
ie.unitDragList.Focus()
|
||||
}
|
||||
@ -485,11 +485,11 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
ie.unitEditor.sliderList.Focus()
|
||||
case key.NameDeleteBackward:
|
||||
t.Units().SetSelectedType("")
|
||||
t.UnitSearching().Bool().Set(true)
|
||||
t.UnitSearching().SetValue(true)
|
||||
gtx.Execute(key.FocusCmd{Tag: &ie.searchEditor.Editor})
|
||||
case key.NameEnter, key.NameReturn:
|
||||
t.Model.AddUnit(e.Modifiers.Contain(key.ModCtrl)).Do()
|
||||
t.UnitSearching().Bool().Set(true)
|
||||
t.UnitSearching().SetValue(true)
|
||||
gtx.Execute(key.FocusCmd{Tag: &ie.searchEditor.Editor})
|
||||
}
|
||||
}
|
||||
|
@ -129,28 +129,28 @@ func (t *Tracker) KeyEvent(e key.Event, gtx C) {
|
||||
case "RemoveUnused":
|
||||
t.RemoveUnused().Do()
|
||||
case "PlayCurrentPosFollow":
|
||||
t.Follow().Bool().Set(true)
|
||||
t.Follow().SetValue(true)
|
||||
t.PlayCurrentPos().Do()
|
||||
case "PlayCurrentPosUnfollow":
|
||||
t.Follow().Bool().Set(false)
|
||||
t.Follow().SetValue(false)
|
||||
t.PlayCurrentPos().Do()
|
||||
case "PlaySongStartFollow":
|
||||
t.Follow().Bool().Set(true)
|
||||
t.Follow().SetValue(true)
|
||||
t.PlaySongStart().Do()
|
||||
case "PlaySongStartUnfollow":
|
||||
t.Follow().Bool().Set(false)
|
||||
t.Follow().SetValue(false)
|
||||
t.PlaySongStart().Do()
|
||||
case "PlaySelectedFollow":
|
||||
t.Follow().Bool().Set(true)
|
||||
t.Follow().SetValue(true)
|
||||
t.PlaySelected().Do()
|
||||
case "PlaySelectedUnfollow":
|
||||
t.Follow().Bool().Set(false)
|
||||
t.Follow().SetValue(false)
|
||||
t.PlaySelected().Do()
|
||||
case "PlayLoopFollow":
|
||||
t.Follow().Bool().Set(true)
|
||||
t.Follow().SetValue(true)
|
||||
t.PlayFromLoopStart().Do()
|
||||
case "PlayLoopUnfollow":
|
||||
t.Follow().Bool().Set(false)
|
||||
t.Follow().SetValue(false)
|
||||
t.PlayFromLoopStart().Do()
|
||||
case "StopPlaying":
|
||||
t.StopPlaying().Do()
|
||||
@ -186,33 +186,33 @@ func (t *Tracker) KeyEvent(e key.Event, gtx C) {
|
||||
t.SplitInstrument().Do()
|
||||
// Booleans
|
||||
case "PanicToggle":
|
||||
t.Panic().Bool().Toggle()
|
||||
t.Panic().Toggle()
|
||||
case "RecordingToggle":
|
||||
t.IsRecording().Bool().Toggle()
|
||||
t.IsRecording().Toggle()
|
||||
case "PlayingToggleFollow":
|
||||
t.Follow().Bool().Set(true)
|
||||
t.Playing().Bool().Toggle()
|
||||
t.Follow().SetValue(true)
|
||||
t.Playing().Toggle()
|
||||
case "PlayingToggleUnfollow":
|
||||
t.Follow().Bool().Set(false)
|
||||
t.Playing().Bool().Toggle()
|
||||
t.Follow().SetValue(false)
|
||||
t.Playing().Toggle()
|
||||
case "InstrEnlargedToggle":
|
||||
t.InstrEnlarged().Bool().Toggle()
|
||||
t.InstrEnlarged().Toggle()
|
||||
case "LinkInstrTrackToggle":
|
||||
t.LinkInstrTrack().Bool().Toggle()
|
||||
t.LinkInstrTrack().Toggle()
|
||||
case "CommentExpandedToggle":
|
||||
t.CommentExpanded().Bool().Toggle()
|
||||
t.CommentExpanded().Toggle()
|
||||
case "FollowToggle":
|
||||
t.Follow().Bool().Toggle()
|
||||
t.Follow().Toggle()
|
||||
case "UnitDisabledToggle":
|
||||
t.UnitDisabled().Bool().Toggle()
|
||||
t.UnitDisabled().Toggle()
|
||||
case "LoopToggle":
|
||||
t.LoopToggle().Bool().Toggle()
|
||||
t.LoopToggle().Toggle()
|
||||
case "UniquePatternsToggle":
|
||||
t.UniquePatterns().Bool().Toggle()
|
||||
t.UniquePatterns().Toggle()
|
||||
case "MuteToggle":
|
||||
t.Mute().Bool().Toggle()
|
||||
t.Mute().Toggle()
|
||||
case "SoloToggle":
|
||||
t.Solo().Bool().Toggle()
|
||||
t.Solo().Toggle()
|
||||
// Integers
|
||||
case "InstrumentVoicesAdd":
|
||||
t.Model.InstrumentVoices().Int().Add(1)
|
||||
|
@ -85,9 +85,9 @@ func NewNoteEditor(model *tracker.Model) *NoteEditor {
|
||||
AddOctaveBtn: NewActionClickable(model.AddOctave()),
|
||||
SubtractOctaveBtn: NewActionClickable(model.SubtractOctave()),
|
||||
NoteOffBtn: NewActionClickable(model.EditNoteOff()),
|
||||
EffectBtn: NewBoolClickable(model.Effect().Bool()),
|
||||
UniqueBtn: NewBoolClickable(model.UniquePatterns().Bool()),
|
||||
TrackMidiInBtn: NewBoolClickable(model.TrackMidiIn().Bool()),
|
||||
EffectBtn: NewBoolClickable(model.Effect()),
|
||||
UniqueBtn: NewBoolClickable(model.UniquePatterns()),
|
||||
TrackMidiInBtn: NewBoolClickable(model.TrackMidiIn()),
|
||||
scrollTable: NewScrollTable(
|
||||
model.Notes().Table(),
|
||||
model.Tracks().List(),
|
||||
|
@ -45,8 +45,8 @@ type (
|
||||
|
||||
func NewOscilloscope(model *tracker.Model) *OscilloscopeState {
|
||||
return &OscilloscopeState{
|
||||
onceBtn: NewBoolClickable(model.SignalAnalyzer().Once().Bool()),
|
||||
wrapBtn: NewBoolClickable(model.SignalAnalyzer().Wrap().Bool()),
|
||||
onceBtn: NewBoolClickable(model.SignalAnalyzer().Once()),
|
||||
wrapBtn: NewBoolClickable(model.SignalAnalyzer().Wrap()),
|
||||
lengthInBeatsNumber: NewNumberInput(model.SignalAnalyzer().LengthInBeats().Int()),
|
||||
triggerChannelNumber: NewNumberInput(model.SignalAnalyzer().TriggerChannel().Int()),
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ func (s *SongPanel) Update(gtx C, t *Tracker) {
|
||||
t.Model.DetectorWeighting().Int().Set((t.DetectorWeighting().Value() + 1) % int(tracker.NumWeightingTypes))
|
||||
}
|
||||
for s.OversamplingBtn.Clicked(gtx) {
|
||||
t.Model.Oversampling().Bool().Set(!t.Oversampling().Value())
|
||||
t.Model.Oversampling().SetValue(!t.Oversampling().Value())
|
||||
}
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ func NewMenuBar(model *tracker.Model) *MenuBar {
|
||||
ret := &MenuBar{
|
||||
Clickables: make([]Clickable, 3),
|
||||
Menus: make([]Menu, 3),
|
||||
PanicBtn: NewBoolClickable(model.Panic().Bool()),
|
||||
PanicBtn: NewBoolClickable(model.Panic()),
|
||||
panicHint: makeHint("Panic", " (%s)", "PanicToggle"),
|
||||
}
|
||||
ret.fileMenuItems = []MenuItem{
|
||||
@ -369,10 +369,10 @@ type PlayBar struct {
|
||||
|
||||
func NewPlayBar(model *tracker.Model) *PlayBar {
|
||||
ret := &PlayBar{
|
||||
LoopBtn: NewBoolClickable(model.LoopToggle().Bool()),
|
||||
RecordBtn: NewBoolClickable(model.IsRecording().Bool()),
|
||||
FollowBtn: NewBoolClickable(model.Follow().Bool()),
|
||||
PlayingBtn: NewBoolClickable(model.Playing().Bool()),
|
||||
LoopBtn: NewBoolClickable(model.LoopToggle()),
|
||||
RecordBtn: NewBoolClickable(model.IsRecording()),
|
||||
FollowBtn: NewBoolClickable(model.Follow()),
|
||||
PlayingBtn: NewBoolClickable(model.Playing()),
|
||||
RewindBtn: NewActionClickable(model.PlaySongStart()),
|
||||
}
|
||||
ret.rewindHint = makeHint("Rewind", "\n(%s)", "PlaySongStartUnfollow")
|
||||
|
@ -46,7 +46,7 @@ func NewUnitEditor(m *tracker.Model) *UnitEditor {
|
||||
ret := &UnitEditor{
|
||||
DeleteUnitBtn: NewActionClickable(m.DeleteUnit()),
|
||||
ClearUnitBtn: NewActionClickable(m.ClearUnit()),
|
||||
DisableUnitBtn: NewBoolClickable(m.UnitDisabled().Bool()),
|
||||
DisableUnitBtn: NewBoolClickable(m.UnitDisabled()),
|
||||
CopyUnitBtn: new(TipClickable),
|
||||
SelectTypeBtn: new(Clickable),
|
||||
commentEditor: NewEditor(widget.Editor{SingleLine: true, Submit: true}),
|
||||
|
@ -61,15 +61,15 @@ func (s *modelFuzzState) Iterate(yield func(string, func(p string, t *testing.T)
|
||||
s.IterateList("OrderRows", s.model.OrderRows().List(), yield, seed)
|
||||
s.IterateList("NoteRows", s.model.NoteRows().List(), yield, seed)
|
||||
s.IterateList("UnitSearchResults", s.model.SearchResults().List(), yield, seed)
|
||||
s.IterateBool("Panic", s.model.Panic().Bool(), yield, seed)
|
||||
s.IterateBool("Recording", s.model.IsRecording().Bool(), yield, seed)
|
||||
s.IterateBool("Playing", s.model.Playing().Bool(), yield, seed)
|
||||
s.IterateBool("InstrEnlarged", s.model.InstrEnlarged().Bool(), yield, seed)
|
||||
s.IterateBool("Effect", s.model.Effect().Bool(), yield, seed)
|
||||
s.IterateBool("CommentExpanded", s.model.CommentExpanded().Bool(), yield, seed)
|
||||
s.IterateBool("Follow", s.model.Follow().Bool(), yield, seed)
|
||||
s.IterateBool("UniquePatterns", s.model.UniquePatterns().Bool(), yield, seed)
|
||||
s.IterateBool("LinkInstrTrack", s.model.LinkInstrTrack().Bool(), yield, seed)
|
||||
s.IterateBool("Panic", s.model.Panic(), yield, seed)
|
||||
s.IterateBool("Recording", s.model.IsRecording(), yield, seed)
|
||||
s.IterateBool("Playing", s.model.Playing(), yield, seed)
|
||||
s.IterateBool("InstrEnlarged", s.model.InstrEnlarged(), yield, seed)
|
||||
s.IterateBool("Effect", s.model.Effect(), yield, seed)
|
||||
s.IterateBool("CommentExpanded", s.model.CommentExpanded(), yield, seed)
|
||||
s.IterateBool("Follow", s.model.Follow(), yield, seed)
|
||||
s.IterateBool("UniquePatterns", s.model.UniquePatterns(), yield, seed)
|
||||
s.IterateBool("LinkInstrTrack", s.model.LinkInstrTrack(), yield, seed)
|
||||
// Strings
|
||||
s.IterateString("FilePath", s.model.FilePath().String(), yield, seed)
|
||||
s.IterateString("InstrumentName", s.model.InstrumentName().String(), yield, seed)
|
||||
@ -153,7 +153,7 @@ func (s *modelFuzzState) IterateAction(name string, a tracker.Action, yield func
|
||||
|
||||
func (s *modelFuzzState) IterateBool(name string, b tracker.Bool, yield func(string, func(p string, t *testing.T)) bool, seed int) {
|
||||
yield(name+".Set", func(p string, t *testing.T) {
|
||||
b.Set(seed%2 == 0)
|
||||
b.SetValue(seed%2 == 0)
|
||||
})
|
||||
yield(name+".Toggle", func(p string, t *testing.T) {
|
||||
b.Toggle()
|
||||
|
@ -67,20 +67,16 @@ func NewScopeModel(broker *Broker, bpm int) *ScopeModel {
|
||||
|
||||
func (s *ScopeModel) Waveform() RingBuffer[[2]float32] { return s.waveForm }
|
||||
|
||||
func (s *ScopeModel) Once() *SignalOnce { return (*SignalOnce)(s) }
|
||||
func (s *ScopeModel) Wrap() *SignalWrap { return (*SignalWrap)(s) }
|
||||
func (s *ScopeModel) Once() Bool { return MakeEnabledBool((*SignalOnce)(s)) }
|
||||
func (s *ScopeModel) Wrap() Bool { return MakeEnabledBool((*SignalWrap)(s)) }
|
||||
func (s *ScopeModel) LengthInBeats() *SignalLengthInBeats { return (*SignalLengthInBeats)(s) }
|
||||
func (s *ScopeModel) TriggerChannel() *TriggerChannel { return (*TriggerChannel)(s) }
|
||||
|
||||
func (m *SignalOnce) Bool() Bool { return Bool{m} }
|
||||
func (m *SignalOnce) Value() bool { return m.once }
|
||||
func (m *SignalOnce) setValue(val bool) { m.once = val }
|
||||
func (m *SignalOnce) Enabled() bool { return true }
|
||||
func (m *SignalOnce) SetValue(val bool) { m.once = val }
|
||||
|
||||
func (m *SignalWrap) Bool() Bool { return Bool{m} }
|
||||
func (m *SignalWrap) Value() bool { return m.wrap }
|
||||
func (m *SignalWrap) setValue(val bool) { m.wrap = val }
|
||||
func (m *SignalWrap) Enabled() bool { return true }
|
||||
func (m *SignalWrap) SetValue(val bool) { m.wrap = val }
|
||||
|
||||
func (m *SignalLengthInBeats) Int() Int { return Int{m} }
|
||||
func (m *SignalLengthInBeats) Value() int { return m.lengthInBeats }
|
||||
|
Reference in New Issue
Block a user