blob: 217934803c54aa015e9c515fbf8644128c53102c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#ifndef COMET_BLOCK_H
#define COMET_BLOCK_H
#include <stddef.h>
#include <stdbool.h>
#include <time.h>
#include "event.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);
// Block struct
//
struct block {
bool hidden;
color_t color;
color_t line_color;
int line_width;
int x_padding, y_padding;
int min_width, max_width;
int update_interval;
struct timespec update_last;
block_update_t update_cb;
block_event_t event_cb;
block_type_t type;
union {
struct {
const char *text;
color_t text_color;
align_t text_align;
int text_size;
} text;
struct {
int spacing;
int n_children;
struct block *children;
} group;
};
};
#endif
|