X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FText.hpp;fp=src%2Fgraphics%2FText.hpp;h=5d7a8b3a47577118301005043f1ff72e9b4b8220;hb=50f35affb16c78bd3d0b420f5ba37d74fcac391f;hp=0000000000000000000000000000000000000000;hpb=1bc6f085c53cdeaa08e2c00e821d4e2e25cae1c8;p=blank.git diff --git a/src/graphics/Text.hpp b/src/graphics/Text.hpp new file mode 100644 index 0000000..5d7a8b3 --- /dev/null +++ b/src/graphics/Text.hpp @@ -0,0 +1,79 @@ +#ifndef BLANK_GRAPHICS_TEXT_HPP_ +#define BLANK_GRAPHICS_TEXT_HPP_ + +#include "align.hpp" +#include "Texture.hpp" +#include "../model/SpriteModel.hpp" + +#include +#include + + +namespace blank { + +class Font; +class Viewport; + +class Text { + +public: + Text() noexcept; + + void Set(const Font &, const char *); + void Set(const Font &f, const std::string &s) { + Set(f, s.c_str()); + } + + void Position(const glm::vec3 &p) noexcept { + pos = p; + } + void Position( + const glm::vec3 &p, + Gravity g + ) noexcept { + pos = p; + grav = g; + pivot = g; + dirty = true; + } + void Position( + const glm::vec3 &p, + Gravity g, + Gravity pv + ) noexcept { + pos = p; + grav = g; + pivot = pv; + dirty = true; + } + + void Foreground(const glm::vec4 &col) noexcept { fg = col; } + void Background(const glm::vec4 &col) noexcept { bg = col; } + + void Render(Viewport &) noexcept; + + void Show() noexcept { visible = true; } + void Hide() noexcept { visible = false; } + void Toggle() noexcept { visible = !visible; } + bool Visible() const noexcept { return visible; } + +private: + void Update(); + +private: + Texture tex; + SpriteModel sprite; + glm::vec4 bg; + glm::vec4 fg; + glm::vec2 size; + glm::vec3 pos; + Gravity grav; + Gravity pivot; + bool dirty; + bool visible; + +}; + +} + +#endif