mirror of
https://github.com/vsariola/sointu.git
synced 2025-11-12 21:02:52 -05:00
refactor(tracker/gioui): combine UnitList & UnitEditor structs
This commit is contained in:
parent
48dc4a35bb
commit
91c9701f14
@ -28,18 +28,11 @@ import (
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
InstrumentEditor struct {
|
InstrumentEditor struct {
|
||||||
unitList UnitList
|
|
||||||
unitEditor UnitEditor
|
|
||||||
}
|
|
||||||
|
|
||||||
UnitList struct {
|
|
||||||
dragList *DragList
|
dragList *DragList
|
||||||
searchEditor *Editor
|
searchEditor *Editor
|
||||||
addUnitBtn *Clickable
|
addUnitBtn *Clickable
|
||||||
addUnitAction tracker.Action
|
addUnitAction tracker.Action
|
||||||
}
|
|
||||||
|
|
||||||
UnitEditor struct {
|
|
||||||
paramTable *ScrollTable
|
paramTable *ScrollTable
|
||||||
searchList *DragList
|
searchList *DragList
|
||||||
Parameters [][]*ParamState
|
Parameters [][]*ParamState
|
||||||
@ -59,43 +52,51 @@ type (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func MakeInstrumentEditor(model *tracker.Model) InstrumentEditor {
|
func NewInstrumentEditor(m *tracker.Model) *InstrumentEditor {
|
||||||
return InstrumentEditor{
|
ret := &InstrumentEditor{
|
||||||
unitList: MakeUnitList(model),
|
dragList: NewDragList(m.Units().List(), layout.Vertical),
|
||||||
unitEditor: *NewUnitEditor(model),
|
addUnitBtn: new(Clickable),
|
||||||
}
|
searchEditor: NewEditor(true, true, text.Start),
|
||||||
}
|
DeleteUnitBtn: new(Clickable),
|
||||||
|
ClearUnitBtn: new(Clickable),
|
||||||
func (ie *InstrumentEditor) layout(gtx C) D {
|
DisableUnitBtn: new(Clickable),
|
||||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
CopyUnitBtn: new(Clickable),
|
||||||
layout.Rigid(ie.unitList.Layout),
|
SelectTypeBtn: new(Clickable),
|
||||||
layout.Flexed(1, ie.unitEditor.Layout),
|
commentEditor: NewEditor(true, true, text.Start),
|
||||||
)
|
paramTable: NewScrollTable(m.Params().Table(), m.ParamVertList().List(), m.Units().List()),
|
||||||
}
|
searchList: NewDragList(m.SearchResults().List(), layout.Vertical),
|
||||||
|
searching: m.UnitSearching(),
|
||||||
func (ie *InstrumentEditor) Tags(level int, yield TagYieldFunc) bool {
|
|
||||||
return ie.unitList.Tags(level, yield) &&
|
|
||||||
ie.unitEditor.Tags(level, yield)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnitList methods
|
|
||||||
|
|
||||||
func MakeUnitList(m *tracker.Model) UnitList {
|
|
||||||
ret := UnitList{
|
|
||||||
dragList: NewDragList(m.Units().List(), layout.Vertical),
|
|
||||||
addUnitBtn: new(Clickable),
|
|
||||||
searchEditor: NewEditor(true, true, text.Start),
|
|
||||||
}
|
}
|
||||||
ret.addUnitAction = tracker.MakeEnabledAction(tracker.DoFunc(func() {
|
ret.addUnitAction = tracker.MakeEnabledAction(tracker.DoFunc(func() {
|
||||||
m.AddUnit(false).Do()
|
m.AddUnit(false).Do()
|
||||||
ret.searchEditor.Focus()
|
ret.searchEditor.Focus()
|
||||||
}))
|
}))
|
||||||
|
ret.caser = cases.Title(language.English)
|
||||||
|
ret.copyHint = makeHint("Copy unit", " (%s)", "Copy")
|
||||||
|
ret.disableUnitHint = makeHint("Disable unit", " (%s)", "UnitDisabledToggle")
|
||||||
|
ret.enableUnitHint = makeHint("Enable unit", " (%s)", "UnitDisabledToggle")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ul *UnitList) Layout(gtx C) D {
|
func (ie *InstrumentEditor) layout(gtx C) D {
|
||||||
|
ie.update(gtx)
|
||||||
|
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||||
|
layout.Rigid(ie.layoutList),
|
||||||
|
layout.Flexed(1, ie.layoutTable),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ie *InstrumentEditor) Tags(level int, yield TagYieldFunc) bool {
|
||||||
|
ret := yield(level, ie.dragList) && yield(level+1, &ie.searchEditor.widgetEditor)
|
||||||
|
if ie.searching.Value() {
|
||||||
|
ret = ret && yield(level, ie.searchList) && yield(level+1, &ie.commentEditor.widgetEditor)
|
||||||
|
}
|
||||||
|
return ret && yield(level+1, ie.paramTable.RowTitleList) && yield(level, ie.paramTable) && yield(level+1, &ie.commentEditor.widgetEditor)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ul *InstrumentEditor) layoutList(gtx C) D {
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
ul.update(gtx, t)
|
|
||||||
element := func(gtx C, i int) D {
|
element := func(gtx C, i int) D {
|
||||||
gtx.Constraints.Max.Y = gtx.Dp(20)
|
gtx.Constraints.Max.Y = gtx.Dp(20)
|
||||||
gtx.Constraints.Min.Y = gtx.Constraints.Max.Y
|
gtx.Constraints.Min.Y = gtx.Constraints.Max.Y
|
||||||
@ -153,18 +154,17 @@ func (ul *UnitList) Layout(gtx C) D {
|
|||||||
return Surface{Gray: 30, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, surface)
|
return Surface{Gray: 30, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, surface)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ul *UnitList) update(gtx C, t *Tracker) {
|
func (ul *InstrumentEditor) update(gtx C) {
|
||||||
for ul.addUnitBtn.Clicked(gtx) {
|
t := TrackerFromContext(gtx)
|
||||||
ul.addUnitAction.Do()
|
|
||||||
t.UnitSearching().SetValue(true)
|
|
||||||
ul.searchEditor.Focus()
|
|
||||||
}
|
|
||||||
for {
|
for {
|
||||||
event, ok := gtx.Event(
|
event, ok := gtx.Event(
|
||||||
key.Filter{Focus: ul.dragList, Name: key.NameRightArrow},
|
key.Filter{Focus: ul.dragList, Name: key.NameRightArrow},
|
||||||
key.Filter{Focus: ul.dragList, Name: key.NameEnter, Optional: key.ModCtrl},
|
key.Filter{Focus: ul.dragList, Name: key.NameEnter, Optional: key.ModCtrl},
|
||||||
key.Filter{Focus: ul.dragList, Name: key.NameReturn, Optional: key.ModCtrl},
|
key.Filter{Focus: ul.dragList, Name: key.NameReturn, Optional: key.ModCtrl},
|
||||||
key.Filter{Focus: ul.dragList, Name: key.NameDeleteBackward},
|
key.Filter{Focus: ul.dragList, Name: key.NameDeleteBackward},
|
||||||
|
key.Filter{Focus: ul.paramTable.RowTitleList, Name: key.NameEnter, Optional: key.ModCtrl},
|
||||||
|
key.Filter{Focus: ul.paramTable.RowTitleList, Name: key.NameReturn, Optional: key.ModCtrl},
|
||||||
|
key.Filter{Focus: ul.paramTable.RowTitleList, Name: key.NameDeleteBackward},
|
||||||
)
|
)
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
@ -172,7 +172,7 @@ func (ul *UnitList) update(gtx C, t *Tracker) {
|
|||||||
if e, ok := event.(key.Event); ok && e.State == key.Press {
|
if e, ok := event.(key.Event); ok && e.State == key.Press {
|
||||||
switch e.Name {
|
switch e.Name {
|
||||||
case key.NameRightArrow:
|
case key.NameRightArrow:
|
||||||
t.PatchPanel.instrEditor.unitEditor.paramTable.RowTitleList.Focus()
|
t.PatchPanel.instrEditor.paramTable.RowTitleList.Focus()
|
||||||
case key.NameDeleteBackward:
|
case key.NameDeleteBackward:
|
||||||
t.Units().SetSelectedType("")
|
t.Units().SetSelectedType("")
|
||||||
t.UnitSearching().SetValue(true)
|
t.UnitSearching().SetValue(true)
|
||||||
@ -201,74 +201,34 @@ func (ul *UnitList) update(gtx C, t *Tracker) {
|
|||||||
ul.dragList.Focus()
|
ul.dragList.Focus()
|
||||||
t.UnitSearching().SetValue(false)
|
t.UnitSearching().SetValue(false)
|
||||||
}
|
}
|
||||||
}
|
for ul.addUnitBtn.Clicked(gtx) {
|
||||||
|
ul.addUnitAction.Do()
|
||||||
func (ul *UnitList) Tags(curLevel int, yield TagYieldFunc) bool {
|
t.UnitSearching().SetValue(true)
|
||||||
return yield(curLevel, ul.dragList) && yield(curLevel+1, &ul.searchEditor.widgetEditor)
|
ul.searchEditor.Focus()
|
||||||
}
|
|
||||||
|
|
||||||
func NewUnitEditor(m *tracker.Model) *UnitEditor {
|
|
||||||
ret := &UnitEditor{
|
|
||||||
DeleteUnitBtn: new(Clickable),
|
|
||||||
ClearUnitBtn: new(Clickable),
|
|
||||||
DisableUnitBtn: new(Clickable),
|
|
||||||
CopyUnitBtn: new(Clickable),
|
|
||||||
SelectTypeBtn: new(Clickable),
|
|
||||||
commentEditor: NewEditor(true, true, text.Start),
|
|
||||||
paramTable: NewScrollTable(m.Params().Table(), m.ParamVertList().List(), m.Units().List()),
|
|
||||||
searchList: NewDragList(m.SearchResults().List(), layout.Vertical),
|
|
||||||
searching: m.UnitSearching(),
|
|
||||||
}
|
}
|
||||||
ret.caser = cases.Title(language.English)
|
for ul.CopyUnitBtn.Clicked(gtx) {
|
||||||
ret.copyHint = makeHint("Copy unit", " (%s)", "Copy")
|
|
||||||
ret.disableUnitHint = makeHint("Disable unit", " (%s)", "UnitDisabledToggle")
|
|
||||||
ret.enableUnitHint = makeHint("Enable unit", " (%s)", "UnitDisabledToggle")
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pe *UnitEditor) Layout(gtx C) D {
|
|
||||||
t := TrackerFromContext(gtx)
|
|
||||||
pe.update(gtx, t)
|
|
||||||
editorFunc := pe.layoutRack
|
|
||||||
if pe.showingChooser() {
|
|
||||||
editorFunc = pe.layoutUnitTypeChooser
|
|
||||||
}
|
|
||||||
return Surface{Gray: 24, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D {
|
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
|
||||||
layout.Flexed(1, editorFunc),
|
|
||||||
layout.Rigid(pe.layoutFooter),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pe *UnitEditor) showingChooser() bool {
|
|
||||||
return pe.searching.Value()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
|
||||||
for pe.CopyUnitBtn.Clicked(gtx) {
|
|
||||||
if contents, ok := t.Units().List().CopyElements(); ok {
|
if contents, ok := t.Units().List().CopyElements(); ok {
|
||||||
gtx.Execute(clipboard.WriteCmd{Type: "application/text", Data: io.NopCloser(bytes.NewReader(contents))})
|
gtx.Execute(clipboard.WriteCmd{Type: "application/text", Data: io.NopCloser(bytes.NewReader(contents))})
|
||||||
t.Alerts().Add("Unit(s) copied to clipboard", tracker.Info)
|
t.Alerts().Add("Unit(s) copied to clipboard", tracker.Info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for pe.SelectTypeBtn.Clicked(gtx) {
|
for ul.SelectTypeBtn.Clicked(gtx) {
|
||||||
pe.ChooseUnitType(t)
|
ul.ChooseUnitType(t)
|
||||||
}
|
}
|
||||||
for pe.commentEditor.Update(gtx, t.UnitComment()) != EditorEventNone {
|
for ul.commentEditor.Update(gtx, t.UnitComment()) != EditorEventNone {
|
||||||
t.FocusPrev(gtx, false)
|
t.FocusPrev(gtx, false)
|
||||||
}
|
}
|
||||||
for pe.ClearUnitBtn.Clicked(gtx) {
|
for ul.ClearUnitBtn.Clicked(gtx) {
|
||||||
t.ClearUnit().Do()
|
t.ClearUnit().Do()
|
||||||
t.UnitSearch().SetValue("")
|
t.UnitSearch().SetValue("")
|
||||||
t.UnitSearching().SetValue(true)
|
t.UnitSearching().SetValue(true)
|
||||||
pe.searchList.Focus()
|
ul.searchList.Focus()
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
e, ok := gtx.Event(
|
e, ok := gtx.Event(
|
||||||
key.Filter{Focus: pe.searchList, Name: key.NameEnter},
|
key.Filter{Focus: ul.searchList, Name: key.NameEnter},
|
||||||
key.Filter{Focus: pe.searchList, Name: key.NameReturn},
|
key.Filter{Focus: ul.searchList, Name: key.NameReturn},
|
||||||
key.Filter{Focus: pe.searchList, Name: key.NameEscape},
|
key.Filter{Focus: ul.searchList, Name: key.NameEscape},
|
||||||
)
|
)
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
@ -277,18 +237,18 @@ func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
|||||||
switch e.Name {
|
switch e.Name {
|
||||||
case key.NameEscape:
|
case key.NameEscape:
|
||||||
t.UnitSearching().SetValue(false)
|
t.UnitSearching().SetValue(false)
|
||||||
pe.paramTable.RowTitleList.Focus()
|
ul.paramTable.RowTitleList.Focus()
|
||||||
case key.NameEnter, key.NameReturn:
|
case key.NameEnter, key.NameReturn:
|
||||||
pe.ChooseUnitType(t)
|
ul.ChooseUnitType(t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
e, ok := gtx.Event(
|
e, ok := gtx.Event(
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameLeftArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
key.Filter{Focus: ul.paramTable, Name: key.NameLeftArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameRightArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
key.Filter{Focus: ul.paramTable, Name: key.NameRightArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteBackward},
|
key.Filter{Focus: ul.paramTable, Name: key.NameDeleteBackward},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteForward},
|
key.Filter{Focus: ul.paramTable, Name: key.NameDeleteForward},
|
||||||
)
|
)
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
@ -303,50 +263,46 @@ func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
|||||||
t.Model.Params().Table().Clear()
|
t.Model.Params().Table().Clear()
|
||||||
}
|
}
|
||||||
c := t.Model.Params().Cursor()
|
c := t.Model.Params().Cursor()
|
||||||
if c.X >= 0 && c.Y >= 0 && c.Y < len(pe.Parameters) && c.X < len(pe.Parameters[c.Y]) {
|
if c.X >= 0 && c.Y >= 0 && c.Y < len(ul.Parameters) && c.X < len(ul.Parameters[c.Y]) {
|
||||||
ta := &pe.Parameters[c.Y][c.X].tipArea
|
ta := &ul.Parameters[c.Y][c.X].tipArea
|
||||||
ta.Appear(gtx.Now)
|
ta.Appear(gtx.Now)
|
||||||
ta.Exit.SetTarget(gtx.Now.Add(ta.ExitDuration))
|
ta.Exit.SetTarget(gtx.Now.Add(ta.ExitDuration))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
e, ok := gtx.Event(
|
e, ok := gtx.Event(key.Filter{Focus: ul.paramTable.RowTitleList, Name: key.NameLeftArrow})
|
||||||
key.Filter{Focus: pe.paramTable.RowTitleList, Name: key.NameEnter},
|
|
||||||
key.Filter{Focus: pe.paramTable.RowTitleList, Name: key.NameReturn},
|
|
||||||
key.Filter{Focus: pe.paramTable.RowTitleList, Name: key.NameLeftArrow},
|
|
||||||
key.Filter{Focus: pe.paramTable.RowTitleList, Name: key.NameDeleteBackward},
|
|
||||||
)
|
|
||||||
if !ok {
|
if !ok {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if e, ok := e.(key.Event); ok && e.State == key.Press {
|
if e, ok := e.(key.Event); ok && e.State == key.Press && e.Name == key.NameLeftArrow {
|
||||||
switch e.Name {
|
t.PatchPanel.instrEditor.dragList.Focus()
|
||||||
case key.NameLeftArrow:
|
|
||||||
t.PatchPanel.instrEditor.unitList.dragList.Focus()
|
|
||||||
case key.NameDeleteBackward:
|
|
||||||
t.ClearUnit().Do()
|
|
||||||
t.UnitSearch().SetValue("")
|
|
||||||
t.UnitSearching().SetValue(true)
|
|
||||||
pe.searchList.Focus()
|
|
||||||
case key.NameEnter, key.NameReturn:
|
|
||||||
t.Model.AddUnit(e.Modifiers.Contain(key.ModCtrl)).Do()
|
|
||||||
t.UnitSearch().SetValue("")
|
|
||||||
t.UnitSearching().SetValue(true)
|
|
||||||
pe.searchList.Focus()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) ChooseUnitType(t *Tracker) {
|
func (pe *InstrumentEditor) layoutTable(gtx C) D {
|
||||||
|
t := TrackerFromContext(gtx)
|
||||||
|
editorFunc := pe.layoutRack
|
||||||
|
if pe.searching.Value() {
|
||||||
|
editorFunc = pe.layoutUnitTypeChooser
|
||||||
|
}
|
||||||
|
return Surface{Gray: 24, Focus: t.PatchPanel.TreeFocused(gtx)}.Layout(gtx, func(gtx C) D {
|
||||||
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
|
layout.Flexed(1, editorFunc),
|
||||||
|
layout.Rigid(pe.layoutFooter),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pe *InstrumentEditor) ChooseUnitType(t *Tracker) {
|
||||||
if ut, ok := t.SearchResults().Item(pe.searchList.TrackerList.Selected()); ok {
|
if ut, ok := t.SearchResults().Item(pe.searchList.TrackerList.Selected()); ok {
|
||||||
t.Units().SetSelectedType(ut)
|
t.Units().SetSelectedType(ut)
|
||||||
pe.paramTable.RowTitleList.Focus()
|
pe.paramTable.RowTitleList.Focus()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) layoutRack(gtx C) D {
|
func (pe *InstrumentEditor) layoutRack(gtx C) D {
|
||||||
defer clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Push(gtx.Ops).Pop()
|
defer clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Push(gtx.Ops).Pop()
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
// create enough parameter widget to match the number of parameters
|
// create enough parameter widget to match the number of parameters
|
||||||
@ -436,7 +392,7 @@ func (pe *UnitEditor) layoutRack(gtx C) D {
|
|||||||
return dims
|
return dims
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) drawSignals(gtx C, rowTitleWidth int) {
|
func (pe *InstrumentEditor) drawSignals(gtx C, rowTitleWidth int) {
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
colP := pe.paramTable.ColTitleList.List.Position
|
colP := pe.paramTable.ColTitleList.List.Position
|
||||||
rowP := pe.paramTable.RowTitleList.List.Position
|
rowP := pe.paramTable.RowTitleList.List.Position
|
||||||
@ -461,7 +417,7 @@ func (pe *UnitEditor) drawSignals(gtx C, rowTitleWidth int) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) drawBackGround(gtx C) {
|
func (pe *InstrumentEditor) drawBackGround(gtx C) {
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
rowP := pe.paramTable.RowTitleList.List.Position
|
rowP := pe.paramTable.RowTitleList.List.Position
|
||||||
defer op.Offset(image.Pt(0, -rowP.Offset)).Push(gtx.Ops).Pop()
|
defer op.Offset(image.Pt(0, -rowP.Offset)).Push(gtx.Ops).Pop()
|
||||||
@ -471,14 +427,14 @@ func (pe *UnitEditor) drawBackGround(gtx C) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) drawRemoteSendSignal(gtx C, wire tracker.Wire, col, row int) {
|
func (pe *InstrumentEditor) drawRemoteSendSignal(gtx C, wire tracker.Wire, col, row int) {
|
||||||
sy := wire.From - row
|
sy := wire.From - row
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
defer op.Offset(image.Pt(gtx.Dp(5), (sy+1)*gtx.Dp(t.Theme.UnitEditor.Height)-gtx.Dp(16))).Push(gtx.Ops).Pop()
|
defer op.Offset(image.Pt(gtx.Dp(5), (sy+1)*gtx.Dp(t.Theme.UnitEditor.Height)-gtx.Dp(16))).Push(gtx.Ops).Pop()
|
||||||
Label(t.Theme, &t.Theme.UnitEditor.WireHint, wire.Hint).Layout(gtx)
|
Label(t.Theme, &t.Theme.UnitEditor.WireHint, wire.Hint).Layout(gtx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) drawRemoteReceiveSignal(gtx C, wire tracker.Wire, col, row int, clr color.NRGBA) {
|
func (pe *InstrumentEditor) drawRemoteReceiveSignal(gtx C, wire tracker.Wire, col, row int, clr color.NRGBA) {
|
||||||
ex := wire.To.X - col
|
ex := wire.To.X - col
|
||||||
ey := wire.To.Y - row
|
ey := wire.To.Y - row
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
@ -506,7 +462,7 @@ func (pe *UnitEditor) drawRemoteReceiveSignal(gtx C, wire tracker.Wire, col, row
|
|||||||
Label(t.Theme, &t.Theme.UnitEditor.WireHint, wire.Hint).Layout(gtx)
|
Label(t.Theme, &t.Theme.UnitEditor.WireHint, wire.Hint).Layout(gtx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) drawSignal(gtx C, wire tracker.Wire, col, row int, clr color.NRGBA) {
|
func (pe *InstrumentEditor) drawSignal(gtx C, wire tracker.Wire, col, row int, clr color.NRGBA) {
|
||||||
sy := wire.From - row
|
sy := wire.From - row
|
||||||
ex := wire.To.X - col
|
ex := wire.To.X - col
|
||||||
ey := wire.To.Y - row
|
ey := wire.To.Y - row
|
||||||
@ -551,7 +507,7 @@ func mulVec(a, b f32.Point) f32.Point {
|
|||||||
return f32.Pt(a.X*b.X, a.Y*b.Y)
|
return f32.Pt(a.X*b.X, a.Y*b.Y)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) layoutFooter(gtx C) D {
|
func (pe *InstrumentEditor) layoutFooter(gtx C) D {
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
text := "Choose unit type"
|
text := "Choose unit type"
|
||||||
if !t.UnitSearching().Value() {
|
if !t.UnitSearching().Value() {
|
||||||
@ -577,7 +533,7 @@ func (pe *UnitEditor) layoutFooter(gtx C) D {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pe *UnitEditor) layoutUnitTypeChooser(gtx C) D {
|
func (pe *InstrumentEditor) layoutUnitTypeChooser(gtx C) D {
|
||||||
t := TrackerFromContext(gtx)
|
t := TrackerFromContext(gtx)
|
||||||
var namesArray [256]string
|
var namesArray [256]string
|
||||||
names := namesArray[:0]
|
names := namesArray[:0]
|
||||||
@ -600,10 +556,3 @@ func (pe *UnitEditor) layoutUnitTypeChooser(gtx C) D {
|
|||||||
fdl.LayoutScrollBar(gtx)
|
fdl.LayoutScrollBar(gtx)
|
||||||
return dims
|
return dims
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *UnitEditor) Tags(level int, yield TagYieldFunc) bool {
|
|
||||||
if t.showingChooser() {
|
|
||||||
return yield(level, t.searchList) && yield(level+1, &t.commentEditor.widgetEditor)
|
|
||||||
}
|
|
||||||
return yield(level+1, t.paramTable.RowTitleList) && yield(level, t.paramTable) && yield(level+1, &t.commentEditor.widgetEditor)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -62,7 +62,7 @@ type (
|
|||||||
|
|
||||||
func NewPatchPanel(model *tracker.Model) *PatchPanel {
|
func NewPatchPanel(model *tracker.Model) *PatchPanel {
|
||||||
return &PatchPanel{
|
return &PatchPanel{
|
||||||
instrEditor: MakeInstrumentEditor(model),
|
instrEditor: *NewInstrumentEditor(model),
|
||||||
instrList: MakeInstrList(model),
|
instrList: MakeInstrList(model),
|
||||||
tools: MakeInstrumentTools(model),
|
tools: MakeInstrumentTools(model),
|
||||||
instrProps: *NewInstrumentProperties(),
|
instrProps: *NewInstrumentProperties(),
|
||||||
|
|||||||
Reference in New Issue
Block a user