Skip to main content

Module toolbar

Module toolbar 

Source
Expand description

A horizontal bar of grouped actions, with the rest behind an overflow menu.

§Why overflow is declared, not measured

A truthful overflow needs to know how wide every item is before it decides which ones fit. GPUI measures during layout, which happens after the element tree has been built, and a toolbar child is an AnyElement that can be consumed exactly once — so a builder cannot measure a child and then still move it into a menu. Guessing at widths would produce a bar that claims to have dropped items it in fact drew, which is worse than not overflowing at all.

So the caller declares the cut with Toolbar::overflow_after, and the toolbar guarantees the part it can: an item past the cut is moved, never dropped. It becomes a row in the overflow Menu, keeping its identity, its label, and its refusal, and the trigger publishes how many items went there. With no menu to move them into, every item is drawn inline, because losing an action is never the better failure.

Structs§

Toolbar
A bar of grouped actions.
ToolbarItem
One action in the bar.