mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
drafting
This commit is contained in:
parent
80797b023c
commit
2b673dc721
@ -1,8 +1,12 @@
|
||||
package gioui
|
||||
|
||||
import (
|
||||
"image/color"
|
||||
|
||||
"gioui.org/font"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
)
|
||||
@ -17,6 +21,13 @@ type (
|
||||
filters []event.Filter
|
||||
requestFocus bool
|
||||
}
|
||||
|
||||
EditorStyle struct {
|
||||
Color color.NRGBA
|
||||
HintColor color.NRGBA
|
||||
Font font.Font
|
||||
TextSize unit.Sp
|
||||
}
|
||||
)
|
||||
|
||||
func NewEditor(e widget.Editor) *Editor {
|
||||
@ -34,11 +45,20 @@ func NewEditor(e widget.Editor) *Editor {
|
||||
return ret
|
||||
}
|
||||
|
||||
func MaterialEditor(th *Theme, style *LabelStyle, editor *Editor, hint string) material.EditorStyle {
|
||||
func (s *EditorStyle) AsLabelStyle() LabelStyle {
|
||||
return LabelStyle{
|
||||
Color: s.Color,
|
||||
Font: s.Font,
|
||||
TextSize: s.TextSize,
|
||||
}
|
||||
}
|
||||
|
||||
func MaterialEditor(th *Theme, style *EditorStyle, editor *Editor, hint string) material.EditorStyle {
|
||||
ret := material.Editor(&th.Material, &editor.Editor, hint)
|
||||
ret.Font = style.Font
|
||||
ret.TextSize = style.TextSize
|
||||
ret.Color = style.Color
|
||||
ret.HintColor = style.HintColor
|
||||
return ret
|
||||
}
|
||||
|
||||
|
@ -301,7 +301,8 @@ func (ie *InstrumentEditor) layoutInstrumentList(gtx C, t *Tracker) D {
|
||||
if name == "" {
|
||||
name = "Instr"
|
||||
}
|
||||
return layout.Center.Layout(gtx, Label(t.Theme, &s, name).Layout)
|
||||
l := s.AsLabelStyle()
|
||||
return layout.Center.Layout(gtx, Label(t.Theme, &l, name).Layout)
|
||||
}
|
||||
return layout.Center.Layout(gtx, func(gtx C) D {
|
||||
return layout.Inset{Left: unit.Dp(6), Right: unit.Dp(6)}.Layout(gtx, func(gtx C) D {
|
||||
@ -379,17 +380,17 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
}
|
||||
u := units[i]
|
||||
|
||||
labelStyle := t.Theme.InstrumentEditor.UnitList.Name
|
||||
editorStyle := t.Theme.InstrumentEditor.UnitList.Name
|
||||
if u.Disabled {
|
||||
labelStyle = t.Theme.InstrumentEditor.UnitList.NameDisabled
|
||||
editorStyle = t.Theme.InstrumentEditor.UnitList.NameDisabled
|
||||
}
|
||||
|
||||
stackText := strconv.FormatInt(int64(u.StackAfter), 10)
|
||||
if u.StackNeed > u.StackBefore {
|
||||
labelStyle.Color = t.Theme.InstrumentEditor.UnitList.Error
|
||||
editorStyle.Color = t.Theme.InstrumentEditor.UnitList.Error
|
||||
(*tracker.Alerts)(t.Model).AddNamed("UnitNeedsInputs", fmt.Sprintf("%v needs at least %v input signals, got %v", u.Type, u.StackNeed, u.StackBefore), tracker.Error)
|
||||
} else if i == count-1 && u.StackAfter != 0 {
|
||||
labelStyle.Color = t.Theme.InstrumentEditor.UnitList.Warning
|
||||
editorStyle.Color = t.Theme.InstrumentEditor.UnitList.Warning
|
||||
(*tracker.Alerts)(t.Model).AddNamed("InstrumentLeavesSignals", fmt.Sprintf("Instrument leaves %v signal(s) on the stack", u.StackAfter), tracker.Warning)
|
||||
}
|
||||
|
||||
@ -420,7 +421,7 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
ie.searchEditor.SetText(str.Value())
|
||||
ie.unitDragList.Focus()
|
||||
}
|
||||
style := MaterialEditor(t.Theme, &labelStyle, ie.searchEditor, "---")
|
||||
style := MaterialEditor(t.Theme, &editorStyle, ie.searchEditor, "---")
|
||||
ret := style.Layout(gtx)
|
||||
str.Set(ie.searchEditor.Text())
|
||||
return ret
|
||||
@ -429,7 +430,8 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
if text == "" {
|
||||
text = "---"
|
||||
}
|
||||
return Label(t.Theme, &labelStyle, text).Layout(gtx)
|
||||
l := editorStyle.AsLabelStyle()
|
||||
return Label(t.Theme, &l, text).Layout(gtx)
|
||||
}
|
||||
}),
|
||||
layout.Flexed(1, func(gtx C) D {
|
||||
|
@ -73,17 +73,17 @@ type Theme struct {
|
||||
InstrumentEditor struct {
|
||||
Octave LabelStyle
|
||||
Voices LabelStyle
|
||||
InstrumentComment LabelStyle
|
||||
UnitComment LabelStyle
|
||||
InstrumentComment EditorStyle
|
||||
UnitComment EditorStyle
|
||||
InstrumentList struct {
|
||||
Number LabelStyle
|
||||
Name LabelStyle
|
||||
NameMuted LabelStyle
|
||||
Name EditorStyle
|
||||
NameMuted EditorStyle
|
||||
ScrollBar ScrollBarStyle
|
||||
}
|
||||
UnitList struct {
|
||||
Name LabelStyle
|
||||
NameDisabled LabelStyle
|
||||
Name EditorStyle
|
||||
NameDisabled EditorStyle
|
||||
Comment LabelStyle
|
||||
Stack LabelStyle
|
||||
Disabled LabelStyle
|
||||
|
@ -92,7 +92,7 @@ alert:
|
||||
text: { textsize: 16, color: *black }
|
||||
info:
|
||||
bg: { r: 50, g: 50, b: 51, a: 255 }
|
||||
text: { textsize: 16, shadowcolor: *black }
|
||||
text: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||
dialog:
|
||||
bg: { r: 0, g: 0, b: 0, a: 224 }
|
||||
title: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||
@ -129,19 +129,20 @@ menu:
|
||||
instrumenteditor:
|
||||
octave: { textsize: 14, color: *disabled }
|
||||
voices: { textsize: 14, color: *disabled }
|
||||
instrumentcomment: { textsize: 14, color: *mediumemphasis }
|
||||
unitcomment: { textsize: 14, color: *mediumemphasis }
|
||||
instrumentcomment:
|
||||
{ textsize: 14, color: *highemphasis, hintcolor: *disabled }
|
||||
unitcomment: { textsize: 14, color: *highemphasis, hintcolor: *disabled }
|
||||
instrumentlist:
|
||||
number: { textsize: 10, color: *mediumemphasis, shadowcolor: *black }
|
||||
name: { textsize: 12, color: *white, shadowcolor: *black }
|
||||
namemuted: { textsize: 12, color: *disabled }
|
||||
number: { textsize: 10, color: *mediumemphasis }
|
||||
name: { textsize: 12, color: *white, hintcolor: *disabled }
|
||||
namemuted: { textsize: 12, color: *disabled, hintcolor: *disabled }
|
||||
scrollbar: { width: 6, color: *scrollbarcolor }
|
||||
unitlist:
|
||||
name: { textsize: 12, color: *white, shadowcolor: *black }
|
||||
name: { textsize: 12, color: *white, hintcolor: *disabled }
|
||||
namedisabled:
|
||||
textsize: 12
|
||||
color: *disabled
|
||||
shadowcolor: *black
|
||||
hintcolor: *disabled
|
||||
font: { style: 1 }
|
||||
comment: { textsize: 12, color: *disabled }
|
||||
stack: { textsize: 12, color: *mediumemphasis, shadowcolor: *black }
|
||||
|
Loading…
Reference in New Issue
Block a user