core/scrollview/painter.go

Functions Structs Interfaces

Functions

func PaintScrollbar

PaintScrollbar renders minimal scrollbars with gray track and darker thumb.

func (p DefaultPainter) PaintScrollbar(canvas widget.Canvas, ps PaintState) {
	if ps.Bounds.IsEmpty() {
		return
	}

	hasScheme := ps.ColorScheme != (ScrollbarColorScheme{})

	if ps.VScrollVisible {
		paintScrollbarTrack(canvas, ps.VTrackRect, hasScheme, ps.ColorScheme)
		paintScrollbarThumb(canvas, ps.VThumbRect, ps, hasScheme)
	}

	if ps.HScrollVisible {
		paintScrollbarTrack(canvas, ps.HTrackRect, hasScheme, ps.ColorScheme)
		paintScrollbarThumb(canvas, ps.HThumbRect, ps, hasScheme)
	}
}

Structs

type PaintState struct

PaintState provides the current scrollbar state to the painter.

type PaintState struct {
	Bounds		geometry.Rect	// total widget bounds (viewport)
	Direction	ScrollDirection
	Focused		bool
	Hovered		bool
	Dragging	bool
	ColorScheme	ScrollbarColorScheme

	// Vertical scrollbar state.
	VScrollVisible	bool		// whether vertical scrollbar should be drawn
	VThumbRect	geometry.Rect	// vertical thumb rectangle
	VTrackRect	geometry.Rect	// vertical track rectangle

	// Horizontal scrollbar state.
	HScrollVisible	bool		// whether horizontal scrollbar should be drawn
	HThumbRect	geometry.Rect	// horizontal thumb rectangle
	HTrackRect	geometry.Rect	// horizontal track rectangle
}

type ScrollbarColorScheme struct

ScrollbarColorScheme provides theme-derived colors for scrollbar painting.

Zero value means the painter should use its built-in defaults.

type ScrollbarColorScheme struct {
	Track		widget.Color	// scrollbar track background
	Thumb		widget.Color	// scrollbar thumb fill
	ThumbHover	widget.Color	// scrollbar thumb fill when hovered
	ThumbDrag	widget.Color	// scrollbar thumb fill when dragging
}

type DefaultPainter struct

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

It draws simple scrollbars -- useful for testing and as a base reference.

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of scrollbars.

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

Painter implementation to render scrollbars in its visual style.

 

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

type Painter interface {
	PaintScrollbar(canvas widget.Canvas, state PaintState)
}