diff options
| author | Federico Angelilli <code@fedang.net> | 2023-11-26 20:18:08 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2023-11-26 20:18:08 +0100 |
| commit | 00bd74159e2f7d209a10d11e8cbecb894c3d0ef0 (patch) | |
| tree | 01ea73f9635c282ec8b0fcb4c5e775448dda9502 /src/button.h | |
| parent | f9ec9bb88ae2b1423d30da21c76a7e131cb383cc (diff) | |
Generalize button struct
Diffstat (limited to 'src/button.h')
| -rw-r--r-- | src/button.h | 43 |
1 files changed, 33 insertions, 10 deletions
diff --git a/src/button.h b/src/button.h index f9406f1..aa22001 100644 --- a/src/button.h +++ b/src/button.h @@ -2,9 +2,11 @@ #define COMET_BUTTON_H #include <stdbool.h> +#include <glib.h> #include <pango/pangocairo.h> -// TODO: Generic button shapes/actions +// For pointers only +#define CAST(ptr, type) ((type *)ptr) typedef struct Button Button; @@ -15,20 +17,41 @@ typedef struct { } Color; struct Button { - ButtonAction action; - gpointer action_data; - char *text; + bool simple; PangoAlignment align; - Color background; - Color foreground; - Color stroke; + Color color; + Color line_color; }; -Button *button_create(const char *text, PangoAlignment align); +typedef struct { + Button btn; + Color text_color; + char *text; + ButtonAction action; + gpointer action_data; +} ButtonSimple; + +typedef struct { + Button btn; + GList *children; +} ButtonGroup; + +// NOTE: For the moment all button specific functions take a generic button +// pointer and assert the right type, so the check should be done by the caller + +Button *button_simple_create(PangoAlignment align, Color color, Color line_color); + +void button_simple_set_text(Button *btn, const char *text, Color text_color); + +const char *button_simple_get_text(Button *btn); + +void button_simple_set_action(Button *btn, ButtonAction action, gpointer data); + +ButtonAction button_simple_get_action(Button *btn); -void button_set_colors(Button *btn, Color background, Color foreground, Color stroke); +Button *button_group_create(PangoAlignment align, Color color, Color line_color); -void button_set_action(Button *btn, ButtonAction action, gpointer data); +void button_group_append(Button *btn, Button *child); void button_destroy(Button *btn); |
