theme/devtools/collapsible.go
Functions
func PaintHeader
func (p CollapsiblePainter) PaintHeader(canvas widget.Canvas, s collapsible.HeaderState) {
if s.Bounds.IsEmpty() {
return
}
// Resolve colors from theme or defaults.
bgColor, textColor, arrowColor, focusColor := p.resolveHeaderColors(s)
// Apply interaction state to background.
bgColor = dtApplyCollapsibleState(bgColor, s.Hovered, s.Pressed)
// Draw header background (flat, no rounded corners).
canvas.DrawRect(s.Bounds, bgColor)
// 1px bottom border separator.
borderRect := geometry.NewRect(
s.Bounds.Min.X,
s.Bounds.Max.Y-dtCollapsibleBorderWidth,
s.Bounds.Width(),
dtCollapsibleBorderWidth,
)
canvas.DrawRect(borderRect, dtCollapsibleBorderColor(p.Theme))
// Draw arrow indicator.
dtDrawCollapsibleArrow(canvas, s.Bounds, arrowColor, s.ArrowProgress)
// Draw title text.
if s.Title != "" {
titleBounds := dtCollapsibleTitleBounds(s.Bounds)
canvas.DrawText(s.Title, titleBounds, dtCollapsibleFontSize, textColor, true, dtCollapsibleTextAlign)
}
// Focus ring (1px DevTools style).
if s.Focused {
canvas.StrokeRect(s.Bounds, focusColor, dtCollapsibleFocusRingWidth)
}
}
Structs
type CollapsiblePainter struct
CollapsiblePainter renders collapsible section headers using DevTools design tokens.
DevTools collapsibles use minimal styling: Surface background, a subtle chevron
(Gray7 -> Gray12 on hover), 1px bottom border separator, and compact 8px padding,
matching JetBrains IDE tool window section headers.
If Theme is nil, CollapsiblePainter falls back to the default DevTools dark palette.
type CollapsiblePainter struct {
Theme *Theme // nil uses default DevTools dark fallback
}
PaintHeader renders a collapsible header according to DevTools specifications.