diff libui/ui/label.h @ 152:1008a796a9e7

ui: make UI widgets usable as actions While here add a example-ui program with move support.
author David Demelier <markand@malikania.fr>
date Thu, 15 Oct 2020 18:09:45 +0200
parents b19d076856d2
children aa6e70e330a1
line wrap: on
line diff
--- a/libui/ui/label.h	Thu Oct 15 14:01:24 2020 +0200
+++ b/libui/ui/label.h	Thu Oct 15 18:09:45 2020 +0200
@@ -22,10 +22,12 @@
 /**
  * \file label.h
  * \brief GUI label.
+ * \ingroup ui
  */
 
 #include "align.h"
 
+struct action;
 struct theme;
 
 /**
@@ -74,4 +76,23 @@
 void
 label_draw(const struct label *label);
 
+/**
+ * Convert the label into an action.
+ *
+ * The following field will be set into the action:
+ *
+ * - act->data: points to label (reference),
+ * - act->draw: a wrapper to label_draw.
+ *
+ * The label being an UI element is considered to never completes, as such
+ * you will need to handle this case or to use a custom update function.
+ *
+ * \pre frame != NULL
+ * \pre act != NULL
+ * \param label the label to reference
+ * \param act the action to fill
+ */
+void
+label_action(struct label *label, struct action *act);
+
 #endif /* !MOLKO_LABEL_H */