core/collapsible/painter.go

Functions Structs Interfaces

Functions

func PaintHeader

PaintHeader renders a minimal collapsible header.

func (p DefaultPainter) PaintHeader(canvas widget.Canvas, s HeaderState) {
	if s.Bounds.IsEmpty() {
		return
	}

	bg := resolveHeaderBg(s)
	bg = applyStateModifier(bg, s.Hovered, s.Pressed)
	canvas.DrawRect(s.Bounds, bg)

	// Draw arrow indicator.
	arrowColor := resolveArrowColor(s)
	drawArrow(canvas, s.Bounds, arrowColor, s.ArrowProgress)

	// Draw title text.
	if s.Title != "" {
		titleBounds := titleTextBounds(s.Bounds)
		canvas.DrawText(s.Title, titleBounds, defaultFontSize, defaultTitleColor, true, textAlignLeft)
	}

	// Focus ring.
	if s.Focused {
		canvas.StrokeRect(s.Bounds, focusRingColor, focusRingStrokeWidth)
	}
}

Structs

type HeaderState struct

HeaderState provides the current state to the painter for header rendering.

type HeaderState struct {
	Title		string
	Expanded	bool
	Hovered		bool
	Pressed		bool
	Focused		bool
	Bounds		geometry.Rect
	ArrowProgress	float32	// 0.0 = collapsed (right arrow), 1.0 = expanded (down arrow)

	// Styling overrides (zero value means use painter defaults).
	HeaderColor	widget.Color
	ArrowColor	widget.Color
}

type DefaultPainter struct

DefaultPainter provides a minimal fallback header painter.

It draws a background, title text, and an arrow indicator.

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of a collapsible section header.

Each design system (Material 3, Fluent, Cupertino) provides its own

Painter implementation.

 

If no Painter is set, the section uses [DefaultPainter].

type Painter interface {
	PaintHeader(canvas widget.Canvas, state HeaderState)
}