theme/material3/popover.go
Functions
func PaintPopover
func (p PopoverPainter) PaintPopover(canvas widget.Canvas, st *popover.PopoverPaintState) {
if st.Bounds.IsEmpty() {
return
}
bg, border, shadow := p.resolvePopoverColors(st.ColorScheme)
shadowBlur := m3PopoverShadowBlur
if st.ColorScheme != (popover.PopoverColorScheme{}) && st.ColorScheme.ShadowBlur > 0 {
shadowBlur = st.ColorScheme.ShadowBlur
}
// Shadow (offset slightly down).
shadowBounds := geometry.Rect{
Min: geometry.Pt(st.Bounds.Min.X+m3PopoverShadowOffX, st.Bounds.Min.Y+shadowBlur/2),
Max: geometry.Pt(st.Bounds.Max.X+m3PopoverShadowOffX, st.Bounds.Max.Y+shadowBlur/2),
}
canvas.DrawRoundRect(shadowBounds, shadow, m3PopoverRadius)
// Background.
canvas.DrawRoundRect(st.Bounds, bg, m3PopoverRadius)
// Border.
canvas.StrokeRoundRect(st.Bounds, border, m3PopoverRadius, m3PopoverBorderWidth)
}
func PaintTooltip
PaintTooltip renders a tooltip background and text according to M3 specifications.
func (p PopoverPainter) PaintTooltip(canvas widget.Canvas, st *popover.TooltipPaintState) {
if st.Bounds.IsEmpty() {
return
}
bg, textColor, border := p.resolveTooltipColors(st.ColorScheme)
// Background.
canvas.DrawRoundRect(st.Bounds, bg, m3TooltipRadius)
// Border (subtle).
if border != (widget.Color{}) {
canvas.StrokeRoundRect(st.Bounds, border, m3TooltipRadius, m3TooltipBorderWidth)
}
// Text.
textBounds := geometry.Rect{
Min: geometry.Pt(st.Bounds.Min.X+m3TooltipPadH, st.Bounds.Min.Y),
Max: geometry.Pt(st.Bounds.Max.X-m3TooltipPadH, st.Bounds.Max.Y),
}
canvas.DrawText(st.Text, textBounds, m3TooltipFontSize, textColor, false, m3TooltipTextAlign)
}
Structs
type PopoverPainter struct
PopoverPainter renders popovers and tooltips using Material 3 design tokens.
It applies M3 surface container elevation, outline-variant borders,
and inverse-surface tooltip styling.
If Theme is nil, PopoverPainter falls back to the default M3 purple palette.
type PopoverPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
PaintPopover renders a popover background with shadow according to M3 specifications.