|
#pragma once |
|
|
|
#include <string> |
|
#include <iostream> |
|
#include <bitset> |
|
|
|
#include <SDL/SDL.h> |
|
|
|
#include "Position.h" |
|
#include "Debug.h" |
|
|
|
// basic setup for checking things that would not cause a crash |
|
// but are probably unwanted behavior, this just logs it. |
|
#ifdef DEBUG |
|
#define dLog(x) std::cout<< "Debug: " << x << '\n' |
|
#define should(x) if(x) |
|
#else |
|
#define dLog(x) |
|
#define should(x) |
|
#endif |
|
|
|
#undef SDL_Colour |
|
|
|
typedef SDL_Color SDL_Colour; |
|
typedef size_t length; |
|
typedef size_t area; |
|
typedef int8_t flag; |
|
|
|
|
|
// flags |
|
#define BORDER_ONLY 0x00000001 |
|
#define BODY_ONLY 0x00000010 |
|
#define ALL 0x00000100 |
|
|
|
class Button { |
|
public: |
|
Button(); |
|
~Button(); |
|
public: |
|
// basic parameters of a Button |
|
// TODO functionality still has to be implemented |
|
void hide(); |
|
void show(); |
|
void makeTransparent(); |
|
void makeOpaque(); |
|
void makeRound(); |
|
void makeEdgy(); |
|
public: |
|
void draw(SDL_Renderer* rend); |
|
|
|
public: |
|
// basically just setters for all attributes a Button has |
|
// TODO implement functionality of Button |
|
void moveTo(const int x, const int y); |
|
void moveTo(const Position to); |
|
void setText(const std::string to); |
|
void setText(const char* to); |
|
void setWidth(const length to); |
|
void setHeight(const length to); |
|
void setBorderSize(const length to); |
|
void setBorderColour(const SDL_Colour to); |
|
void setBorderColour(const Uint8 R, const Uint8 G, const Uint8 B, const Uint8 A); |
|
void setColour(const SDL_Colour to); |
|
void setColour(const Uint8 R, const Uint8 G, const Uint8 B, const Uint8 A); |
|
public: |
|
// useful getters, might be expanded |
|
area getArea(const flag option) const; |
|
length getLength(const flag option) const; |
|
length getHeight(const flag option) const; |
|
private: |
|
// The actual Rectangle and the Button Border + Colours |
|
// TODO consider changing to general shape, y'know, if you want like |
|
// TODO special shapes for you button |
|
SDL_Rect border; |
|
SDL_Colour borderColour; |
|
SDL_Rect body; |
|
SDL_Colour colour; |
|
SDL_Surface* surface; |
|
private: |
|
std::string text; |
|
public: |
|
bool hidden; |
|
bool transparent; |
|
bool rounded; |
|
private: |
|
Position pos; |
|
length width; |
|
length height; |
|
}; |