diff --git a/README.md b/README.md index 08a928f..11bf47d 100644 --- a/README.md +++ b/README.md @@ -53,21 +53,23 @@ Execute the `tray_example` application: ## API -Tray structure defines an icon and a menu. -Menu is a NULL-terminated array of items. -Menu item defines menu text, menu checked and disabled (grayed) flags and a -callback with some optional context pointer. +A tray is defined by an icon, an optional tooltip and a menu. +The menu is a NULL-terminated array of items. +Each menu item can be disabled, checked, represented as a checkbox and invoke a +callback with an optional context pointer. ```c struct tray { - char *icon; + const char *icon; + char *tooltip; struct tray_menu *menu; }; struct tray_menu { - char *text; + const char *text; int disabled; int checked; + int checkbox; void (*cb)(struct tray_menu *); void *context; @@ -76,15 +78,23 @@ struct tray_menu { }; ``` -* `int tray_init(struct tray *)` - creates tray icon. Returns -1 if tray icon/menu can't be created. -* `void tray_update(struct tray *)` - updates tray icon and menu. -* `int tray_loop(int blocking)` - runs one iteration of the UI loop. Returns -1 if `tray_exit()` has been called. -* `void tray_exit()` - terminates UI loop. +* `int tray_init(struct tray *)` - creates the tray icon and its menu. Returns `-1` if the tray icon or menu cannot be created. +* `void tray_update(struct tray *)` - updates the tray icon, tooltip and menu state. +* `int tray_loop(int blocking)` - runs one iteration of the UI loop. Returns `-1` after `tray_exit()` has been called. +* `void tray_exit(void)` - terminates the UI loop and cleans up tray resources. All functions are meant to be called from the UI thread only. -Menu arrays must be terminated with a NULL item, e.g. the last item in the -array must have text field set to NULL. +Menu arrays must be terminated with a NULL item, i.e. the last item in the +array must have `text == NULL`. + +### Notes + +* `tooltip` is optional. +* A separator is created by using `text = "-"`. +* Some behavior may depend on the underlying backend or desktop environment. + Keep the public API generic and treat platform-specific interaction details as + backend-specific implementation behavior. ## License