theme/devtools/datatable.go
Functions
func PaintCell
func (p DataTablePainter) PaintCell(canvas widget.Canvas, cps datatable.CellPaintState) {
if cps.Bounds.IsEmpty() {
return
}
colors := p.effectiveCellColors(cps.ColorScheme)
fg := colors.CellText
if cps.Disabled {
fg = fg.WithAlpha(dtTableDisabledAlpha)
}
textBounds := geometry.NewRect(
cps.Bounds.Min.X+dtTableCellPaddingH,
cps.Bounds.Min.Y,
cps.Bounds.Width()-dtTableCellPaddingH*2,
cps.Bounds.Height(),
)
canvas.DrawText(cps.Value, textBounds, dtTableCellFontSize, fg, false, cps.Align)
}
func PaintEmptyState
PaintEmptyState draws a centered "No data" message.
func (p DataTablePainter) PaintEmptyState(canvas widget.Canvas, bounds geometry.Rect) {
if bounds.IsEmpty() {
return
}
colors := p.resolveColors()
canvas.DrawText(dtTableEmptyText, bounds, dtTableEmptyFontSize, colors.EmptyText, false, widget.TextAlignCenter)
}
func PaintHeader
PaintHeader draws the table header background with DevTools elevated surface color.
func (p DataTablePainter) PaintHeader(canvas widget.Canvas, bounds geometry.Rect, hps datatable.HeaderPaintState) {
if bounds.IsEmpty() {
return
}
colors := p.effectiveHeaderColors(hps.ColorScheme)
canvas.DrawRect(bounds, colors.HeaderBackground)
// Bottom divider line.
dividerRect := geometry.NewRect(bounds.Min.X, bounds.Max.Y-dtTableDividerHeight, bounds.Width(), dtTableDividerHeight)
canvas.DrawRect(dividerRect, colors.Divider)
}
func PaintHeaderCell
PaintHeaderCell draws a column header with title and sort indicator.
func (p DataTablePainter) PaintHeaderCell(canvas widget.Canvas, bounds geometry.Rect, hcs datatable.HeaderCellPaintState) {
if bounds.IsEmpty() {
return
}
colors := p.effectiveHeaderCellColors(hcs.ColorScheme)
// Highlight on hover for sortable columns.
if hcs.Hovered && hcs.Sortable && !hcs.Disabled {
canvas.DrawRect(bounds, colors.HoverColor)
}
// Build display text with sort indicator.
displayText := hcs.Title
if indicator := hcs.SortDir.Indicator(); indicator != "" {
displayText = hcs.Title + " " + indicator
}
// Inset for text padding.
textBounds := geometry.NewRect(
bounds.Min.X+dtTableCellPaddingH,
bounds.Min.Y,
bounds.Width()-dtTableCellPaddingH*2,
bounds.Height(),
)
fg := colors.HeaderText
if hcs.Disabled {
fg = fg.WithAlpha(dtTableDisabledAlpha)
}
canvas.DrawText(displayText, textBounds, dtTableHeaderFontSize, fg, true, hcs.Align)
}
func PaintRow
PaintRow draws the row background with zebra striping and DevTools selection/hover highlights.
func (p DataTablePainter) PaintRow(canvas widget.Canvas, rps datatable.RowPaintState) {
if rps.Bounds.IsEmpty() {
return
}
colors := p.effectiveRowColors(rps.ColorScheme)
// Zebra striping for alternate rows.
if rps.RowIndex%2 == 1 {
canvas.DrawRect(rps.Bounds, colors.RowAlternate)
}
// Selection highlight.
if rps.Selected {
canvas.DrawRect(rps.Bounds, colors.SelectionColor)
}
// Hover highlight (only when not selected to avoid double-tinting).
if rps.Hovered && !rps.Selected && !rps.Disabled {
canvas.DrawRect(rps.Bounds, colors.HoverColor)
}
// Focus ring (1px DevTools style).
if rps.Focused && !rps.Disabled {
canvas.StrokeRect(rps.Bounds, colors.FocusColor, dtTableFocusBorderWidth)
}
}
Structs
type DataTablePainter struct
DataTablePainter renders data tables using DevTools design tokens.
DevTools tables use striped rows (alternating Background/Surface), compact
24px row height, and a fixed header with SurfaceElevated background,
matching JetBrains IDE table styling.
If Theme is nil, DataTablePainter falls back to the default DevTools dark palette.
type DataTablePainter struct {
Theme *Theme // nil uses default DevTools dark fallback
}
PaintCell draws a single data cell with DevTools on-surface text color.