theme/material3/progress.go

Functions Structs

Functions

func PaintProgress

PaintProgress renders a circular progress indicator according to Material 3 specifications.

func (p ProgressPainter) PaintProgress(canvas widget.Canvas, ps progress.PaintState) {
	if ps.Bounds.IsEmpty() {
		return
	}

	bounds := ps.Bounds
	centerX := bounds.Min.X + bounds.Width()/2
	centerY := bounds.Min.Y + bounds.Height()/2
	center := geometry.Pt(centerX, centerY)

	// Use the smaller of width/height for the radius, minus stroke width.
	availDiameter := ps.Diameter
	if bounds.Width() < availDiameter {
		availDiameter = bounds.Width()
	}
	if bounds.Height() < availDiameter {
		availDiameter = bounds.Height()
	}
	radius := (availDiameter - ps.StrokeWidth) / 2
	if radius <= 0 {
		return
	}

	if ps.Indeterminate {
		p.paintIndeterminate(canvas, ps, center, radius)
	} else {
		p.paintDeterminate(canvas, ps, center, radius)
	}
}

Structs

type ProgressPainter struct

ProgressPainter renders circular progress indicators using Material 3 design tokens.

It maps progress states (determinate, indeterminate, disabled) to the M3 color scheme

with primary color for the arc and surface variant for the track.

 

If Theme is nil, ProgressPainter falls back to the default M3 purple palette.

type ProgressPainter struct {
	Theme *Theme	// nil uses default M3 purple fallback
}