Add input components 066-085; gallery chrome on real components; deploy warms the edge

This commit is contained in:
ZacharyZhang-NY committed 2026-10-11 19:05:42 -04:00
1 parent 0247a130f5
commit 095eab2b4c
38 files changed
+2340 -172

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
package input
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type FaderOptions struct {
Min, Max float64
// Height is the travel in dots; zero means 64.
Height int
Disabled bool
}
type FaderResult = SliderResult
// Fader is a vertical slider with a cap and ticks.
func Fader(c *ui.Context, text string, value *float64, o FaderOptions) FaderResult {
k := pixel.K(c)
lo, hi := bounds(o.Min, o.Max)
h := orDef("Fader Height", o.Height, 64)
shell, st, changed := slide(c, value, rail{lo: lo, hi: hi, vertical: true, label: text, disabled: o.Disabled})
shell.Size(k.D(16), k.D(h)).Draw(func(p *ui.Painter, r ui.Rect) {
g := k.Canvas(p, r)
for t := 0; t <= 4; t++ {
y := 3 + t*(g.H-7)/4
g.HLine(0, y, 3, pixel.Faint)
g.HLine(13, y, 3, pixel.Faint)
}
g.Frame(6, 0, 4, g.H, pixel.Sunken, pixel.Well)
y := g.H - 7 - knobAt(*value, lo, hi, g.H-7)
g.Rect(7, y+3, 2, g.H-y-4, pixel.Accent)
g.Frame(2, y, 12, 7, pixel.Raised, pixel.Face)
g.HLine(4, y+3, 8, pixel.Edge)
finish(g, st)
})
return report(shell, changed, "fader", text, *value)
}