Aegis2D
Modular C++26 2D game engine for networked games
Loading...
Searching...
No Matches
text_layout.hpp
Go to the documentation of this file.
1
3#pragma once
4
8#include <aegis2d/render/export.hpp>
10
11#include <span>
12#include <string_view>
13#include <vector>
14
15namespace aegis2d::render {
16
22struct AEGIS2D_RENDER_EXPORT TextSize {
24 static constexpr float smallest = 1.0F;
26 static constexpr float largest = 2.0F;
28 static constexpr float step = 0.25F;
29
31 float factor = 1.0F;
32
35 [[nodiscard]] float scale() const noexcept;
36
39 [[nodiscard]] int percent() const noexcept;
40
42 void larger() noexcept;
43
45 void smaller() noexcept;
46
50 [[nodiscard]] TextStyle apply(TextStyle style) const noexcept;
51
55 void save(core::Config& settings, std::string_view path) const;
56
62 void load(const core::Config& settings, std::string_view path);
63};
64
69[[nodiscard]] AEGIS2D_RENDER_EXPORT bool overlaps(const Rect& first, const Rect& second) noexcept;
70
75[[nodiscard]] AEGIS2D_RENDER_EXPORT bool contains(const Rect& outer, const Rect& inner) noexcept;
76
78struct FlowLayout {
80 std::vector<Vec2> positions;
83};
84
93[[nodiscard]] AEGIS2D_RENDER_EXPORT FlowLayout flow_layout(std::span<const Vec2> sizes,
94 const Rect& area, Vec2 gap);
95
96} // namespace aegis2d::render
Text drawn with a bitmap font, through the sprite batcher.
JSON configuration with dotted-path lookups, which can be changed and saved.
Vector and matrix types of the engine (GLM behind engine names).
OpenGL renderer: sprites, text and camera (client only).
Definition bitmap_font.hpp:16
aegis2d::Vec2 Vec2
2D vector of floats, in logical pixels: the engine-wide aegis2d::Vec2.
Definition renderer.hpp:17
FlowLayout flow_layout(std::span< const Vec2 > sizes, const Rect &area, Vec2 gap)
Places boxes left to right in an area, starting a new row when one does not fit.
Definition endpoint.hpp:85
Backend-independent renderer interface and the sprite it draws.
Boxes placed by flow_layout().
Definition text_layout.hpp:78
Vec2 size
Width of the widest row and height of all rows.
Definition text_layout.hpp:82
std::vector< Vec2 > positions
Top-left corner of each box, in the order of the sizes given.
Definition text_layout.hpp:80
Axis-aligned rectangle.
Definition renderer.hpp:20
Size of the HUD and menu text chosen by the player, from 100% to 200%.
Definition text_layout.hpp:22
float scale() const noexcept
The factor, brought into [smallest, largest]; not-a-number gives 1.
How a text is drawn.
Definition bitmap_font.hpp:49