#ifndef COMET_BLOCK_H #define COMET_BLOCK_H #include #include #include #include "event.h" #include "util.h" #include "layout.h" // Element or text alignment // typedef enum { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT, } align_t; // Block type identifier // typedef enum { BLOCK_TEXT, BLOCK_GROUP, BLOCK_SPEC, } 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); // Called to cleanup a block and free its memory // NOTE: This should NOT free any other block! // typedef void (*block_clean_t)(block_t *block); // 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; struct timespec update_interval; struct timespec update_last; 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; }; 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; block_t **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_free(block_t *block); #endif