mirror of
https://github.com/vsariola/sointu.git
synced 2025-06-03 09:08:18 -04:00
refactor(gioui): move common button code to two functions
This commit is contained in:
parent
c0a0a5d501
commit
e544e955cb
@ -18,3 +18,19 @@ func IconButton(th *material.Theme, w *widget.Clickable, icon []byte, enabled bo
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
func LowEmphasisButton(th *material.Theme, w *widget.Clickable, text string) material.ButtonStyle {
|
||||
ret := material.Button(th, w, text)
|
||||
ret.Color = th.Palette.Fg
|
||||
ret.Background = transparent
|
||||
ret.Inset = layout.UniformInset(unit.Dp(6))
|
||||
return ret
|
||||
}
|
||||
|
||||
func HighEmphasisButton(th *material.Theme, w *widget.Clickable, text string) material.ButtonStyle {
|
||||
ret := material.Button(th, w, text)
|
||||
ret.Color = th.Palette.ContrastFg
|
||||
ret.Background = th.Palette.Fg
|
||||
ret.Inset = layout.UniformInset(unit.Dp(6))
|
||||
return ret
|
||||
}
|
||||
|
@ -30,13 +30,10 @@ func ConfirmDialog(th *material.Theme, dialog *Dialog, text string) DialogStyle
|
||||
dialog: dialog,
|
||||
Text: text,
|
||||
Inset: layout.Inset{Top: unit.Dp(12), Bottom: unit.Dp(12), Left: unit.Dp(20), Right: unit.Dp(20)},
|
||||
AltStyle: material.Button(th, &dialog.BtnAlt, "Alt"),
|
||||
OkStyle: material.Button(th, &dialog.BtnOk, "Ok"),
|
||||
CancelStyle: material.Button(th, &dialog.BtnCancel, "Cancel"),
|
||||
AltStyle: HighEmphasisButton(th, &dialog.BtnAlt, "Alt"),
|
||||
OkStyle: HighEmphasisButton(th, &dialog.BtnOk, "Ok"),
|
||||
CancelStyle: HighEmphasisButton(th, &dialog.BtnCancel, "Cancel"),
|
||||
}
|
||||
ret.AltStyle.Background = primaryColor
|
||||
ret.OkStyle.Background = primaryColor
|
||||
ret.CancelStyle.Background = primaryColor
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@ -76,11 +76,9 @@ func commonFileDialog(th *material.Theme, f *FileDialog) FileDialogStyle {
|
||||
FolderUpStyle: IconButton(th, &f.BtnFolderUp, icons.NavigationArrowUpward, true),
|
||||
DirEditorStyle: material.Editor(th, &f.Directory, "Directory"),
|
||||
FileNameStyle: material.Editor(th, &f.FileName, "Filename"),
|
||||
CancelStyle: material.Button(th, &f.BtnCancel, "Cancel"),
|
||||
CancelStyle: LowEmphasisButton(th, &f.BtnCancel, "Cancel"),
|
||||
UseAltExtStyle: material.Switch(th, &f.UseAltExt),
|
||||
}
|
||||
ret.CancelStyle.Background = transparent
|
||||
ret.CancelStyle.Color = primaryColor
|
||||
ret.UseAltExtStyle.Color.Enabled = white
|
||||
ret.UseAltExtStyle.Color.Disabled = white
|
||||
ret.ExtMain = ".yml"
|
||||
|
@ -112,13 +112,11 @@ func (t *Tracker) layoutSongOptions(gtx C) D {
|
||||
|
||||
in := layout.UniformInset(unit.Dp(1))
|
||||
|
||||
panicBtnStyle := material.Button(t.Theme, t.PanicBtn, "Panic")
|
||||
var panicBtnStyle material.ButtonStyle
|
||||
if t.player.Enabled() {
|
||||
panicBtnStyle.Background = transparent
|
||||
panicBtnStyle.Color = t.Theme.Palette.Fg
|
||||
panicBtnStyle = LowEmphasisButton(t.Theme, t.PanicBtn, "Panic")
|
||||
} else {
|
||||
panicBtnStyle.Background = t.Theme.Palette.Fg
|
||||
panicBtnStyle.Color = t.Theme.Palette.ContrastFg
|
||||
panicBtnStyle = HighEmphasisButton(t.Theme, t.PanicBtn, "Panic")
|
||||
}
|
||||
|
||||
for t.PanicBtn.Clicked() {
|
||||
|
@ -66,26 +66,11 @@ func (t *Tracker) layoutTracker(gtx layout.Context) layout.Dimensions {
|
||||
}
|
||||
|
||||
menu := func(gtx C) D {
|
||||
addSemitoneBtnStyle := material.Button(t.Theme, t.AddSemitoneBtn, "+1")
|
||||
addSemitoneBtnStyle.Color = primaryColor
|
||||
addSemitoneBtnStyle.Background = transparent
|
||||
addSemitoneBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
|
||||
subtractSemitoneBtnStyle := material.Button(t.Theme, t.SubtractSemitoneBtn, "-1")
|
||||
subtractSemitoneBtnStyle.Color = primaryColor
|
||||
subtractSemitoneBtnStyle.Background = transparent
|
||||
subtractSemitoneBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
|
||||
addOctaveBtnStyle := material.Button(t.Theme, t.AddOctaveBtn, "+12")
|
||||
addOctaveBtnStyle.Color = primaryColor
|
||||
addOctaveBtnStyle.Background = transparent
|
||||
addOctaveBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
|
||||
subtractOctaveBtnStyle := material.Button(t.Theme, t.SubtractOctaveBtn, "-12")
|
||||
subtractOctaveBtnStyle.Color = primaryColor
|
||||
subtractOctaveBtnStyle.Background = transparent
|
||||
subtractOctaveBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
|
||||
noteOffBtnStyle := material.Button(t.Theme, t.NoteOffBtn, "Note Off")
|
||||
noteOffBtnStyle.Color = primaryColor
|
||||
noteOffBtnStyle.Background = transparent
|
||||
noteOffBtnStyle.Inset = layout.UniformInset(unit.Dp(6))
|
||||
addSemitoneBtnStyle := LowEmphasisButton(t.Theme, t.AddSemitoneBtn, "+1")
|
||||
subtractSemitoneBtnStyle := LowEmphasisButton(t.Theme, t.SubtractSemitoneBtn, "-1")
|
||||
addOctaveBtnStyle := LowEmphasisButton(t.Theme, t.AddOctaveBtn, "+12")
|
||||
subtractOctaveBtnStyle := LowEmphasisButton(t.Theme, t.SubtractOctaveBtn, "-12")
|
||||
noteOffBtnStyle := LowEmphasisButton(t.Theme, t.NoteOffBtn, "Note Off")
|
||||
deleteTrackBtnStyle := IconButton(t.Theme, t.DeleteTrackBtn, icons.ActionDelete, t.CanDeleteTrack())
|
||||
newTrackBtnStyle := IconButton(t.Theme, t.NewTrackBtn, icons.ContentAdd, t.CanAddTrack())
|
||||
in := layout.UniformInset(unit.Dp(1))
|
||||
|
Loading…
x
Reference in New Issue
Block a user