mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-20 05:54:34 -04:00
drafting
This commit is contained in:
parent
0182d004b1
commit
285f33c261
3
go.mod
3
go.mod
@ -6,7 +6,7 @@ toolchain go1.24.0
|
||||
|
||||
require (
|
||||
gioui.org v0.8.1-0.20250624114559-c3ce484b5e80
|
||||
gioui.org/x v0.7.1
|
||||
gioui.org/x v0.8.1
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible
|
||||
github.com/ebitengine/oto/v3 v3.3.0
|
||||
github.com/viterin/vek v0.4.2
|
||||
@ -23,6 +23,7 @@ require (
|
||||
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 // indirect
|
||||
github.com/Masterminds/goutils v1.1.0 // indirect
|
||||
github.com/Masterminds/semver v1.5.0 // indirect
|
||||
github.com/andybalholm/stroke v0.0.0-20221221101821-bd29b49d73f0 // indirect
|
||||
github.com/chewxy/math32 v1.11.1 // indirect
|
||||
github.com/ebitengine/purego v0.8.0 // indirect
|
||||
github.com/go-text/typesetting v0.3.0 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -9,6 +9,8 @@ gioui.org/shader v1.0.8 h1:6ks0o/A+b0ne7RzEqRZK5f4Gboz2CfG+mVliciy6+qA=
|
||||
gioui.org/shader v1.0.8/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM=
|
||||
gioui.org/x v0.7.1 h1:7bnQHsV7qB36tIUit2WDcUx4Cnmo+6T9I38B9brLQ7o=
|
||||
gioui.org/x v0.7.1/go.mod h1:5CzZ64oFpOaqb2kaMvj+QEr5T3nVuLKD0LizLH32ii0=
|
||||
gioui.org/x v0.8.1 h1:Q2wumEOfjz3XfRa3TEi6w7dq8+cxV8zsYK8xXQkrCRk=
|
||||
gioui.org/x v0.8.1/go.mod h1:v2g60aiZtIVR7lNFXZ123+U0kijJeOChODSuqr7MFSI=
|
||||
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0 h1:bGG/g4ypjrCJoSvFrP5hafr9PPB5aw8SjcOWWila7ZI=
|
||||
git.wow.st/gmp/jni v0.0.0-20210610011705-34026c7e22d0/go.mod h1:+axXBRUTIDlCeE73IKeD/os7LoEnTKdkp8/gQOFjqyo=
|
||||
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
|
||||
@ -17,6 +19,8 @@ github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3Q
|
||||
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
|
||||
github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
|
||||
github.com/andybalholm/stroke v0.0.0-20221221101821-bd29b49d73f0 h1:uF5Q/hWnDU1XZeT6CsrRSxHLroUSEYYO3kgES+yd+So=
|
||||
github.com/andybalholm/stroke v0.0.0-20221221101821-bd29b49d73f0/go.mod h1:ccdDYaY5+gO+cbnQdFxEXqfy0RkoV25H3jLXUDNM3wg=
|
||||
github.com/chewxy/math32 v1.11.1 h1:b7PGHlp8KjylDoU8RrcEsRuGZhJuz8haxnKfuMMRqy8=
|
||||
github.com/chewxy/math32 v1.11.1/go.mod h1:dOB2rcuFrCn6UHrze36WSLVPKtzPMRAQvBvUwkSsLqs=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
|
@ -181,6 +181,9 @@ func (m *Model) deriveParams(unit *sointu.Unit) []Parameter {
|
||||
if unit.Type == "oscillator" && unit.Parameters["type"] != sointu.Sample && (up.Name == "samplestart" || up.Name == "loopstart" || up.Name == "looplength") {
|
||||
continue // don't show the sample related params unless necessary
|
||||
}
|
||||
if unit.Type == "send" && up.Name == "port" {
|
||||
continue
|
||||
}
|
||||
ret = append(ret, Parameter{m: m, unit: unit, up: &unitType[i], vtable: &namedParameter{}})
|
||||
}
|
||||
if unit.Type == "oscillator" && unit.Parameters["type"] == sointu.Sample {
|
||||
|
@ -219,7 +219,8 @@ uniteditor:
|
||||
rowtitle: { textsize: 12, color: *white, alignment: 2 }
|
||||
knob:
|
||||
diameter: 36
|
||||
strokewidth: 4
|
||||
color: *primarycolor
|
||||
trackcolor: { r: 0, g: 0, b: 0, a: 255 }
|
||||
value: { textsize: 12, color: *highemphasis }
|
||||
strokewidth: 4
|
||||
pos: { color: *primarycolor, bg: { r: 51, g: 36, b: 54, a: 255 } }
|
||||
neg: { color: *secondarycolor, bg: { r: 32, g: 55, b: 58, a: 255 } }
|
||||
indicator: { color: *white, width: 2, innerdiam: 24, outerdiam: 36 }
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"gioui.org/unit"
|
||||
"gioui.org/widget"
|
||||
"gioui.org/widget/material"
|
||||
"gioui.org/x/stroke"
|
||||
"github.com/vsariola/sointu"
|
||||
"github.com/vsariola/sointu/tracker"
|
||||
"golang.org/x/exp/shiny/materialdesign/icons"
|
||||
@ -61,8 +62,20 @@ type (
|
||||
KnobStyle struct {
|
||||
Diameter unit.Dp
|
||||
StrokeWidth unit.Dp
|
||||
Pos struct {
|
||||
Color color.NRGBA
|
||||
TrackColor color.NRGBA
|
||||
Bg color.NRGBA
|
||||
}
|
||||
Neg struct {
|
||||
Color color.NRGBA
|
||||
Bg color.NRGBA
|
||||
}
|
||||
Indicator struct {
|
||||
Color color.NRGBA
|
||||
Width unit.Dp
|
||||
InnerDiam unit.Dp
|
||||
OuterDiam unit.Dp
|
||||
}
|
||||
Value LabelStyle
|
||||
Title LabelStyle
|
||||
}
|
||||
@ -452,8 +465,9 @@ func (k *KnobWidget) Layout(gtx C) D {
|
||||
event.Op(gtx.Ops, k.State)
|
||||
k.State.drag.Add(gtx.Ops)
|
||||
k.State.click.Add(gtx.Ops)
|
||||
strokeKnobArc(gtx, k.Style.TrackColor, sw, d, 1)
|
||||
strokeKnobArc(gtx, k.Style.Color, sw, d, amount)
|
||||
k.strokeKnobArc(gtx, k.Style.Pos.Bg, sw, d, amount, 1)
|
||||
k.strokeKnobArc(gtx, k.Style.Pos.Color, sw, d, 0, amount)
|
||||
k.strokeIndicator(gtx, amount)
|
||||
return D{Size: image.Pt(d, d)}
|
||||
}
|
||||
label := Label(k.Theme, &k.Style.Value, strconv.Itoa(k.Value.Value()))
|
||||
@ -519,23 +533,50 @@ func (k *KnobWidget) update(gtx C) {
|
||||
}
|
||||
}
|
||||
|
||||
func strokeKnobArc(gtx C, color color.NRGBA, strokeWidth, diameter int, amount float32) {
|
||||
var path clip.Path
|
||||
func (k *KnobWidget) strokeKnobArc(gtx C, color color.NRGBA, strokeWidth, diameter int, start, end float32) {
|
||||
rad := float32(diameter) / 2
|
||||
amount = min(max(amount, 0), 1)
|
||||
if amount <= 0 {
|
||||
end = min(max(end, 0), 1)
|
||||
if end <= 0 {
|
||||
return
|
||||
}
|
||||
angle := amount * 8 * math.Pi / 5
|
||||
startAngle := float64((start*8 + 1) / 10 * 2 * math.Pi)
|
||||
deltaAngle := (end - start) * 8 * math.Pi / 5
|
||||
center := f32.Point{X: rad, Y: rad}
|
||||
r2 := rad - float32(strokeWidth)/2
|
||||
start := f32.Point{X: rad - r2*float32(math.Sin(math.Pi/5)), Y: rad + r2*float32(math.Cos(math.Pi/5))}
|
||||
path.Begin(gtx.Ops)
|
||||
path.MoveTo(start)
|
||||
path.ArcTo(center, center, angle)
|
||||
paint.FillShape(gtx.Ops, color,
|
||||
clip.Stroke{
|
||||
Path: path.End(),
|
||||
startPt := f32.Point{X: rad - r2*float32(math.Sin(startAngle)), Y: rad + r2*float32(math.Cos(startAngle))}
|
||||
segments := [...]stroke.Segment{
|
||||
stroke.MoveTo(startPt),
|
||||
stroke.ArcTo(center, deltaAngle),
|
||||
}
|
||||
s := stroke.Stroke{
|
||||
Path: stroke.Path{Segments: segments[:]},
|
||||
Width: float32(strokeWidth),
|
||||
}.Op())
|
||||
Cap: stroke.FlatCap,
|
||||
}
|
||||
paint.FillShape(gtx.Ops, color, s.Op(gtx.Ops))
|
||||
}
|
||||
|
||||
func (k *KnobWidget) strokeIndicator(gtx C, amount float32) {
|
||||
innerRad := float32(gtx.Dp(k.Style.Indicator.InnerDiam)) / 2
|
||||
outerRad := float32(gtx.Dp(k.Style.Indicator.OuterDiam)) / 2
|
||||
center := float32(gtx.Dp(k.Style.Diameter)) / 2
|
||||
angle := (float64(amount)*8 + 1) / 10 * 2 * math.Pi
|
||||
start := f32.Point{
|
||||
X: center - innerRad*float32(math.Sin(angle)),
|
||||
Y: center + innerRad*float32(math.Cos(angle)),
|
||||
}
|
||||
end := f32.Point{
|
||||
X: center - outerRad*float32(math.Sin(angle)),
|
||||
Y: center + outerRad*float32(math.Cos(angle)),
|
||||
}
|
||||
segments := [...]stroke.Segment{
|
||||
stroke.MoveTo(start),
|
||||
stroke.LineTo(end),
|
||||
}
|
||||
s := stroke.Stroke{
|
||||
Path: stroke.Path{Segments: segments[:]},
|
||||
Width: float32(k.Style.Indicator.Width),
|
||||
Cap: stroke.FlatCap,
|
||||
}
|
||||
paint.FillShape(gtx.Ops, k.Style.Indicator.Color, s.Op(gtx.Ops))
|
||||
}
|
||||
|
Reference in New Issue
Block a user