theme/fluent/dropdown.go
Functions
func PaintMenu
func (p DropdownPainter) PaintMenu(canvas widget.Canvas, st *dropdown.MenuPaintState) {
if st.Bounds.IsEmpty() {
return
}
colors := st.ColorScheme
if colors == (dropdown.DropdownColorScheme{}) {
colors = p.resolveColors()
}
// Menu background with subtle border.
canvas.DrawRoundRect(st.Bounds, colors.MenuBg, flDDMenuRadius)
canvas.StrokeRoundRect(st.Bounds, colors.MenuBorder, flDDMenuRadius, flDDBorderWidth)
canvas.PushClip(st.Bounds)
defer canvas.PopClip()
endIndex := st.ScrollOffset + st.VisibleCount
if endIndex > len(st.Items) {
endIndex = len(st.Items)
}
for i := st.ScrollOffset; i < endIndex; i++ {
item := st.Items[i]
row := i - st.ScrollOffset
itemRect := geometry.Rect{
Min: geometry.Pt(st.Bounds.Min.X, st.Bounds.Min.Y+float32(row)*st.ItemHeight),
Max: geometry.Pt(st.Bounds.Max.X, st.Bounds.Min.Y+float32(row+1)*st.ItemHeight),
}
flDDPaintMenuItem(canvas, itemRect, item, i, st.HighlightedIndex, st.SelectedIndex, colors)
}
}
func PaintTrigger
PaintTrigger renders a dropdown trigger according to Fluent Design specifications.
func (p DropdownPainter) PaintTrigger(canvas widget.Canvas, st *dropdown.TriggerPaintState) {
if st.Bounds.IsEmpty() {
return
}
colors := st.ColorScheme
if colors == (dropdown.DropdownColorScheme{}) {
colors = p.resolveColors()
}
flDDPaintTriggerBg(canvas, st, colors)
flDDPaintTriggerBorder(canvas, st, colors)
flDDPaintTriggerText(canvas, st, colors)
flDDPaintTriggerChevron(canvas, st, colors)
if st.Focused && !st.Disabled {
flDrawFocusRing(canvas, st.Bounds, flDDTriggerRadius, colors.FocusRing)
}
}
Structs
type DropdownPainter struct
DropdownPainter renders dropdowns using Fluent Design tokens.
If Theme is nil, DropdownPainter falls back to the default Fluent Blue palette.
type DropdownPainter struct {
Theme *Theme // nil uses default Fluent Blue fallback
}
PaintMenu renders a dropdown menu according to Fluent Design specifications.