The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
idunn.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file idunn.h
5 * @brief idunn: the widget toolkit of ginnOS.
6 *
7 * an app makes a tree of widgets (rows and columns of labels, buttons and
8 * so on), puts it in a window and runs the app loop. widgets keep their
9 * state between frames; the toolkit lays them out, draws only what
10 * changed, in step with the screen, and sends the pointer and the keys to
11 * them. the look comes from the theme (idunn_theme.h).
12 *
13 * idunn_app_t *app = idunn_app_new("Files");
14 * idunn_window_t *win = idunn_window_new(app, "Files", 720, 480);
15 * idunn_widget_t *col = idunn_column(4, 6);
16 * idunn_add(col, idunn_label("Rename file", IDUNN_TEXT_HEADING));
17 * idunn_add(col, idunn_button("Rename", IDUNN_PRIMARY, on_rename, NULL));
18 * idunn_window_set_root(win, col);
19 * return idunn_app_run(app);
20 *
21 * sizes are in design pixels (the theme's scale makes them larger);
22 * gaps and paddings are in space units of 4 design pixels.
23 */
24
25#include "idunn_theme.h"
26
27#include <gfx.h>
28#include <heimdall_proto.h>
29#include <stdbool.h>
30#include <stdint.h>
31
32typedef struct heim_conn heim_conn_t; // as in heimdall.h
33
34typedef struct idunn_app idunn_app_t;
38
39typedef void (*idunn_callback_t)(idunn_widget_t *widget, void *data);
40
41// pointer shapes (the same values as HEIM_CURSOR_)
42#define IDUNN_CURSOR_ARROW 0
43#define IDUNN_CURSOR_TEXT 1
44#define IDUNN_CURSOR_HAND 2
45
46// modifier keys (the same values as HEIM_MOD_)
47#define IDUNN_MOD_SHIFT 0x01
48#define IDUNN_MOD_CTRL 0x02
49#define IDUNN_MOD_ALT 0x04
50
51// keys idunn uses (Linux key codes, as in sys/input.h)
52#define IDUNN_KEY_ESCAPE 1
53#define IDUNN_KEY_BACKSPACE 14
54#define IDUNN_KEY_TAB 15
55#define IDUNN_KEY_ENTER 28
56#define IDUNN_KEY_A 30
57#define IDUNN_KEY_X 45
58#define IDUNN_KEY_C 46
59#define IDUNN_KEY_V 47
60#define IDUNN_KEY_SPACE 57
61#define IDUNN_KEY_HOME 102
62#define IDUNN_KEY_UP 103
63#define IDUNN_KEY_PAGEUP 104
64#define IDUNN_KEY_LEFT 105
65#define IDUNN_KEY_RIGHT 106
66#define IDUNN_KEY_END 107
67#define IDUNN_KEY_DOWN 108
68#define IDUNN_KEY_PAGEDOWN 109
69#define IDUNN_KEY_DELETE 111
70
71/**
72 * connect to the window server and read the theme.
73 * @param name the program's id, the name of its .app file
74 * ("idunn-gallery"): the shell shows its icon with its windows.
75 * @return the app, or NULL (no server, or no fonts).
76 */
77idunn_app_t *idunn_app_new(const char *name);
78
79/**
80 * the connection to the window server, for calls idunn does not wrap
81 * (the shell's heim_shell_start, for example).
82 */
84
85/**
86 * get the events that are about no window of the app (the shell's
87 * HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP, HEIM_EV_WINDOW_GONE), and
88 * HEIM_EV_SETTINGS (after idunn applied a new theme).
89 */
91 void (*on_event)(idunn_app_t *app, const heim_msg_t *msg, void *data),
92 void *data);
93
94/**
95 * call every(data) each period ms while the app runs (a clock). one per
96 * app; a new call replaces it, period 0 stops it.
97 */
98void idunn_app_every(idunn_app_t *app, uint32_t period, void (*every)(void *data), void *data);
99
100#define IDUNN_WATCH_MAX 4
101
102/**
103 * call ready(fd, data) when fd can be read (or has hung up) while the app
104 * runs: a pty, a pipe. at most IDUNN_WATCH_MAX at a time; ready NULL
105 * stops watching fd.
106 */
107void idunn_app_watch(idunn_app_t *app, int fd, void (*ready)(int fd, void *data), void *data);
108
109/**
110 * ask for the clipboard's text for the program itself (not a widget):
111 * got gets it when it comes ("" when the clipboard is empty).
112 */
113void idunn_app_paste(idunn_app_t *app, void (*got)(const char *text, size_t length, void *data),
114 void *data);
115
116/**
117 * run until the last window is closed or idunn_app_quit.
118 * @return the exit status for main.
119 */
120int idunn_app_run(idunn_app_t *app);
121void idunn_app_quit(idunn_app_t *app);
122
123/**
124 * use another theme in all windows of the app (they are drawn again).
125 */
126void idunn_app_set_theme(idunn_app_t *app, const idunn_theme_t *theme);
127/**
128 * change a theme setting (mode, accent, radius, font_size, scale, motion)
129 * in the user's theme file. every app and the window decorations change.
130 * @return false if the file cannot be written; this app changes then.
131 */
132bool idunn_app_save_theme(idunn_app_t *app, const char *key, const char *value);
133const idunn_theme_t *idunn_app_theme(const idunn_app_t *app);
134
135/**
136 * a window with a title bar; it shows when the app runs.
137 * @param width the size of its content, in design pixels.
138 */
141
142/**
143 * a window as large as the screen with no title bar (a login screen).
144 * @param backdrop the picture under the widgets, as large as the screen
145 * (or NULL: the surface colour). it must stay until the app ends.
146 */
148
149/**
150 * a panel of the desktop shell: no title bar, at the bottom of the screen,
151 * as wide as the screen, above the windows (HEIM_WINDOW_PANEL).
152 * @param height in design pixels.
153 */
155
156/**
157 * the widget that fills the window (a row or a column, usually). the
158 * window owns the tree from now on.
159 */
161
162/**
163 * free w (and its children) after the event that is running: for a
164 * widget that may be in its own callback (a button that rebuilds the
165 * view it is in).
166 */
168
169/**
170 * keys for a widget (when it or a child has the keyboard) before the
171 * widget gets them. return true to use the key (the widget does not get
172 * it), false to let it go on as before.
173 */
174typedef bool (*idunn_widget_key_t)(idunn_widget_t *w, uint16_t code, uint32_t mods, void *data);
176
177/**
178 * keys that no widget used (the focused one and its parents): the
179 * window's own shortcuts. on_key returns true when it used the key.
180 * code is a Linux key code, mods IDUNN_MOD_, text what it types or "".
181 */
183 const char *text, void *data);
185
186/**
187 * close and free the window (and its widgets).
188 */
190
191/**
192 * the close button (or the shell's Close): on_close returns true to let
193 * the window close, false to keep it (to ask about unsaved changes first,
194 * and close it later with idunn_window_close).
195 */
196void idunn_window_on_close(idunn_window_t *win, bool (*on_close)(idunn_window_t *win, void *data),
197 void *data);
198
199/**
200 * a new title in the window's title bar (and the shell's window list).
201 */
202void idunn_window_set_title(idunn_window_t *win, const char *title);
203
204// the tree and the layout
205
206typedef enum
207{
211 IDUNN_STRETCH, // across a box: the full size (the default)
212 IDUNN_SPACE_BETWEEN, // along a box: the free space between the children
214
215/**
216 * a box that puts its children in a row (left to right) or a column (top
217 * to bottom), like a CSS flexbox.
218 * @param gap the space between children, in units (4 design pixels).
219 * @param padding the space inside the box, in units.
220 */
221idunn_widget_t *idunn_row(int gap, int padding);
222idunn_widget_t *idunn_column(int gap, int padding);
223
224/**
225 * how a box places its children: align across it (default: stretch) and
226 * justify along it (default: start).
227 */
229
230/**
231 * other paddings for the sides of a box, in units: across and along.
232 */
233void idunn_box_set_padding(idunn_widget_t *box, int vertical, int horizontal);
234
235/**
236 * a background for a box, a colour token (by default it has none).
237 */
239/**
240 * a row that is too short for its children shows the last ones: the
241 * first go out of view on the left, whole (a path bar keeps the folder
242 * that is open in view).
243 */
244void idunn_box_set_keep_end(idunn_widget_t *box, bool keep_end);
245
246/**
247 * a card: a column on the card colour with a border, the large radius and
248 * a small shadow, 24 pixels inside.
249 * @param gap the space between its children, in units.
250 */
251idunn_widget_t *idunn_card(int gap);
252/**
253 * frosted glass: the card is see-through, lighter than what is under it,
254 * with a thin light edge and a larger shadow (over a blurred picture, as
255 * on a login screen).
256 */
257void idunn_card_set_glass(idunn_widget_t *card, bool glass);
258
259/**
260 * a title and a muted description (or NULL) at the top of a card.
261 */
262void idunn_card_header(idunn_widget_t *card, const char *title, const char *description);
263
264/**
265 * a scroll view: the child can be taller than the view. the view takes
266 * the height it is given (let it grow, or give it a size), as a CSS box
267 * with min-height 0. the wheel, the keys its children do not use and a
268 * thin scroll bar scroll it; Tab scrolls the focus into view.
269 */
273
274/**
275 * empty space that grows (put it between children to push them apart).
276 */
278
279/**
280 * add child at the end of parent.
281 * @return child.
282 */
284
285/**
286 * take a widget out of its parent and free it and its children.
287 */
289
290/**
291 * let a widget take a share of the free space along its box.
292 * @return w.
293 */
295
296/**
297 * a size a widget must have, in design pixels (0: its own size).
298 */
300
301/**
302 * a hidden widget is not drawn, takes no room in its box and gets no input.
303 */
304void idunn_set_hidden(idunn_widget_t *w, bool hidden);
305
306/**
307 * a disabled widget is drawn at half opacity and gets no input.
308 */
309void idunn_set_disabled(idunn_widget_t *w, bool disabled);
310/**
311 * on_menu on a right click on the widget or in it, when no widget in it
312 * used the click (a list view uses it on its items: idunn_list_view_on_menu).
313 * open a menu with idunn_menu_popup_at_pointer.
314 */
316
317/**
318 * on_middle on a press of the middle button on the widget or in it (the
319 * nearest widget that has one): a task button closes its window.
320 */
322
323/**
324 * a control with a wrong value: its border and ring are red (a field
325 * sets this on its control with idunn_field_set_error).
326 */
328
329// the widgets
330
331/**
332 * text in a style; it ends with "..." when it is too wide, or wraps.
333 */
334idunn_widget_t *idunn_label(const char *text, idunn_text_t style);
335void idunn_label_set_text(idunn_widget_t *label, const char *text);
337void idunn_label_set_wrap(idunn_widget_t *label, bool wrap);
338
339typedef enum
340{
341 IDUNN_PRIMARY, // the main action: the accent
342 IDUNN_SECONDARY, // a quiet filled button
343 IDUNN_OUTLINE, // a border and a light fill
344 IDUNN_GHOST, // only on hover (toolbars, icon buttons)
345 IDUNN_DESTRUCTIVE, // delete: soft red
346 IDUNN_LINK, // text, underlined on hover
348
349typedef enum
350{
351 IDUNN_SIZE_DEFAULT, // 32 pixels high
355
356/**
357 * a button; on_click gets the button and data.
358 * @param text the label, or NULL for an icon button.
359 */
360idunn_widget_t *idunn_button(const char *text, idunn_variant_t variant, idunn_callback_t on_click,
361 void *data);
362
363/**
364 * a square button with only an icon (a Lucide name).
365 */
366idunn_widget_t *idunn_icon_button(const char *icon, idunn_variant_t variant,
367 idunn_callback_t on_click, void *data);
368
369/**
370 * an icon (a Lucide name) before the text.
371 */
372void idunn_button_set_icon(idunn_widget_t *button, const char *icon);
373
374/** a picture in its own colours (a Tela name, an app's icon) before the text */
375void idunn_button_set_picture(idunn_widget_t *button, const char *picture);
376
377/**
378 * the button is on (a task's window is active, a toggle is on): a
379 * filled look with a short accent line under it.
380 */
381void idunn_button_set_active(idunn_widget_t *button, bool active);
382
383/** the content muted (a task whose window is minimized) */
384void idunn_button_set_dim(idunn_widget_t *button, bool dim);
385/** round ends: the radius is half the height */
386void idunn_button_set_pill(idunn_widget_t *button, bool pill);
387/** see-through, lighter than what is under it (over a picture) */
388void idunn_button_set_glass(idunn_widget_t *button, bool glass);
389/** a tile: the icon larger, over the text in small type (Restart, Power off) */
390void idunn_button_set_tile(idunn_widget_t *button, bool tile);
392void idunn_button_set_text(idunn_widget_t *button, const char *text);
394
395/**
396 * where the icon and text go: IDUNN_CENTER (the default) or IDUNN_START
397 * (side bar items, menu-like lists).
398 */
400
401/**
402 * a 1 pixel line: across a column, or down a row.
403 */
405
406/**
407 * a one-line text field, 32 pixels high.
408 * @param placeholder the muted text it shows when it is empty, or NULL.
409 */
410idunn_widget_t *idunn_text_field(const char *placeholder);
411
412/** the text (UTF-8); valid until the text changes */
413const char *idunn_text_field_text(const idunn_widget_t *field);
414void idunn_text_field_set_text(idunn_widget_t *field, const char *text);
415/**
416 * select bytes start to end (the caret at end); typing replaces them.
417 * (size_t)-1 is the end of the text.
418 */
419/**
420 * a plain field: a thin box around the text, with little padding and no
421 * ring (a name that is changed in place, as in a file list).
422 */
423void idunn_text_field_set_plain(idunn_widget_t *field, bool plain);
424/**
425 * a pill: round ends, see-through (over a picture, as on a login screen),
426 * no border, the text in the middle while it fits.
427 */
428void idunn_text_field_set_pill(idunn_widget_t *field, bool pill);
429/** a password field: a bullet for each character, and no Copy or Cut */
430void idunn_text_field_set_secret(idunn_widget_t *field, bool secret);
431/** the width of the field's text in pixels (0 before it is in a window) */
433void idunn_text_field_select(idunn_widget_t *field, size_t start, size_t end);
434
435/** an icon (a Lucide name) at the start, as in a search field */
436void idunn_text_field_set_icon(idunn_widget_t *field, const char *icon);
437
438/** on_change after every change of the text; on_submit on Enter */
441/** on_blur when the field loses the keyboard */
443
444/**
445 * a text area: lines that wrap, Enter for a new line; it scrolls.
446 * @param rows the lines it shows (its height), 0 for 4.
447 */
448idunn_widget_t *idunn_text_area(const char *placeholder, int rows);
449const char *idunn_text_area_text(const idunn_widget_t *area);
450void idunn_text_area_set_text(idunn_widget_t *area, const char *text);
452
453typedef enum
454{
457 IDUNN_MIXED, // some of the things it stands for (a dash)
459
460/**
461 * a check box with a label to its right (a click on the label clicks it).
462 * on_change comes after a click or Space.
463 */
464idunn_widget_t *idunn_check_box(const char *label, bool checked, idunn_callback_t on_change,
465 void *data);
468
469/**
470 * a group of choices with round buttons, one chosen; one Tab stop, the
471 * arrows move the choice. in a column (or a row: idunn_radio_group_set_row).
472 * @param chosen the index of the chosen one, or -1 for none.
473 */
474idunn_widget_t *idunn_radio_group(const char *const *labels, int count, int chosen,
475 idunn_callback_t on_change, void *data);
479
480/**
481 * a switch with a label to its right; it slides when it changes.
482 */
483idunn_widget_t *idunn_switch(const char *label, bool on, idunn_callback_t on_change, void *data);
484bool idunn_switch_on(const idunn_widget_t *sw);
485void idunn_switch_set_on(idunn_widget_t *sw, bool on);
486
487/**
488 * a slider from min to max in steps (the arrows move it by one step).
489 */
491 idunn_callback_t on_change, void *data);
494
502
503/** a badge: a short word in a small pill */
504idunn_widget_t *idunn_badge(const char *text, idunn_badge_t variant);
505
506/** a Lucide icon on its own, size points, in a colour token */
507idunn_widget_t *idunn_icon_view(const char *name, int32_t size, idunn_color_t color);
508
509/**
510 * an empty state: an icon on a muted square, a title and a muted line (or
511 * NULL), in the middle of its space. add buttons to it for actions.
512 */
513idunn_widget_t *idunn_empty_state(const char *icon, const char *title, const char *text);
514
515#define IDUNN_PROGRESS_MAX 1000
516/** a progress bar across its box; value 0 to IDUNN_PROGRESS_MAX */
518void idunn_progress_set(idunn_widget_t *progress, int32_t value);
519
520/**
521 * tabs: a strip of names and the page of the active one below it. the
522 * strip is one Tab stop; the arrows change the tab.
523 */
525/** add a tab with its page (the tabs own it); the first one is active */
526idunn_widget_t *idunn_tabs_add(idunn_widget_t *tabs, const char *name, idunn_widget_t *page);
527int idunn_tabs_active(const idunn_widget_t *tabs);
528void idunn_tabs_set_active(idunn_widget_t *tabs, int active);
529
530/**
531 * a list view: rows with a Lucide icon (or NULL), text and a muted second
532 * text on the right (or NULL). put it in a scroll view when it is long.
533 */
535/**
536 * a grid view: the same, as tiles of a 48 point Tela icon (a file or
537 * folder icon name) with the name below; it wraps to the width.
538 */
540/** @return the index of the new item, or -1 */
541int idunn_list_view_add(idunn_widget_t *list, const char *icon, const char *text,
542 const char *detail);
544/**
545 * change an item; only its row is drawn again, and only when something
546 * differs (a list that is filled again each second, as in a monitor).
547 */
548void idunn_list_view_set_item(idunn_widget_t *list, int item, const char *icon, const char *text,
549 const char *detail);
550/** keep only the first count items (a smaller count than now) */
551void idunn_list_view_set_count(idunn_widget_t *list, int count);
553const char *idunn_list_view_text(const idunn_widget_t *list, int item);
554/** many items can be selected (Ctrl, Shift, Ctrl+A) */
555void idunn_list_view_set_multiple(idunn_widget_t *list, bool multiple);
556/** rows with a Tela icon (a file or folder icon name) in colour, not a Lucide one */
557void idunn_list_view_set_pictures(idunn_widget_t *list, bool pictures);
558/** a border, the large radius and the card colour around the items */
559void idunn_list_view_set_framed(idunn_widget_t *list, bool framed);
560bool idunn_list_view_selected(const idunn_widget_t *list, int item);
561void idunn_list_view_select(idunn_widget_t *list, int item, bool selected);
562/** the item with the keyboard, or -1 */
564/** on_select after the selection changes; on_activate on a double click or Enter */
567/**
568 * what an edit in place gives: the new text, or NULL when it was taken
569 * back (Escape). it comes after the event, so the list can be made again.
570 */
571typedef void (*idunn_edit_done_t)(idunn_widget_t *list, int item, const char *text, void *data);
572/**
573 * edit an item's text in place (a rename): a text field over it with the
574 * bytes start to end selected ((size_t)-1: to the end). Enter, or the
575 * keyboard going elsewhere, keeps the text; Escape takes it back.
576 * @return false when the item is not there or the list is not shown.
577 */
578bool idunn_list_view_edit(idunn_widget_t *list, int item, size_t start, size_t end,
579 idunn_edit_done_t done, void *data);
580/**
581 * columns at the right of the rows: an item's detail is split at tabs,
582 * and each part is drawn at the right of its column (numbers line up).
583 * @param widths the columns' widths in design pixels, left to right.
584 */
585void idunn_list_view_set_columns(idunn_widget_t *list, const int32_t *widths, int count);
586/**
587 * heads over the columns of a list view, which line up with it. a click
588 * on a head calls on_click; idunn_list_heads_clicked tells which.
589 * @param names the name column's head, then one for each column of
590 * idunn_list_view_set_columns.
591 */
592idunn_widget_t *idunn_list_heads(idunn_widget_t *list, const char *const *names, int count,
593 idunn_callback_t on_click, void *data);
594/** the head that was clicked: 0 for the names, 1 and on for the columns */
596/** show the order on a head (an arrow), or on none with head -1 */
597void idunn_list_heads_set_order(idunn_widget_t *heads, int head, bool descending);
598/**
599 * draw some columns at their left, for text (a date, a type); the others
600 * stay at their right, for numbers. bit c is column c.
601 */
603/** make an item the current one and select only it, as the arrow keys do */
604void idunn_list_view_go_to(idunn_widget_t *list, int item);
605/** the items in a line (1 for a list, more for a grid) */
607/** true while an item is edited in place */
609/** one click activates an item (a launcher); the arrow keys only move */
610void idunn_list_view_set_single_click(idunn_widget_t *list, bool single);
611/**
612 * on_menu on a right click: on an item that is not selected, it selects
613 * only that item first; on no item, nothing stays selected. open a menu
614 * with idunn_menu_popup_at_pointer.
615 */
617/** the item at a point of the window, or -1 */
619
620// things that float: menus, selects, tooltips, popovers and dialogs
621
622/** a menu: items the app adds, shown in a popup by idunn_menu_popup */
623typedef struct idunn_menu idunn_menu_t;
624
626/** free a menu (not while it is open) and its sub-menus */
627void idunn_menu_free(idunn_menu_t *menu);
628/**
629 * an item: a Lucide icon (or NULL), text and a shortcut to show (or NULL).
630 * on_choose gets the widget the menu was opened for.
631 * @return the index of the item.
632 */
633int idunn_menu_add(idunn_menu_t *menu, const char *icon, const char *text, const char *shortcut,
634 idunn_callback_t on_choose, void *data);
635/** an item with a check that a choice turns on and off */
636int idunn_menu_add_check(idunn_menu_t *menu, const char *text, bool checked,
637 idunn_callback_t on_choose, void *data);
639/** an item that opens a sub-menu (the menu owns it) */
640int idunn_menu_add_sub(idunn_menu_t *menu, const char *icon, const char *text, idunn_menu_t *sub);
641void idunn_menu_set_disabled(idunn_menu_t *menu, int item, bool disabled);
642bool idunn_menu_checked(const idunn_menu_t *menu, int item);
643void idunn_menu_set_checked(idunn_menu_t *menu, int item, bool checked);
644/** the least width of the menu, in design pixels (160 by default) */
646/** open the menu under a widget (a button's on_click does it) */
648/** open the menu where the last right click was (a context menu) */
650
651/**
652 * a select: a field with the chosen value; it opens a menu of the choices.
653 * @param chosen the index of the chosen one, or -1 (the placeholder shows).
654 */
655idunn_widget_t *idunn_select(const char *const *choices, int count, int chosen,
656 idunn_callback_t on_change, void *data);
658void idunn_select_choose(idunn_widget_t *select, int chosen);
659void idunn_select_set_placeholder(idunn_widget_t *select, const char *text);
660
661/** a tooltip: shown over the widget after 600 ms under the pointer (NULL: none) */
662void idunn_set_tooltip(idunn_widget_t *w, const char *text);
663
664/**
665 * a popover: content in a card under owner; a press outside it or Escape
666 * closes it. the popover owns content. it is 288 wide, or as wide as
667 * content when content has a larger width (idunn_set_size).
668 */
669void idunn_popover(idunn_widget_t *owner, idunn_widget_t *content);
670/** close the popover a widget is in */
672
673typedef enum
674{
675 IDUNN_FILE_OPEN, // choose a file that is there
676 IDUNN_FILE_SAVE, // choose a name to save as (a question before one is replaced)
678
679/** the path chosen in a file dialog (the dialog is closed already) */
680typedef void (*idunn_file_done_t)(const char *path, void *data);
681
682/**
683 * a dialog to choose a file: the folder's items as a list, a button to
684 * the folder above, and to save, a field with the name. nothing is
685 * called when it is cancelled.
686 * @param path the folder to start in, or (to save) the whole path of the
687 * file, whose name is then in the field.
688 */
689void idunn_file_dialog(idunn_widget_t *owner, idunn_file_mode_t mode, const char *title,
690 const char *path, idunn_file_done_t done, void *data);
691
692/**
693 * a dialog: a card with a title and a description (or NULL), in the middle
694 * of the window over the overlay colour. add content to
695 * idunn_dialog_content, then the buttons; a button closes the dialog and
696 * then calls its on_click (with the dialog). Escape closes it too.
697 */
698idunn_widget_t *idunn_dialog(const char *title, const char *description);
700/** a button at the bottom right: Cancel as outline, the action primary or destructive */
701idunn_widget_t *idunn_dialog_add_button(idunn_widget_t *dialog, const char *text,
702 idunn_variant_t variant, idunn_callback_t on_click,
703 void *data);
704/** show a dialog over the window of owner; the window owns it then */
707
708/**
709 * a form row: a label above the control and help text below it (or NULL).
710 * the field owns the control.
711 */
712idunn_widget_t *idunn_field(const char *label, idunn_widget_t *control, const char *help);
713
714/**
715 * show an error: the message in red under the control, and the control's
716 * border and ring red. NULL takes it away (the help text comes back).
717 */
718void idunn_field_set_error(idunn_widget_t *field, const char *message);
719
720// without the window server: for tests and pictures
721
722/**
723 * fonts and icons for a theme.
724 * @param font_dir the directory with inter/ and jetbrains-mono/.
725 * @param icon_pack the Lucide pack, or NULL (no icons).
726 * @return the context, or NULL (no fonts).
727 */
728idunn_context_t *idunn_context_new(const idunn_theme_t *theme, const char *font_dir,
729 const char *icon_pack);
732
733/**
734 * a window that draws into its own buffer, of that many pixels.
735 */
737
738/**
739 * a new size for the window's buffer (the window lays out again).
740 */
741void idunn_window_resize(idunn_window_t *win, int32_t width, int32_t height);
742
744
745/**
746 * lay out and draw what changed.
747 * @return the part of the buffer that changed (empty: none).
748 */
750
751/**
752 * the whole window must be drawn again (after a theme change).
753 */
755
756typedef enum
757{
759 IDUNN_POINTER_PRESS, // the left button
762 IDUNN_POINTER_MENU, // the right button went down: a context menu
763 IDUNN_POINTER_MIDDLE, // the middle button went down
765
766/**
767 * the pointer moved, or the left button went down or up, at (x, y),
768 * with these modifier keys held (Shift+click extends a selection).
769 */
771 uint32_t mods);
772
773/**
774 * the wheel turned over (x, y): steps, up is positive.
775 */
777
778/**
779 * the clipboard text a widget asked for came (from the window server).
780 */
781void idunn_window_paste(idunn_window_t *win, const char *text, size_t length);
782
783/**
784 * the next time (ms) the window must be ticked for a timer, or 0 for none.
785 */
787
788/**
789 * a key press (or repeat).
790 * @param code a Linux key code (KEY_ in sys/input.h).
791 * @param text the characters it types (UTF-8), or "".
792 */
793void idunn_window_key(idunn_window_t *win, uint16_t code, uint32_t mods, const char *text);
794
795/**
796 * the time now in ms, for transitions.
797 * @return true while a transition runs (draw again in a frame).
798 */
800
801/**
802 * the pointer shape for where the pointer is (IDUNN_CURSOR_).
803 */
805
806/**
807 * the widget with the keyboard focus, or NULL.
808 */
810
811typedef enum
812{
813 IDUNN_INPUT_KEY, // code, mods, text (a press or a repeat)
814 IDUNN_INPUT_PRESS, // the left button went down: x, y, mods, clicks (1 to 3)
815 IDUNN_INPUT_DRAG, // the pointer moved with the button down: x, y
816 IDUNN_INPUT_RELEASE, // the button went up: x, y
817 IDUNN_INPUT_MOTION, // the pointer moved, no button down: x, y
818 IDUNN_INPUT_SCROLL, // the wheel: steps, up is positive
819 IDUNN_INPUT_PASTE, // the clipboard text it asked for: text, length
820 IDUNN_INPUT_FOCUS, // it got the keyboard
821 IDUNN_INPUT_BLUR, // it lost the keyboard
822 IDUNN_INPUT_TIMER, // the time it asked for (idunn_canvas_wake) came
824
825/**
826 * input for a canvas. x and y are from the canvas's top left corner.
827 */
828typedef struct
829{
831 uint16_t code; // KEY: the Linux key code
832 uint32_t mods; // KEY, PRESS: IDUNN_MOD_
833 const char *text; // KEY: the characters it types (UTF-8), or ""; PASTE: the text
834 size_t length; // PASTE
840
841/**
842 * what a canvas does; each hook can be NULL.
843 */
844typedef struct
845{
846 /**
847 * draw the canvas, which is at rect in the window. only the part in
848 * buf->clip must be drawn (the rest is still right).
849 */
850 void (*draw)(idunn_widget_t *canvas, gfx_buffer_t *buf, gfx_rect_t rect, void *data);
851 /** @return true if it used the input (else it goes to the parents) */
852 bool (*input)(idunn_widget_t *canvas, const idunn_input_t *in, void *data);
853 /** the canvas has a new size (also the first time it is laid out) */
854 void (*resize)(idunn_widget_t *canvas, int32_t width, int32_t height, void *data);
855 /**
856 * before a frame is drawn, while the window still holds the last
857 * frame: move pixels (idunn_canvas_move) and say what to draw again.
858 */
859 void (*frame)(idunn_widget_t *canvas, void *data);
861
862/**
863 * a widget the program draws itself: a terminal, a game. it takes the
864 * keyboard (Tab too), the pointer and the wheel. it is as large as its
865 * box lets it grow, or idunn_set_size.
866 */
867idunn_widget_t *idunn_canvas(const idunn_canvas_hooks_t *hooks, void *data);
868
869/** draw a rect of the canvas again (canvas coordinates) */
871
872/** a frame soon, so the frame hook runs (new data came) */
874
875/**
876 * in the frame hook: move the pixels of area up (dy < 0) or down; the
877 * strip that comes into view is damaged.
878 */
879void idunn_canvas_move(idunn_widget_t *canvas, gfx_rect_t area, int32_t dy);
880
881/** put text on the clipboard; ask for its text (an IDUNN_INPUT_PASTE comes) */
882void idunn_canvas_copy(idunn_widget_t *canvas, const char *text, size_t length);
884
885/** an IDUNN_INPUT_TIMER in ms (one at a time; a new call moves it) */
887
888/** the pointer shape over the canvas (IDUNN_CURSOR_) */
890
891/**
892 * give the keyboard to a widget in a window (a canvas at the start).
893 */
895
896/**
897 * where a widget is in its window, after layout.
898 */
const idunn_theme_t * idunn_app_theme(const idunn_app_t *app)
Definition app.c:182
idunn_window_t * idunn_window_new(idunn_app_t *app, const char *title, int32_t width, int32_t height)
a window with a title bar; it shows when the app runs.
Definition app.c:283
void idunn_app_on_event(idunn_app_t *app, void(*on_event)(idunn_app_t *app, const heim_msg_t *msg, void *data), void *data)
get the events that are about no window of the app (the shell's HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP,...
Definition app.c:102
void idunn_window_close(idunn_window_t *win)
close and free the window (and its widgets).
Definition app.c:336
void idunn_window_on_close(idunn_window_t *win, bool(*on_close)(idunn_window_t *win, void *data), void *data)
the close button (or the shell's Close): on_close returns true to let the window close,...
Definition app.c:552
heim_conn_t * idunn_app_conn(const idunn_app_t *app)
the connection to the window server, for calls idunn does not wrap (the shell's heim_shell_start,...
Definition app.c:97
void idunn_app_every(idunn_app_t *app, uint32_t period, void(*every)(void *data), void *data)
call every(data) each period ms while the app runs (a clock).
Definition app.c:110
idunn_window_t * idunn_screen_window_new(idunn_app_t *app, const gfx_buffer_t *backdrop)
a window as large as the screen with no title bar (a login screen).
Definition app.c:294
idunn_app_t * idunn_app_new(const char *name)
connect to the window server and read the theme.
Definition app.c:70
idunn_window_t * idunn_panel_new(idunn_app_t *app, int32_t height)
a panel of the desktop shell: no title bar, at the bottom of the screen, as wide as the screen,...
Definition app.c:306
void idunn_window_set_title(idunn_window_t *win, const char *title)
a new title in the window's title bar (and the shell's window list).
Definition app.c:176
bool idunn_app_save_theme(idunn_app_t *app, const char *key, const char *value)
change a theme setting (mode, accent, radius, font_size, scale, motion) in the user's theme file.
Definition app.c:217
int idunn_app_run(idunn_app_t *app)
run until the last window is closed or idunn_app_quit.
Definition app.c:407
void idunn_app_watch(idunn_app_t *app, int fd, void(*ready)(int fd, void *data), void *data)
call ready(fd, data) when fd can be read (or has hung up) while the app runs: a pty,...
Definition app.c:118
void idunn_app_paste(idunn_app_t *app, void(*got)(const char *text, size_t length, void *data), void *data)
ask for the clipboard's text for the program itself (not a widget): got gets it when it comes ("" whe...
Definition app.c:543
void idunn_app_set_theme(idunn_app_t *app, const idunn_theme_t *theme)
use another theme in all windows of the app (they are drawn again).
Definition app.c:197
void idunn_app_quit(idunn_app_t *app)
Definition app.c:92
idunn_widget_t * idunn_badge(const char *text, idunn_badge_t variant)
a badge: a short word in a small pill
Definition badge.c:80
void idunn_button_set_text(idunn_widget_t *button, const char *text)
Definition button.c:480
void idunn_button_set_variant(idunn_widget_t *button, idunn_variant_t variant)
Definition button.c:492
void idunn_button_set_pill(idunn_widget_t *button, bool pill)
round ends: the radius is half the height
Definition button.c:435
void idunn_button_set_align(idunn_widget_t *button, idunn_align_t align)
where the icon and text go: IDUNN_CENTER (the default) or IDUNN_START (side bar items,...
Definition button.c:502
idunn_widget_t * idunn_icon_button(const char *icon, idunn_variant_t variant, idunn_callback_t on_click, void *data)
a square button with only an icon (a Lucide name).
Definition button.c:393
void idunn_button_set_picture(idunn_widget_t *button, const char *picture)
a picture in its own colours (a Tela name, an app's icon) before the text
Definition button.c:418
void idunn_button_set_dim(idunn_widget_t *button, bool dim)
the content muted (a task whose window is minimized)
Definition button.c:462
void idunn_button_set_icon(idunn_widget_t *button, const char *icon)
an icon (a Lucide name) before the text.
Definition button.c:406
void idunn_button_set_tile(idunn_widget_t *button, bool tile)
a tile: the icon larger, over the text in small type (Restart, Power off)
Definition button.c:453
void idunn_button_set_glass(idunn_widget_t *button, bool glass)
see-through, lighter than what is under it (over a picture)
Definition button.c:444
void idunn_button_set_size(idunn_widget_t *button, idunn_size_t size)
Definition button.c:471
idunn_widget_t * idunn_button(const char *text, idunn_variant_t variant, idunn_callback_t on_click, void *data)
a button; on_click gets the button and data.
Definition button.c:373
void idunn_button_set_active(idunn_widget_t *button, bool active)
the button is on (a task's window is active, a toggle is on): a filled look with a short accent line ...
Definition button.c:426
void idunn_canvas_wake(idunn_widget_t *canvas, uint32_t ms)
an IDUNN_INPUT_TIMER in ms (one at a time; a new call moves it)
Definition canvas.c:190
idunn_widget_t * idunn_canvas(const idunn_canvas_hooks_t *hooks, void *data)
a widget the program draws itself: a terminal, a game.
Definition canvas.c:129
void idunn_canvas_set_cursor(idunn_widget_t *canvas, uint32_t shape)
the pointer shape over the canvas (IDUNN_CURSOR_)
Definition canvas.c:196
void idunn_canvas_paste(idunn_widget_t *canvas)
Definition canvas.c:184
void idunn_canvas_move(idunn_widget_t *canvas, gfx_rect_t area, int32_t dy)
in the frame hook: move the pixels of area up (dy < 0) or down; the strip that comes into view is dam...
Definition canvas.c:170
void idunn_canvas_damage(idunn_widget_t *canvas, gfx_rect_t r)
draw a rect of the canvas again (canvas coordinates)
Definition canvas.c:154
void idunn_canvas_update(idunn_widget_t *canvas)
a frame soon, so the frame hook runs (new data came)
Definition canvas.c:164
void idunn_canvas_copy(idunn_widget_t *canvas, const char *text, size_t length)
put text on the clipboard; ask for its text (an IDUNN_INPUT_PASTE comes)
Definition canvas.c:178
void idunn_check_box_set_state(idunn_widget_t *box, idunn_check_t state)
Definition check.c:121
idunn_widget_t * idunn_check_box(const char *label, bool checked, idunn_callback_t on_change, void *data)
a check box with a label to its right (a click on the label clicks it).
Definition check.c:91
idunn_check_t idunn_check_box_state(const idunn_widget_t *box)
Definition check.c:115
idunn_context_t * idunn_context_new(const idunn_theme_t *theme, const char *font_dir, const char *icon_pack)
fonts and icons for a theme.
Definition context.c:48
void idunn_context_set_theme(idunn_context_t *ctx, const idunn_theme_t *theme)
Definition context.c:90
void idunn_context_free(idunn_context_t *ctx)
Definition context.c:75
idunn_widget_t * idunn_empty_state(const char *icon, const char *title, const char *text)
an empty state: an icon on a muted square, a title and a muted line (or NULL), in the middle of its s...
Definition empty.c:91
idunn_widget_t * idunn_icon_view(const char *name, int32_t size, idunn_color_t color)
a Lucide icon on its own, size points, in a colour token
Definition empty.c:86
idunn_widget_t * idunn_field(const char *label, idunn_widget_t *control, const char *help)
a form row: a label above the control and help text below it (or NULL).
Definition field.c:74
void idunn_field_set_error(idunn_widget_t *field, const char *message)
show an error: the message in red under the control, and the control's border and ring red.
Definition field.c:94
void idunn_file_dialog(idunn_widget_t *owner, idunn_file_mode_t mode, const char *title, const char *path, idunn_file_done_t done, void *data)
a dialog to choose a file: the folder's items as a list, a button to the folder above,...
Definition file_dialog.c:289
idunn_widget_t * idunn_dialog(const char *title, const char *description)
a dialog: a card with a title and a description (or NULL), in the middle of the window over the overl...
Definition floating.c:165
idunn_widget_t * idunn_dialog_add_button(idunn_widget_t *dialog, const char *text, idunn_variant_t variant, idunn_callback_t on_click, void *data)
a button at the bottom right: Cancel as outline, the action primary or destructive
Definition floating.c:201
void idunn_popover(idunn_widget_t *owner, idunn_widget_t *content)
a popover: content in a card under owner; a press outside it or Escape closes it.
Definition floating.c:84
void idunn_dialog_open(idunn_widget_t *owner, idunn_widget_t *dialog)
show a dialog over the window of owner; the window owns it then
Definition floating.c:224
void idunn_dialog_close(idunn_widget_t *dialog)
Definition floating.c:267
idunn_widget_t * idunn_dialog_content(idunn_widget_t *dialog)
Definition floating.c:182
void idunn_popover_close(idunn_widget_t *inside)
close the popover a widget is in
Definition floating.c:111
libgfx: drawing into pixel buffers in memory.
struct heim_conn heim_conn_t
Definition heimdall.h:28
the messages between heimdalld (the window server) and its clients.
void idunn_widget_free(idunn_widget_t *w)
take a widget out of its parent and free it and its children.
Definition widget.c:111
gfx_rect_t idunn_window_draw(idunn_window_t *win)
lay out and draw what changed.
Definition window.c:319
void idunn_window_resize(idunn_window_t *win, int32_t width, int32_t height)
a new size for the window's buffer (the window lays out again).
Definition window.c:69
void(*) idunn_callback_t(idunn_widget_t *widget, void *data)
Definition idunn.h:39
idunn_widget_t * idunn_label(const char *text, idunn_text_t style)
text in a style; it ends with "..." when it is too wide, or wraps.
Definition label.c:92
int idunn_list_view_count(const idunn_widget_t *list)
Definition list.c:880
bool idunn_list_view_edit(idunn_widget_t *list, int item, size_t start, size_t end, idunn_edit_done_t done, void *data)
edit an item's text in place (a rename): a text field over it with the bytes start to end selected ((...
Definition list.c:985
int idunn_list_view_current(const idunn_widget_t *list)
the item with the keyboard, or -1
Definition list.c:932
void idunn_set_tooltip(idunn_widget_t *w, const char *text)
a tooltip: shown over the widget after 600 ms under the pointer (NULL: none)
Definition widget.c:83
void idunn_tabs_set_active(idunn_widget_t *tabs, int active)
Definition tabs.c:259
idunn_variant_t
Definition idunn.h:340
@ IDUNN_LINK
Definition idunn.h:346
@ IDUNN_SECONDARY
Definition idunn.h:342
@ IDUNN_DESTRUCTIVE
Definition idunn.h:345
@ IDUNN_GHOST
Definition idunn.h:344
@ IDUNN_OUTLINE
Definition idunn.h:343
@ IDUNN_PRIMARY
Definition idunn.h:341
int idunn_menu_add_sub(idunn_menu_t *menu, const char *icon, const char *text, idunn_menu_t *sub)
an item that opens a sub-menu (the menu owns it)
Definition menu.c:142
void idunn_set_size(idunn_widget_t *w, int32_t width, int32_t height)
a size a widget must have, in design pixels (0: its own size).
Definition widget.c:155
int idunn_menu_add_check(idunn_menu_t *menu, const char *text, bool checked, idunn_callback_t on_choose, void *data)
an item with a check that a choice turns on and off
Definition menu.c:125
idunn_widget_t * idunn_list_view(void)
a list view: rows with a Lucide icon (or NULL), text and a muted second text on the right (or NULL).
Definition list.c:755
int32_t idunn_text_field_text_width(idunn_widget_t *field)
the width of the field's text in pixels (0 before it is in a window)
Definition text_field.c:486
void idunn_text_area_set_text(idunn_widget_t *area, const char *text)
Definition text_area.c:441
int idunn_list_view_columns(const idunn_widget_t *list)
the items in a line (1 for a list, more for a grid)
Definition list.c:927
idunn_widget_t * idunn_row(int gap, int padding)
a box that puts its children in a row (left to right) or a column (top to bottom),...
Definition layout.c:263
void idunn_window_key(idunn_window_t *win, uint16_t code, uint32_t mods, const char *text)
a key press (or repeat).
Definition window.c:747
void idunn_menu_popup_at_pointer(idunn_menu_t *menu, idunn_widget_t *owner)
open the menu where the last right click was (a context menu)
Definition menu.c:567
idunn_widget_t * idunn_text_area(const char *placeholder, int rows)
a text area: lines that wrap, Enter for a new line; it scrolls.
Definition text_area.c:407
struct idunn_app idunn_app_t
Definition idunn.h:34
void idunn_label_set_color(idunn_widget_t *label, idunn_color_t color)
Definition label.c:136
void idunn_text_field_on_submit(idunn_widget_t *field, idunn_callback_t on_submit, void *data)
Definition text_field.c:512
void idunn_menu_set_checked(idunn_menu_t *menu, int item, bool checked)
Definition menu.c:165
void idunn_menu_popup(idunn_menu_t *menu, idunn_widget_t *owner)
open the menu under a widget (a button's on_click does it)
Definition menu.c:550
void idunn_list_view_set_multiple(idunn_widget_t *list, bool multiple)
many items can be selected (Ctrl, Shift, Ctrl+A)
Definition list.c:886
idunn_widget_t * idunn_card(int gap)
a card: a column on the card colour with a border, the large radius and a small shadow,...
Definition layout.c:334
void idunn_list_view_set_columns(idunn_widget_t *list, const int32_t *widths, int count)
columns at the right of the rows: an item's detail is split at tabs, and each part is drawn at the ri...
Definition list.c:1013
idunn_widget_t * idunn_progress(void)
a progress bar across its box; value 0 to IDUNN_PROGRESS_MAX
Definition progress.c:55
void idunn_window_pointer(idunn_window_t *win, idunn_pointer_t kind, int32_t x, int32_t y, uint32_t mods)
the pointer moved, or the left button went down or up, at (x, y), with these modifier keys held (Shif...
Definition window.c:612
const char * idunn_text_area_text(const idunn_widget_t *area)
Definition text_area.c:435
int idunn_menu_add(idunn_menu_t *menu, const char *icon, const char *text, const char *shortcut, idunn_callback_t on_choose, void *data)
an item: a Lucide icon (or NULL), text and a shortcut to show (or NULL).
Definition menu.c:113
const char * idunn_text_field_text(const idunn_widget_t *field)
the text (UTF-8); valid until the text changes
Definition text_field.c:433
void idunn_menu_set_disabled(idunn_menu_t *menu, int item, bool disabled)
Definition menu.c:154
void idunn_text_area_on_change(idunn_widget_t *area, idunn_callback_t on_change, void *data)
Definition text_area.c:452
idunn_menu_t * idunn_menu_new(void)
Definition menu.c:70
void idunn_list_view_set_columns_left(idunn_widget_t *list, uint32_t mask)
draw some columns at their left, for text (a date, a type); the others stay at their right,...
Definition list.c:1053
uint32_t idunn_window_cursor(const idunn_window_t *win)
the pointer shape for where the pointer is (IDUNN_CURSOR_).
Definition window.c:429
void idunn_set_disabled(idunn_widget_t *w, bool disabled)
a disabled widget is drawn at half opacity and gets no input.
Definition widget.c:162
idunn_widget_t * idunn_add(idunn_widget_t *parent, idunn_widget_t *child)
add child at the end of parent.
Definition widget.c:23
void idunn_list_view_on_menu(idunn_widget_t *list, idunn_callback_t on_menu, void *data)
on_menu on a right click: on an item that is not selected, it selects only that item first; on no ite...
Definition list.c:969
void idunn_scroll_view_scroll_to(idunn_widget_t *view, int32_t offset)
Definition scroll.c:315
void idunn_text_field_set_text(idunn_widget_t *field, const char *text)
Definition text_field.c:439
const char * idunn_list_view_text(const idunn_widget_t *list, int item)
Definition list.c:938
void idunn_switch_set_on(idunn_widget_t *sw, bool on)
Definition switch.c:140
void idunn_window_paste(idunn_window_t *win, const char *text, size_t length)
the clipboard text a widget asked for came (from the window server).
Definition window.c:419
int idunn_list_view_item_at(const idunn_widget_t *list, int32_t x, int32_t y)
the item at a point of the window, or -1
Definition list.c:978
void idunn_text_field_select(idunn_widget_t *field, size_t start, size_t end)
Definition text_field.c:521
idunn_widget_t * idunn_text_field(const char *placeholder)
a one-line text field, 32 pixels high.
Definition text_field.c:406
void idunn_list_view_on_select(idunn_widget_t *list, idunn_callback_t on_select, void *data)
on_select after the selection changes; on_activate on a double click or Enter
Definition list.c:944
void idunn_window_on_key(idunn_window_t *win, idunn_key_hook_t on_key, void *data)
Definition window.c:710
struct idunn_menu idunn_menu_t
a menu: items the app adds, shown in a popup by idunn_menu_popup
Definition idunn.h:623
gfx_buffer_t * idunn_window_buffer(const idunn_window_t *win)
Definition window.c:78
idunn_input_type_t
Definition idunn.h:812
@ IDUNN_INPUT_PRESS
Definition idunn.h:814
@ IDUNN_INPUT_BLUR
Definition idunn.h:821
@ IDUNN_INPUT_FOCUS
Definition idunn.h:820
@ IDUNN_INPUT_SCROLL
Definition idunn.h:818
@ IDUNN_INPUT_PASTE
Definition idunn.h:819
@ IDUNN_INPUT_KEY
Definition idunn.h:813
@ IDUNN_INPUT_TIMER
Definition idunn.h:822
@ IDUNN_INPUT_DRAG
Definition idunn.h:815
@ IDUNN_INPUT_RELEASE
Definition idunn.h:816
@ IDUNN_INPUT_MOTION
Definition idunn.h:817
void idunn_box_set_background(idunn_widget_t *box, idunn_color_t color)
a background for a box, a colour token (by default it has none).
Definition layout.c:314
void idunn_label_set_text(idunn_widget_t *label, const char *text)
Definition label.c:114
void idunn_free_later(idunn_widget_t *w)
free w (and its children) after the event that is running: for a widget that may be in its own callba...
Definition widget.c:91
void(*) idunn_edit_done_t(idunn_widget_t *list, int item, const char *text, void *data)
what an edit in place gives: the new text, or NULL when it was taken back (Escape).
Definition idunn.h:571
void idunn_select_choose(idunn_widget_t *select, int chosen)
Definition select.c:179
void idunn_text_field_set_secret(idunn_widget_t *field, bool secret)
a password field: a bullet for each character, and no Copy or Cut
Definition text_field.c:477
void idunn_window_scroll(idunn_window_t *win, int32_t x, int32_t y, int32_t steps)
the wheel turned over (x, y): steps, up is positive.
Definition window.c:808
void idunn_card_header(idunn_widget_t *card, const char *title, const char *description)
a title and a muted description (or NULL) at the top of a card.
Definition layout.c:339
void idunn_list_view_set_count(idunn_widget_t *list, int count)
keep only the first count items (a smaller count than now)
Definition list.c:858
void idunn_on_middle_click(idunn_widget_t *w, idunn_callback_t on_middle, void *data)
on_middle on a press of the middle button on the widget or in it (the nearest widget that has one): a...
Definition widget.c:358
void idunn_list_view_select(idunn_widget_t *list, int item, bool selected)
Definition list.c:908
void idunn_text_field_on_change(idunn_widget_t *field, idunn_callback_t on_change, void *data)
on_change after every change of the text; on_submit on Enter
Definition text_field.c:494
idunn_widget_t * idunn_window_focus(const idunn_window_t *win)
the widget with the keyboard focus, or NULL.
Definition window.c:434
idunn_check_t
Definition idunn.h:454
@ IDUNN_UNCHECKED
Definition idunn.h:455
@ IDUNN_CHECKED
Definition idunn.h:456
@ IDUNN_MIXED
Definition idunn.h:457
idunn_widget_t * idunn_tabs_add(idunn_widget_t *tabs, const char *name, idunn_widget_t *page)
add a tab with its page (the tabs own it); the first one is active
Definition tabs.c:222
void idunn_list_view_clear(idunn_widget_t *list)
Definition list.c:812
bool(*) idunn_key_hook_t(idunn_window_t *win, uint16_t code, uint32_t mods, const char *text, void *data)
keys that no widget used (the focused one and its parents): the window's own shortcuts.
Definition idunn.h:182
int idunn_list_heads_clicked(const idunn_widget_t *heads)
the head that was clicked: 0 for the names, 1 and on for the columns
Definition list_heads.c:208
int idunn_tabs_active(const idunn_widget_t *tabs)
Definition tabs.c:253
void idunn_list_view_on_activate(idunn_widget_t *list, idunn_callback_t on_activate, void *data)
Definition list.c:953
void idunn_text_field_set_pill(idunn_widget_t *field, bool pill)
a pill: round ends, see-through (over a picture, as on a login screen), no border,...
Definition text_field.c:467
void idunn_box_set_align(idunn_widget_t *box, idunn_align_t align, idunn_align_t justify)
how a box places its children: align across it (default: stretch) and justify along it (default: star...
Definition layout.c:284
idunn_widget_t * idunn_list_heads(idunn_widget_t *list, const char *const *names, int count, idunn_callback_t on_click, void *data)
heads over the columns of a list view, which line up with it.
Definition list_heads.c:177
idunn_widget_t * idunn_scroll_view(idunn_widget_t *child)
a scroll view: the child can be taller than the view.
Definition scroll.c:294
int idunn_select_chosen(const idunn_widget_t *select)
Definition select.c:173
void idunn_text_field_set_plain(idunn_widget_t *field, bool plain)
select bytes start to end (the caret at end); typing replaces them.
Definition text_field.c:458
void idunn_window_invalidate(idunn_window_t *win)
the whole window must be drawn again (after a theme change).
Definition window.c:83
idunn_widget_t * idunn_grid_view(void)
a grid view: the same, as tiles of a 48 point Tela icon (a file or folder icon name) with the name be...
Definition list.c:770
idunn_widget_t * idunn_column(int gap, int padding)
Definition layout.c:268
uint32_t idunn_window_next_wake(const idunn_window_t *win)
the next time (ms) the window must be ticked for a timer, or 0 for none.
Definition window.c:351
idunn_widget_t * idunn_spacer(void)
empty space that grows (put it between children to push them apart).
Definition layout.c:353
void idunn_set_error(idunn_widget_t *w, bool error)
a control with a wrong value: its border and ring are red (a field sets this on its control with idun...
Definition widget.c:181
idunn_badge_t
Definition idunn.h:496
@ IDUNN_BADGE_DESTRUCTIVE
Definition idunn.h:500
@ IDUNN_BADGE_DEFAULT
Definition idunn.h:497
@ IDUNN_BADGE_SECONDARY
Definition idunn.h:498
@ IDUNN_BADGE_OUTLINE
Definition idunn.h:499
int32_t idunn_slider_value(const idunn_widget_t *slider)
Definition slider.c:174
idunn_widget_t * idunn_slider(int32_t min, int32_t max, int32_t step, int32_t value, idunn_callback_t on_change, void *data)
a slider from min to max in steps (the arrows move it by one step).
Definition slider.c:151
idunn_widget_t * idunn_switch(const char *label, bool on, idunn_callback_t on_change, void *data)
a switch with a label to its right; it slides when it changes.
Definition switch.c:110
idunn_file_mode_t
Definition idunn.h:674
@ IDUNN_FILE_SAVE
Definition idunn.h:676
@ IDUNN_FILE_OPEN
Definition idunn.h:675
void idunn_set_hidden(idunn_widget_t *w, bool hidden)
a hidden widget is not drawn, takes no room in its box and gets no input.
Definition widget.c:258
idunn_widget_t * idunn_grow(idunn_widget_t *w, int weight)
let a widget take a share of the free space along its box.
Definition widget.c:145
void idunn_on_key(idunn_widget_t *w, idunn_widget_key_t on_key, void *data)
Definition widget.c:366
bool idunn_list_view_editing(const idunn_widget_t *list)
true while an item is edited in place
Definition list.c:1069
bool idunn_switch_on(const idunn_widget_t *sw)
Definition switch.c:134
void idunn_list_view_set_item(idunn_widget_t *list, int item, const char *icon, const char *text, const char *detail)
change an item; only its row is drawn again, and only when something differs (a list that is filled a...
Definition list.c:844
idunn_size_t
Definition idunn.h:350
@ IDUNN_SIZE_SMALL
Definition idunn.h:352
@ IDUNN_SIZE_DEFAULT
Definition idunn.h:351
@ IDUNN_SIZE_LARGE
Definition idunn.h:353
void idunn_box_set_padding(idunn_widget_t *box, int vertical, int horizontal)
other paddings for the sides of a box, in units: across and along.
Definition layout.c:294
void idunn_list_view_go_to(idunn_widget_t *list, int item)
make an item the current one and select only it, as the arrow keys do
Definition list.c:921
int idunn_list_view_add(idunn_widget_t *list, const char *icon, const char *text, const char *detail)
Definition list.c:788
void idunn_label_set_wrap(idunn_widget_t *label, bool wrap)
Definition label.c:145
void idunn_card_set_glass(idunn_widget_t *card, bool glass)
frosted glass: the card is see-through, lighter than what is under it, with a thin light edge and a l...
Definition layout.c:304
idunn_widget_t * idunn_radio_group(const char *const *labels, int count, int chosen, idunn_callback_t on_change, void *data)
a group of choices with round buttons, one chosen; one Tab stop, the arrows move the choice.
Definition radio.c:183
int idunn_radio_group_chosen(const idunn_widget_t *group)
Definition radio.c:210
void idunn_list_heads_set_order(idunn_widget_t *heads, int head, bool descending)
show the order on a head (an arrow), or on none with head -1
Definition list_heads.c:214
void idunn_list_view_set_single_click(idunn_widget_t *list, bool single)
one click activates an item (a launcher); the arrow keys only move
Definition list.c:962
idunn_window_t * idunn_window_offscreen(idunn_context_t *ctx, int32_t width, int32_t height)
a window that draws into its own buffer, of that many pixels.
Definition window.c:17
void idunn_list_view_set_framed(idunn_widget_t *list, bool framed)
a border, the large radius and the card colour around the items
Definition list.c:893
void idunn_window_set_root(idunn_window_t *win, idunn_widget_t *root)
the widget that fills the window (a row or a column, usually).
Definition window.c:47
void idunn_on_menu(idunn_widget_t *w, idunn_callback_t on_menu, void *data)
on_menu on a right click on the widget or in it, when no widget in it used the click (a list view use...
Definition widget.c:374
struct idunn_widget idunn_widget_t
Definition idunn.h:37
void(*) idunn_file_done_t(const char *path, void *data)
the path chosen in a file dialog (the dialog is closed already)
Definition idunn.h:680
gfx_rect_t idunn_widget_rect(const idunn_widget_t *w)
where a widget is in its window, after layout.
Definition widget.c:190
int32_t idunn_scroll_view_offset(const idunn_widget_t *view)
Definition scroll.c:310
void idunn_progress_set(idunn_widget_t *progress, int32_t value)
Definition progress.c:66
struct idunn_window idunn_window_t
Definition idunn.h:36
idunn_align_t
Definition idunn.h:207
@ IDUNN_STRETCH
Definition idunn.h:211
@ IDUNN_END
Definition idunn.h:210
@ IDUNN_START
Definition idunn.h:208
@ IDUNN_SPACE_BETWEEN
Definition idunn.h:212
@ IDUNN_CENTER
Definition idunn.h:209
void idunn_menu_add_separator(idunn_menu_t *menu)
Definition menu.c:137
void idunn_menu_free(idunn_menu_t *menu)
free a menu (not while it is open) and its sub-menus
Definition menu.c:78
struct idunn_context idunn_context_t
Definition idunn.h:35
idunn_widget_t * idunn_tabs(idunn_callback_t on_change, void *data)
tabs: a strip of names and the page of the active one below it.
Definition tabs.c:201
bool idunn_menu_checked(const idunn_menu_t *menu, int item)
Definition menu.c:160
void idunn_text_field_set_icon(idunn_widget_t *field, const char *icon)
an icon (a Lucide name) at the start, as in a search field
Definition text_field.c:448
bool idunn_window_tick(idunn_window_t *win, uint32_t now)
the time now in ms, for transitions.
Definition window.c:329
void idunn_slider_set_value(idunn_widget_t *slider, int32_t value)
Definition slider.c:180
void idunn_text_field_on_blur(idunn_widget_t *field, idunn_callback_t on_blur, void *data)
on_blur when the field loses the keyboard
Definition text_field.c:503
void idunn_box_set_keep_end(idunn_widget_t *box, bool keep_end)
a row that is too short for its children shows the last ones: the first go out of view on the left,...
Definition layout.c:361
void idunn_menu_set_min_width(idunn_menu_t *menu, int32_t width)
the least width of the menu, in design pixels (160 by default)
Definition menu.c:171
void idunn_radio_group_choose(idunn_widget_t *group, int chosen)
Definition radio.c:216
idunn_widget_t * idunn_select(const char *const *choices, int count, int chosen, idunn_callback_t on_change, void *data)
a select: a field with the chosen value; it opens a menu of the choices.
Definition select.c:146
bool idunn_list_view_selected(const idunn_widget_t *list, int item)
Definition list.c:902
void idunn_set_focus(idunn_widget_t *w)
give the keyboard to a widget in a window (a canvas at the start).
Definition window.c:781
idunn_widget_t * idunn_separator(void)
a 1 pixel line: across a column, or down a row.
Definition separator.c:30
void idunn_radio_group_set_row(idunn_widget_t *group, bool row)
Definition radio.c:225
void idunn_select_set_placeholder(idunn_widget_t *select, const char *text)
Definition select.c:188
bool(*) idunn_widget_key_t(idunn_widget_t *w, uint16_t code, uint32_t mods, void *data)
keys for a widget (when it or a child has the keyboard) before the widget gets them.
Definition idunn.h:174
void idunn_list_view_set_pictures(idunn_widget_t *list, bool pictures)
rows with a Tela icon (a file or folder icon name) in colour, not a Lucide one
Definition list.c:1075
idunn_pointer_t
Definition idunn.h:757
@ IDUNN_POINTER_MOTION
Definition idunn.h:758
@ IDUNN_POINTER_MIDDLE
Definition idunn.h:763
@ IDUNN_POINTER_PRESS
Definition idunn.h:759
@ IDUNN_POINTER_MENU
Definition idunn.h:762
@ IDUNN_POINTER_LEAVE
Definition idunn.h:761
@ IDUNN_POINTER_RELEASE
Definition idunn.h:760
idunn: the design tokens (colours, sizes, text styles, shadows).
idunn_color_t
Definition idunn_theme.h:33
idunn_text_t
Definition idunn_theme.h:63
uint32_t error
Definition isr.h:3
unsigned int uint32_t
Definition fb.h:17
integer types of fixed width.
unsigned short uint16_t
Definition stdint.h:13
int int32_t
Definition stdint.h:14
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
wait until a descriptor in one of the sets is ready.
bool, true and false.
#define bool
Definition stdbool.h:8
Definition gfx.h:41
Definition gfx.h:33
Definition grp.h:11
Definition heimdall_proto.h:149
what a canvas does; each hook can be NULL.
Definition idunn.h:845
void(*) draw(idunn_widget_t *canvas, gfx_buffer_t *buf, gfx_rect_t rect, void *data)
draw the canvas, which is at rect in the window.
Definition idunn.h:850
void(*) frame(idunn_widget_t *canvas, void *data)
before a frame is drawn, while the window still holds the last frame: move pixels (idunn_canvas_move)...
Definition idunn.h:859
bool(*) input(idunn_widget_t *canvas, const idunn_input_t *in, void *data)
Definition idunn.h:852
void(*) resize(idunn_widget_t *canvas, int32_t width, int32_t height, void *data)
the canvas has a new size (also the first time it is laid out)
Definition idunn.h:854
Definition idunn_internal.h:149
input for a canvas.
Definition idunn.h:829
uint32_t mods
Definition idunn.h:832
int clicks
Definition idunn.h:837
size_t length
Definition idunn.h:834
uint16_t code
Definition idunn.h:831
int32_t x
Definition idunn.h:835
int32_t steps
Definition idunn.h:838
const char * text
Definition idunn.h:833
idunn_input_type_t type
Definition idunn.h:830
int32_t y
Definition idunn.h:836
Definition idunn_theme.h:96
Definition idunn_internal.h:122
int32_t height
Definition idunn_internal.h:135
int32_t width
Definition idunn_internal.h:134
void * data
Definition idunn_internal.h:145
idunn_callback_t on_middle
Definition idunn_internal.h:141
uint32_t state
Definition idunn_internal.h:131
idunn_callback_t on_menu
Definition idunn_internal.h:139
idunn_widget_t * parent
Definition idunn_internal.h:125
idunn_widget_key_t on_key
Definition idunn_internal.h:142
Definition idunn_internal.h:165