Skip to main content

Module tool_box

Module tool_box 

Source
Expand description

ToolBox — a vertical stack of collapsible sections, exactly one expanded at a time.

Semantic cousin of Qt’s QToolBox and the collapsible groups in IntelliJ’s Settings dialog. Differs from Accordion (single-item independent disclosure) and TabWidget (horizontal tab bar with dormant panes) by combining vertical layout, always-visible headers, and exclusive expansion in one widget.

Int UI visual language:

  • flat, borderless headers (no corner radius)
  • 1 dp accent indicator bar on the leading edge of the active header
  • color-only emphasis (selected / hover / pressed surface roles)
  • border IS the focus ring: an accent border at the theme’s focus_ring_width (2 dp under Int UI) appears on the focused header, no separate ring primitive
  • content swaps are instant — Int UI’s house rule is to avoid decorative animation for inline transitions; see MotionTokens. Matches the existing TabWidget precedent where pane swaps have no transition.
ⓘ
let selected = ctx.signal(0_usize);
ToolBox::new(selected.clone())
    .item(lit!("Outline"),    outline_widget)
    .item(lit!("Properties"), properties_widget)
    .add(ToolBoxItem::new(lit!("Build"), build_widget).enabled(false))

§Touch and pen

A section header activates from its tap, so it already actuates on the release. Two things did change:

  • its pressed appearance is the framework’s press now, not the keyboard path’s — before, the recipe painted a state no pointer of either kind ever wrote;
  • a tap by a contact rests the header idle rather than hovered. A finger sends no hover-leave to correct a resting Hovered with, so a tapped header stayed lit with nothing on it — visible once the selection moved elsewhere, because a selected header’s own chrome hides the tint until then.

The optional header drag (on_header_drag, the dock panel’s handle) needs no declaration for a contact: DragActivation::Auto resolves to Immediate where nothing competes for the axis, and to the hold where a scroller does.

Structs§

ToolBox
A vertical container of collapsible sections with exactly one expanded at a time — the Int UI / QToolBox pattern.
ToolBoxItem
One section of a ToolBox. Construct with ToolBoxItem::new and pass to ToolBox::add, or use the convenience ToolBox::item builder directly (it takes a widget or a WidgetId) when leading / trailing slots and tooltip are not needed.

Enums§

ToolBoxOrientation
Orientation of a ToolBox: how its collapsible sections are arranged.

Constants§

TOOL_BOX_CHEVRON_SIZE
TOOL_BOX_HEADER_MIN_HEIGHT
ToolBox design tokens.
TOOL_BOX_HEADER_PADDING_HORIZONTAL
TOOL_BOX_ICON_TEXT_SPACING
TOOL_BOX_INDICATOR_THICKNESS

Functions§

tool_box_header_min_height
TOOL_BOX_HEADER_MIN_HEIGHT raised to the density’s target_size (24 / 32 / 44 dp). The identity at Compact.
tool_box_header_padding_horizontal
TOOL_BOX_HEADER_PADDING_HORIZONTAL scaled by the density’s spacing_factor (1.00 / 1.15 / 1.30).
tool_box_icon_text_spacing
TOOL_BOX_ICON_TEXT_SPACING scaled by the density’s spacing_factor (1.00 / 1.15 / 1.30).