11#include "../utility/module.hpp"
14namespace hi {
inline namespace v1 {
63 float guideline_width)
69 hilet guideline_top =
top - padding_top - guideline_width;
76 if (guideline_bottom <=
top) {
82 if (guideline_top >=
bottom) {
88 if (guideline_bottom <= guideline_top) {
89 return std::clamp(guideline_middle, guideline_bottom, guideline_top);
164 float guideline_width = 0.0f)
169 hilet guideline_left =
left + padding_left;
170 hilet guideline_right =
right - padding_right - guideline_width;
177 if (guideline_left <=
right) {
178 return guideline_left;
183 if (guideline_right >=
left) {
184 return guideline_right;
189 if (guideline_left <= guideline_right) {
190 return std::clamp(guideline_center, guideline_left, guideline_right);
233 return resolve(
mirror(rhs, left_to_right), left_to_right);
241 constexpr alignment() noexcept : _value(0) {}
247 constexpr explicit alignment(uint8_t value) noexcept : _value(value) {}
250 _value((std::to_underlying(v) << 4) | std::to_underlying(t))
252 hi_axiom(std::to_underlying(v) <= 0xf);
253 hi_axiom(std::to_underlying(t) <= 0xf);
257 _value((std::to_underlying(v) << 4) | std::to_underlying(h))
259 hi_axiom(std::to_underlying(v) <= 0xf);
260 hi_axiom(std::to_underlying(h) <= 0xf);
263 [[nodiscard]]
static constexpr alignment top_flush()
noexcept
268 [[nodiscard]]
static constexpr alignment top_left()
noexcept
273 [[nodiscard]]
static constexpr alignment top_center()
noexcept
278 [[nodiscard]]
static constexpr alignment top_justified()
noexcept
283 [[nodiscard]]
static constexpr alignment top_right()
noexcept
288 [[nodiscard]]
static constexpr alignment middle_flush()
noexcept
293 [[nodiscard]]
static constexpr alignment middle_left()
noexcept
298 [[nodiscard]]
static constexpr alignment middle_center()
noexcept
303 [[nodiscard]]
static constexpr alignment middle_justified()
noexcept
308 [[nodiscard]]
static constexpr alignment middle_right()
noexcept
313 [[nodiscard]]
static constexpr alignment bottom_left()
noexcept
318 [[nodiscard]]
static constexpr alignment bottom_center()
noexcept
323 [[nodiscard]]
static constexpr alignment bottom_right()
noexcept
338 [[nodiscard]]
constexpr friend bool operator==(
alignment const& lhs,
alignment const& rhs)
noexcept =
default;
342 return lhs.horizontal() == rhs;
347 return lhs == rhs.horizontal();
352 return lhs.vertical() == rhs;
357 return lhs == rhs.vertical();
362 return alignment{mirror(rhs.horizontal()), rhs.vertical()};
365 [[nodiscard]]
constexpr friend alignment mirror(
alignment const& rhs,
bool left_to_right)
noexcept
367 return alignment{mirror(rhs.horizontal(), left_to_right), rhs.vertical()};
370 [[nodiscard]]
constexpr friend alignment resolve(
alignment const& rhs,
bool left_to_right)
noexcept
372 return alignment{resolve(rhs.horizontal(), left_to_right), rhs.vertical()};
375 [[nodiscard]]
constexpr friend alignment resolve_mirror(
alignment const& rhs,
bool left_to_right)
noexcept
377 return alignment{resolve_mirror(rhs.horizontal(), left_to_right), rhs.vertical()};
#define hi_no_default(...)
This part of the code should not be reachable, unless a programming bug.
Definition assert.hpp:279
#define hi_axiom(expression,...)
Specify an axiom; an expression that is true.
Definition assert.hpp:253
#define hilet
Invariant should be the default for variables.
Definition utility.hpp:23
vertical_alignment
Vertical alignment.
Definition alignment.hpp:19
constexpr std::optional< float > make_guideline(vertical_alignment alignment, float bottom, float top, float padding_bottom, float padding_top, float guideline_width)
Create a guideline between two points.
Definition alignment.hpp:57
horizontal_alignment
Horizontal alignment.
Definition alignment.hpp:100
@ middle
Align to the vertical-middle.
@ bottom
Align to the bottom.
@ right
Align the text to the right side.
@ left
Align the text to the left side.
@ flush
Align the text naturally based on the writing direction of each paragraph.
@ justified
Stretch the text to be flush to both sides.
@ center
Align the text in the center.
DOXYGEN BUG.
Definition algorithm.hpp:13
geometry/margins.hpp
Definition cache.hpp:11
constexpr horizontal_alignment mirror(horizontal_alignment const &rhs) noexcept
Mirror the horizontal alignment.
Definition alignment.hpp:200
Horizontal/Vertical alignment combination.
Definition alignment.hpp:239