From 03130c5bcec3c885a1be005c24e192dfb57f3fe5 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 12 Apr 2016 18:48:49 -0400 Subject: moved menu stuff to own file --- include/ui_menu.hpp | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 include/ui_menu.hpp (limited to 'include/ui_menu.hpp') diff --git a/include/ui_menu.hpp b/include/ui_menu.hpp new file mode 100644 index 0000000..9a51739 --- /dev/null +++ b/include/ui_menu.hpp @@ -0,0 +1,63 @@ +#ifndef UI_MENU_H_ +#define UI_MENU_H_ + +#include +#include + +typedef void (*menuFunc)(void); + +struct menuItem { + int member; + union { + struct { + vec2 loc; + dim2 dim; + Color color; + + const char *text; + menuFunc func; + } button; + struct { + vec2 loc; + dim2 dim; + Color color; + + float minValue; + float maxValue; + float sliderLoc; + + const char *text; + float *var; + } slider; + }; +}; + +class Menu { +public: + std::vector items; + Menu *child, *parent; + + ~Menu() { + // TODO you CANNOT delete null pointers! + /*child = NULL; + parent = NULL; + delete child; + delete parent;*/ + } + + void gotoChild(void); + void gotoParent(void); +}; + +namespace ui { + namespace menu { + menuItem createButton(vec2 l, dim2 d, Color c, const char* t, menuFunc f); + menuItem createChildButton(vec2 l, dim2 d, Color c, const char* t); + menuItem createParentButton(vec2 l, dim2 d, Color c, const char* t); + menuItem createSlider(vec2 l, dim2 d, Color c, float min, float max, const char* t, float* v); + + void draw( void ); + } +} + +#endif // UI_MENU_H_ -- cgit v1.2.3