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
|
#ifndef __H_GAME_BUTTON__
#define __H_GAME_BUTTON__
#include <SDL2/SDL.h>
#include <stdbool.h>
#include "MousePointer.h"
typedef struct _GameButton GameButton;
typedef void (* BtnCallback)(GameButton * self, void * data);
struct _GameButton {
SDL_Rect base; //this will behave like an SDL_Rect when cast to an SDL_Rect.
bool fill;
bool is_clicked;
bool is_hover;
bool is_stop_hover;
SDL_Color colour;
BtnCallback clicked;
void * clicked_data;
BtnCallback hover;
void * hover_data;
BtnCallback stop_hover;
void * stop_hover_data;
};
GameButton * game_button_new (int x, int y, int h, int w);
bool game_button_check_clicked (GameButton * self, MousePointer * pointer);
bool game_button_check_hover (GameButton * self, MousePointer * pointer);
void game_button_set_callback (GameButton * self,
const char * name,
BtnCallback callback,
void * data);
void game_button_do_callback (GameButton * self,
const char * name);
void game_button_draw (GameButton * self, SDL_Renderer * renderer);
void game_button_set_fill (GameButton * self, bool fill);
void game_button_free (GameButton * self);
#endif
|