theme/devtools/titlebar.go
Functions
func DrawBackground
func (p TitleBarPainter) DrawBackground(canvas widget.Canvas, bounds geometry.Rect, _ titlebar.BackgroundState) {
if bounds.IsEmpty() {
return
}
colors := p.resolveColors()
// Dark header background.
canvas.DrawRect(bounds, colors.Background)
// 1px bottom border.
borderRect := geometry.NewRect(
bounds.Min.X,
bounds.Max.Y-dtTitleBarBorderWidth,
bounds.Width(),
dtTitleBarBorderWidth,
)
canvas.DrawRect(borderRect, colors.BorderColor)
}
func DrawControlButton
DrawControlButton renders a window control button with Windows-style hover.
func (p TitleBarPainter) DrawControlButton(canvas widget.Canvas, bounds geometry.Rect, control titlebar.ControlType, state titlebar.ControlState) {
if bounds.IsEmpty() {
return
}
colors := p.resolveColors()
// Background on hover/press.
isClose := control == titlebar.ControlClose
bg := dtControlBackground(isClose, state, colors)
if !bg.IsTransparent() {
canvas.DrawRect(bounds, bg)
}
// Icon color.
fg := colors.IconColor
if isClose && state.Hovered {
fg = colors.CloseHoverIconFg
}
// Draw icon glyph centered.
cx := bounds.Min.X + bounds.Width()/2
cy := bounds.Min.Y + bounds.Height()/2
switch control {
case titlebar.ControlMinimize:
drawMinimizeIcon(canvas, cx, cy, fg)
case titlebar.ControlMaximize:
drawMaximizeIcon(canvas, cx, cy, fg)
case titlebar.ControlRestore:
drawRestoreIcon(canvas, cx, cy, fg, colors.Background)
case titlebar.ControlClose:
drawCloseIcon(canvas, cx, cy, fg)
}
}
Structs
type TitleBarPainter struct
TitleBarPainter renders title bars using DevTools design tokens.
DevTools title bars use a dark header background (#27282E) that is always
dark even in light mode, matching JetBrains IDE behavior. Window control
buttons are 46x40px with no border and Windows-style hover effects.
If Theme is nil, TitleBarPainter falls back to default DevTools dark colors.
type TitleBarPainter struct {
Theme *Theme // nil uses default DevTools dark fallback
}
DrawBackground renders the dark header background with a 1px bottom border.