theme/material3/dialog.go

Functions Structs

Functions

func PaintDialog

PaintDialog renders a dialog according to Material 3 specifications.

func (p DialogPainter) PaintDialog(canvas widget.Canvas, ps dialog.PaintState) {
	if ps.Bounds.IsEmpty() {
		return
	}

	// Determine the color scheme to use.
	colors := ps.ColorScheme
	if colors == (dialog.DialogColorScheme{}) {
		colors = p.resolveColors()
	}

	// Draw surface with M3 corner radius (28dp for full-screen dialog, 24dp standard).
	canvas.DrawRoundRect(ps.Bounds, colors.Surface, m3DialogRadius)

	// Draw title (headline small: 24px).
	if ps.Title != "" {
		titleBounds := geometry.Rect{
			Min:	geometry.Pt(ps.Bounds.Min.X+m3DialogPadding, ps.Bounds.Min.Y+m3DialogPadding),
			Max:	geometry.Pt(ps.Bounds.Max.X-m3DialogPadding, ps.Bounds.Min.Y+m3DialogPadding+m3DialogTitleHeight),
		}
		canvas.DrawText(ps.Title, titleBounds, m3DialogTitleFontSize, colors.Title, false, m3DialogTextAlignLeft)
	}

	// Draw action buttons (text buttons, right-aligned).
	p.paintActions(canvas, ps, colors)

	// Focus indicator.
	if ps.Focused {
		ringBounds := ps.Bounds.Expand(m3DialogFocusRingOffset)
		ringRadius := m3DialogRadius + m3DialogFocusRingOffset
		canvas.StrokeRoundRect(ringBounds, colors.ActionFg.WithAlpha(m3DialogFocusRingAlpha), ringRadius, m3DialogFocusRingStroke)
	}
}

Structs

type DialogPainter struct

DialogPainter renders dialogs using Material 3 design tokens.

It applies the M3 dialog specification: surface tint, headline small

typography, and text action buttons.

 

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

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