mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-25 16:34:45 -04:00
draftingf
This commit is contained in:
parent
89b728a269
commit
083ccc58b5
@ -17,7 +17,6 @@ import (
|
|||||||
"gioui.org/op/clip"
|
"gioui.org/op/clip"
|
||||||
"gioui.org/op/paint"
|
"gioui.org/op/paint"
|
||||||
"gioui.org/text"
|
"gioui.org/text"
|
||||||
"gioui.org/unit"
|
|
||||||
"gioui.org/widget"
|
"gioui.org/widget"
|
||||||
"gioui.org/widget/material"
|
"gioui.org/widget/material"
|
||||||
"gioui.org/x/component"
|
"gioui.org/x/component"
|
||||||
@ -113,8 +112,8 @@ func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
|||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
e, ok := gtx.Event(
|
e, ok := gtx.Event(
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameLeftArrow, Required: key.ModShift},
|
key.Filter{Focus: pe.paramTable, Name: key.NameLeftArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameRightArrow, Required: key.ModShift},
|
key.Filter{Focus: pe.paramTable, Name: key.NameRightArrow, Required: key.ModShift, Optional: key.ModShortcut},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteBackward},
|
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteBackward},
|
||||||
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteForward},
|
key.Filter{Focus: pe.paramTable, Name: key.NameDeleteForward},
|
||||||
)
|
)
|
||||||
@ -126,13 +125,13 @@ func (pe *UnitEditor) update(gtx C, t *Tracker) {
|
|||||||
item := params.Item(params.Cursor())
|
item := params.Item(params.Cursor())
|
||||||
switch e.Name {
|
switch e.Name {
|
||||||
case key.NameLeftArrow:
|
case key.NameLeftArrow:
|
||||||
if e.Modifiers.Contain(key.ModShift) {
|
if e.Modifiers.Contain(key.ModShortcut) {
|
||||||
item.SetValue(item.Value() - item.LargeStep())
|
item.SetValue(item.Value() - item.LargeStep())
|
||||||
} else {
|
} else {
|
||||||
item.SetValue(item.Value() - 1)
|
item.SetValue(item.Value() - 1)
|
||||||
}
|
}
|
||||||
case key.NameRightArrow:
|
case key.NameRightArrow:
|
||||||
if e.Modifiers.Contain(key.ModShift) {
|
if e.Modifiers.Contain(key.ModShortcut) {
|
||||||
item.SetValue(item.Value() + item.LargeStep())
|
item.SetValue(item.Value() + item.LargeStep())
|
||||||
} else {
|
} else {
|
||||||
item.SetValue(item.Value() + 1)
|
item.SetValue(item.Value() + 1)
|
||||||
@ -172,7 +171,7 @@ func (pe *UnitEditor) layoutSliders(gtx C) D {
|
|||||||
defer op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), -90*math.Pi/180).Offset(f32.Point{X: 0, Y: float32(h)})).Push(gtx.Ops).Pop()
|
defer op.Affine(f32.Affine2D{}.Rotate(f32.Pt(0, 0), -90*math.Pi/180).Offset(f32.Point{X: 0, Y: float32(h)})).Push(gtx.Ops).Pop()
|
||||||
gtx.Constraints = layout.Exact(image.Pt(1e6, 1e6))
|
gtx.Constraints = layout.Exact(image.Pt(1e6, 1e6))
|
||||||
Label(t.Theme, &t.Theme.OrderEditor.TrackTitle, t.Units().Item(y).Type).Layout(gtx)
|
Label(t.Theme, &t.Theme.OrderEditor.TrackTitle, t.Units().Item(y).Type).Layout(gtx)
|
||||||
return D{Size: image.Pt(gtx.Dp(patternCellWidth), h)}
|
return D{Size: image.Pt(gtx.Dp(10), h)}
|
||||||
}
|
}
|
||||||
cursor := t.Model.Params().Cursor()
|
cursor := t.Model.Params().Cursor()
|
||||||
cell := func(gtx C, x, y int) D {
|
cell := func(gtx C, x, y int) D {
|
||||||
@ -304,12 +303,13 @@ func (t *Tracker) ParamStyle(th *Theme, paramWidget *ParameterWidget) ParameterS
|
|||||||
|
|
||||||
func (p ParameterStyle) Layout(gtx C) D {
|
func (p ParameterStyle) Layout(gtx C) D {
|
||||||
info, infoOk := p.w.Parameter.Info()
|
info, infoOk := p.w.Parameter.Info()
|
||||||
return layout.Flex{Axis: layout.Horizontal, Alignment: layout.Middle}.Layout(gtx,
|
title := Label(p.Theme, &p.Theme.UnitEditor.ParameterName, p.w.Parameter.Name())
|
||||||
layout.Rigid(func(gtx C) D {
|
title.Alignment = text.Middle
|
||||||
gtx.Constraints.Min.X = gtx.Dp(unit.Dp(110))
|
return layout.Flex{Axis: layout.Vertical, Alignment: layout.Middle}.Layout(gtx,
|
||||||
return layout.E.Layout(gtx, Label(p.Theme, &p.Theme.UnitEditor.ParameterName, p.w.Parameter.Name()).Layout)
|
layout.Rigid(title.Layout),
|
||||||
}),
|
|
||||||
layout.Rigid(func(gtx C) D {
|
layout.Rigid(func(gtx C) D {
|
||||||
|
gtx.Constraints.Min.X = gtx.Dp(100)
|
||||||
|
gtx.Constraints.Min.Y = gtx.Dp(50)
|
||||||
switch p.w.Parameter.Type() {
|
switch p.w.Parameter.Type() {
|
||||||
case tracker.IntegerParameter:
|
case tracker.IntegerParameter:
|
||||||
for p.Focus {
|
for p.Focus {
|
||||||
@ -404,6 +404,7 @@ func (p ParameterStyle) Layout(gtx C) D {
|
|||||||
if p.w.Parameter.Type() != tracker.IDParameter {
|
if p.w.Parameter.Type() != tracker.IDParameter {
|
||||||
hint := p.w.Parameter.Hint()
|
hint := p.w.Parameter.Hint()
|
||||||
label := Label(p.tracker.Theme, &p.tracker.Theme.UnitEditor.Hint, hint.Label)
|
label := Label(p.tracker.Theme, &p.tracker.Theme.UnitEditor.Hint, hint.Label)
|
||||||
|
label.Alignment = text.Middle
|
||||||
if !hint.Valid {
|
if !hint.Valid {
|
||||||
label.Color = p.tracker.Theme.UnitEditor.InvalidParam
|
label.Color = p.tracker.Theme.UnitEditor.InvalidParam
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ type (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
IntegerParameter ParameterType = iota
|
NoParameter ParameterType = iota
|
||||||
|
IntegerParameter
|
||||||
BoolParameter
|
BoolParameter
|
||||||
IDParameter
|
IDParameter
|
||||||
)
|
)
|
||||||
@ -88,7 +89,7 @@ func (p *Parameter) Range() IntRange {
|
|||||||
}
|
}
|
||||||
func (p *Parameter) Type() ParameterType {
|
func (p *Parameter) Type() ParameterType {
|
||||||
if p.vtable == nil {
|
if p.vtable == nil {
|
||||||
return IntegerParameter
|
return NoParameter
|
||||||
}
|
}
|
||||||
return p.vtable.Type(p)
|
return p.vtable.Type(p)
|
||||||
}
|
}
|
||||||
@ -140,8 +141,8 @@ func (pt *Params) Table() Table { return Table{pt} }
|
|||||||
func (pt *Params) Cursor() Point { return Point{pt.d.ParamIndex, pt.d.UnitIndex} }
|
func (pt *Params) Cursor() Point { return Point{pt.d.ParamIndex, pt.d.UnitIndex} }
|
||||||
func (pt *Params) Cursor2() Point { return pt.Cursor() }
|
func (pt *Params) Cursor2() Point { return pt.Cursor() }
|
||||||
func (pt *Params) SetCursor(p Point) {
|
func (pt *Params) SetCursor(p Point) {
|
||||||
pt.d.ParamIndex = p.X
|
pt.d.ParamIndex = max(min(p.X, pt.Width()-1), 0)
|
||||||
pt.d.UnitIndex = p.Y
|
pt.d.UnitIndex = max(min(p.Y, pt.Height()-1), 0)
|
||||||
}
|
}
|
||||||
func (pt *Params) SetCursor2(p Point) {}
|
func (pt *Params) SetCursor2(p Point) {}
|
||||||
func (pt *Params) Width() int {
|
func (pt *Params) Width() int {
|
||||||
@ -156,14 +157,11 @@ func (pt *Params) Width() int {
|
|||||||
}
|
}
|
||||||
func (pt *Params) Height() int { return (*Model)(pt).Units().Count() }
|
func (pt *Params) Height() int { return (*Model)(pt).Units().Count() }
|
||||||
func (pt *Params) MoveCursor(dx, dy int) (ok bool) {
|
func (pt *Params) MoveCursor(dx, dy int) (ok bool) {
|
||||||
if pt.d.InstrIndex < 0 || pt.d.InstrIndex >= len(pt.d.Song.Patch) {
|
p := pt.Cursor()
|
||||||
return false
|
p.X += dx
|
||||||
}
|
p.Y += dy
|
||||||
pt.d.ParamIndex += dx
|
pt.SetCursor(p)
|
||||||
pt.d.UnitIndex += dy
|
return p == pt.Cursor()
|
||||||
pt.d.ParamIndex = clamp(pt.d.ParamIndex, 0, 7)
|
|
||||||
pt.d.UnitIndex = clamp(pt.d.UnitIndex, 0, len(pt.d.Song.Patch[pt.d.InstrIndex].Units)-1)
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
func (pt *Params) Item(p Point) Parameter {
|
func (pt *Params) Item(p Point) Parameter {
|
||||||
if pt.d.InstrIndex < 0 || pt.d.InstrIndex >= len(pt.d.Song.Patch) ||
|
if pt.d.InstrIndex < 0 || pt.d.InstrIndex >= len(pt.d.Song.Patch) ||
|
||||||
|
Reference in New Issue
Block a user