mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-23 07:24:47 -04:00
drafting
This commit is contained in:
parent
0d21afa2c1
commit
95515ee4a8
@ -85,14 +85,15 @@ type Theme struct {
|
||||
}
|
||||
}
|
||||
UnitEditor struct {
|
||||
Name LabelStyle
|
||||
Chooser LabelStyle
|
||||
Hint LabelStyle
|
||||
WireColor color.NRGBA
|
||||
WireHint LabelStyle
|
||||
Width unit.Dp
|
||||
Height unit.Dp
|
||||
UnitList struct {
|
||||
Name LabelStyle
|
||||
Chooser LabelStyle
|
||||
Hint LabelStyle
|
||||
WireColor color.NRGBA
|
||||
WireHint LabelStyle
|
||||
Width unit.Dp
|
||||
Height unit.Dp
|
||||
RackComment LabelStyle
|
||||
UnitList struct {
|
||||
LabelWidth unit.Dp
|
||||
Name LabelStyle
|
||||
Disabled LabelStyle
|
||||
|
@ -221,6 +221,7 @@ uniteditor:
|
||||
{ textsize: 12, color: *disabled, font: { style: 1 }, alignment: 2 }
|
||||
error: *errorcolor
|
||||
divider: { r: 255, g: 255, b: 255, a: 5 }
|
||||
rackcomment: { textsize: 16, color: *mediumemphasis, shadowcolor: *black }
|
||||
knob:
|
||||
diameter: 36
|
||||
value: { textsize: 12, color: *highemphasis }
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"image"
|
||||
"io"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
@ -137,6 +138,12 @@ func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
||||
case key.NameDeleteBackward, key.NameDeleteForward:
|
||||
t.Model.Params().Table().Clear()
|
||||
}
|
||||
c := t.Model.Params().Cursor()
|
||||
if c.X >= 0 && c.Y >= 0 && c.Y < len(pe.Parameters) && c.X < len(pe.Parameters[c.Y]) {
|
||||
ta := &pe.Parameters[c.Y][c.X].knobState.tipArea
|
||||
ta.Appear(gtx.Now)
|
||||
ta.Exit.SetTarget(gtx.Now.Add(ta.ExitDuration))
|
||||
}
|
||||
}
|
||||
}
|
||||
for {
|
||||
@ -191,7 +198,7 @@ func (pe *UnitEditor) layoutRack(gtx C) D {
|
||||
columnTitleHeight := gtx.Dp(0)
|
||||
for i := range pe.Parameters {
|
||||
for len(pe.Parameters[i]) < width {
|
||||
pe.Parameters[i] = append(pe.Parameters[i], &ParameterState{})
|
||||
pe.Parameters[i] = append(pe.Parameters[i], &ParameterState{knobState: KnobState{tipArea: TipArea{ExitDuration: time.Second * 2}}})
|
||||
}
|
||||
}
|
||||
coltitle := func(gtx C, x int) D {
|
||||
@ -242,6 +249,15 @@ func (pe *UnitEditor) layoutRack(gtx C) D {
|
||||
param := t.Model.Params().Item(point)
|
||||
paramStyle := t.ParamStyle(param, t.Theme, pe.Parameters[y][x], pe.paramTable.Table.Cursor() == point)
|
||||
paramStyle.Layout(gtx)
|
||||
comment := t.Units().Item(y).Comment
|
||||
if comment != "" && x == t.Model.Params().RowWidth(y) {
|
||||
label := Label(t.Theme, &t.Theme.UnitEditor.RackComment, comment)
|
||||
return layout.W.Layout(gtx, func(gtx C) D {
|
||||
gtx.Constraints.Max.X = 1e6
|
||||
gtx.Constraints.Min.Y = 0
|
||||
return label.Layout(gtx)
|
||||
})
|
||||
}
|
||||
return D{Size: image.Pt(gtx.Constraints.Max.X, gtx.Constraints.Max.Y)}
|
||||
}
|
||||
table := FilledScrollTable(t.Theme, pe.paramTable)
|
||||
@ -368,10 +384,9 @@ func mulVec(a, b f32.Point) f32.Point {
|
||||
|
||||
func (pe *UnitEditor) layoutFooter(gtx C) D {
|
||||
t := TrackerFromContext(gtx)
|
||||
st := t.Units().SelectedType()
|
||||
text := "Choose unit type"
|
||||
if !t.UnitSearching().Value() {
|
||||
text = pe.caser.String(st)
|
||||
text = pe.caser.String(t.Units().SelectedType())
|
||||
}
|
||||
hintText := Label(t.Theme, &t.Theme.UnitEditor.Hint, text)
|
||||
deleteUnitBtn := ActionIconBtn(t.DeleteUnit(), t.Theme, pe.DeleteUnitBtn, icons.ActionDelete, "Delete unit (Ctrl+Backspace)")
|
||||
|
@ -175,6 +175,12 @@ func (pt *Params) Width() int {
|
||||
}
|
||||
return pt.derived.patch[pt.d.InstrIndex].paramsWidth
|
||||
}
|
||||
func (pt *Params) RowWidth(y int) int {
|
||||
if pt.d.InstrIndex < 0 || pt.d.InstrIndex >= len(pt.derived.patch) || y < 0 || y >= len(pt.derived.patch[pt.d.InstrIndex].params) {
|
||||
return 0
|
||||
}
|
||||
return len(pt.derived.patch[pt.d.InstrIndex].params[y])
|
||||
}
|
||||
func (pt *Params) Height() int { return (*Model)(pt).Units().Count() }
|
||||
func (pt *Params) MoveCursor(dx, dy int) (ok bool) {
|
||||
p := pt.Cursor()
|
||||
@ -260,8 +266,29 @@ func (pt *Params) unmarshalAtCursor(data []byte) (ret bool) {
|
||||
}
|
||||
return ret
|
||||
}
|
||||
func (pt *Params) unmarshalRange(rect Rect, data []byte) (ok bool) {
|
||||
panic("NOT IMPLEMENTED")
|
||||
func (pt *Params) unmarshalRange(rect Rect, data []byte) (ret bool) {
|
||||
table, ok := pt.unmarshal(data)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if len(table.Params) == 0 || len(table.Params[0]) == 0 {
|
||||
return false
|
||||
}
|
||||
width := rect.BottomRight.X - rect.TopLeft.X + 1
|
||||
height := rect.BottomRight.Y - rect.TopLeft.Y + 1
|
||||
if len(table.Params) < width {
|
||||
return false
|
||||
}
|
||||
for x := 0; x < width; x++ {
|
||||
for y := 0; y < height; y++ {
|
||||
if len(table.Params[0]) < height {
|
||||
return false
|
||||
}
|
||||
p := pt.Item(Point{x + rect.TopLeft.X, y + rect.TopLeft.Y})
|
||||
ret = p.SetValue(table.Params[x][y]) || ret
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
func (pt *Params) change(kind string, severity ChangeSeverity) func() {
|
||||
return (*Model)(pt).change(kind, PatchChange, severity)
|
||||
|
Reference in New Issue
Block a user