#ifndef COMET_BLOCK_H #define COMET_BLOCK_H #include #include #include #include "event.h" #include "util.h" #include "config.h" #include "action.h" #include "effect.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_type_t; typedef struct block block_t; // Regularly called depending on the inverval passed from the last update // typedef void (*block_update_t)(block_t *block); // Block finalization routine // NOTE: The block state must be freed by this function // typedef void (*block_finalize_t)(block_t *block); // 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; block_finalize_t finalize; effect_t *effect; action_t *right_click_action; action_t *middle_click_action; action_t *left_click_action; 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; }; }; void block_update(block_t *block); void block_copy(block_t *copy, const block_t *block); void block_free(block_t *block); #endif