/+junk/c_sdl_joypad

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad
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
#ifndef __H_GAME_BUTTON__
#define __H_GAME_BUTTON__

/**
 * This file, as the rest of the project is under MIT license.
 * see http://opensource.org/licenses/MIT
 *
 * Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
 */

#include <SDL2/SDL.h>
#include <stdbool.h>

#include "MousePointer.h"

typedef struct _GameButton GameButton;
//typedef struct _GameButtonClass GameButtonClass; //TODO

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