diff options
| author | Federico Angelilli <code@fedang.net> | 2024-07-09 01:23:11 +0200 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-07-09 01:23:11 +0200 |
| commit | 748613db7a794be69def5f008e2e2eea428d8541 (patch) | |
| tree | 9db7f9e84a9fc9b3f69086803407eecc4297cc8e /src | |
| parent | 8e392c583c7c0b68bae6204bf98e7f8e077c5bbf (diff) | |
Add block type
Diffstat (limited to 'src')
| -rw-r--r-- | src/block.h | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/block.h b/src/block.h new file mode 100644 index 0000000..3df760b --- /dev/null +++ b/src/block.h @@ -0,0 +1,72 @@ +#ifndef COMET_BLOCK_H +#define COMET_BLOCK_H + +#include <stddef.h> +#include <stdbool.h> +#include <time.h> + +// Color representation normalized to [0, 1] +// +typedef struct { + double r, g, b, a; +} color_t; + +// Element or text alignment +// +typedef enum { + ALIGN_LEFT, + ALIGN_CENTER, + ALIGN_RIGHT, +} align_t; + +// Block type identifier +// +typedef enum { + BLOCK_TEXT, + BLOCK_GROUP, +} block_type_t; + +typedef struct block block_t; + +// Triggered when an event is directed towards the block +// +typedef void (*block_event_t)(block_t *block, event_t *event); + +// Regularly called depending on the inverval passed from the last update +// +typedef void (*block_update_t)(block_t *block); + +// Generic block type +// +typedef struct block { + block_type_t type; + bool hidden; + color_t color; + color_t line_color; + int line_width; + int x_padding, y_padding; + int min_width, max_width; + block_event_t event_cb; +}; + +// Block text type +// +typedef struct { + block_t block; + const char *text; + color_t text_color; + align_t text_align; + int text_width; + int update_interval; + struct timespec update_last; + block_update_t update_cb; +} block_text_t; + +// Block group type +// +typedef struct block_group { + block_t block; + struct block_group *next; +} block_group_t; + +#endif |
