From 2b673dc721d155baf9fa81a6d5aad0801853d2e4 Mon Sep 17 00:00:00 2001 From: "5684185+vsariola@users.noreply.github.com" <5684185+vsariola@users.noreply.github.com> Date: Tue, 20 May 2025 18:53:19 +0300 Subject: [PATCH] drafting --- tracker/gioui/editor.go | 22 +++++++++++++++++++++- tracker/gioui/instrument_editor.go | 16 +++++++++------- tracker/gioui/theme.go | 12 ++++++------ tracker/gioui/theme.yml | 17 +++++++++-------- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/tracker/gioui/editor.go b/tracker/gioui/editor.go index 7a65b83..39e8b48 100644 --- a/tracker/gioui/editor.go +++ b/tracker/gioui/editor.go @@ -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 } diff --git a/tracker/gioui/instrument_editor.go b/tracker/gioui/instrument_editor.go index 447a5ab..7fbbc72 100644 --- a/tracker/gioui/instrument_editor.go +++ b/tracker/gioui/instrument_editor.go @@ -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 { diff --git a/tracker/gioui/theme.go b/tracker/gioui/theme.go index 26a709c..c263934 100644 --- a/tracker/gioui/theme.go +++ b/tracker/gioui/theme.go @@ -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 diff --git a/tracker/gioui/theme.yml b/tracker/gioui/theme.yml index 185ae00..f5bcf36 100644 --- a/tracker/gioui/theme.yml +++ b/tracker/gioui/theme.yml @@ -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 }