CUI

Components / Conversation and media

Presence, counter and ticker

Small live pieces: who is here now, a number that rolls when it changes, and a line of text that scrolls past.

Functions: cui_counter, cui_presence, cui_ticker

Presence, counter and ticker

Usage

cui_presence(ui, "here", users, 7, 5, 30);                     /* show 5, then "+2" */
cui_counter(ui, "revenue", revenue, .format = "$%.0f", .size = 34, .group_thousands = true);
static const cui_ticker_item items[] = { { "Builds", "1,204", 12.0f }, { "Latency", "182 ms", -8.4f, true } };
cui_ticker(ui, "kpis", items, 2);   /* true: lower is better, so the fall shows green */

Presence avatars overlap with colored rings and spread out under the pointer; idle people are dimmed. The counter rolls each digit like an odometer when the value changes. The ticker scrolls continuously, fades at the edges and pauses under the pointer.

None of the three returns anything. cui_presence reads your array of cui_presence_user: a name, a ring color, an optional avatar texture and idle. Its last two arguments are how many avatars to show before the "+N" and the avatar size in points; 0 means 5 and 30.

cui_counter takes the value on every frame and keeps only the position of each digit under id. format is a printf format for one double ("%.0f" when not set), and size is in points (32).

Each cui_ticker_item is a label, a value as text, a change in percent and lower_is_better. The ticker fills the width and moves at speed points per second (40).

Options of cui_counter

OptionTypeDefaultDescription
.formatconst char *A printf format for the values, such as "%.0f ms".
.sizefloatSize in points; 0 uses the component's own.
.fontcui_font`CUI_FONT_DISPLAY`default CUI_FONT_DISPLAY
.colorcui_colorA theme color such as CUI_COLOR_ACCENT, or CUI_RGB(0x7747ff); unset uses the theme's.
.group_thousandsboolcommas between thousands: 48210 shows as 48,210

Options of cui_ticker

OptionTypeDefaultDescription
.speedfloat40points per second, default 40
.heightfloatHeight in points; 0 uses the component's own.

cui_presence_user

FieldTypeDescription
nameconst char *shown in the tooltip, and as initials when there is no avatar
colorcui_colorA theme color such as CUI_COLOR_ACCENT, or CUI_RGB(0x7747ff); unset uses the theme's.
avatarcui_texturepicture to show instead of the initials
idleboolaway: the avatar dims, its ring turns gray and the tooltip adds "(away)"

cui_ticker_item

FieldTypeDescription
labelconst char *A label shown above or beside the control.
valueconst char *text after the label in medium weight, e.g. a price; may be NULL
deltafloatpercent change, shown with a trend arrow in green or red; 0 hides it
lower_is_betterboola fall in delta is good news: it shows green, and a rise red

Related

  • Carousel: A strip of slides the user drags or steps through, one at a time.
  • Comments: A comment with its author, time, replies indented under it and a like button.
  • Image compare and card stack: A divider that reveals one picture over another, and a stack of cards the user swipes through.
  • Chat: Message bubbles for a conversation, with grouping, dividers and a typing indicator.