5
#include "base/basictypes.h"
6
#include "math/geom2d.h"
7
#include "gfx/texture_atlas.h"
9
// Everything you need to draw a UI collected into a single unit that can be passed around.
10
// Everything forward declared so this header is safe everywhere.
13
class Thin3DShaderSet;
14
class Thin3DDepthStencilState;
16
class Thin3DBlendState;
17
class Thin3DSamplerState;
35
void Init(Thin3DContext *thin3d, Thin3DShaderSet *uiShaderTex, Thin3DShaderSet *uiShaderNoTex, Thin3DTexture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop);
42
void RebindTexture() const;
44
// TODO: Support transformed bounds using stencil
45
void PushScissor(const Bounds &bounds);
47
Bounds GetScissorBounds();
49
void ActivateTopScissor();
51
DrawBuffer *Draw() const { return uidrawbuffer_; }
52
DrawBuffer *DrawTop() const { return uidrawbufferTop_; }
53
const UI::Theme *theme;
57
TextDrawer *Text() const { return textDrawer_; }
59
void SetFontStyle(const UI::FontStyle &style);
60
const UI::FontStyle &GetFontStyle() { return *fontStyle_; }
61
void SetFontScale(float scaleX, float scaleY);
62
void MeasureTextCount(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, int count, float *x, float *y, int align = 0) const;
63
void MeasureText(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, float *x, float *y, int align = 0) const;
64
void MeasureTextRect(const UI::FontStyle &style, float scaleX, float scaleY, const char *str, int count, const Bounds &bounds, float *x, float *y, int align = 0) const;
65
void DrawText(const char *str, float x, float y, uint32_t color, int align = 0);
66
void DrawTextShadow(const char *str, float x, float y, uint32_t color, int align = 0);
67
void DrawTextRect(const char *str, const Bounds &bounds, uint32_t color, int align = 0);
68
void FillRect(const UI::Drawable &drawable, const Bounds &bounds);
70
// in dps, like dp_xres and dp_yres
71
void SetBounds(const Bounds &b) { bounds_ = b; }
72
const Bounds &GetBounds() const { return bounds_; }
73
Thin3DContext *GetThin3DContext() { return thin3d_; }
76
Thin3DContext *thin3d_;
81
UI::FontStyle *fontStyle_;
82
TextDrawer *textDrawer_;
84
Thin3DContext *thin3D_;
85
Thin3DDepthStencilState *depth_;
86
Thin3DBlendState *blend_;
87
Thin3DSamplerState *sampler_;
88
Thin3DShaderSet *uishader_;
89
Thin3DShaderSet *uishadernotex_;
90
Thin3DTexture *uitexture_;
92
DrawBuffer *uidrawbuffer_;
93
DrawBuffer *uidrawbufferTop_;
95
std::vector<Bounds> scissorStack_;