feat(tracker): add button for deleting instrument

This commit is contained in:
vsariola
2021-01-30 22:55:27 +02:00
parent 6c97b5e736
commit 22c433b3e4
3 changed files with 49 additions and 0 deletions

View File

@ -44,10 +44,41 @@ func (t *Tracker) layoutInstruments() layout.Widget {
}),
)
}),
layout.Rigid(t.layoutInstrumentHeader()),
layout.Flexed(1, t.layoutInstrumentEditor()))
}
}
func (t *Tracker) layoutInstrumentHeader() layout.Widget {
headerBg := func(gtx C) D {
paint.FillShape(gtx.Ops, trackMenuSurfaceColor, clip.Rect{
Max: gtx.Constraints.Min,
}.Op())
return layout.Dimensions{Size: gtx.Constraints.Min}
}
header := func(gtx C) D {
deleteInstrumentBtnStyle := material.IconButton(t.Theme, t.DeleteInstrumentBtn, deleteIcon)
deleteInstrumentBtnStyle.Background = transparent
deleteInstrumentBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
if len(t.song.Patch.Instruments) > 1 {
deleteInstrumentBtnStyle.Color = primaryColor
} else {
deleteInstrumentBtnStyle.Color = disabledTextColor
}
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Flexed(1, func(gtx C) D { return layout.Dimensions{Size: gtx.Constraints.Min} }),
layout.Rigid(deleteInstrumentBtnStyle.Layout))
}
for t.DeleteInstrumentBtn.Clicked() {
t.DeleteInstrument()
}
return func(gtx C) D {
return layout.Stack{Alignment: layout.Center}.Layout(gtx,
layout.Expanded(headerBg),
layout.Stacked(header))
}
}
func (t *Tracker) layoutInstrumentNames() layout.Widget {
return func(gtx C) D {
gtx.Constraints.Max.Y = gtx.Px(unit.Dp(36))