45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#ifndef BUTTON_H
|
|
#define BUTTON_H
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include "Item.h"
|
|
|
|
class Button : public Item {
|
|
protected:
|
|
string text;
|
|
SDL_Color color;
|
|
SDL_Surface *button_up;
|
|
SDL_Surface *button_down;
|
|
bool toggle_selected;
|
|
private:
|
|
bool pressed;
|
|
bool selected;
|
|
int finger_id;
|
|
void (*button_func)(void *p, Item *b);
|
|
void (*button_press_func)(void *p, Item *b);
|
|
void (*button_release_func)(void *p, Item *b);
|
|
void *p;
|
|
public:
|
|
//void init();
|
|
//void destroy();
|
|
Button(string text, SDL_Color color, SDL_Rect pos);
|
|
virtual ~Button();
|
|
virtual void drawButton();
|
|
bool onMousePress(int x, int y);
|
|
void onMouseRelease(int x, int y);
|
|
void onFingerDown(int x, int y, int finger_id);
|
|
void onFingerUp(int x, int y, int finger_id);
|
|
void setButtonFunc(void (*button_func)(void *p, Item *b), void *p);
|
|
void setButtonPressFunc(void (*button_press_func)(void *p, Item *b), void *p);
|
|
void setButtonReleaseFunc(void (*button_release_func)(void *p, Item *b), void *p);
|
|
void setText(string text);
|
|
string getText();
|
|
void setColor(SDL_Color color);
|
|
void setSelected(bool selected);
|
|
bool isSelected();
|
|
void selectSurface();
|
|
};
|
|
|
|
#endif
|