theme/devtools/toolbar.go
Functions
func PaintButtonItem
func (p ToolbarPainter) PaintButtonItem(canvas widget.Canvas, state toolbar.PaintButtonState) {
if state.Bounds.IsEmpty() {
return
}
colors := p.resolveColors()
// Background on hover/press (disabled items get no feedback).
if !state.Disabled {
bg := widget.ColorTransparent
if state.Pressed {
bg = colors.PressedBg
} else if state.Hovered {
bg = colors.HoverBg
}
if !bg.IsTransparent() {
canvas.DrawRoundRect(state.Bounds, bg, dtToolbarItemRadius)
}
}
// Icon color.
fg := colors.IconColor
if state.Disabled {
fg = colors.DisabledFg
}
// Draw icon centered in the button area.
iconBounds := dtToolbarIconBounds(state.Bounds, state.ShowLabel)
icon.Draw(canvas, state.Icon, iconBounds, fg)
// Draw label text if ShowLabel is true.
if state.ShowLabel && state.Label != "" {
textBounds := dtToolbarTextBounds(state.Bounds, iconBounds)
canvas.DrawText(state.Label, textBounds, dtToolbarFontSize, fg, false, widget.TextAlignLeft)
}
// Focus ring (1px DevTools style).
if state.Focused && !state.Disabled {
canvas.StrokeRoundRect(state.Bounds, colors.FocusRing, dtToolbarItemRadius, dtToolbarFocusRingWidth)
}
}
func PaintSeparator
PaintSeparator renders a vertical separator line.
func (p ToolbarPainter) PaintSeparator(canvas widget.Canvas, bounds geometry.Rect) {
if bounds.IsEmpty() {
return
}
colors := p.resolveColors()
centerX := bounds.Min.X + bounds.Width()/2
canvas.DrawLine(
geometry.Pt(centerX, bounds.Min.Y+dtToolbarSepInset),
geometry.Pt(centerX, bounds.Max.Y-dtToolbarSepInset),
colors.SeparatorFg, dtToolbarSepWidth,
)
}
func PaintToolbar
PaintToolbar renders the toolbar background with a subtle bottom border.
func (p ToolbarPainter) PaintToolbar(canvas widget.Canvas, state toolbar.PaintToolbarState) {
if state.Bounds.IsEmpty() {
return
}
colors := p.resolveColors()
// Transparent background (flat DevTools style).
if !colors.Background.IsTransparent() {
canvas.DrawRect(state.Bounds, colors.Background)
}
// 1px bottom border.
borderRect := geometry.NewRect(
state.Bounds.Min.X,
state.Bounds.Max.Y-dtToolbarBorderWidth,
state.Bounds.Width(),
dtToolbarBorderWidth,
)
canvas.DrawRect(borderRect, colors.BorderColor)
}
Structs
type ToolbarPainter struct
ToolbarPainter renders toolbars using DevTools design tokens.
DevTools toolbars are flat and transparent with no background, featuring
a subtle 1px bottom border (Gray3) and compact 28px square icon buttons
with 4px radius, matching JetBrains IDE toolbar styling.
If Theme is nil, ToolbarPainter falls back to the default DevTools dark palette.
type ToolbarPainter struct {
Theme *Theme // nil uses default DevTools dark fallback
}
PaintButtonItem renders a button item with icon and optional text label.