1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */ 2 3 #ifndef GUI_H 4 #define GUI_H 5 6 #include <list> 7 #include <boost/signals2/connection.hpp> 8 #include <boost/signals2/shared_connection_block.hpp> 9 10 union SDL_Event; 11 12 namespace agui 13 { 14 15 class GuiElement; 16 17 class Gui 18 { 19 public: 20 Gui(); 21 virtual ~Gui(); 22 23 void Clean(); 24 void Draw(); 25 void AddElement(GuiElement*, bool asBackground = false); 26 /// deletes the element on the next draw 27 void RmElement(GuiElement*); 28 29 void UpdateScreenGeometry(int screenx, int screeny, int screenOffsetX, int screenOffsetY); 30 31 bool MouseOverElement(const GuiElement*, int x, int y) const; 32 33 private: 34 bool HandleEvent(const SDL_Event& ev); 35 boost::signals2::scoped_connection inputCon; 36 boost::signals2::shared_connection_block inputConBlock; 37 38 struct GuiItem 39 { GuiItemGuiItem40 GuiItem(GuiElement* el, bool back) : element(el), asBackground(back) {}; 41 GuiElement* element; 42 bool asBackground; 43 }; 44 typedef std::list<GuiItem> ElList; 45 ElList elements; 46 ElList toBeRemoved; 47 ElList toBeAdded; 48 }; 49 50 extern Gui* gui; 51 void InitGui(); 52 void FreeGui(); 53 54 } 55 56 #endif 57