aboutsummaryrefslogtreecommitdiff
path: root/src/button.h
blob: 0a9b2ce0d482fbf3e1b4a96d08ba21f9209aa7ef (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
#ifndef COMET_BUTTON_H
#define COMET_BUTTON_H

#include <stdbool.h>
#include <glib.h>
#include <pango/pangocairo.h>

#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 padding;
    PangoAlignment align;
    Color color;
    Color line_color;
    Animation *anim;
};

typedef struct {
    Button btn;
    Color text_color;
    char *text;
    ButtonAction action;
    gpointer action_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, Color line_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, Color line_color);

void button_group_append(Button *btn, Button *child);

void button_set_padding(Button *btn, int padding);

bool button_set_animation(Button *btn, Animation *anim);

void button_destroy(Button *btn);

#endif

// vim: ts=4 sw=4 et