mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 21:02:52 -05:00
drafting
This commit is contained in:
parent
e5a2fbec51
commit
0bd652dcbb
@ -66,7 +66,13 @@ func (e *Editor) Layout(gtx C, str tracker.String, th *Theme, style *EditorStyle
|
||||
// just consume all events if the user did not consume them
|
||||
}
|
||||
if e.widgetEditor.Text() != str.Value() {
|
||||
line, col := e.widgetEditor.CaretPos()
|
||||
// if the user has moved the caret, put it in the end
|
||||
e.widgetEditor.SetText(str.Value())
|
||||
if line > 0 || col > 0 {
|
||||
l := len(e.widgetEditor.Text())
|
||||
e.widgetEditor.SetCaret(l, l)
|
||||
}
|
||||
}
|
||||
me := material.Editor(&th.Material, &e.widgetEditor, hint)
|
||||
me.Font = style.Font
|
||||
|
||||
55
tracker/gioui/instrument_presets.go
Normal file
55
tracker/gioui/instrument_presets.go
Normal file
@ -0,0 +1,55 @@
|
||||
package gioui
|
||||
|
||||
import (
|
||||
"gioui.org/layout"
|
||||
"gioui.org/text"
|
||||
"gioui.org/unit"
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
)
|
||||
|
||||
type (
|
||||
InstrumentPresets struct {
|
||||
searchEditor *Editor
|
||||
gmDlsBtn *Clickable
|
||||
userPresetsBtn *Clickable
|
||||
builtinPresetsBtn *Clickable
|
||||
clearSearchBtn *Clickable
|
||||
dirList *DragList
|
||||
resultList *DragList
|
||||
}
|
||||
)
|
||||
|
||||
func NewInstrumentPresets(m *tracker.Model) *InstrumentPresets {
|
||||
return &InstrumentPresets{
|
||||
searchEditor: NewEditor(false, false, text.Start),
|
||||
gmDlsBtn: new(Clickable),
|
||||
clearSearchBtn: new(Clickable),
|
||||
userPresetsBtn: new(Clickable),
|
||||
builtinPresetsBtn: new(Clickable),
|
||||
dirList: NewDragList(m.Instruments().List(), layout.Vertical),
|
||||
resultList: NewDragList(m.Instruments().List(), layout.Vertical),
|
||||
}
|
||||
}
|
||||
|
||||
func (ip *InstrumentPresets) layout(gtx C) D {
|
||||
// get tracker from values
|
||||
tr := TrackerFromContext(gtx)
|
||||
gmDlsBtn := ToggleBtn(tr.NoGmDls(), tr.Theme, ip.gmDlsBtn, "No gm.dls", "Exclude presets using gm.dls")
|
||||
userPresetsFilterBtn := ToggleBtn(tr.UserPresetFilter(), tr.Theme, ip.userPresetsBtn, "User", "Show only user presets")
|
||||
builtinPresetsFilterBtn := ToggleBtn(tr.BuiltinPresetsFilter(), tr.Theme, ip.builtinPresetsBtn, "Builtin", "Show only builtin presets")
|
||||
// layout
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Rigid(func(gtx C) D {
|
||||
return layout.UniformInset(unit.Dp(4)).Layout(gtx, func(gtx C) D {
|
||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||
layout.Flexed(1, func(gtx C) D {
|
||||
return ip.searchEditor.Layout(gtx, tr.Model.PresetSearchString(), tr.Theme, &tr.Theme.InstrumentEditor.InstrumentComment, "Search presets")
|
||||
}),
|
||||
layout.Rigid(userPresetsFilterBtn.Layout),
|
||||
layout.Rigid(builtinPresetsFilterBtn.Layout),
|
||||
layout.Rigid(gmDlsBtn.Layout),
|
||||
)
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
@ -20,11 +20,12 @@ import (
|
||||
|
||||
type (
|
||||
PatchPanel struct {
|
||||
instrList InstrumentList
|
||||
tools InstrumentTools
|
||||
unitList UnitList
|
||||
unitEditor UnitEditor
|
||||
instrProps InstrumentProperties
|
||||
instrList InstrumentList
|
||||
tools InstrumentTools
|
||||
unitList UnitList
|
||||
unitEditor UnitEditor
|
||||
instrProps InstrumentProperties
|
||||
instrPresets InstrumentPresets
|
||||
}
|
||||
|
||||
InstrumentList struct {
|
||||
@ -66,11 +67,12 @@ type (
|
||||
|
||||
func NewPatchPanel(model *tracker.Model) *PatchPanel {
|
||||
return &PatchPanel{
|
||||
instrList: MakeInstrList(model),
|
||||
tools: MakeInstrumentTools(model),
|
||||
unitList: MakeUnitList(model),
|
||||
unitEditor: *NewUnitEditor(model),
|
||||
instrProps: *NewInstrumentProperties(),
|
||||
instrList: MakeInstrList(model),
|
||||
tools: MakeInstrumentTools(model),
|
||||
unitList: MakeUnitList(model),
|
||||
unitEditor: *NewUnitEditor(model),
|
||||
instrProps: *NewInstrumentProperties(),
|
||||
instrPresets: *NewInstrumentPresets(model),
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +83,7 @@ func (pp *PatchPanel) Layout(gtx C) D {
|
||||
case tr.InstrComment().Value():
|
||||
return pp.instrProps.layout(gtx)
|
||||
case tr.InstrPresets().Value():
|
||||
return pp.instrProps.layout(gtx)
|
||||
return pp.instrPresets.layout(gtx)
|
||||
default: // editor
|
||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||
layout.Rigid(pp.unitList.Layout),
|
||||
|
||||
Reference in New Issue
Block a user