mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
drafting
This commit is contained in:
parent
ec8c51b003
commit
dd564815d4
@ -259,6 +259,7 @@ type ButtonStyle struct {
|
|||||||
TextSize unit.Sp
|
TextSize unit.Sp
|
||||||
Background color.NRGBA
|
Background color.NRGBA
|
||||||
CornerRadius unit.Dp
|
CornerRadius unit.Dp
|
||||||
|
Height unit.Dp
|
||||||
Inset layout.Inset
|
Inset layout.Inset
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,8 +305,9 @@ func IconButton(th *material.Theme, button *Clickable, icon *widget.Icon, descri
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b Button) Layout(gtx layout.Context) layout.Dimensions {
|
func (b *Button) Layout(gtx layout.Context) layout.Dimensions {
|
||||||
min := gtx.Constraints.Min
|
min := gtx.Constraints.Min
|
||||||
|
min.Y = gtx.Dp(b.Height)
|
||||||
return b.Button.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
return b.Button.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||||
semantic.Button.Add(gtx.Ops)
|
semantic.Button.Add(gtx.Ops)
|
||||||
return layout.Background{}.Layout(gtx,
|
return layout.Background{}.Layout(gtx,
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"gioui.org/io/key"
|
"gioui.org/io/key"
|
||||||
"gioui.org/layout"
|
"gioui.org/layout"
|
||||||
"gioui.org/op/paint"
|
"gioui.org/op/paint"
|
||||||
"gioui.org/text"
|
|
||||||
"gioui.org/unit"
|
"gioui.org/unit"
|
||||||
"gioui.org/widget"
|
"gioui.org/widget"
|
||||||
"gioui.org/widget/material"
|
"gioui.org/widget/material"
|
||||||
@ -28,7 +27,7 @@ type DialogStyle struct {
|
|||||||
AltStyle material.ButtonStyle
|
AltStyle material.ButtonStyle
|
||||||
OkStyle material.ButtonStyle
|
OkStyle material.ButtonStyle
|
||||||
CancelStyle material.ButtonStyle
|
CancelStyle material.ButtonStyle
|
||||||
Shaper *text.Shaper
|
Theme *Theme
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDialog(ok, alt, cancel tracker.Action) *Dialog {
|
func NewDialog(ok, alt, cancel tracker.Action) *Dialog {
|
||||||
@ -37,22 +36,22 @@ func NewDialog(ok, alt, cancel tracker.Action) *Dialog {
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func ConfirmDialog(gtx C, th *material.Theme, dialog *Dialog, title, text string) DialogStyle {
|
func ConfirmDialog(gtx C, th *Theme, dialog *Dialog, title, text string) DialogStyle {
|
||||||
ret := DialogStyle{
|
ret := DialogStyle{
|
||||||
dialog: dialog,
|
dialog: dialog,
|
||||||
Title: title,
|
Title: title,
|
||||||
Text: text,
|
Text: text,
|
||||||
Inset: layout.Inset{Top: unit.Dp(12), Bottom: unit.Dp(12), Left: unit.Dp(20), Right: unit.Dp(20)},
|
Inset: layout.Inset{Top: unit.Dp(12), Bottom: unit.Dp(12), Left: unit.Dp(20), Right: unit.Dp(20)},
|
||||||
TextInset: layout.Inset{Top: unit.Dp(12), Bottom: unit.Dp(12)},
|
TextInset: layout.Inset{Top: unit.Dp(12), Bottom: unit.Dp(12)},
|
||||||
AltStyle: material.Button(th, &dialog.BtnAlt, "Alt"),
|
AltStyle: material.Button(&th.Material, &dialog.BtnAlt, "Alt"),
|
||||||
OkStyle: material.Button(th, &dialog.BtnOk, "Ok"),
|
OkStyle: material.Button(&th.Material, &dialog.BtnOk, "Ok"),
|
||||||
CancelStyle: material.Button(th, &dialog.BtnCancel, "Cancel"),
|
CancelStyle: material.Button(&th.Material, &dialog.BtnCancel, "Cancel"),
|
||||||
Shaper: th.Shaper,
|
Theme: th,
|
||||||
}
|
}
|
||||||
for _, b := range [...]*material.ButtonStyle{&ret.AltStyle, &ret.OkStyle, &ret.CancelStyle} {
|
for _, b := range [...]*material.ButtonStyle{&ret.AltStyle, &ret.OkStyle, &ret.CancelStyle} {
|
||||||
b.Background = transparent
|
b.Background = transparent
|
||||||
b.Inset = layout.UniformInset(unit.Dp(6))
|
b.Inset = layout.UniformInset(unit.Dp(6))
|
||||||
b.Color = th.Palette.Fg
|
b.Color = th.Material.Palette.Fg
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@ -107,16 +106,13 @@ func (d *DialogStyle) Layout(gtx C) D {
|
|||||||
}
|
}
|
||||||
d.dialog.handleKeys(gtx)
|
d.dialog.handleKeys(gtx)
|
||||||
paint.Fill(gtx.Ops, dialogBgColor)
|
paint.Fill(gtx.Ops, dialogBgColor)
|
||||||
text := func(gtx C) D {
|
|
||||||
return d.TextInset.Layout(gtx, LabelStyle{Text: d.Text, Color: highEmphasisTextColor, Font: labelDefaultFont, FontSize: unit.Sp(14), Shaper: d.Shaper}.Layout)
|
|
||||||
}
|
|
||||||
visible := true
|
visible := true
|
||||||
return layout.Center.Layout(gtx, func(gtx C) D {
|
return layout.Center.Layout(gtx, func(gtx C) D {
|
||||||
return Popup(&visible).Layout(gtx, func(gtx C) D {
|
return Popup(&visible).Layout(gtx, func(gtx C) D {
|
||||||
return d.Inset.Layout(gtx, func(gtx C) D {
|
return d.Inset.Layout(gtx, func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(Label(d.Title, highEmphasisTextColor, d.Shaper)),
|
layout.Rigid(Label(d.Theme, &d.Theme.Dialog.Title, d.Title).Layout),
|
||||||
layout.Rigid(text),
|
layout.Rigid(Label(d.Theme, &d.Theme.Dialog.Text, d.Text).Layout),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layout.E.Layout(gtx, func(gtx C) D {
|
return layout.E.Layout(gtx, func(gtx C) D {
|
||||||
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(120))
|
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(120))
|
||||||
|
@ -144,7 +144,7 @@ func (ie *InstrumentEditor) Layout(gtx C, t *Tracker) D {
|
|||||||
return ie.layoutInstrumentList(gtx, t)
|
return ie.layoutInstrumentList(gtx, t)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(layout.Spacer{Width: 10}.Layout),
|
layout.Rigid(layout.Spacer{Width: 10}.Layout),
|
||||||
layout.Rigid(LabelStyle{Text: "Octave", Color: disabledTextColor, Alignment: layout.W, FontSize: t.Theme.Material.TextSize * 14.0 / 16.0, Shaper: t.Theme.Material.Shaper}.Layout),
|
layout.Rigid(Label(t.Theme, &t.Theme.InstrumentEditor.Octave, "Octave").Layout),
|
||||||
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
||||||
layout.Rigid(octave),
|
layout.Rigid(octave),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
@ -186,7 +186,7 @@ func (ie *InstrumentEditor) layoutInstrumentHeader(gtx C, t *Tracker) D {
|
|||||||
soloBtnStyle := ToggleIcon(gtx, &t.Theme.Material, ie.soloBtn, icons.SocialGroup, icons.SocialPerson, ie.soloHint, ie.unsoloHint)
|
soloBtnStyle := ToggleIcon(gtx, &t.Theme.Material, ie.soloBtn, icons.SocialGroup, icons.SocialPerson, ie.soloHint, ie.unsoloHint)
|
||||||
muteBtnStyle := ToggleIcon(gtx, &t.Theme.Material, ie.muteBtn, icons.AVVolumeUp, icons.AVVolumeOff, ie.muteHint, ie.unmuteHint)
|
muteBtnStyle := ToggleIcon(gtx, &t.Theme.Material, ie.muteBtn, icons.AVVolumeUp, icons.AVVolumeOff, ie.muteHint, ie.unmuteHint)
|
||||||
|
|
||||||
m := PopupMenu(&ie.presetMenu, t.Theme.Material.Shaper)
|
m := PopupMenu(t.Theme, &ie.presetMenu)
|
||||||
|
|
||||||
for ie.copyInstrumentBtn.Clickable.Clicked(gtx) {
|
for ie.copyInstrumentBtn.Clickable.Clicked(gtx) {
|
||||||
if contents, ok := t.Instruments().List().CopyElements(); ok {
|
if contents, ok := t.Instruments().List().CopyElements(); ok {
|
||||||
@ -214,7 +214,7 @@ func (ie *InstrumentEditor) layoutInstrumentHeader(gtx C, t *Tracker) D {
|
|||||||
header := func(gtx C) D {
|
header := func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(layout.Spacer{Width: 6}.Layout),
|
layout.Rigid(layout.Spacer{Width: 6}.Layout),
|
||||||
layout.Rigid(LabelStyle{Text: "Voices", Color: disabledTextColor, Alignment: layout.W, FontSize: t.Theme.Material.TextSize * 14.0 / 16.0, Shaper: t.Theme.Material.Shaper}.Layout),
|
layout.Rigid(Label(t.Theme, &t.Theme.InstrumentEditor.Voices, "Voices").Layout),
|
||||||
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
||||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||||
numStyle := NumUpDown(t.Theme, t.InstrumentVoices, "Number of voices for this instrument")
|
numStyle := NumUpDown(t.Theme, t.InstrumentVoices, "Number of voices for this instrument")
|
||||||
@ -274,29 +274,30 @@ func (ie *InstrumentEditor) layoutInstrumentList(gtx C, t *Tracker) D {
|
|||||||
element := func(gtx C, i int) D {
|
element := func(gtx C, i int) D {
|
||||||
gtx.Constraints.Min.Y = gtx.Dp(unit.Dp(36))
|
gtx.Constraints.Min.Y = gtx.Dp(unit.Dp(36))
|
||||||
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(30))
|
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(30))
|
||||||
grabhandle := LabelStyle{Text: strconv.Itoa(i + 1), ShadeColor: black, Color: mediumEmphasisTextColor, FontSize: unit.Sp(10), Alignment: layout.Center, Shaper: t.Theme.Material.Shaper}
|
grabhandle := Label(t.Theme, &t.Theme.InstrumentEditor.InstrumentNumber, strconv.Itoa(i+1))
|
||||||
label := func(gtx C) D {
|
label := func(gtx C) D {
|
||||||
name, level, mute, ok := (*tracker.Instruments)(t.Model).Item(i)
|
name, level, mute, ok := (*tracker.Instruments)(t.Model).Item(i)
|
||||||
if !ok {
|
if !ok {
|
||||||
labelStyle := LabelStyle{Text: "", ShadeColor: black, Color: white, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
labelStyle := Label(t.Theme, &t.Theme.InstrumentEditor.InstrumentName, "")
|
||||||
return layout.Center.Layout(gtx, labelStyle.Layout)
|
return layout.Center.Layout(gtx, labelStyle.Layout)
|
||||||
}
|
}
|
||||||
k := byte(255 - level*127)
|
k := byte(255 - level*127)
|
||||||
color := color.NRGBA{R: 255, G: k, B: 255, A: 255}
|
color := color.NRGBA{R: 255, G: k, B: 255, A: 255}
|
||||||
|
s := t.Theme.InstrumentEditor.InstrumentName
|
||||||
|
if mute {
|
||||||
|
s = t.Theme.InstrumentEditor.InstrumentNameMuted
|
||||||
|
}
|
||||||
|
s.Color = color
|
||||||
if i == ie.instrumentDragList.TrackerList.Selected() {
|
if i == ie.instrumentDragList.TrackerList.Selected() {
|
||||||
ie.nameEditor.SetText(name)
|
ie.nameEditor.SetText(name)
|
||||||
for ie.nameEditor.Submitted(gtx) || ie.nameEditor.Cancelled(gtx) {
|
for ie.nameEditor.Submitted(gtx) || ie.nameEditor.Cancelled(gtx) {
|
||||||
ie.instrumentDragList.Focus()
|
ie.instrumentDragList.Focus()
|
||||||
}
|
}
|
||||||
style := MaterialEditor(&t.Theme.Material, ie.nameEditor, "Instr")
|
style := MaterialEditor(&t.Theme.Material, ie.nameEditor, "Instr")
|
||||||
style.Color = color
|
style.Color = s.Color
|
||||||
style.HintColor = instrumentNameHintColor
|
style.HintColor = instrumentNameHintColor
|
||||||
style.TextSize = unit.Sp(12)
|
style.TextSize = s.TextSize
|
||||||
style.Font = labelDefaultFont
|
style.Font = s.Font
|
||||||
if mute {
|
|
||||||
style.Color = disabledTextColor
|
|
||||||
style.Font.Style = font.Italic
|
|
||||||
}
|
|
||||||
dims := layout.Center.Layout(gtx, func(gtx C) D {
|
dims := layout.Center.Layout(gtx, func(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()
|
||||||
return style.Layout(gtx)
|
return style.Layout(gtx)
|
||||||
@ -307,12 +308,7 @@ func (ie *InstrumentEditor) layoutInstrumentList(gtx C, t *Tracker) D {
|
|||||||
if name == "" {
|
if name == "" {
|
||||||
name = "Instr"
|
name = "Instr"
|
||||||
}
|
}
|
||||||
labelStyle := LabelStyle{Text: name, ShadeColor: black, Color: color, Font: labelDefaultFont, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
return layout.Center.Layout(gtx, Label(t.Theme, &s, name).Layout)
|
||||||
if mute {
|
|
||||||
labelStyle.Color = disabledTextColor
|
|
||||||
labelStyle.Font.Style = font.Italic
|
|
||||||
}
|
|
||||||
return layout.Center.Layout(gtx, labelStyle.Layout)
|
|
||||||
}
|
}
|
||||||
return layout.Inset{Left: unit.Dp(6), Right: unit.Dp(6), Top: unit.Dp(4)}.Layout(gtx, func(gtx C) D {
|
return layout.Inset{Left: unit.Dp(6), Right: unit.Dp(6), Top: unit.Dp(4)}.Layout(gtx, func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
|
||||||
@ -409,7 +405,8 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
|||||||
f.Style = font.Italic
|
f.Style = font.Italic
|
||||||
}
|
}
|
||||||
|
|
||||||
stackLabel := LabelStyle{Text: stackText, ShadeColor: black, Color: mediumEmphasisTextColor, Font: labelDefaultFont, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
stackLabel := Label(t.Theme, &t.Theme.InstrumentEditor.UnitList.Stack, stackText)
|
||||||
|
|
||||||
rightMargin := layout.Inset{Right: unit.Dp(10)}
|
rightMargin := layout.Inset{Right: unit.Dp(10)}
|
||||||
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
@ -444,15 +441,15 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
|||||||
str.Set(ie.searchEditor.Text())
|
str.Set(ie.searchEditor.Text())
|
||||||
return ret
|
return ret
|
||||||
} else {
|
} else {
|
||||||
unitNameLabel := LabelStyle{Text: u.Type, ShadeColor: black, Color: color, Font: f, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
text := u.Type
|
||||||
if unitNameLabel.Text == "" {
|
if text == "" {
|
||||||
unitNameLabel.Text = "---"
|
text = "---"
|
||||||
}
|
}
|
||||||
return unitNameLabel.Layout(gtx)
|
return Label(t.Theme, &t.Theme.InstrumentEditor.UnitList.Name, text).Layout(gtx)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
layout.Flexed(1, func(gtx C) D {
|
layout.Flexed(1, func(gtx C) D {
|
||||||
unitNameLabel := LabelStyle{Text: u.Comment, ShadeColor: black, Color: mediumEmphasisTextColor, Font: f, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
unitNameLabel := Label(t.Theme, &t.Theme.InstrumentEditor.UnitList.Comment, u.Comment)
|
||||||
inset := layout.Inset{Left: unit.Dp(5)}
|
inset := layout.Inset{Left: unit.Dp(5)}
|
||||||
return inset.Layout(gtx, unitNameLabel.Layout)
|
return inset.Layout(gtx, unitNameLabel.Layout)
|
||||||
}),
|
}),
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
"image/color"
|
"image/color"
|
||||||
|
|
||||||
"gioui.org/font"
|
"gioui.org/font"
|
||||||
"gioui.org/layout"
|
|
||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
"gioui.org/op/paint"
|
"gioui.org/op/paint"
|
||||||
"gioui.org/text"
|
"gioui.org/text"
|
||||||
@ -14,37 +13,38 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LabelStyle struct {
|
type LabelStyle struct {
|
||||||
Text string
|
|
||||||
Color color.NRGBA
|
Color color.NRGBA
|
||||||
ShadeColor color.NRGBA
|
ShadowColor color.NRGBA
|
||||||
Alignment layout.Direction
|
Alignment text.Alignment
|
||||||
Font font.Font
|
Font font.Font
|
||||||
FontSize unit.Sp
|
TextSize unit.Sp
|
||||||
|
}
|
||||||
|
|
||||||
|
type LabelWidget struct {
|
||||||
|
Text string
|
||||||
Shaper *text.Shaper
|
Shaper *text.Shaper
|
||||||
|
LabelStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l LabelStyle) Layout(gtx layout.Context) layout.Dimensions {
|
func (l LabelWidget) Layout(gtx C) D {
|
||||||
return l.Alignment.Layout(gtx, func(gtx C) D {
|
textColorMacro := op.Record(gtx.Ops)
|
||||||
gtx.Constraints.Min = image.Point{}
|
|
||||||
paint.ColorOp{Color: l.ShadeColor}.Add(gtx.Ops)
|
|
||||||
offs := op.Offset(image.Pt(2, 2)).Push(gtx.Ops)
|
|
||||||
widget.Label{
|
|
||||||
Alignment: text.Start,
|
|
||||||
MaxLines: 1,
|
|
||||||
}.Layout(gtx, l.Shaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
|
||||||
offs.Pop()
|
|
||||||
paint.ColorOp{Color: l.Color}.Add(gtx.Ops)
|
paint.ColorOp{Color: l.Color}.Add(gtx.Ops)
|
||||||
dims := widget.Label{
|
textColor := textColorMacro.Stop()
|
||||||
Alignment: text.Start,
|
t := widget.Label{
|
||||||
|
Alignment: l.Alignment,
|
||||||
MaxLines: 1,
|
MaxLines: 1,
|
||||||
}.Layout(gtx, l.Shaper, l.Font, l.FontSize, l.Text, op.CallOp{})
|
|
||||||
return layout.Dimensions{
|
|
||||||
Size: dims.Size,
|
|
||||||
Baseline: dims.Baseline,
|
|
||||||
}
|
}
|
||||||
})
|
if l.ShadowColor.A > 0 {
|
||||||
|
shadowColorMacro := op.Record(gtx.Ops)
|
||||||
|
paint.ColorOp{Color: l.ShadowColor}.Add(gtx.Ops)
|
||||||
|
shadowColor := shadowColorMacro.Stop()
|
||||||
|
offs := op.Offset(image.Pt(2, 2)).Push(gtx.Ops)
|
||||||
|
t.Layout(gtx, l.Shaper, l.Font, l.TextSize, l.Text, shadowColor)
|
||||||
|
offs.Pop()
|
||||||
|
}
|
||||||
|
return t.Layout(gtx, l.Shaper, l.Font, l.TextSize, l.Text, textColor)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Label(str string, color color.NRGBA, shaper *text.Shaper) layout.Widget {
|
func Label(th *Theme, style *LabelStyle, txt string) LabelWidget {
|
||||||
return LabelStyle{Text: str, Color: color, ShadeColor: black, Font: labelDefaultFont, FontSize: labelDefaultFontSize, Alignment: layout.W, Shaper: shaper}.Layout
|
return LabelWidget{Text: txt, Shaper: th.Material.Shaper, LabelStyle: *style}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"gioui.org/op"
|
"gioui.org/op"
|
||||||
"gioui.org/op/clip"
|
"gioui.org/op/clip"
|
||||||
"gioui.org/op/paint"
|
"gioui.org/op/paint"
|
||||||
"gioui.org/text"
|
|
||||||
"gioui.org/unit"
|
"gioui.org/unit"
|
||||||
"github.com/vsariola/sointu/tracker"
|
"github.com/vsariola/sointu/tracker"
|
||||||
)
|
)
|
||||||
@ -33,7 +32,7 @@ type MenuStyle struct {
|
|||||||
FontSize unit.Sp
|
FontSize unit.Sp
|
||||||
IconSize unit.Dp
|
IconSize unit.Dp
|
||||||
HoverColor color.NRGBA
|
HoverColor color.NRGBA
|
||||||
Shaper *text.Shaper
|
Theme *Theme
|
||||||
}
|
}
|
||||||
|
|
||||||
type MenuItem struct {
|
type MenuItem struct {
|
||||||
@ -105,11 +104,11 @@ func (m *MenuStyle) Layout(gtx C, items ...MenuItem) D {
|
|||||||
iconColor = mediumEmphasisTextColor
|
iconColor = mediumEmphasisTextColor
|
||||||
}
|
}
|
||||||
iconInset := layout.Inset{Left: unit.Dp(12), Right: unit.Dp(6)}
|
iconInset := layout.Inset{Left: unit.Dp(12), Right: unit.Dp(6)}
|
||||||
textLabel := LabelStyle{Text: item.Text, FontSize: m.FontSize, Color: m.TextColor, Shaper: m.Shaper}
|
textLabel := Label(m.Theme, &m.Theme.Menu.Text, item.Text)
|
||||||
if !item.Doer.Allowed() {
|
if !item.Doer.Allowed() {
|
||||||
textLabel.Color = mediumEmphasisTextColor
|
textLabel.Color = mediumEmphasisTextColor
|
||||||
}
|
}
|
||||||
shortcutLabel := LabelStyle{Text: item.ShortcutText, FontSize: m.FontSize, Color: m.ShortCutColor, Shaper: m.Shaper}
|
shortcutLabel := Label(m.Theme, &m.Theme.Menu.ShortCut, item.ShortcutText)
|
||||||
shortcutInset := layout.Inset{Left: unit.Dp(12), Right: unit.Dp(12), Bottom: unit.Dp(2), Top: unit.Dp(2)}
|
shortcutInset := layout.Inset{Left: unit.Dp(12), Right: unit.Dp(12), Bottom: unit.Dp(2), Top: unit.Dp(2)}
|
||||||
dims := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
dims := layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
@ -153,7 +152,7 @@ func (m *MenuStyle) Layout(gtx C, items ...MenuItem) D {
|
|||||||
return popup.Layout(gtx, contents)
|
return popup.Layout(gtx, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
func PopupMenu(menu *Menu, shaper *text.Shaper) MenuStyle {
|
func PopupMenu(th *Theme, menu *Menu) MenuStyle {
|
||||||
return MenuStyle{
|
return MenuStyle{
|
||||||
Menu: menu,
|
Menu: menu,
|
||||||
IconColor: white,
|
IconColor: white,
|
||||||
@ -162,7 +161,7 @@ func PopupMenu(menu *Menu, shaper *text.Shaper) MenuStyle {
|
|||||||
FontSize: unit.Sp(16),
|
FontSize: unit.Sp(16),
|
||||||
IconSize: unit.Dp(16),
|
IconSize: unit.Dp(16),
|
||||||
HoverColor: menuHoverColor,
|
HoverColor: menuHoverColor,
|
||||||
Shaper: shaper,
|
Theme: th,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,7 +169,7 @@ func (tr *Tracker) layoutMenu(gtx C, title string, clickable *Clickable, menu *M
|
|||||||
for clickable.Clicked(gtx) {
|
for clickable.Clicked(gtx) {
|
||||||
menu.Visible = true
|
menu.Visible = true
|
||||||
}
|
}
|
||||||
m := PopupMenu(menu, tr.Theme.Material.Shaper)
|
m := PopupMenu(tr.Theme, menu)
|
||||||
return func(gtx C) D {
|
return func(gtx C) D {
|
||||||
defer op.Offset(image.Point{}).Push(gtx.Ops).Pop()
|
defer op.Offset(image.Point{}).Push(gtx.Ops).Pop()
|
||||||
titleBtn := Btn(tr.Theme, &tr.Theme.MenuButton, clickable, title)
|
titleBtn := Btn(tr.Theme, &tr.Theme.MenuButton, clickable, title)
|
||||||
|
@ -176,7 +176,7 @@ func (te *NoteEditor) layoutButtons(gtx C, t *Tracker) D {
|
|||||||
layout.Rigid(effectBtnStyle.Layout),
|
layout.Rigid(effectBtnStyle.Layout),
|
||||||
layout.Rigid(uniqueBtnStyle.Layout),
|
layout.Rigid(uniqueBtnStyle.Layout),
|
||||||
layout.Rigid(layout.Spacer{Width: 10}.Layout),
|
layout.Rigid(layout.Spacer{Width: 10}.Layout),
|
||||||
layout.Rigid(LabelStyle{Text: "Voices", Color: disabledTextColor, Alignment: layout.W, FontSize: t.Theme.Material.TextSize * 14.0 / 16.0, Shaper: t.Theme.Material.Shaper}.Layout),
|
layout.Rigid(Label(t.Theme, &t.Theme.NoteEditor.Header, "Voices").Layout),
|
||||||
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
layout.Rigid(layout.Spacer{Width: 4}.Layout),
|
||||||
layout.Rigid(voiceUpDown),
|
layout.Rigid(voiceUpDown),
|
||||||
layout.Rigid(splitTrackBtnStyle.Layout),
|
layout.Rigid(splitTrackBtnStyle.Layout),
|
||||||
@ -224,13 +224,7 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
|||||||
colTitle := func(gtx C, i int) D {
|
colTitle := func(gtx C, i int) D {
|
||||||
h := gtx.Dp(trackColTitleHeight)
|
h := gtx.Dp(trackColTitleHeight)
|
||||||
gtx.Constraints = layout.Exact(image.Pt(pxWidth, h))
|
gtx.Constraints = layout.Exact(image.Pt(pxWidth, h))
|
||||||
LabelStyle{
|
Label(t.Theme, &t.Theme.NoteEditor.TrackTitle, t.Model.TrackTitle(i)).Layout(gtx)
|
||||||
Alignment: layout.N,
|
|
||||||
Text: t.Model.TrackTitle(i),
|
|
||||||
FontSize: unit.Sp(12),
|
|
||||||
Color: mediumEmphasisTextColor,
|
|
||||||
Shaper: t.Theme.Material.Shaper,
|
|
||||||
}.Layout(gtx)
|
|
||||||
return D{Size: image.Pt(pxWidth, h)}
|
return D{Size: image.Pt(pxWidth, h)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,7 @@ func (oe *OrderEditor) Layout(gtx C, t *Tracker) D {
|
|||||||
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()
|
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()
|
||||||
defer op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), -90*math.Pi/180).Offset(f32.Point{X: 0, Y: float32(h)})).Push(gtx.Ops).Pop()
|
defer op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), -90*math.Pi/180).Offset(f32.Point{X: 0, Y: float32(h)})).Push(gtx.Ops).Pop()
|
||||||
gtx.Constraints = layout.Exact(image.Pt(1e6, 1e6))
|
gtx.Constraints = layout.Exact(image.Pt(1e6, 1e6))
|
||||||
LabelStyle{
|
Label(t.Theme, &t.Theme.OrderEditor.TrackTitle, t.Model.TrackTitle(i)).Layout(gtx)
|
||||||
Alignment: layout.NW,
|
|
||||||
Text: t.Model.TrackTitle(i),
|
|
||||||
FontSize: unit.Sp(12),
|
|
||||||
Color: mediumEmphasisTextColor,
|
|
||||||
Shaper: t.Theme.Material.Shaper,
|
|
||||||
}.Layout(gtx)
|
|
||||||
return D{Size: image.Pt(gtx.Dp(patternCellWidth), h)}
|
return D{Size: image.Pt(gtx.Dp(patternCellWidth), h)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (s *Oscilloscope) Layout(gtx C) D {
|
|||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(leftSpacer),
|
layout.Rigid(leftSpacer),
|
||||||
layout.Rigid(LabelStyle{Text: "Trigger", Color: disabledTextColor, Alignment: layout.W, FontSize: s.Theme.Material.TextSize * 14.0 / 16.0, Shaper: s.Theme.Material.Shaper}.Layout),
|
layout.Rigid(Label(s.Theme, &s.Theme.SongPanel.RowHeader, "Trigger").Layout),
|
||||||
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
||||||
layout.Rigid(onceBtnStyle.Layout),
|
layout.Rigid(onceBtnStyle.Layout),
|
||||||
layout.Rigid(triggerChannelStyle.Layout),
|
layout.Rigid(triggerChannelStyle.Layout),
|
||||||
@ -80,7 +80,7 @@ func (s *Oscilloscope) Layout(gtx C) D {
|
|||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(leftSpacer),
|
layout.Rigid(leftSpacer),
|
||||||
layout.Rigid(LabelStyle{Text: "Buffer", Color: disabledTextColor, Alignment: layout.W, FontSize: s.Theme.Material.TextSize * 14.0 / 16.0, Shaper: s.Theme.Material.Shaper}.Layout),
|
layout.Rigid(Label(s.Theme, &s.Theme.SongPanel.RowHeader, "Buffer").Layout),
|
||||||
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
||||||
layout.Rigid(wrapBtnStyle.Layout),
|
layout.Rigid(wrapBtnStyle.Layout),
|
||||||
layout.Rigid(lengthNumberStyle.Layout),
|
layout.Rigid(lengthNumberStyle.Layout),
|
||||||
|
@ -20,14 +20,19 @@ type PopupAlert struct {
|
|||||||
shaper *text.Shaper
|
shaper *text.Shaper
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PopupAlertStyle struct {
|
||||||
|
Bg color.NRGBA
|
||||||
|
Text LabelStyle
|
||||||
|
}
|
||||||
|
|
||||||
var alertMargin = layout.UniformInset(unit.Dp(6))
|
var alertMargin = layout.UniformInset(unit.Dp(6))
|
||||||
var alertInset = layout.UniformInset(unit.Dp(6))
|
var alertInset = layout.UniformInset(unit.Dp(6))
|
||||||
|
|
||||||
func NewPopupAlert(alerts *tracker.Alerts, shaper *text.Shaper) *PopupAlert {
|
func NewPopupAlert(alerts *tracker.Alerts) *PopupAlert {
|
||||||
return &PopupAlert{alerts: alerts, shaper: shaper, prevUpdate: time.Now()}
|
return &PopupAlert{alerts: alerts, prevUpdate: time.Now()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *PopupAlert) Layout(gtx C) D {
|
func (a *PopupAlert) Layout(gtx C, th *Theme) D {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if a.alerts.Update(now.Sub(a.prevUpdate)) {
|
if a.alerts.Update(now.Sub(a.prevUpdate)) {
|
||||||
gtx.Execute(op.InvalidateCmd{At: now.Add(50 * time.Millisecond)})
|
gtx.Execute(op.InvalidateCmd{At: now.Add(50 * time.Millisecond)})
|
||||||
@ -36,26 +41,22 @@ func (a *PopupAlert) Layout(gtx C) D {
|
|||||||
|
|
||||||
var totalY float64 = float64(gtx.Dp(38))
|
var totalY float64 = float64(gtx.Dp(38))
|
||||||
for _, alert := range a.alerts.Iterate {
|
for _, alert := range a.alerts.Iterate {
|
||||||
var color, textColor, shadeColor color.NRGBA
|
var alertStyle *PopupAlertStyle
|
||||||
switch alert.Priority {
|
switch alert.Priority {
|
||||||
case tracker.Warning:
|
case tracker.Warning:
|
||||||
color = warningColor
|
alertStyle = &th.Alert.Warning
|
||||||
textColor = black
|
|
||||||
case tracker.Error:
|
case tracker.Error:
|
||||||
color = errorColor
|
alertStyle = &th.Alert.Error
|
||||||
textColor = black
|
|
||||||
default:
|
default:
|
||||||
color = popupSurfaceColor
|
alertStyle = &th.Alert.Info
|
||||||
textColor = white
|
|
||||||
shadeColor = black
|
|
||||||
}
|
}
|
||||||
bgWidget := func(gtx C) D {
|
bgWidget := func(gtx C) D {
|
||||||
paint.FillShape(gtx.Ops, color, clip.Rect{
|
paint.FillShape(gtx.Ops, alertStyle.Bg, clip.Rect{
|
||||||
Max: gtx.Constraints.Min,
|
Max: gtx.Constraints.Min,
|
||||||
}.Op())
|
}.Op())
|
||||||
return D{Size: gtx.Constraints.Min}
|
return D{Size: gtx.Constraints.Min}
|
||||||
}
|
}
|
||||||
labelStyle := LabelStyle{Text: alert.Message, Color: textColor, ShadeColor: shadeColor, Font: labelDefaultFont, Alignment: layout.Center, FontSize: unit.Sp(16), Shaper: a.shaper}
|
labelStyle := Label(th, &alertStyle.Text, alert.Message)
|
||||||
alertMargin.Layout(gtx, func(gtx C) D {
|
alertMargin.Layout(gtx, func(gtx C) D {
|
||||||
return layout.S.Layout(gtx, func(gtx C) D {
|
return layout.S.Layout(gtx, func(gtx C) D {
|
||||||
defer op.Offset(image.Point{}).Push(gtx.Ops).Pop()
|
defer op.Offset(image.Point{}).Push(gtx.Ops).Pop()
|
||||||
|
@ -97,8 +97,6 @@ func (s *SongPanel) Layout(gtx C, t *Tracker) D {
|
|||||||
func (t *SongPanel) layoutSongOptions(gtx C, tr *Tracker) D {
|
func (t *SongPanel) layoutSongOptions(gtx C, tr *Tracker) D {
|
||||||
paint.FillShape(gtx.Ops, songSurfaceColor, clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Op())
|
paint.FillShape(gtx.Ops, songSurfaceColor, clip.Rect(image.Rect(0, 0, gtx.Constraints.Max.X, gtx.Constraints.Max.Y)).Op())
|
||||||
|
|
||||||
scopeStyle := Scope(t.Scope, tr.SignalAnalyzer().Waveform(), tr.Theme)
|
|
||||||
|
|
||||||
var weightingTxt string
|
var weightingTxt string
|
||||||
switch tracker.WeightingType(tr.Model.DetectorWeighting().Value()) {
|
switch tracker.WeightingType(tr.Model.DetectorWeighting().Value()) {
|
||||||
case tracker.KWeighting:
|
case tracker.KWeighting:
|
||||||
@ -121,51 +119,51 @@ func (t *SongPanel) layoutSongOptions(gtx C, tr *Tracker) D {
|
|||||||
|
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return t.SongSettingsExpander.Layout(gtx, &tr.Theme.Material, "Song",
|
return t.SongSettingsExpander.Layout(gtx, tr.Theme, "Song",
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
return LabelStyle{Text: strconv.Itoa(tr.BPM().Value()) + " BPM", Color: mediumEmphasisTextColor, Alignment: layout.W, FontSize: tr.Theme.Material.TextSize * 14.0 / 16.0, Shaper: tr.Theme.Material.Shaper}.Layout(gtx)
|
return Label(tr.Theme, &tr.Theme.SongPanel.RowHeader, strconv.Itoa(tr.BPM().Value())+" BPM").Layout(gtx)
|
||||||
},
|
},
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "BPM", NumUpDown(tr.Theme, t.BPM, "Song Length").Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "BPM", NumUpDown(tr.Theme, t.BPM, "Song Length").Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Song length", NumUpDown(tr.Theme, t.SongLength, "Song Length").Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Song length", NumUpDown(tr.Theme, t.SongLength, "Song Length").Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Rows per pat", NumUpDown(tr.Theme, t.RowsPerPattern, "Rows per pattern").Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Rows per pat", NumUpDown(tr.Theme, t.RowsPerPattern, "Rows per pattern").Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Rows per beat", NumUpDown(tr.Theme, t.RowsPerBeat, "Rows per beat").Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Rows per beat", NumUpDown(tr.Theme, t.RowsPerBeat, "Rows per beat").Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Cursor step", NumUpDown(tr.Theme, t.Step, "Cursor step").Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Cursor step", NumUpDown(tr.Theme, t.Step, "Cursor step").Layout)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return t.LoudnessExpander.Layout(gtx, &tr.Theme.Material, "Loudness",
|
return t.LoudnessExpander.Layout(gtx, tr.Theme, "Loudness",
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
return LabelStyle{Text: fmt.Sprintf("%.1f dB", tr.Model.DetectorResult().Loudness[tracker.LoudnessShortTerm]), Color: mediumEmphasisTextColor, Alignment: layout.W, FontSize: tr.Theme.Material.TextSize * 14.0 / 16.0, Shaper: tr.Theme.Material.Shaper}.Layout(gtx)
|
return Label(tr.Theme, &tr.Theme.SongPanel.RowHeader, fmt.Sprintf("%.1f dB", tr.Model.DetectorResult().Loudness[tracker.LoudnessShortTerm])).Layout(gtx)
|
||||||
},
|
},
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Vertical, Alignment: layout.End}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical, Alignment: layout.End}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Momentary", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Loudness[tracker.LoudnessMomentary]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Momentary", dbLabel(tr.Theme, tr.Model.DetectorResult().Loudness[tracker.LoudnessMomentary]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Short term", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Loudness[tracker.LoudnessShortTerm]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Short term", dbLabel(tr.Theme, tr.Model.DetectorResult().Loudness[tracker.LoudnessShortTerm]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Integrated", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Loudness[tracker.LoudnessIntegrated]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Integrated", dbLabel(tr.Theme, tr.Model.DetectorResult().Loudness[tracker.LoudnessIntegrated]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Max. momentary", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Loudness[tracker.LoudnessMaxMomentary]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Max. momentary", dbLabel(tr.Theme, tr.Model.DetectorResult().Loudness[tracker.LoudnessMaxMomentary]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Max. short term", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Loudness[tracker.LoudnessMaxShortTerm]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Max. short term", dbLabel(tr.Theme, tr.Model.DetectorResult().Loudness[tracker.LoudnessMaxShortTerm]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
gtx.Constraints.Min.X = 0
|
gtx.Constraints.Min.X = 0
|
||||||
@ -176,25 +174,25 @@ func (t *SongPanel) layoutSongOptions(gtx C, tr *Tracker) D {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return t.PeakExpander.Layout(gtx, &tr.Theme.Material, "Peaks",
|
return t.PeakExpander.Layout(gtx, tr.Theme, "Peaks",
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
maxPeak := max(tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][0], tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][1])
|
maxPeak := max(tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][0], tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][1])
|
||||||
return dbLabel(&tr.Theme.Material, maxPeak).Layout(gtx)
|
return dbLabel(tr.Theme, maxPeak).Layout(gtx)
|
||||||
},
|
},
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
return layout.Flex{Axis: layout.Vertical, Alignment: layout.End}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical, Alignment: layout.End}.Layout(gtx,
|
||||||
// no need to show momentary peak, it does not have too much meaning
|
// no need to show momentary peak, it does not have too much meaning
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Short term L", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][0]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Short term L", dbLabel(tr.Theme, tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][0]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Short term R", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][1]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Short term R", dbLabel(tr.Theme, tr.Model.DetectorResult().Peaks[tracker.PeakShortTerm][1]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Integrated L", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Peaks[tracker.PeakIntegrated][0]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Integrated L", dbLabel(tr.Theme, tr.Model.DetectorResult().Peaks[tracker.PeakIntegrated][0]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
return layoutSongOptionRow(gtx, &tr.Theme.Material, "Integrated R", dbLabel(&tr.Theme.Material, tr.Model.DetectorResult().Peaks[tracker.PeakIntegrated][1]).Layout)
|
return layoutSongOptionRow(gtx, tr.Theme, "Integrated R", dbLabel(tr.Theme, tr.Model.DetectorResult().Peaks[tracker.PeakIntegrated][1]).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
gtx.Constraints.Min.X = 0
|
gtx.Constraints.Min.X = 0
|
||||||
@ -205,36 +203,27 @@ func (t *SongPanel) layoutSongOptions(gtx C, tr *Tracker) D {
|
|||||||
)
|
)
|
||||||
}),
|
}),
|
||||||
layout.Flexed(1, func(gtx C) D {
|
layout.Flexed(1, func(gtx C) D {
|
||||||
return t.ScopeExpander.Layout(gtx, &tr.Theme.Material, "Oscilloscope", func(gtx C) D { return D{} }, scopeStyle.Layout)
|
return t.ScopeExpander.Layout(gtx, tr.Theme, "Oscilloscope", func(gtx C) D { return D{} }, Scope(t.Scope, tr.SignalAnalyzer().Waveform(), tr.Theme).Layout)
|
||||||
}),
|
|
||||||
layout.Rigid(func(gtx C) D {
|
|
||||||
labelStyle := LabelStyle{Text: version.VersionOrHash, FontSize: unit.Sp(12), Color: mediumEmphasisTextColor, Shaper: tr.Theme.Material.Shaper}
|
|
||||||
return labelStyle.Layout(gtx)
|
|
||||||
}),
|
}),
|
||||||
|
layout.Rigid(Label(tr.Theme, &tr.Theme.SongPanel.Version, version.VersionOrHash).Layout),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func dbLabel(th *material.Theme, value tracker.Decibel) LabelStyle {
|
func dbLabel(th *Theme, value tracker.Decibel) LabelWidget {
|
||||||
color := mediumEmphasisTextColor
|
ret := Label(th, &th.SongPanel.RowValue, fmt.Sprintf("%.1f dB", value))
|
||||||
if value >= 0 {
|
if value >= 0 {
|
||||||
color = errorColor
|
ret.Color = th.SongPanel.ErrorColor
|
||||||
}
|
|
||||||
return LabelStyle{
|
|
||||||
Text: fmt.Sprintf("%.1f dB", value),
|
|
||||||
Color: color,
|
|
||||||
Alignment: layout.W,
|
|
||||||
FontSize: th.TextSize * 14.0 / 16.0,
|
|
||||||
Shaper: th.Shaper,
|
|
||||||
}
|
}
|
||||||
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func layoutSongOptionRow(gtx C, th *material.Theme, label string, widget layout.Widget) D {
|
func layoutSongOptionRow(gtx C, th *Theme, label string, widget layout.Widget) D {
|
||||||
leftSpacer := layout.Spacer{Width: unit.Dp(6), Height: unit.Dp(24)}.Layout
|
leftSpacer := layout.Spacer{Width: unit.Dp(6), Height: unit.Dp(24)}.Layout
|
||||||
rightSpacer := layout.Spacer{Width: unit.Dp(6)}.Layout
|
rightSpacer := layout.Spacer{Width: unit.Dp(6)}.Layout
|
||||||
|
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(leftSpacer),
|
layout.Rigid(leftSpacer),
|
||||||
layout.Rigid(LabelStyle{Text: label, Color: mediumEmphasisTextColor, Alignment: layout.W, FontSize: th.TextSize * 14.0 / 16.0, Shaper: th.Shaper}.Layout),
|
layout.Rigid(Label(th, &th.SongPanel.RowHeader, label).Layout),
|
||||||
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
||||||
layout.Rigid(widget),
|
layout.Rigid(widget),
|
||||||
layout.Rigid(rightSpacer),
|
layout.Rigid(rightSpacer),
|
||||||
@ -255,7 +244,7 @@ func (e *Expander) Update(gtx C) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expander) Layout(gtx C, th *material.Theme, title string, smallWidget, largeWidget layout.Widget) D {
|
func (e *Expander) Layout(gtx C, th *Theme, title string, smallWidget, largeWidget layout.Widget) D {
|
||||||
e.Update(gtx)
|
e.Update(gtx)
|
||||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D { return e.layoutHeader(gtx, th, title, smallWidget) }),
|
layout.Rigid(func(gtx C) D { return e.layoutHeader(gtx, th, title, smallWidget) }),
|
||||||
@ -273,7 +262,7 @@ func (e *Expander) Layout(gtx C, th *material.Theme, title string, smallWidget,
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *Expander) layoutHeader(gtx C, th *material.Theme, title string, smallWidget layout.Widget) D {
|
func (e *Expander) layoutHeader(gtx C, th *Theme, title string, smallWidget layout.Widget) D {
|
||||||
return layout.Background{}.Layout(gtx,
|
return layout.Background{}.Layout(gtx,
|
||||||
func(gtx C) D {
|
func(gtx C) D {
|
||||||
defer clip.Rect(image.Rect(0, 0, gtx.Constraints.Min.X, gtx.Constraints.Min.Y)).Push(gtx.Ops).Pop()
|
defer clip.Rect(image.Rect(0, 0, gtx.Constraints.Min.X, gtx.Constraints.Min.Y)).Push(gtx.Ops).Pop()
|
||||||
@ -285,7 +274,7 @@ func (e *Expander) layoutHeader(gtx C, th *material.Theme, title string, smallWi
|
|||||||
leftSpacer := layout.Spacer{Width: unit.Dp(6), Height: unit.Dp(24)}.Layout
|
leftSpacer := layout.Spacer{Width: unit.Dp(6), Height: unit.Dp(24)}.Layout
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(leftSpacer),
|
layout.Rigid(leftSpacer),
|
||||||
layout.Rigid(LabelStyle{Text: title, Color: disabledTextColor, Alignment: layout.W, FontSize: th.TextSize * 14.0 / 16.0, Shaper: th.Shaper}.Layout),
|
layout.Rigid(Label(th, &th.SongPanel.Expander, title).Layout),
|
||||||
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
layout.Flexed(1, func(gtx C) D { return D{Size: gtx.Constraints.Min} }),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
if !e.Expanded {
|
if !e.Expanded {
|
||||||
@ -300,7 +289,7 @@ func (e *Expander) layoutHeader(gtx C, th *material.Theme, title string, smallWi
|
|||||||
icon = icons.NavigationExpandLess
|
icon = icons.NavigationExpandLess
|
||||||
}
|
}
|
||||||
gtx.Constraints.Min = image.Pt(gtx.Dp(unit.Dp(24)), gtx.Dp(unit.Dp(24)))
|
gtx.Constraints.Min = image.Pt(gtx.Dp(unit.Dp(24)), gtx.Dp(unit.Dp(24)))
|
||||||
return widgetForIcon(icon).Layout(gtx, th.Palette.Fg)
|
return widgetForIcon(icon).Layout(gtx, th.SongPanel.Expander.Color)
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
@ -22,6 +22,53 @@ type Theme struct {
|
|||||||
MenuButton ButtonStyle
|
MenuButton ButtonStyle
|
||||||
Oscilloscope OscilloscopeStyle
|
Oscilloscope OscilloscopeStyle
|
||||||
NumericUpDown NumericUpDownStyle
|
NumericUpDown NumericUpDownStyle
|
||||||
|
DialogTitle LabelStyle
|
||||||
|
DialogText LabelStyle
|
||||||
|
SongPanel struct {
|
||||||
|
RowHeader LabelStyle
|
||||||
|
RowValue LabelStyle
|
||||||
|
Expander LabelStyle
|
||||||
|
Version LabelStyle
|
||||||
|
ErrorColor color.NRGBA
|
||||||
|
}
|
||||||
|
Alert struct {
|
||||||
|
Warning PopupAlertStyle
|
||||||
|
Error PopupAlertStyle
|
||||||
|
Info PopupAlertStyle
|
||||||
|
}
|
||||||
|
NoteEditor struct {
|
||||||
|
TrackTitle LabelStyle
|
||||||
|
Header LabelStyle
|
||||||
|
}
|
||||||
|
Dialog struct {
|
||||||
|
Title LabelStyle
|
||||||
|
Text LabelStyle
|
||||||
|
}
|
||||||
|
OrderEditor struct {
|
||||||
|
TrackTitle LabelStyle
|
||||||
|
}
|
||||||
|
Menu struct {
|
||||||
|
Text LabelStyle
|
||||||
|
ShortCut LabelStyle
|
||||||
|
}
|
||||||
|
InstrumentEditor struct {
|
||||||
|
Octave LabelStyle
|
||||||
|
Voices LabelStyle
|
||||||
|
InstrumentNumber LabelStyle
|
||||||
|
InstrumentName LabelStyle
|
||||||
|
InstrumentNameMuted LabelStyle
|
||||||
|
UnitList struct {
|
||||||
|
Name LabelStyle
|
||||||
|
Comment LabelStyle
|
||||||
|
Stack LabelStyle
|
||||||
|
Disabled LabelStyle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
UnitEditor struct {
|
||||||
|
Hint LabelStyle
|
||||||
|
Chooser LabelStyle
|
||||||
|
ParameterName LabelStyle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:embed theme.yml
|
//go:embed theme.yml
|
||||||
|
@ -1,6 +1,17 @@
|
|||||||
primarycolor: &primarycolor { r: 243, g: 187, b: 252, a: 255 }
|
# following definitions are not in theme.go, but defined here just for
|
||||||
secondarycolor: &secondarycolor { r: 187, g: 245, b: 252, a: 255 }
|
# reusability, with &... *... references
|
||||||
|
primarycolor: &primarycolor { r: 206, g: 147, b: 216, a: 255 } # { r: 243, g: 187, b: 252, a: 255 }
|
||||||
|
secondarycolor: &secondarycolor { r: 128, g: 222, b: 234, a: 255 } # { r: 187, g: 245, b: 252, a: 255 }
|
||||||
transparentcolor: &transparentcolor { r: 0, g: 0, b: 0, a: 0 }
|
transparentcolor: &transparentcolor { r: 0, g: 0, b: 0, a: 0 }
|
||||||
|
mediumemphasis: &mediumemphasis { r: 153, g: 153, b: 153, a: 255 }
|
||||||
|
highemphasis: &highemphasis { r: 222, g: 222, b: 222, a: 255 }
|
||||||
|
disabled: &disabled { r: 255, g: 255, b: 255, a: 97 }
|
||||||
|
errorcolor: &errorcolor { r: 207, g: 102, b: 121, a: 255 }
|
||||||
|
warningcolor: &warningcolor { r: 251, g: 192, b: 45, a: 255 }
|
||||||
|
white: &white { r: 255, g: 255, b: 255, a: 255 }
|
||||||
|
black: &black { r: 0, g: 0, b: 0, a: 255 }
|
||||||
|
|
||||||
|
# from here on starts the structs defined in the theme.go
|
||||||
material:
|
material:
|
||||||
textsize: 16
|
textsize: 16
|
||||||
fingersize: 38
|
fingersize: 38
|
||||||
@ -13,25 +24,29 @@ filledbutton:
|
|||||||
background: *primarycolor
|
background: *primarycolor
|
||||||
color: *contrastfg
|
color: *contrastfg
|
||||||
textsize: &buttontextsize 14
|
textsize: &buttontextsize 14
|
||||||
cornerradius: &buttoncornerradius 12
|
cornerradius: &buttoncornerradius 18
|
||||||
|
height: &buttonheight 36
|
||||||
inset: &buttoninset { top: 0, bottom: 0, left: 6, right: 6 }
|
inset: &buttoninset { top: 0, bottom: 0, left: 6, right: 6 }
|
||||||
textbutton:
|
textbutton:
|
||||||
background: *transparentcolor
|
background: *transparentcolor
|
||||||
color: *primarycolor
|
color: *primarycolor
|
||||||
textsize: *buttontextsize
|
textsize: *buttontextsize
|
||||||
cornerradius: *buttoncornerradius
|
cornerradius: *buttoncornerradius
|
||||||
|
height: *buttonheight
|
||||||
inset: *buttoninset
|
inset: *buttoninset
|
||||||
disabledbutton:
|
disabledbutton:
|
||||||
background: { r: 53, g: 51, b: 55, a: 255 }
|
background: { r: 53, g: 51, b: 55, a: 255 }
|
||||||
color: { r: 120, g: 116, b: 121, a: 255 }
|
color: { r: 120, g: 116, b: 121, a: 255 }
|
||||||
textsize: *buttontextsize
|
textsize: *buttontextsize
|
||||||
cornerradius: *buttoncornerradius
|
cornerradius: *buttoncornerradius
|
||||||
|
height: *buttonheight
|
||||||
inset: *buttoninset
|
inset: *buttoninset
|
||||||
menubutton:
|
menubutton:
|
||||||
background: *transparentcolor
|
background: *transparentcolor
|
||||||
color: { r: 255, g: 255, b: 255, a: 255 }
|
color: { r: 255, g: 255, b: 255, a: 255 }
|
||||||
textsize: *buttontextsize
|
textsize: *buttontextsize
|
||||||
cornerradius: 0
|
cornerradius: 0
|
||||||
|
height: *buttonheight
|
||||||
inset: *buttoninset
|
inset: *buttoninset
|
||||||
oscilloscope:
|
oscilloscope:
|
||||||
curvecolors: [*primarycolor, *secondarycolor]
|
curvecolors: [*primarycolor, *secondarycolor]
|
||||||
@ -47,3 +62,56 @@ numericupdown:
|
|||||||
textsize: 14
|
textsize: 14
|
||||||
width: 70
|
width: 70
|
||||||
height: 20
|
height: 20
|
||||||
|
songpanel:
|
||||||
|
rowheader:
|
||||||
|
textsize: 14
|
||||||
|
color: *mediumemphasis
|
||||||
|
rowvalue:
|
||||||
|
textsize: 14
|
||||||
|
color: *mediumemphasis
|
||||||
|
expander:
|
||||||
|
textsize: 14
|
||||||
|
color: *highemphasis
|
||||||
|
errorcolor: *errorcolor
|
||||||
|
version:
|
||||||
|
textsize: 12
|
||||||
|
color: *mediumemphasis
|
||||||
|
alerts:
|
||||||
|
error:
|
||||||
|
bg: *errorcolor
|
||||||
|
text: { textsize: 16, color: *black }
|
||||||
|
warning:
|
||||||
|
bg: *warningcolor
|
||||||
|
text: { textsize: 16, color: *black }
|
||||||
|
info:
|
||||||
|
bg: { r: 50, g: 50, b: 51, a: 255 }
|
||||||
|
text: { textsize: 16, shadowcolor: *black }
|
||||||
|
dialog:
|
||||||
|
title: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||||
|
text: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||||
|
ordereditor:
|
||||||
|
tracktitle:
|
||||||
|
textsize: 12
|
||||||
|
color: *mediumemphasis
|
||||||
|
noteeditor:
|
||||||
|
tracktitle: { textsize: 12, color: *mediumemphasis }
|
||||||
|
header: { textsize: 14, color: *disabled }
|
||||||
|
menu:
|
||||||
|
text: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||||
|
shortcut: { textsize: 16, color: *mediumemphasis, shadowcolor: *black }
|
||||||
|
instrumenteditor:
|
||||||
|
octave: { textsize: 14, color: *disabled }
|
||||||
|
voices: { textsize: 14, color: *disabled }
|
||||||
|
instrumentnumber:
|
||||||
|
{ textsize: 10, color: *mediumemphasis, shadowcolor: *black, alignment: 1 }
|
||||||
|
instrumentname:
|
||||||
|
{ textsize: 10, color: *white, shadowcolor: *black, alignment: 1 }
|
||||||
|
unitlist:
|
||||||
|
name: { textsize: 12, color: *mediumemphasis, shadowcolor: *black }
|
||||||
|
comment: { textsize: 12, color: *disabled }
|
||||||
|
stack: { textsize: 12, color: *mediumemphasis, shadowcolor: *black }
|
||||||
|
disabled: { textsize: 12, color: *disabled }
|
||||||
|
uniteditor:
|
||||||
|
hint: { textsize: 12, color: *highemphasis, shadowcolor: *black }
|
||||||
|
chooser: { textsize: 12, color: *white, shadowcolor: *black }
|
||||||
|
parametername: { textsize: 12, color: *white, shadowcolor: *black }
|
||||||
|
@ -95,7 +95,7 @@ func NewTracker(model *tracker.Model) *Tracker {
|
|||||||
preferences: MakePreferences(),
|
preferences: MakePreferences(),
|
||||||
}
|
}
|
||||||
t.Theme.Material.Shaper = text.NewShaper(text.WithCollection(fontCollection))
|
t.Theme.Material.Shaper = text.NewShaper(text.WithCollection(fontCollection))
|
||||||
t.PopupAlert = NewPopupAlert(model.Alerts(), t.Theme.Material.Shaper)
|
t.PopupAlert = NewPopupAlert(model.Alerts())
|
||||||
if t.preferences.YmlError != nil {
|
if t.preferences.YmlError != nil {
|
||||||
model.Alerts().Add(
|
model.Alerts().Add(
|
||||||
fmt.Sprintf("Preferences YML Error: %s", t.preferences.YmlError),
|
fmt.Sprintf("Preferences YML Error: %s", t.preferences.YmlError),
|
||||||
@ -201,7 +201,7 @@ func (t *Tracker) Layout(gtx layout.Context, w *app.Window) {
|
|||||||
t.layoutTop,
|
t.layoutTop,
|
||||||
t.layoutBottom)
|
t.layoutBottom)
|
||||||
}
|
}
|
||||||
t.PopupAlert.Layout(gtx)
|
t.PopupAlert.Layout(gtx, t.Theme)
|
||||||
t.showDialog(gtx)
|
t.showDialog(gtx)
|
||||||
// this is the top level input handler for the whole app
|
// this is the top level input handler for the whole app
|
||||||
// it handles all the global key events and clipboard events
|
// it handles all the global key events and clipboard events
|
||||||
@ -241,12 +241,12 @@ func (t *Tracker) showDialog(gtx C) {
|
|||||||
}
|
}
|
||||||
switch t.Dialog() {
|
switch t.Dialog() {
|
||||||
case tracker.NewSongChanges, tracker.OpenSongChanges, tracker.QuitChanges:
|
case tracker.NewSongChanges, tracker.OpenSongChanges, tracker.QuitChanges:
|
||||||
dstyle := ConfirmDialog(gtx, &t.Theme.Material, t.SaveChangesDialog, "Save changes to song?", "Your changes will be lost if you don't save them.")
|
dstyle := ConfirmDialog(gtx, t.Theme, t.SaveChangesDialog, "Save changes to song?", "Your changes will be lost if you don't save them.")
|
||||||
dstyle.OkStyle.Text = "Save"
|
dstyle.OkStyle.Text = "Save"
|
||||||
dstyle.AltStyle.Text = "Don't save"
|
dstyle.AltStyle.Text = "Don't save"
|
||||||
dstyle.Layout(gtx)
|
dstyle.Layout(gtx)
|
||||||
case tracker.Export:
|
case tracker.Export:
|
||||||
dstyle := ConfirmDialog(gtx, &t.Theme.Material, t.WaveTypeDialog, "", "Export .wav in int16 or float32 sample format?")
|
dstyle := ConfirmDialog(gtx, t.Theme, t.WaveTypeDialog, "", "Export .wav in int16 or float32 sample format?")
|
||||||
dstyle.OkStyle.Text = "Int16"
|
dstyle.OkStyle.Text = "Int16"
|
||||||
dstyle.AltStyle.Text = "Float32"
|
dstyle.AltStyle.Text = "Float32"
|
||||||
dstyle.Layout(gtx)
|
dstyle.Layout(gtx)
|
||||||
|
@ -112,7 +112,7 @@ func (pe *UnitEditor) layoutSliders(gtx C, t *Tracker) D {
|
|||||||
if index < 0 || index >= numItems {
|
if index < 0 || index >= numItems {
|
||||||
return D{}
|
return D{}
|
||||||
}
|
}
|
||||||
paramStyle := t.ParamStyle(&t.Theme.Material, pe.Parameters[index])
|
paramStyle := t.ParamStyle(t.Theme, pe.Parameters[index])
|
||||||
paramStyle.Focus = pe.sliderList.TrackerList.Selected() == index
|
paramStyle.Focus = pe.sliderList.TrackerList.Selected() == index
|
||||||
dims := paramStyle.Layout(gtx)
|
dims := paramStyle.Layout(gtx)
|
||||||
return D{Size: image.Pt(gtx.Constraints.Max.X, dims.Size.Y)}
|
return D{Size: image.Pt(gtx.Constraints.Max.X, dims.Size.Y)}
|
||||||
@ -141,7 +141,7 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
|
|||||||
} else {
|
} else {
|
||||||
text = pe.caser.String(text)
|
text = pe.caser.String(text)
|
||||||
}
|
}
|
||||||
hintText := Label(text, white, t.Theme.Material.Shaper)
|
hintText := Label(t.Theme, &t.Theme.UnitEditor.Hint, text)
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(deleteUnitBtnStyle.Layout),
|
layout.Rigid(deleteUnitBtnStyle.Layout),
|
||||||
layout.Rigid(copyUnitBtnStyle.Layout),
|
layout.Rigid(copyUnitBtnStyle.Layout),
|
||||||
@ -156,7 +156,7 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
|
|||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
gtx.Constraints.Min.X = gtx.Dp(120)
|
gtx.Constraints.Min.X = gtx.Dp(120)
|
||||||
return hintText(gtx)
|
return hintText.Layout(gtx)
|
||||||
}),
|
}),
|
||||||
layout.Flexed(1, func(gtx C) D {
|
layout.Flexed(1, func(gtx C) D {
|
||||||
s := t.UnitComment().String()
|
s := t.UnitComment().String()
|
||||||
@ -185,7 +185,8 @@ func (pe *UnitEditor) layoutUnitTypeChooser(gtx C, t *Tracker) D {
|
|||||||
names[i] = item
|
names[i] = item
|
||||||
}
|
}
|
||||||
element := func(gtx C, i int) D {
|
element := func(gtx C, i int) D {
|
||||||
w := LabelStyle{Text: names[i], ShadeColor: black, Color: white, Font: labelDefaultFont, FontSize: unit.Sp(12), Shaper: t.Theme.Material.Shaper}
|
w := Label(t.Theme, &t.Theme.UnitEditor.Chooser, names[i])
|
||||||
|
|
||||||
if i == pe.searchList.TrackerList.Selected() {
|
if i == pe.searchList.TrackerList.Selected() {
|
||||||
for pe.SelectTypeBtn.Clicked(gtx) {
|
for pe.SelectTypeBtn.Clicked(gtx) {
|
||||||
t.Units().SetSelectedType(names[i])
|
t.Units().SetSelectedType(names[i])
|
||||||
@ -248,17 +249,17 @@ type ParameterWidget struct {
|
|||||||
type ParameterStyle struct {
|
type ParameterStyle struct {
|
||||||
tracker *Tracker
|
tracker *Tracker
|
||||||
w *ParameterWidget
|
w *ParameterWidget
|
||||||
Theme *material.Theme
|
Theme *Theme
|
||||||
SendTargetTheme *material.Theme
|
SendTargetTheme *material.Theme
|
||||||
Focus bool
|
Focus bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tracker) ParamStyle(th *material.Theme, paramWidget *ParameterWidget) ParameterStyle {
|
func (t *Tracker) ParamStyle(th *Theme, paramWidget *ParameterWidget) ParameterStyle {
|
||||||
sendTargetTheme := th.WithPalette(material.Palette{
|
sendTargetTheme := th.Material.WithPalette(material.Palette{
|
||||||
Bg: th.Bg,
|
Bg: th.Material.Bg,
|
||||||
Fg: paramIsSendTargetColor,
|
Fg: paramIsSendTargetColor,
|
||||||
ContrastBg: th.ContrastBg,
|
ContrastBg: th.Material.ContrastBg,
|
||||||
ContrastFg: th.ContrastFg,
|
ContrastFg: th.Material.ContrastFg,
|
||||||
})
|
})
|
||||||
return ParameterStyle{
|
return ParameterStyle{
|
||||||
tracker: t, // TODO: we need this to pull the instrument names for ID style parameters, find out another way
|
tracker: t, // TODO: we need this to pull the instrument names for ID style parameters, find out another way
|
||||||
@ -273,7 +274,7 @@ func (p ParameterStyle) Layout(gtx C) D {
|
|||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(110))
|
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(110))
|
||||||
return layout.E.Layout(gtx, Label(p.w.Parameter.Name(), white, p.tracker.Theme.Material.Shaper))
|
return layout.E.Layout(gtx, Label(p.Theme, &p.Theme.UnitEditor.ParameterName, p.w.Parameter.Name()).Layout)
|
||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
switch p.w.Parameter.Type() {
|
switch p.w.Parameter.Type() {
|
||||||
@ -298,7 +299,7 @@ func (p ParameterStyle) Layout(gtx C) D {
|
|||||||
if !p.w.floatWidget.Dragging() {
|
if !p.w.floatWidget.Dragging() {
|
||||||
p.w.floatWidget.Value = (float32(p.w.Parameter.Value()) - float32(ra.Min)) / float32(ra.Max-ra.Min)
|
p.w.floatWidget.Value = (float32(p.w.Parameter.Value()) - float32(ra.Min)) / float32(ra.Max-ra.Min)
|
||||||
}
|
}
|
||||||
sliderStyle := material.Slider(p.Theme, &p.w.floatWidget)
|
sliderStyle := material.Slider(&p.Theme.Material, &p.w.floatWidget)
|
||||||
if isSendTarget {
|
if isSendTarget {
|
||||||
sliderStyle.Color = paramIsSendTargetColor
|
sliderStyle.Color = paramIsSendTargetColor
|
||||||
}
|
}
|
||||||
@ -316,8 +317,8 @@ func (p ParameterStyle) Layout(gtx C) D {
|
|||||||
gtx.Constraints.Min.Y = gtx.Dp(unit.Dp(40))
|
gtx.Constraints.Min.Y = gtx.Dp(unit.Dp(40))
|
||||||
ra := p.w.Parameter.Range()
|
ra := p.w.Parameter.Range()
|
||||||
p.w.boolWidget.Value = p.w.Parameter.Value() > ra.Min
|
p.w.boolWidget.Value = p.w.Parameter.Value() > ra.Min
|
||||||
boolStyle := material.Switch(p.Theme, &p.w.boolWidget, "Toggle boolean parameter")
|
boolStyle := material.Switch(&p.Theme.Material, &p.w.boolWidget, "Toggle boolean parameter")
|
||||||
boolStyle.Color.Disabled = p.Theme.Fg
|
boolStyle.Color.Disabled = p.Theme.Material.Fg
|
||||||
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
|
defer pointer.PassOp{}.Push(gtx.Ops).Pop()
|
||||||
dims := layout.Center.Layout(gtx, boolStyle.Layout)
|
dims := layout.Center.Layout(gtx, boolStyle.Layout)
|
||||||
if p.w.boolWidget.Value {
|
if p.w.boolWidget.Value {
|
||||||
@ -372,17 +373,16 @@ func (p ParameterStyle) Layout(gtx C) D {
|
|||||||
}),
|
}),
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
if p.w.Parameter.Type() != tracker.IDParameter {
|
if p.w.Parameter.Type() != tracker.IDParameter {
|
||||||
color := white
|
|
||||||
hint := p.w.Parameter.Hint()
|
hint := p.w.Parameter.Hint()
|
||||||
|
label := Label(p.tracker.Theme, &p.tracker.Theme.UnitEditor.Hint, hint.Label)
|
||||||
if !hint.Valid {
|
if !hint.Valid {
|
||||||
color = paramValueInvalidColor
|
label.Color = paramValueInvalidColor
|
||||||
}
|
}
|
||||||
label := Label(hint.Label, color, p.tracker.Theme.Material.Shaper)
|
|
||||||
if info == "" {
|
if info == "" {
|
||||||
return label(gtx)
|
return label.Layout(gtx)
|
||||||
}
|
}
|
||||||
tooltip := component.PlatformTooltip(p.SendTargetTheme, info)
|
tooltip := component.PlatformTooltip(p.SendTargetTheme, info)
|
||||||
return p.w.tipArea.Layout(gtx, tooltip, label)
|
return p.w.tipArea.Layout(gtx, tooltip, label.Layout)
|
||||||
}
|
}
|
||||||
return D{}
|
return D{}
|
||||||
}),
|
}),
|
||||||
|
Loading…
Reference in New Issue
Block a user