57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#ifndef IC_EXPLORER_BUTTON_H
|
|
#define IC_EXPLORER_BUTTON_H
|
|
|
|
#include "window.h"
|
|
|
|
#include <SDL_mixer.h>
|
|
#include <SDL_ttf.h>
|
|
|
|
#define BUTTON_PADDING 0.005f
|
|
|
|
typedef struct {
|
|
Mix_Chunk *down;
|
|
Mix_Chunk *up;
|
|
Mix_Chunk *hover;
|
|
} ButtonSoundSet;
|
|
|
|
struct Button;
|
|
|
|
typedef void (*ButtonAction)(struct Button *button, Window *window, float x,
|
|
float y);
|
|
|
|
typedef struct Button {
|
|
float x;
|
|
float y;
|
|
float w;
|
|
float h;
|
|
char *text;
|
|
SDL_Texture *current;
|
|
SDL_Texture *inactive;
|
|
SDL_Texture *active;
|
|
SDL_Color textColor;
|
|
TTF_Font *font;
|
|
SDL_Texture *renderedText;
|
|
ButtonSoundSet sounds;
|
|
int textW;
|
|
int textH;
|
|
ButtonAction action;
|
|
int down;
|
|
} Button;
|
|
|
|
Button *buttonNew(const char *text, float x, float y, float w, float h,
|
|
SDL_Texture *inactive, SDL_Texture *active,
|
|
SDL_Color textColor, TTF_Font *font, ButtonSoundSet sounds,
|
|
const Window *window);
|
|
|
|
void buttonDelete(Button *button);
|
|
|
|
void buttonDraw(const Button *button, const Window *window);
|
|
|
|
void buttonUpdate(Button *button, const Window *window);
|
|
|
|
void buttonProcessInput(Button *button, Window *window, const SDL_Event *event);
|
|
|
|
void buttonGetCenter(const Button *button, Point *point);
|
|
|
|
#endif /* IC_EXPLORER_BUTTON_H */
|