theme/devtools/button.go
Functions
func PaintButton
func (p ButtonPainter) PaintButton(canvas widget.Canvas, state button.PaintState) {
if state.Bounds.IsEmpty() {
return
}
radius := dtButtonRadius
if state.Radius != nil {
radius = *state.Radius
}
colors := state.ColorScheme
if colors == (button.ButtonColorScheme{}) {
colors = p.resolveColors()
}
disabled := state.Disabled
bg := dtButtonBackground(state, disabled, colors)
fg := dtButtonForeground(state.Variant, disabled, colors)
// Draw background based on variant.
switch state.Variant {
case button.Filled, button.Tonal:
canvas.DrawRoundRect(state.Bounds, bg, radius)
case button.Outlined:
if state.Hovered || state.Pressed {
canvas.DrawRoundRect(state.Bounds, colors.Primary.WithAlpha(0.08), radius)
}
canvas.StrokeRoundRect(state.Bounds, bg, radius, dtButtonBorderWidth)
case button.TextOnly:
if state.Hovered || state.Pressed {
canvas.DrawRoundRect(state.Bounds, bg, radius)
}
}
// Draw text centered.
fontSize := dtButtonFontSize(state.Size)
canvas.DrawText(state.Text, state.Bounds, fontSize, fg, false, dtTextAlignCenter)
// Focus indicator: 1px border (DevTools style).
if state.Focused && !disabled {
dtDrawFocusRing(canvas, state.Bounds, radius, colors.FocusRing)
}
}
Structs
type ButtonPainter struct
ButtonPainter renders buttons using DevTools design tokens.
DevTools buttons are compact (28px height) with 4px corner radius,
matching JetBrains IDE toolbar and dialog button styling.
If Theme is nil, ButtonPainter falls back to the default DevTools dark palette.
type ButtonPainter struct {
Theme *Theme // nil uses default DevTools dark fallback
}
PaintButton renders a button according to DevTools design specifications.