mirror of
https://github.com/vsariola/sointu.git
synced 2026-02-12 19:23:12 -05:00
drafting
This commit is contained in:
parent
179ebb7cc3
commit
fcb9a06249
@ -8,6 +8,7 @@ import (
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/event"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/op"
|
||||
"gioui.org/op/clip"
|
||||
"gioui.org/op/paint"
|
||||
)
|
||||
@ -27,6 +28,7 @@ type (
|
||||
CurveColors [2]color.NRGBA `yaml:",flow"`
|
||||
LimitColor color.NRGBA `yaml:",flow"`
|
||||
CursorColor color.NRGBA `yaml:",flow"`
|
||||
Ticks LabelStyle
|
||||
}
|
||||
|
||||
PlotDataFunc func(chn int, xr plotRange) (yr plotRange)
|
||||
@ -47,7 +49,7 @@ func NewPlot(xlim, ylim plotRange) *Plot {
|
||||
func (p *Plot) Layout(gtx C, data PlotDataFunc, xticks, yticks PlotTickFunc, cursornx float32, numchns int) D {
|
||||
p.update(gtx)
|
||||
t := TrackerFromContext(gtx)
|
||||
style := t.Theme.Oscilloscope
|
||||
style := t.Theme.Plot
|
||||
s := gtx.Constraints.Max
|
||||
if s.X <= 1 || s.Y <= 1 {
|
||||
return D{}
|
||||
@ -59,16 +61,21 @@ func (p *Plot) Layout(gtx C, data PlotDataFunc, xticks, yticks PlotTickFunc, cur
|
||||
ylim := p.ylim()
|
||||
|
||||
// draw tick marks
|
||||
paint.ColorOp{Color: style.LimitColor}.Add(gtx.Ops)
|
||||
|
||||
xticks(xlim, func(x float32, label string) {
|
||||
xticks(xlim, func(x float32, txt string) {
|
||||
paint.ColorOp{Color: style.LimitColor}.Add(gtx.Ops)
|
||||
sx := plotPx(s.X).toScreen(xlim.toRelative(x))
|
||||
fillRect(gtx, clip.Rect{Min: image.Pt(sx, 0), Max: image.Pt(sx+1, s.Y)})
|
||||
defer op.Offset(image.Pt(sx, gtx.Dp(2))).Push(gtx.Ops).Pop()
|
||||
Label(t.Theme, &t.Theme.Plot.Ticks, txt).Layout(gtx)
|
||||
})
|
||||
|
||||
yticks(ylim, func(y float32, label string) {
|
||||
yticks(ylim, func(y float32, txt string) {
|
||||
paint.ColorOp{Color: style.LimitColor}.Add(gtx.Ops)
|
||||
sy := plotPx(s.Y).toScreen(ylim.toRelative(y))
|
||||
fillRect(gtx, clip.Rect{Min: image.Pt(0, sy), Max: image.Pt(s.X, sy+1)})
|
||||
defer op.Offset(image.Pt(gtx.Dp(2), sy)).Push(gtx.Ops).Pop()
|
||||
Label(t.Theme, &t.Theme.Plot.Ticks, txt).Layout(gtx)
|
||||
})
|
||||
|
||||
// draw cursor
|
||||
|
||||
Reference in New Issue
Block a user