theme/fluent/radio.go

Functions Structs

Functions

func PaintRadio

PaintRadio renders a radio item according to Fluent Design specifications.

func (p RadioPainter) PaintRadio(canvas widget.Canvas, state radio.PaintState) {
	if state.Bounds.IsEmpty() {
		return
	}

	colors := state.ColorScheme
	if colors == (radio.RadioColorScheme{}) {
		colors = p.resolveColors()
	}

	disabled := state.Disabled
	center, radius := flRadioCircleGeometry(state.Bounds)

	if state.Selected {
		flPaintSelectedRadio(canvas, center, radius, state, disabled, colors)
	} else {
		flPaintUnselectedRadio(canvas, center, radius, state, disabled, colors)
	}

	// Label.
	if state.Label != "" {
		fg := colors.LabelColor
		if disabled {
			fg = colors.DisabledFg
		}
		labelBounds := flRadioLabelBounds(state.Bounds)
		canvas.DrawText(state.Label, labelBounds, flRadioFontSize, fg, false, flRadioTextAlignLeft)
	}

	// Focus ring.
	if state.Focused && !disabled {
		canvas.StrokeCircle(center, radius+flRadioFocusRingOffset, colors.FocusRing, flRadioFocusRingStrokeWidth)
	}
}

Structs

type RadioPainter struct

RadioPainter renders radio items using Fluent Design tokens.

 

If Theme is nil, RadioPainter falls back to the default Fluent Blue palette.

type RadioPainter struct {
	Theme *Theme	// nil uses default Fluent Blue fallback
}