le2d v0.4.7
2D game engine framework
 
Loading...
Searching...
No Matches
text_buffer.hpp
Go to the documentation of this file.
1#pragma once
2#include "le2d/primitive.hpp"
6#include <deque>
7#include <gsl/pointers>
8#include <span>
9
10namespace le {
13 public:
14 explicit TextBuffer(gsl::not_null<IFontAtlas*> atlas, std::size_t limit, float n_line_spacing = 1.5f);
15
16 void push_front(std::string text, kvf::Color color) { push_front({&text, 1}, color); }
17 void push_front(std::span<std::string> lines, kvf::Color color);
18
19 [[nodiscard]] auto get_size() const -> glm::vec2 { return m_size; }
20
21 [[nodiscard]] auto to_primitive() const -> Primitive;
22
23 private:
24 struct Line {
25 std::string text{};
26 kvf::Color color{};
27 };
28
29 void refresh();
30
31 gsl::not_null<IFontAtlas*> m_atlas;
32 std::size_t m_limit;
33 float m_n_line_spacing;
34
35 std::deque<Line> m_lines{};
36
37 std::vector<kvf::ttf::GlyphLayout> m_layouts{};
38 TextGeometry m_geometry{};
39 glm::vec4 m_size{};
40};
41} // namespace le
Wall of text as a single Primitive.
Definition text_buffer.hpp:12
auto to_primitive() const -> Primitive
void push_front(std::span< std::string > lines, kvf::Color color)
TextBuffer(gsl::not_null< IFontAtlas * > atlas, std::size_t limit, float n_line_spacing=1.5f)
auto get_size() const -> glm::vec2
Definition text_buffer.hpp:19
void push_front(std::string text, kvf::Color color)
Definition text_buffer.hpp:16
Definition animation.hpp:8
Draw primitive.
Definition primitive.hpp:10