#ifndef UI_H
#define UI_H
#include "renderer.h"
#include <GLFW/glfw3.h>
#include <string>
#include <map>
class UI {
public:
float height;
float width;
float xpos;
float ypos;
int R;
int G;
int B;
int texIndex = 0; // default dummy texture
const float* uvs = nullptr; // default no texture coordinates
virtual void pushToRenderer(Renderer* renderer);
virtual bool isHovered(GLFWwindow* window);
virtual bool isClicked(GLFWwindow* window);
};
class Button : public UI {
public:
Button(float height, float width, float xpos, float ypos, int R, int G, int B, int texIndex, const float* uvs);
Button(float height, float width, float xpos, float ypos, int R, int G, int B, int texIndex, std::string message);
void pushToRenderer(Renderer* renderer) override;
std::string message;
};
class Text : public UI {
public:
Text(float width, float xpos, float ypos, int texIndex, std::string message);
void pushToRenderer(Renderer* renderer) override;
std::string message;
};
class TextBox : public Text {
public:
TextBox(float width, float fontSize, float xpos, float ypos, int texIndex, std::string defaultMessage);
void pushToRenderer(Renderer* renderer) override;
void collectInput(GLFWwindow* window);
float fontSize;
std::map<int, bool> keyHeld;
};
class DrawingBoard : public UI {
private:
std::vector<std::pair<GLfloat, GLfloat>> drawingPoints;
public:
Button& clearBtn;
Button& saveBtn;
bool saveRequested = false;
bool saved = false;
std::string saveAs;
DrawingBoard(float height, float width, float xpos, float ypos, std::string saveAs);
void pushToRenderer(Renderer* renderer) override;
bool isClicked(GLFWwindow* window) override;
bool isCleared(GLFWwindow* window);
bool isSaved(GLFWwindow* window);
};
#endif