1 #ifndef UI_BUTTON_H
2 #define UI_BUTTON_H
3 
4 #include "panel.h"
5 
6 #include "../ui.h"
7 
8 #include <stdbool.h>
9 #include <stdint.h>
10 
11 typedef struct button BUTTON;
12 struct button {
13     PANEL panel;
14 
15     /* Button bitmap id,
16      * fill is top-left aligned
17      * icon is centered. */
18     int bm_fill, bm_icon;
19 
20     // Width & height of bm_icon. Used for centering.
21     int icon_w, icon_h;
22 
23     // Background RGB color for bm picture, when Idle/Hovered/Pressed respectively.
24     uint32_t c1,  // Button normal background color
25              c2,  // Button hover background color
26              c3,  // Button active (press) background color
27              ct1, // Button contents (text or icon) color
28              ct2, // Button contents (text or icon) hover color
29              cd;
30 
31     MAYBE_I18NAL_STRING button_text;
32     MAYBE_I18NAL_STRING tooltip_text;
33 
34     bool mouseover, mousedown, disabled, nodraw;
35 
36     void (*onright)(void); // called when right mouse button goes down
37     void (*on_mdn)(void);
38     void (*on_mup)(void);
39     void (*update)(BUTTON *b);
40 };
41 
42 void button_draw(BUTTON *b, int x, int y, int width, int height);
43 bool button_mmove(BUTTON *b, int x, int y, int width, int height, int mx, int my, int dx, int dy);
44 
45 bool button_mdown(BUTTON *b);
46 bool button_mup(BUTTON *b);
47 
48 bool button_mright(BUTTON *b);
49 bool button_mwheel(BUTTON *b, int height, double d, bool smooth);
50 
51 bool button_mleave(BUTTON *b);
52 
53 
54 // TODO these may move
55 void button_setcolors_success(BUTTON *b);
56 void button_setcolors_danger(BUTTON *b);
57 void button_setcolors_warning(BUTTON *b);
58 void button_setcolors_disabled(BUTTON *b);
59 
60 
61 #endif // UI_BUTTON_H
62