gameui

changeset 4:e0916bb20b7f

changed the name to goatkit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 21 Mar 2014 21:45:37 +0200
parents f1014234dece
children 5a84873185ff
files include/button.h include/gameui.h include/goatkit.h include/label.h include/widget.h src/button.cc src/event.h src/gameui_impl.h src/theme.cc src/theme.h src/vec.h src/widget.cc test.cc
diffstat 13 files changed, 51 insertions(+), 55 deletions(-) [+]
line diff
     1.1 --- a/include/button.h	Fri Mar 21 03:37:16 2014 +0200
     1.2 +++ b/include/button.h	Fri Mar 21 21:45:37 2014 +0200
     1.3 @@ -1,9 +1,9 @@
     1.4 -#ifndef GAMEUI_BUTTON_H_
     1.5 -#define GAMEUI_BUTTON_H_
     1.6 +#ifndef GOATKIT_BUTTON_H_
     1.7 +#define GOATKIT_BUTTON_H_
     1.8  
     1.9  #include "widget.h"
    1.10  
    1.11 -namespace gameui {
    1.12 +namespace goatkit {
    1.13  
    1.14  struct ButtonImpl;
    1.15  
    1.16 @@ -16,6 +16,6 @@
    1.17  	virtual ~Button();
    1.18  };
    1.19  
    1.20 -}
    1.21 +}	// namespace goatkit
    1.22  
    1.23 -#endif	// GAMEUI_BUTTON_H_
    1.24 +#endif	// GOATKIT_BUTTON_H_
     2.1 --- a/include/gameui.h	Fri Mar 21 03:37:16 2014 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,8 +0,0 @@
     2.4 -#ifndef GAMEUI_H_
     2.5 -#define GAMEUI_H_
     2.6 -
     2.7 -#include "widget.h"
     2.8 -#include "button.h"
     2.9 -#include "label.h"
    2.10 -
    2.11 -#endif	// GAMEUI_H_
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/include/goatkit.h	Fri Mar 21 21:45:37 2014 +0200
     3.3 @@ -0,0 +1,8 @@
     3.4 +#ifndef GOATKIT_H_
     3.5 +#define GOATKIT_H_
     3.6 +
     3.7 +#include "widget.h"
     3.8 +#include "button.h"
     3.9 +#include "label.h"
    3.10 +
    3.11 +#endif	// GOATKIT_H_
     4.1 --- a/include/label.h	Fri Mar 21 03:37:16 2014 +0200
     4.2 +++ b/include/label.h	Fri Mar 21 21:45:37 2014 +0200
     4.3 @@ -1,7 +1,7 @@
     4.4 -#ifndef GAMEUI_LABEL_H_
     4.5 -#define GAMEUI_LABEL_H_
     4.6 +#ifndef GOATKIT_LABEL_H_
     4.7 +#define GOATKIT_LABEL_H_
     4.8  
     4.9 -namespace gameui {
    4.10 +namespace goatkit {
    4.11  
    4.12  class LabelImpl;
    4.13  
    4.14 @@ -14,6 +14,6 @@
    4.15  	virtual ~Label();
    4.16  };
    4.17  
    4.18 -}
    4.19 +}	// namespace goatkit
    4.20  
    4.21 -#endif	// GAMEUI_LABEL_H_
    4.22 +#endif	// GOATKIT_LABEL_H_
     5.1 --- a/include/widget.h	Fri Mar 21 03:37:16 2014 +0200
     5.2 +++ b/include/widget.h	Fri Mar 21 21:45:37 2014 +0200
     5.3 @@ -1,10 +1,10 @@
     5.4 -#ifndef GAMEUI_WIDGET_H_
     5.5 -#define GAMEUI_WIDGET_H_
     5.6 +#ifndef GOATKIT_WIDGET_H_
     5.7 +#define GOATKIT_WIDGET_H_
     5.8  
     5.9  #include "vec.h"
    5.10  #include "event.h"
    5.11  
    5.12 -namespace gameui {
    5.13 +namespace goatkit {
    5.14  
    5.15  struct BBox {
    5.16  	Vec2 bmin, bmax;
    5.17 @@ -75,4 +75,4 @@
    5.18  
    5.19  }
    5.20  
    5.21 -#endif	// GAMEUI_WIDGET_H_
    5.22 +#endif	// GOATKIT_WIDGET_H_
     6.1 --- a/src/button.cc	Fri Mar 21 03:37:16 2014 +0200
     6.2 +++ b/src/button.cc	Fri Mar 21 21:45:37 2014 +0200
     6.3 @@ -1,6 +1,6 @@
     6.4  #include "button.h"
     6.5  
     6.6 -namespace gameui {
     6.7 +namespace goatkit {
     6.8  
     6.9  struct ButtonImpl {
    6.10  };
    6.11 @@ -15,4 +15,4 @@
    6.12  	delete button;
    6.13  }
    6.14  
    6.15 -}	// namespace gameui
    6.16 +}	// namespace goatkit
     7.1 --- a/src/event.h	Fri Mar 21 03:37:16 2014 +0200
     7.2 +++ b/src/event.h	Fri Mar 21 21:45:37 2014 +0200
     7.3 @@ -3,7 +3,7 @@
     7.4  
     7.5  #include "vec.h"
     7.6  
     7.7 -namespace gameui {
     7.8 +namespace goatkit {
     7.9  
    7.10  enum EventType {
    7.11  	EV_MOUSE_BUTTON,
    7.12 @@ -40,6 +40,6 @@
    7.13  	KeyEvent key;
    7.14  };
    7.15  
    7.16 -}	// namespace gameui
    7.17 +}	// namespace goatkit
    7.18  
    7.19  #endif	// EVENT_H_
     8.1 --- a/src/gameui_impl.h	Fri Mar 21 03:37:16 2014 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,4 +0,0 @@
     8.4 -#ifndef GAMEUI_IMPL_H_
     8.5 -#define GAMEUI_IMPL_H_
     8.6 -
     8.7 -#endif	// GAMEUI_IMPL_H_
     9.1 --- a/src/theme.cc	Fri Mar 21 03:37:16 2014 +0200
     9.2 +++ b/src/theme.cc	Fri Mar 21 21:45:37 2014 +0200
     9.3 @@ -12,7 +12,7 @@
     9.4  #endif
     9.5  
     9.6  
     9.7 -namespace gameui {
     9.8 +namespace goatkit {
     9.9  
    9.10  Theme *theme;
    9.11  
    9.12 @@ -97,4 +97,4 @@
    9.13  	glPopAttrib();
    9.14  }
    9.15  
    9.16 -}	// namespace gameui
    9.17 +}	// namespace goatkit
    10.1 --- a/src/theme.h	Fri Mar 21 03:37:16 2014 +0200
    10.2 +++ b/src/theme.h	Fri Mar 21 21:45:37 2014 +0200
    10.3 @@ -4,7 +4,7 @@
    10.4  #include <string>
    10.5  #include <map>
    10.6  
    10.7 -namespace gameui {
    10.8 +namespace goatkit {
    10.9  
   10.10  class Widget;
   10.11  
   10.12 @@ -28,6 +28,6 @@
   10.13  
   10.14  extern Theme *theme;	// the current theme
   10.15  
   10.16 -}	// namespace gameui
   10.17 +}	// namespace goatkit
   10.18  
   10.19  #endif	// THEME_H_
    11.1 --- a/src/vec.h	Fri Mar 21 03:37:16 2014 +0200
    11.2 +++ b/src/vec.h	Fri Mar 21 21:45:37 2014 +0200
    11.3 @@ -1,7 +1,7 @@
    11.4  #ifndef VEC_H_
    11.5  #define VEC_H_
    11.6  
    11.7 -namespace gameui {
    11.8 +namespace goatkit {
    11.9  
   11.10  class Vec2 {
   11.11  public:
   11.12 @@ -11,6 +11,6 @@
   11.13  	Vec2(float xx, float yy) : x(xx), y(yy) {}
   11.14  };
   11.15  
   11.16 -}	// namespace gameui
   11.17 +}	// namespace goatkit
   11.18  
   11.19  #endif	// VEC_H_
    12.1 --- a/src/widget.cc	Fri Mar 21 03:37:16 2014 +0200
    12.2 +++ b/src/widget.cc	Fri Mar 21 21:45:37 2014 +0200
    12.3 @@ -6,7 +6,7 @@
    12.4  #include "boolanm.h"
    12.5  #include "theme.h"
    12.6  
    12.7 -namespace gameui {
    12.8 +namespace goatkit {
    12.9  
   12.10  struct WidgetImpl {
   12.11  	std::string type_str;
   12.12 @@ -263,4 +263,4 @@
   12.13  }
   12.14  
   12.15  
   12.16 -}	// namespace gameui
   12.17 +}	// namespace goatkit
    13.1 --- a/test.cc	Fri Mar 21 03:37:16 2014 +0200
    13.2 +++ b/test.cc	Fri Mar 21 21:45:37 2014 +0200
    13.3 @@ -3,7 +3,7 @@
    13.4  #include <assert.h>
    13.5  #include <vector>
    13.6  #include <GL/glut.h>
    13.7 -#include "gameui.h"
    13.8 +#include "goatkit.h"
    13.9  
   13.10  static bool init();
   13.11  static void cleanup();
   13.12 @@ -17,14 +17,14 @@
   13.13  static void mouse(int bn, int st, int x, int y);
   13.14  static void motion(int x, int y);
   13.15  
   13.16 -static std::vector<gameui::Widget*> widgets;
   13.17 +static std::vector<goatkit::Widget*> widgets;
   13.18  
   13.19  int main(int argc, char **argv)
   13.20  {
   13.21  	glutInitWindowSize(800, 600);
   13.22  	glutInit(&argc, argv);
   13.23  	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
   13.24 -	glutCreateWindow("gameui test");
   13.25 +	glutCreateWindow("goatkit test");
   13.26  
   13.27  	glutDisplayFunc(disp);
   13.28  	glutIdleFunc(idle);
   13.29 @@ -49,7 +49,7 @@
   13.30  
   13.31  static bool init()
   13.32  {
   13.33 -	gameui::Button *button = new gameui::Button;
   13.34 +	goatkit::Button *button = new goatkit::Button;
   13.35  	button->set_position(350, 280);
   13.36  	button->set_size(100, 40);
   13.37  	widgets.push_back(button);
   13.38 @@ -115,14 +115,14 @@
   13.39  	bool down = st == GLUT_DOWN;
   13.40  
   13.41  	for(size_t i=0; i<widgets.size(); i++) {
   13.42 -		gameui::Widget *w = widgets[i];
   13.43 +		goatkit::Widget *w = widgets[i];
   13.44  
   13.45 -		if(w->hit_test(gameui::Vec2(x, y))) {
   13.46 -			gameui::Event ev;
   13.47 -			ev.type = gameui::EV_MOUSE_BUTTON;
   13.48 +		if(w->hit_test(goatkit::Vec2(x, y))) {
   13.49 +			goatkit::Event ev;
   13.50 +			ev.type = goatkit::EV_MOUSE_BUTTON;
   13.51  			ev.button.button = bidx;
   13.52  			ev.button.press = down;
   13.53 -			ev.button.pos = gameui::Vec2(x, y);
   13.54 +			ev.button.pos = goatkit::Vec2(x, y);
   13.55  			w->handle_event(ev);
   13.56  		}
   13.57  	}
   13.58 @@ -130,23 +130,23 @@
   13.59  
   13.60  static void motion(int x, int y)
   13.61  {
   13.62 -	static gameui::Widget *active;
   13.63 +	static goatkit::Widget *active;
   13.64  
   13.65 -	if(active && !active->hit_test(gameui::Vec2(x, y))) {
   13.66 -		gameui::Event ev;
   13.67 -		ev.type = gameui::EV_MOUSE_FOCUS;
   13.68 +	if(active && !active->hit_test(goatkit::Vec2(x, y))) {
   13.69 +		goatkit::Event ev;
   13.70 +		ev.type = goatkit::EV_MOUSE_FOCUS;
   13.71  		ev.focus.enter = false;
   13.72  		active->handle_event(ev);
   13.73  		active = 0;
   13.74  	}
   13.75  
   13.76  	for(size_t i=0; i<widgets.size(); i++) {
   13.77 -		gameui::Widget *w = widgets[i];
   13.78 +		goatkit::Widget *w = widgets[i];
   13.79  
   13.80 -		if(w->hit_test(gameui::Vec2(x, y))) {
   13.81 +		if(w->hit_test(goatkit::Vec2(x, y))) {
   13.82  			if(active != w) {
   13.83 -				gameui::Event ev;
   13.84 -				ev.type = gameui::EV_MOUSE_FOCUS;
   13.85 +				goatkit::Event ev;
   13.86 +				ev.type = goatkit::EV_MOUSE_FOCUS;
   13.87  				ev.focus.enter = true;
   13.88  				w->handle_event(ev);
   13.89  				active = w;