diff libmlk-ui/mlk/ui/ui.h @ 628:c2b62ff38224

ui: improve documentation (ui.h)
author David Demelier <markand@malikania.fr>
date Sat, 26 Aug 2023 15:36:07 +0200
parents 281608524dd1
children
line wrap: on
line diff
--- a/libmlk-ui/mlk/ui/ui.h	Sat Aug 26 15:24:33 2023 +0200
+++ b/libmlk-ui/mlk/ui/ui.h	Sat Aug 26 15:36:07 2023 +0200
@@ -38,27 +38,73 @@
 
 union mlk_event;
 
+/**
+ * \enum mlk_ui_font
+ * \brief Predefined font alias.
+ */
 enum mlk_ui_font {
+	/**
+	 * Font for UI elements.
+	 */
 	MLK_UI_FONT_INTERFACE,
+
+	/**
+	 * Unused sentinel value.
+	 */
 	MLK_UI_FONT_LAST
 };
 
+/**
+ * \brief Global array of predefined fonts.
+ */
 extern struct mlk_font mlk_ui_fonts[MLK_UI_FONT_LAST];
 
 #if defined(__cplusplus)
 extern "C" {
 #endif
 
+/**
+ * Initialize the libmlk-ui library.
+ */
 int
 mlk_ui_init(void);
 
+/**
+ * Handle an event in the libmlk-ui library.
+ *
+ * This function is required to adjust global parameters such as dark/light
+ * theme if desired.
+ *
+ * \pre ev != NULL
+ * \param ev the event
+ */
 void
 mlk_ui_handle(const union mlk_event *ev);
 
+/**
+ * Apply the light or dark theme to the predefined UI elements.
+ *
+ * \pre theme must be ::MLK_WINDOW_THEME_DARK or ::MLK_WINDOW_THEME_LIGHT
+ * \param theme new theme to set
+ */
 void
 mlk_ui_set_theme(enum mlk_window_theme theme);
 
-/* TODO: probably better somewhere else? */
+/**
+ * Convenient helper to draw and align text directly on the current rendering
+ * target.
+ *
+ * \pre font != NULL
+ * \pre text != NULL and not empty
+ * \param align alignment into the destination region
+ * \param font the font to use
+ * \param color the text color
+ * \param text the text to show
+ * \param x the x coordinate
+ * \param y the y coordinate
+ * \param w the rectangle destination width
+ * \param h the rectangle destination height
+ */
 void
 mlk_ui_draw_text(enum mlk_align align,
                  struct mlk_font *font,
@@ -69,6 +115,9 @@
                  unsigned int w,
                  unsigned int h);
 
+/**
+ * Cleanup resources allocated by the library.
+ */
 void
 mlk_ui_finish(void);