core/stripe/painter.go

Functions Structs Interfaces

Functions

func PaintBackground

PaintBackground renders a light gray background for the stripe.

func (p DefaultPainter) PaintBackground(canvas widget.Canvas, bounds geometry.Rect) {
	if bounds.IsEmpty() {
		return
	}
	canvas.DrawRect(bounds, defaultStripeBg)
}

func PaintButton

PaintButton renders a button with icon and optional text label.

func (p DefaultPainter) PaintButton(canvas widget.Canvas, state ButtonPaintState) {
	if state.Bounds.IsEmpty() {
		return
	}

	// Background on hover/press/active.
	bg := widget.ColorTransparent
	switch {
	case state.Pressed:
		bg = defaultPressedBg
	case state.Hovered:
		bg = defaultHoverBg
	case state.Active:
		bg = defaultActiveBg
	}
	if !bg.IsTransparent() {
		canvas.DrawRoundRect(state.Bounds, bg, defaultBtnRadius)
	}

	// Icon color.
	fg := defaultFgColor
	if state.Active {
		fg = defaultActiveFg
	}

	// Draw icon centered horizontally.
	iconBounds := buttonIconBounds(state.Bounds, state.ShowLabel)
	icon.Draw(canvas, state.Icon, iconBounds, fg)

	// Draw label below icon if enabled.
	if state.ShowLabel && state.Label != "" {
		textBounds := buttonTextBounds(state.Bounds, iconBounds)
		canvas.DrawText(state.Label, textBounds, defaultLabelFontSize, fg, false, widget.TextAlignCenter)
	}
}

Structs

type ButtonPaintState struct

ButtonPaintState provides the current button state to the painter.

type ButtonPaintState struct {
	// Bounds is the button's rectangle in local coordinates.
	Bounds	geometry.Rect

	// Icon is the vector icon data for the button.
	Icon	icon.IconData

	// Label is the button's text label.
	Label	string

	// Active indicates this button is the currently selected tool window.
	Active	bool

	// Hovered indicates the mouse cursor is over this button.
	Hovered	bool

	// Pressed indicates the mouse button is held down on this button.
	Pressed	bool

	// ShowLabel controls whether the text label is rendered below the icon.
	ShowLabel	bool
}

type DefaultPainter struct

DefaultPainter provides a minimal fallback painter with no design system styling.

It draws simple gray buttons suitable for testing and prototyping.

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of a stripe toolbar.

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

Painter implementation to render the stripe in its visual style.

 

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

type Painter interface {
	// PaintBackground renders the stripe background and optional border.
	PaintBackground(canvas widget.Canvas, bounds geometry.Rect)

	// PaintButton renders a single button within the stripe.
	PaintButton(canvas widget.Canvas, state ButtonPaintState)
}