mirror of
https://github.com/vsariola/sointu.git
synced 2025-08-02 04:15:15 -04:00
feat: UI work to facilitate future improvements in midi-into-track-input
This commit is contained in:
@ -48,7 +48,9 @@ type NumericUpDownStyle struct {
|
||||
Tooltip component.Tooltip
|
||||
Width unit.Dp
|
||||
Height unit.Dp
|
||||
Padding unit.Dp
|
||||
shaper text.Shaper
|
||||
Hidden bool
|
||||
}
|
||||
|
||||
func NewNumberInput(v tracker.Int) *NumberInput {
|
||||
@ -56,6 +58,10 @@ func NewNumberInput(v tracker.Int) *NumberInput {
|
||||
}
|
||||
|
||||
func NumericUpDown(th *material.Theme, number *NumberInput, tooltip string) NumericUpDownStyle {
|
||||
return NumericUpDownPadded(th, number, tooltip, 0)
|
||||
}
|
||||
|
||||
func NumericUpDownPadded(th *material.Theme, number *NumberInput, tooltip string, padding int) NumericUpDownStyle {
|
||||
bgColor := th.Palette.Fg
|
||||
bgColor.R /= 4
|
||||
bgColor.G /= 4
|
||||
@ -74,11 +80,22 @@ func NumericUpDown(th *material.Theme, number *NumberInput, tooltip string) Nume
|
||||
Tooltip: Tooltip(th, tooltip),
|
||||
Width: unit.Dp(70),
|
||||
Height: unit.Dp(20),
|
||||
Padding: unit.Dp(padding),
|
||||
shaper: *th.Shaper,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *NumericUpDownStyle) Layout(gtx C) D {
|
||||
if s.Hidden {
|
||||
return D{}
|
||||
}
|
||||
if s.Padding <= 0 {
|
||||
return s.layoutWithTooltip(gtx)
|
||||
}
|
||||
return layout.UniformInset(s.Padding).Layout(gtx, s.layoutWithTooltip)
|
||||
}
|
||||
|
||||
func (s *NumericUpDownStyle) layoutWithTooltip(gtx C) D {
|
||||
if s.Tooltip.Text.Text != "" {
|
||||
return s.NumberInput.tipArea.Layout(gtx, s.Tooltip, s.actualLayout)
|
||||
}
|
||||
|
Reference in New Issue
Block a user