core/slider/painter.go

Functions Structs Interfaces

Functions

func PaintSlider

PaintSlider renders a minimal slider with gray track, blue active segment,

and a white thumb circle with border.

If state.ColorScheme is non-zero, its colors are used instead of built-in defaults.

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

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

	if ps.Orientation == Vertical {
		paintVerticalSlider(canvas, ps, hasScheme)
	} else {
		paintHorizontalSlider(canvas, ps, hasScheme)
	}
}

Structs

type PaintState struct

PaintState provides the current slider state to the painter.

type PaintState struct {
	Value		float32			// current value (within [Min, Max])
	Min		float32			// minimum value
	Max		float32			// maximum value
	Progress	float32			// normalized 0..1 progress
	Hovered		bool			// mouse is over the slider
	Dragging	bool			// thumb is being dragged
	Focused		bool			// slider has keyboard focus
	Disabled	bool			// slider is disabled
	Bounds		geometry.Rect		// total widget bounds
	Orientation	Orientation		// horizontal or vertical
	Marks		[]Mark			// optional tick marks
	ColorScheme	SliderColorScheme	// theme-derived colors
}

type SliderColorScheme struct

SliderColorScheme provides theme-derived colors for slider painting.

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

type SliderColorScheme struct {
	ActiveTrack	widget.Color	// active (filled) portion of the track
	InactiveTrack	widget.Color	// inactive (empty) portion of the track
	Thumb		widget.Color	// thumb circle fill
	ThumbBorder	widget.Color	// thumb circle border
	FocusRing	widget.Color	// focus indicator color
	DisabledTrack	widget.Color	// track color when disabled
	DisabledThumb	widget.Color	// thumb color when disabled
	MarkColor	widget.Color	// tick mark color
}

type DefaultPainter struct

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

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

type DefaultPainter struct{}

Interfaces

type Painter interface

Painter draws the visual representation of a slider.

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

Painter implementation to render the slider in its visual style.

 

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

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