#pragma once #include #include "gui.h" class FontFace; namespace Gui { class Screen { public: static void Init(int real_width, int real_height, int ui_width, int ui_height); static void Draw(void); static void AddBaseWidget(Widget* w, int x, int y); static void RemoveBaseWidget(Widget* w); static void OnMouseMotion(SDL_MouseMotionEvent* e); static void OnClick(SDL_MouseButtonEvent* e); static void OnKeyDown(const SDL_keysym* sym); static void RenderString(const std::string& s); static void MeasureString(const std::string& s, float& w, float& h); static void RenderMarkup(const std::string& s); static void PutClickableLabel(const std::string& s, float x, float y, sigc::slot slot); static void RenderLabel(const std::string& s, float x, float y); static void EnterOrtho(void); static void LeaveOrtho(void); static int GetWidth(void) { return width; } static int GetHeight(void) { return height; } /* gluProject but fixes UI/screen size mismatch. */ static GLint Project(GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble* model, const GLdouble* proj, const GLint* view, GLdouble* winX, GLdouble* winY, GLdouble* winZ); friend void Widget::SetShortcut(SDLKey key, SDLMod mod); private: struct LabelPos { LabelPos(float _x, float _y) : x(_x), y(_y) {} float x, y; sigc::signal onClick; }; static std::vector labelPositions; static void OnClickTestLabels(const Gui::MouseButtonEvent& ev); static bool CanPutLabel(float x, float y); static void AddShortcutWidget(Widget* w); static void SDLEventCoordToScreenCoord(int sdlev_x, int sdlev_y, float* x, float* y); static bool init; static int width, height; static int realWidth, realHeight; static float invRealWidth, invRealHeight; static std::list kbshortcut_widgets; static std::list mouseHoveredWidgets; static FontFace* font; static float font_xsize; static float font_ysize; static Gui::Fixed* baseContainer; }; }