theme/cupertino/tabview.go
Functions
func PaintTabBar
func (p TabViewPainter) PaintTabBar(canvas widget.Canvas, ps tabview.PaintState) {
if ps.Bounds.IsEmpty() {
return
}
colors := ps.ColorScheme
if colors == (tabview.TabColorScheme{}) {
colors = p.resolveColors()
}
// Segmented control background (pill shape).
canvas.DrawRoundRect(ps.Bounds, colors.Background, cupTabSegmentRadius)
// Draw selected segment indicator first (behind text).
if ps.SelectedIdx >= 0 && ps.SelectedIdx < len(ps.Tabs) {
selected := &ps.Tabs[ps.SelectedIdx]
if !selected.Bounds.IsEmpty() {
segInset := cupTabSegmentInset
segBounds := geometry.NewRect(
selected.Bounds.Min.X+segInset,
selected.Bounds.Min.Y+segInset,
selected.Bounds.Width()-segInset*2,
selected.Bounds.Height()-segInset*2,
)
canvas.DrawRoundRect(segBounds, colors.Indicator, cupTabSelectedRadius)
}
}
// Draw each tab.
for i := range ps.Tabs {
ts := &ps.Tabs[i]
cupPaintTab(canvas, ts, colors)
}
// Focus ring around entire segmented control.
if ps.Focused {
ringBounds := ps.Bounds.Expand(cupTabFocusRingOffset)
canvas.StrokeRoundRect(ringBounds, colors.FocusRing, cupTabSegmentRadius+cupTabFocusRingOffset, cupTabFocusRingStroke)
}
}
Structs
type TabViewPainter struct
TabViewPainter renders tab bars as iOS-style segmented controls.
Instead of a traditional tab bar with an underline indicator, Cupertino
uses a pill-shaped segmented control where the selected segment has a
raised white background.
If Theme is nil, TabViewPainter falls back to the default system blue palette.
type TabViewPainter struct {
Theme *Theme // nil uses default system blue fallback
}
PaintTabBar renders a segmented control according to Apple HIG specifications.