comparison libui/ui/label.h @ 174:6992085d47fd

ui: major theme overhaul, closes #2509 @1h - The font does not contain a color anymore, - Add a new color argument to font_render, - Theme are stored `const` in UI elements to promise no modifications, - Also make all <ui>_draw function to take a const widget too.
author David Demelier <markand@malikania.fr>
date Thu, 22 Oct 2020 15:16:43 +0200
parents 31d7f23c0588
children 49639211d63b
comparison
equal deleted inserted replaced
173:cd69c8791dac 174:6992085d47fd
42 struct label { 42 struct label {
43 int x; /*!< (+) Position in x. */ 43 int x; /*!< (+) Position in x. */
44 int y; /*!< (+) Position in y. */ 44 int y; /*!< (+) Position in y. */
45 const char *text; /*!< (+&) Text to show. */ 45 const char *text; /*!< (+&) Text to show. */
46 enum label_flags flags; /*!< (+) Optional flags. */ 46 enum label_flags flags; /*!< (+) Optional flags. */
47 struct theme *theme; /*!< (+&?) Theme to use. */ 47 const struct theme *theme; /*!< (+&?) Theme to use. */
48 }; 48 };
49 49
50 /** 50 /**
51 * Default drawing function. 51 * Default drawing function.
52 * 52 *
54 * \pre label != NULL 54 * \pre label != NULL
55 * \param t the theme 55 * \param t the theme
56 * \param label the label 56 * \param label the label
57 */ 57 */
58 void 58 void
59 label_draw_default(struct theme *t, const struct label *label); 59 label_draw_default(const struct theme *t, const struct label *label);
60
61 /**
62 * Tells if the label is usable.
63 *
64 * \param label the label to check (may be NULL)
65 * \return False if label is null or as empty text.
66 */
67 bool
68 label_ok(const struct label *label);
60 69
61 /** 70 /**
62 * Update the `w` and `h` fields with the dimensions the text would needs with 71 * Update the `w` and `h` fields with the dimensions the text would needs with
63 * the current theme. 72 * the current theme.
64 * 73 *
66 * \param label the label 75 * \param label the label
67 * \param w the pointer to width (may be NULL) 76 * \param w the pointer to width (may be NULL)
68 * \param h the pointer to height (may be NULL) 77 * \param h the pointer to height (may be NULL)
69 */ 78 */
70 void 79 void
71 label_query(struct label *label, unsigned int *w, unsigned int *h); 80 label_query(const struct label *label, unsigned int *w, unsigned int *h);
72 81
73 /** 82 /**
74 * Draw the label. 83 * Draw the label.
75 * 84 *
76 * \pre label != NULL 85 * \pre label != NULL