CUI

Components / Motion

Now playing, waveform and tab bar

A media player card, an audio waveform to scrub through, and a bottom tab bar for phone layouts.

Functions: cui_now_playing, cui_tab_bar, cui_waveform

Now playing, waveform and tab bar

Usage

static cui_now_playing np = { "Low Tide", "Marlow Avenue", art, { 0 }, 76, 222, true };
int ev = cui_now_playing(ui, "player", &np);
if (ev & CUI_PLAYER_NEXT) next_track();
if (ev & CUI_PLAYER_SEEK) seek(np.position);

static float progress;
if (cui_waveform(ui, "voice", peaks, 96, &progress, .height = 34)) seek_to(progress);

static int tab;
cui_tab_bar(ui, "tabs", tabs, 4, &tab);

The player shows artwork (a texture, or art_color), a play button that morphs between play and pause, and a scrubber that thickens and shows its knob under the pointer. The time on the right counts down. The waveform resamples its peaks to fit its width; the played part takes the accent color and a ghost shows where a click would seek. The tab bar's pill glides to the selection, and arrow keys move it.

Keyboard

  • The tab bar's pill glides to the selection, and arrow keys move it.

Options of cui_now_playing

OptionTypeDefaultDescription
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.compactboolsmaller artwork and padding, and no previous button

Options of cui_tab_bar

OptionTypeDefaultDescription
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.labels_on_selected_onlyboolonly the selected tab shows its label; the others show just their icon

Options of cui_waveform

OptionTypeDefaultDescription
.widthcui_sizeWidth: CUI_FILL, CUI_FIT, CUI_PX(n) or CUI_PCT(n); unset uses the component's own.
.heightfloatHeight in points; 0 uses the component's own.
.barfloat3width of each bar in points, default 3
.gapfloatSpace between the items, in points.
.colorcui_colorA theme color such as CUI_COLOR_ACCENT, or CUI_RGB(0x7747ff); unset uses the theme's.

cui_now_playing

FieldTypeDescription
titleconst char *name of the track, in medium weight
artistconst char *shown under the title
artcui_textureartwork texture; 0 shows a tile in art_color with a note icon
art_colorcui_colorcolor of the tile behind (or in place of) the artwork
positionfloatseconds played; written when the user seeks
durationfloatlength of the track in seconds
playingboolshows pause instead of play; the play button flips it

cui_tab_bar_item

FieldTypeDescription
iconconst char *An icon: a CUI_ICON_* constant, or a string from another icon font.
labelconst char *A label shown above or beside the control.
badgeinta count on the icon ("9+" above 9); 0 for none

Related

  • Control tiles: Large toggle tiles for quick settings such as Wi-Fi or Do not disturb.
  • Dock: A row of icons that grow under the pointer, as in a desktop dock.
  • Loaders: Animated indicators for work in progress, in five styles.
  • Gradient text and spotlight cards: Text filled with a gradient, and a card with a glow that follows the pointer.