Mercurial > molko
diff libmlk-ui/mlk/ui/label.h @ 507:d49a05e7a5b5
ui: separate delegate/style
Now UI elements do have different styling properties:
- _delegate: functions used to update, draw or perform specific actions on the
UI element.
- _style: basic properties that the delegate should support if possible.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 02 Mar 2023 21:36:43 +0100 |
parents | e205625015ba |
children | daf085bf8a8c |
line wrap: on
line diff
--- a/libmlk-ui/mlk/ui/label.h Thu Mar 02 08:54:00 2023 +0100 +++ b/libmlk-ui/mlk/ui/label.h Thu Mar 02 21:36:43 2023 +0100 @@ -25,28 +25,29 @@ struct mlk_label; struct mlk_label_style { + unsigned long color; + struct mlk_font *font; +}; + +struct mlk_label_delegate { void *data; - unsigned long text_color; - struct mlk_font *text_font; - void (*init)(struct mlk_label_style *, struct mlk_label *); - void (*update)(struct mlk_label_style *, struct mlk_label *, unsigned int); - void (*draw)(struct mlk_label_style *, const struct mlk_label *); - void (*finish)(struct mlk_label_style *, struct mlk_label *); + void (*query)(struct mlk_label_delegate *, const struct mlk_label *, unsigned int *, unsigned *); + void (*update)(struct mlk_label_delegate *, struct mlk_label *, unsigned int); + void (*draw)(struct mlk_label_delegate *, const struct mlk_label *); }; struct mlk_label { int x, y; const char *text; struct mlk_label_style *style; + struct mlk_label_delegate *delegate; }; extern struct mlk_label_style mlk_label_style; +extern struct mlk_label_delegate mlk_label_delegate; MLK_CORE_BEGIN_DECLS -void -mlk_label_init(struct mlk_label *); - int mlk_label_ok(const struct mlk_label *); @@ -54,10 +55,10 @@ mlk_label_query(const struct mlk_label *, unsigned int *, unsigned int *); void -mlk_label_draw(const struct mlk_label *); +mlk_label_update(struct mlk_label *, unsigned int ticks); void -mlk_label_finish(struct mlk_label *); +mlk_label_draw(const struct mlk_label *); MLK_CORE_END_DECLS