theme/devtools/popover.go

Functions Structs

Functions

func PaintPopover

PaintPopover renders a popover background with shadow according to DevTools specifications.

func (p PopoverPainter) PaintPopover(canvas widget.Canvas, st *popover.PopoverPaintState) {
	if st.Bounds.IsEmpty() {
		return
	}

	bg, border, shadow := p.resolvePopoverColors(st.ColorScheme)

	// Shadow (offset slightly down).
	shadowBounds := geometry.Rect{
		Min:	geometry.Pt(st.Bounds.Min.X+dtPopoverShadowOffX, st.Bounds.Min.Y+dtPopoverShadowOffY),
		Max:	geometry.Pt(st.Bounds.Max.X+dtPopoverShadowOffX, st.Bounds.Max.Y+dtPopoverShadowOffY),
	}
	canvas.DrawRoundRect(shadowBounds, shadow, dtPopoverRadius)

	// Background.
	canvas.DrawRoundRect(st.Bounds, bg, dtPopoverRadius)

	// Border.
	canvas.StrokeRoundRect(st.Bounds, border, dtPopoverRadius, dtPopoverBorderWidth)
}

func PaintTooltip

PaintTooltip renders a tooltip background and text according to DevTools specifications.

func (p PopoverPainter) PaintTooltip(canvas widget.Canvas, st *popover.TooltipPaintState) {
	if st.Bounds.IsEmpty() {
		return
	}

	bg, textColor, border := p.resolveTooltipColors(st.ColorScheme)

	// Background.
	canvas.DrawRoundRect(st.Bounds, bg, dtTooltipRadius)

	// Border.
	canvas.StrokeRoundRect(st.Bounds, border, dtTooltipRadius, dtTooltipBorderWidth)

	// Text.
	textBounds := geometry.Rect{
		Min:	geometry.Pt(st.Bounds.Min.X+dtTooltipPadH, st.Bounds.Min.Y),
		Max:	geometry.Pt(st.Bounds.Max.X-dtTooltipPadH, st.Bounds.Max.Y),
	}
	canvas.DrawText(st.Text, textBounds, dtTooltipFontSize, textColor, false, dtTooltipTextAlign)
}

Structs

type PopoverPainter struct

PopoverPainter renders popovers and tooltips using DevTools design tokens.

DevTools popovers use SurfaceElevated (#393B40) background with 4px border

radius, 1px Gray5 border, 8px padding, and a subtle shadow, matching

JetBrains IDE popup and tooltip styling.

 

If Theme is nil, PopoverPainter falls back to the default DevTools dark palette.

type PopoverPainter struct {
	Theme *Theme	// nil uses default DevTools dark fallback
}