mirror of
https://github.com/vsariola/sointu.git
synced 2025-05-28 03:10:24 -04:00
drafting
This commit is contained in:
parent
750d88f728
commit
f9e8ff40a6
@ -17,8 +17,6 @@ type (
|
||||
filters []event.Filter
|
||||
requestFocus bool
|
||||
}
|
||||
|
||||
EditorStyle material.EditorStyle
|
||||
)
|
||||
|
||||
func NewEditor(e widget.Editor) *Editor {
|
||||
@ -36,8 +34,12 @@ func NewEditor(e widget.Editor) *Editor {
|
||||
return ret
|
||||
}
|
||||
|
||||
func MaterialEditor(th *material.Theme, e *Editor, hint string) EditorStyle {
|
||||
return EditorStyle(material.Editor(th, &e.Editor, hint))
|
||||
func MaterialEditor(th *Theme, style *LabelStyle, 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
|
||||
return ret
|
||||
}
|
||||
|
||||
func (e *Editor) SetText(s string) {
|
||||
@ -80,7 +82,3 @@ func (e *Editor) Cancelled(gtx C) bool {
|
||||
func (e *Editor) Focus() {
|
||||
e.requestFocus = true
|
||||
}
|
||||
|
||||
func (e *EditorStyle) Layout(gtx C) D {
|
||||
return material.EditorStyle(*e).Layout(gtx)
|
||||
}
|
||||
|
@ -254,8 +254,7 @@ func (ie *InstrumentEditor) layoutInstrumentHeader(gtx C, t *Tracker) D {
|
||||
for ie.commentEditor.Submitted(gtx) || ie.commentEditor.Cancelled(gtx) {
|
||||
ie.instrumentDragList.Focus()
|
||||
}
|
||||
style := MaterialEditor(&t.Theme.Material, ie.commentEditor, "Comment")
|
||||
style.Color = highEmphasisTextColor
|
||||
style := MaterialEditor(t.Theme, &t.Theme.InstrumentEditor.InstrumentComment, ie.commentEditor, "Comment")
|
||||
ret := layout.UniformInset(unit.Dp(6)).Layout(gtx, style.Layout)
|
||||
ie.commentString.Set(ie.commentEditor.Text())
|
||||
return ret
|
||||
@ -292,11 +291,7 @@ func (ie *InstrumentEditor) layoutInstrumentList(gtx C, t *Tracker) D {
|
||||
for ie.nameEditor.Submitted(gtx) || ie.nameEditor.Cancelled(gtx) {
|
||||
ie.instrumentDragList.Focus()
|
||||
}
|
||||
style := MaterialEditor(&t.Theme.Material, ie.nameEditor, "Instr")
|
||||
style.Color = s.Color
|
||||
style.HintColor = instrumentNameHintColor
|
||||
style.TextSize = s.TextSize
|
||||
style.Font = s.Font
|
||||
style := MaterialEditor(t.Theme, &s, ie.nameEditor, "Instr")
|
||||
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()
|
||||
return style.Layout(gtx)
|
||||
@ -431,11 +426,8 @@ func (ie *InstrumentEditor) layoutUnitList(gtx C, t *Tracker) D {
|
||||
ie.searchEditor.SetText(str.Value())
|
||||
ie.unitDragList.Focus()
|
||||
}
|
||||
style := MaterialEditor(&t.Theme.Material, ie.searchEditor, "---")
|
||||
style := MaterialEditor(t.Theme, &t.Theme.InstrumentEditor.UnitList.Name, ie.searchEditor, "---")
|
||||
style.Color = color
|
||||
style.HintColor = t.Theme.InstrumentEditor.UnitList.Comment.Color
|
||||
style.TextSize = t.Theme.InstrumentEditor.UnitList.Name.TextSize
|
||||
style.Font = t.Theme.InstrumentEditor.UnitList.Name.Font
|
||||
ret := style.Layout(gtx)
|
||||
str.Set(ie.searchEditor.Text())
|
||||
return ret
|
||||
|
@ -240,6 +240,10 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
return D{}
|
||||
}
|
||||
|
||||
rowMarkerPatternTextColorOp := colorOp(gtx, rowMarkerPatternTextColor)
|
||||
loopMarkerColorOp := colorOp(gtx, loopMarkerColor)
|
||||
rowMarkerRowTextColorOp := colorOp(gtx, rowMarkerRowTextColor)
|
||||
|
||||
rowTitle := func(gtx C, j int) D {
|
||||
rpp := max(t.RowsPerPattern().Value(), 1)
|
||||
pat := j / rpp
|
||||
@ -247,16 +251,14 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
w := pxPatMarkWidth + pxRowMarkWidth
|
||||
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()
|
||||
if row == 0 {
|
||||
color := rowMarkerPatternTextColor
|
||||
op := rowMarkerPatternTextColorOp
|
||||
if l := t.Loop(); pat >= l.Start && pat < l.Start+l.Length {
|
||||
color = loopMarkerColor
|
||||
op = loopMarkerColorOp
|
||||
}
|
||||
paint.ColorOp{Color: color}.Add(gtx.Ops)
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, strings.ToUpper(fmt.Sprintf("%02x", pat)), op.CallOp{})
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, strings.ToUpper(fmt.Sprintf("%02x", pat)), op)
|
||||
}
|
||||
defer op.Offset(image.Pt(pxPatMarkWidth, 0)).Push(gtx.Ops).Pop()
|
||||
paint.ColorOp{Color: rowMarkerRowTextColor}.Add(gtx.Ops)
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, strings.ToUpper(fmt.Sprintf("%02x", row)), op.CallOp{})
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, strings.ToUpper(fmt.Sprintf("%02x", row)), rowMarkerRowTextColorOp)
|
||||
return D{Size: image.Pt(w, pxHeight)}
|
||||
}
|
||||
|
||||
@ -265,6 +267,11 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
selection := te.scrollTable.Table.Range()
|
||||
hasTrackMidiIn := te.TrackMidiInBtn.Bool.Value()
|
||||
|
||||
trackerPatMarkerOp := colorOp(gtx, trackerPatMarker)
|
||||
mediumEmphasisTextColorOp := colorOp(gtx, mediumEmphasisTextColor)
|
||||
trackerActiveTextColorOp := colorOp(gtx, trackerActiveTextColor)
|
||||
trackerInactiveTextColorOp := colorOp(gtx, trackerInactiveTextColor)
|
||||
|
||||
cell := func(gtx C, x, y int) D {
|
||||
// draw the background, to indicate selection
|
||||
color := transparent
|
||||
@ -303,23 +310,20 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
defer op.Offset(image.Pt(0, -2)).Push(gtx.Ops).Pop()
|
||||
s := t.Model.Order().Value(tracker.Point{X: x, Y: pat})
|
||||
if row == 0 { // draw the pattern marker
|
||||
paint.ColorOp{Color: trackerPatMarker}.Add(gtx.Ops)
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, patternIndexToString(s), op.CallOp{})
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, patternIndexToString(s), trackerPatMarkerOp)
|
||||
}
|
||||
if row == 1 && t.Model.PatternUnique(x, s) { // draw a * if the pattern is unique
|
||||
paint.ColorOp{Color: mediumEmphasisTextColor}.Add(gtx.Ops)
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, "*", op.CallOp{})
|
||||
widget.Label{}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, "*", mediumEmphasisTextColorOp)
|
||||
}
|
||||
op := trackerInactiveTextColorOp
|
||||
if te.scrollTable.Table.Cursor() == point && te.scrollTable.Focused() {
|
||||
paint.ColorOp{Color: trackerActiveTextColor}.Add(gtx.Ops)
|
||||
} else {
|
||||
paint.ColorOp{Color: trackerInactiveTextColor}.Add(gtx.Ops)
|
||||
op = trackerActiveTextColorOp
|
||||
}
|
||||
val := noteStr[byte(t.Model.Notes().Value(tracker.Point{X: x, Y: y}))]
|
||||
if t.Model.Notes().Effect(x) {
|
||||
val = hexStr[byte(t.Model.Notes().Value(tracker.Point{X: x, Y: y}))]
|
||||
}
|
||||
widget.Label{Alignment: text.Middle}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, val, op.CallOp{})
|
||||
widget.Label{Alignment: text.Middle}.Layout(gtx, t.Theme.Material.Shaper, trackerFont, trackerFontSize, val, op)
|
||||
return D{Size: image.Pt(pxWidth, pxHeight)}
|
||||
}
|
||||
table := FilledScrollTable(&t.Theme.Material, te.scrollTable, cell, colTitle, rowTitle, nil, rowTitleBg)
|
||||
@ -330,6 +334,12 @@ func (te *NoteEditor) layoutTracks(gtx C, t *Tracker) D {
|
||||
return table.Layout(gtx)
|
||||
}
|
||||
|
||||
func colorOp(gtx C, c color.NRGBA) op.CallOp {
|
||||
macro := op.Record(gtx.Ops)
|
||||
paint.ColorOp{Color: c}.Add(gtx.Ops)
|
||||
return macro.Stop()
|
||||
}
|
||||
|
||||
func (te *NoteEditor) paintColumnCell(gtx C, x int, t *Tracker, c color.NRGBA) {
|
||||
cw := gtx.Constraints.Min.X
|
||||
cx := 0
|
||||
|
@ -52,9 +52,11 @@ type Theme struct {
|
||||
ShortCut LabelStyle
|
||||
}
|
||||
InstrumentEditor struct {
|
||||
Octave LabelStyle
|
||||
Voices LabelStyle
|
||||
InstrumentList struct {
|
||||
Octave LabelStyle
|
||||
Voices LabelStyle
|
||||
InstrumentComment LabelStyle
|
||||
UnitComment LabelStyle
|
||||
InstrumentList struct {
|
||||
Number LabelStyle
|
||||
Name LabelStyle
|
||||
NameMuted LabelStyle
|
||||
|
@ -102,6 +102,8 @@ menu:
|
||||
instrumenteditor:
|
||||
octave: { textsize: 14, color: *disabled }
|
||||
voices: { textsize: 14, color: *disabled }
|
||||
instrumentcomment: { textsize: 14, color: *mediumemphasis }
|
||||
unitcomment: { textsize: 14, color: *mediumemphasis }
|
||||
instrumentlist:
|
||||
number: { textsize: 10, color: *mediumemphasis, shadowcolor: *black }
|
||||
name: { textsize: 12, color: *white, shadowcolor: *black }
|
||||
@ -112,6 +114,6 @@ instrumenteditor:
|
||||
stack: { textsize: 12, color: *mediumemphasis, shadowcolor: *black }
|
||||
disabled: { textsize: 12, color: *disabled }
|
||||
uniteditor:
|
||||
hint: { textsize: 14, color: *highemphasis, shadowcolor: *black }
|
||||
hint: { textsize: 16, color: *highemphasis, shadowcolor: *black }
|
||||
chooser: { textsize: 12, color: *white, shadowcolor: *black }
|
||||
parametername: { textsize: 14, color: *white, shadowcolor: *black }
|
||||
parametername: { textsize: 16, color: *white, shadowcolor: *black }
|
||||
|
@ -164,11 +164,7 @@ func (pe *UnitEditor) layoutFooter(gtx C, t *Tracker) D {
|
||||
for pe.commentEditor.Submitted(gtx) || pe.commentEditor.Cancelled(gtx) {
|
||||
t.InstrumentEditor.Focus()
|
||||
}
|
||||
commentStyle := MaterialEditor(&t.Theme.Material, pe.commentEditor, "---")
|
||||
commentStyle.Font = labelDefaultFont
|
||||
commentStyle.TextSize = labelDefaultFontSize
|
||||
commentStyle.Color = mediumEmphasisTextColor
|
||||
commentStyle.HintColor = mediumEmphasisTextColor
|
||||
commentStyle := MaterialEditor(t.Theme, &t.Theme.InstrumentEditor.UnitComment, pe.commentEditor, "---")
|
||||
ret := commentStyle.Layout(gtx)
|
||||
s.Set(pe.commentEditor.Text())
|
||||
return ret
|
||||
|
Loading…
Reference in New Issue
Block a user