CUI

Components / Motion

Dock

A row of icons that grow under the pointer, as in a desktop dock.

Functions: cui_dock, cui_dock_item, cui_dock_separator

Dock

Usage

cui_dock(ui, "dock") {
    if (cui_dock_item(ui, CUI_ICON_FOLDER, "Files", .color = CUI_RGB(0x3b82f6), .running = true)) open_files();
    cui_dock_item(ui, CUI_ICON_MAIL, "Mail", .color = CUI_RGB(0x0ea5e9), .badge = 3);
    cui_dock_separator(ui);
    cui_dock_item(ui, CUI_ICON_TRASH_2, "Trash");
}

Icons grow as the pointer passes, with the item under it largest and its neighbours following on a cosine falloff. Items show their label as a tooltip, a dot when running and a count with badge. Tab and Enter work as well.

cui_dock_item returns true on the frame the item is clicked. Nothing is stored for you: which apps are running is your state, passed in on every frame. The second argument is the tooltip, and NULL leaves it out. badge is a count: 0 shows none and anything over 99 shows "99+". Dock options: size, the icon size at rest in points (46), and magnify, how much the icon under the pointer grows (1.55). The dock centers itself in its container, and in a narrow window the icons shrink and stop growing.

Keyboard

  • Tab and Enter work as well.
  • Tab moves through the items, and Enter or Space clicks the focused one.

Options of cui_dock

OptionTypeDefaultDescription
.sizefloatSize in points; 0 uses the component's own.
.magnifyfloat1.55how much the icon under the pointer grows, default 1.55

Options of cui_dock_item

OptionTypeDefaultDescription
.colorcui_colorA theme color such as CUI_COLOR_ACCENT, or CUI_RGB(0x7747ff); unset uses the theme's.
.runningboola small dot under the icon
.badgeinta count badge on the icon ("99+" above 99); 0 for none

Related