aboutsummaryrefslogtreecommitdiff
path: root/src/block.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/block.h')
-rw-r--r--src/block.h71
1 files changed, 48 insertions, 23 deletions
diff --git a/src/block.h b/src/block.h
index 4254355..d9800ee 100644
--- a/src/block.h
+++ b/src/block.h
@@ -7,7 +7,7 @@
#include "event.h"
#include "util.h"
-#include "config.h"
+#include "layout.h"
// Element or text alignment
//
@@ -22,6 +22,7 @@ typedef enum {
typedef enum {
BLOCK_TEXT,
BLOCK_GROUP,
+ BLOCK_SPEC,
} block_type_t;
typedef struct block block_t;
@@ -34,45 +35,69 @@ typedef void (*block_event_t)(block_t *block, event_t event);
//
typedef void (*block_update_t)(block_t *block);
-// Block finalization routine
-// NOTE: The block state must be freed by this function
+// Called to cleanup a block and free its memory
//
-typedef void (*block_finalize_t)(block_t *block);
+typedef void (*block_clean_t)(block_t *block);
-// Block struct
+// Called in layout_init
+//
+typedef void (*block_layout_t)(block_t *block, layout_t *layout, layout_info_t info);
+
+// Called in layout_render
+//
+typedef void (*block_render_t)(layout_t *layout, cairo_t *cr);
+
+// Called in config_resolve_children
+//
+typedef struct config config_t;
+
+typedef bool (*block_resolve_t)(block_t *block, config_t *config);
+
+// The block struct
//
struct block {
block_type_t type;
char *label;
bool resolved;
bool hidden;
- void *state;
struct timespec update_interval;
struct timespec update_last;
- block_update_t update_cb;
- block_event_t event_cb;
- block_finalize_t finalize_cb;
+ block_update_t update_fn;
+ block_event_t event_fn;
+ block_clean_t clean_fn;
+ // TODO
+ //gradient_t bg_color;
+ //gradient_t line_color;
color_t color;
color_t line_color;
unsigned int line_width;
unsigned int x_padding, y_padding;
unsigned int min_width, max_width;
- union {
- struct {
- char *text;
- color_t text_color;
- align_t text_align;
- unsigned int text_size;
- } text;
- struct {
- unsigned int spacing;
- size_t n_children;
- struct block **children;
- bool collapse;
- } group;
- };
};
+typedef struct {
+ block_t block;
+ char *text;
+ color_t text_color;
+ align_t text_align;
+ unsigned int text_size;
+} block_text_t;
+
+typedef struct {
+ block_t block;
+ unsigned int spacing;
+ size_t n_children;
+ struct block **children;
+ bool collapse;
+} block_group_t;
+
+typedef struct {
+ block_t block;
+ block_layout_t layout_fn;
+ block_render_t render_fn;
+ block_resolve_t resolve_fn;
+} block_spec_t;
+
void block_update(block_t *block);
void block_copy(block_t *copy, const block_t *block);