core/progress/painter.go

Functions Structs Interfaces

Functions

func PaintProgress

PaintProgress renders the circular progress indicator.

In determinate mode, it draws a track circle and a progress arc.

In indeterminate mode, it draws a rotating partial arc.

func (p DefaultPainter) PaintProgress(canvas widget.Canvas, ps 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 PaintState struct

PaintState provides the current progress indicator state to the painter.

type PaintState struct {
	Value		float64			// current value clamped to [0, 1] (determinate mode)
	Bounds		geometry.Rect		// total widget bounds
	Diameter	float32			// indicator diameter in logical pixels
	StrokeWidth	float32			// arc stroke width in logical pixels
	ShowLabel	bool			// whether to show percentage label (determinate only)
	Label		string			// pre-formatted label text (empty if ShowLabel is false)
	Indeterminate	bool			// true for spinner mode
	Rotation	float64			// current rotation in radians (indeterminate mode)
	AnimationPhase	float64			// 0-1 sawtooth phase within one grow/shrink cycle
	Disabled	bool			// widget is disabled
	ColorScheme	ProgressColorScheme	// theme-derived colors (zero = use defaults)
}

type DefaultPainter struct

DefaultPainter provides a minimal fallback painter with no design system styling.

It draws a circular progress indicator using cubic Bézier arc strokes.

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of a circular progress indicator.

Each design system (Material 3, Fluent, Cupertino) provides its own

Painter implementation to render the indicator in its visual style.

 

If no Painter is set, the progress indicator uses [DefaultPainter].

type Painter interface {
	PaintProgress(canvas widget.Canvas, state PaintState)
}