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