theme/material3/gridview.go
Functions
func PaintCellBackground
func (p GridViewPainter) PaintCellBackground(canvas widget.Canvas, cps gridview.CellPaintState) {
if cps.Bounds.IsEmpty() {
return
}
// Determine the color scheme to use.
colors := cps.ColorScheme
if colors == (gridview.GridColorScheme{}) {
colors = p.resolveColors()
}
if cps.Hovered && !cps.Disabled {
canvas.DrawRoundRect(cps.Bounds, colors.HoverColor, m3GridCellRadius)
}
}
func PaintEmptyState
PaintEmptyState draws a centered empty state message.
func (p GridViewPainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect) {
if bounds.IsEmpty() {
return
}
textColor := m3GridDefaultEmptyText
if p.Theme != nil {
textColor = p.Theme.Colors.OnSurfaceVariant
}
canvas.DrawText(m3GridEmptyStateText, bounds, m3GridEmptyFontSize, textColor, false, m3GridEmptyTextAlign)
}
func PaintSelection
PaintSelection draws the selection highlight for a selected cell.
This is called before the cell widget's own Draw method.
func (p GridViewPainter) PaintSelection(canvas widget.Canvas, cps gridview.CellPaintState) {
if cps.Bounds.IsEmpty() || !cps.Selected {
return
}
// Determine the color scheme to use.
colors := cps.ColorScheme
if colors == (gridview.GridColorScheme{}) {
colors = p.resolveColors()
}
canvas.DrawRoundRect(cps.Bounds, colors.SelectionColor, m3GridCellRadius)
// Draw focus border.
if cps.Focused && !cps.Disabled {
canvas.StrokeRoundRect(cps.Bounds, colors.FocusColor, m3GridCellRadius, m3GridFocusBorderWidth)
}
}
Structs
type GridViewPainter struct
GridViewPainter renders grid view elements using Material 3 design tokens.
It maps cell states (selected, hovered, focused) to the M3 color scheme
with primary for selection, secondary-container for hover, and surface for cells.
If Theme is nil, GridViewPainter falls back to the default M3 purple palette.
type GridViewPainter struct {
Theme *Theme // nil uses default M3 purple fallback
}
PaintCellBackground draws the background for a grid cell.
This is called before the cell widget's own Draw method.