Lephisto/src/gui_screen.h

59 lines
2.4 KiB
C++

#pragma once
#include <list>
#include "gui.h"
class TextureFontFace;
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 LayoutString(const std::string& s, const float width);
static void MeasureLayout(const std::string& s, const float width, float outSize[2]);
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<void, const Gui::MouseButtonEvent*> 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; }
static float GetFontHeight(void);
/* 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<void, const Gui::MouseButtonEvent*> onClick;
};
static std::vector<LabelPos> 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<Widget*> kbshortcut_widgets;
static std::list<Widget*> mouseHoveredWidgets;
static TextureFontFace* font;
static float fontScale;
static Gui::Fixed* baseContainer;
};
}