#ifndef COMET_BUTTON_H #define COMET_BUTTON_H #include #include #include #include "draw.h" #include "animate.h" // For pointers only #define CAST(ptr, type) ((type *)ptr) typedef struct Button Button; typedef void (* ButtonAction)(Button *btn); struct Button { bool simple; int x_pad; int y_pad; PangoAlignment align; Color color; Color line_color; int line_width; int max_width; int min_width; Animation *anim; }; typedef struct { Button btn; Color text_color; char *text; ButtonAction action; gpointer data; } ButtonSimple; typedef struct { Button btn; GList *children; } ButtonGroup; // NOTE: For the moment all button specific functions take a generic button // pointer and assert the right type, so the check should be done by the caller Button *button_simple_create(PangoAlignment align, Color color); // Takes ownership of text void button_simple_set_text(Button *btn, char *text, Color text_color); const char *button_simple_get_text(Button *btn); void button_simple_set_action(Button *btn, ButtonAction action, gpointer data); ButtonAction button_simple_get_action(Button *btn); Button *button_group_create(PangoAlignment align, Color color); void button_group_append(Button *btn, Button *child); void button_set_padding(Button *btn, int x_pad, int y_pad); bool button_set_animation(Button *btn, Animation *anim); void button_set_line(Button *btn, Color line_color, int line_width); void button_set_width(Button *btn, int max, int min); void button_destroy(Button *btn); #endif // vim: ts=4 sw=4 et