diff options
Diffstat (limited to 'gui.h')
-rw-r--r-- | gui.h | 72 |
1 files changed, 72 insertions, 0 deletions
@@ -0,0 +1,72 @@ +#ifndef GUI_H +#define GUI_H +#include <SDL2/SDL.h> +#include<vector> +#include <string> +#include "gfx.h" +//for the states, they can be OR'd together +#define TOGGLE 1 +#define HOVER 2 +//---=[structure of gui elements]=--- +//gfxupdate handles input events and passess to +//butt and textin classesss +//butt and textin have hitbox members for each of their elements that +//they take mouse data to. +class hitbox { + std::vector<SDL_Rect> rs;//vector of Rects to manage + public: + hitbox();//constructor does nothing + int add(int x, int y, int w, int h); // there is an add but no remove + //because this class is not meant to be edited at runtime. the reason + //we don't just pass a vector is for ease of use by parent function + int check(int x, int y);//checks hitbox + SDL_Rect get(int index); +}; +class butt { + std::vector<std::string> names; // vector of strings that are the names + //of buttons + std::vector<int> states; + hitbox boxes;//manager of the hitboxes of all the buttons + + public : + butt(); // empty constructor + int add(int x, int y, int w, int h, std::string name); // not meant + //to be done during runtime, it's not in the constructor for ease + + //of use handle the three mouseevents from updategfx(), not return + //because they're not going to run into a runtime error the parent + //has to handle + int hover(int x, int y); + int press(int x,int y ); + int unpress(int index); + //as the Renderer is a global var, draw does not take any inputs + int drawbutt(); + //get's the state of a button; + int state(int index); + int size(); +}; +class tbuff { + public : + std::vector<std::string> buffs; // vector of strings that are the names + //of buttons + std::vector<int> states; + hitbox boxes;//manager of the hitboxes of all the buttons + tbuff(); // empty constructor + int add(int x, int y, int w, int h); // not meant + //to be done during runtime, it's not in the constructor for ease + + //of use handle the three mouseevents from updategfx(), not return + //because they're not going to run into a runtime error the parent + //has to handle + int hover(int x, int y); + int press(int x,int y ); + int unpress(int index); + //as the Renderer is a global var, draw does not take any inputs + int drawtbuff(); + //get's the state of a button; + int state(int index); + int size(); + int reset(); + int charin(const char *); +}; +#endif |