HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
alignment.hpp
Go to the documentation of this file.
1// Copyright Take Vos 2019-2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
6
7#pragma once
8
9#include "assert.hpp"
10
11namespace tt {
12
18 top,
19
22 middle,
23
26 bottom
27};
28
34 left,
35
38 center,
39
42 right
43};
44
47enum class alignment {
51
55
59
63
67
71
75
79
83};
84
92{
93 switch (lhs) {
94 case vertical_alignment::top:
95 switch (rhs) {
96 case horizontal_alignment::left: return alignment::top_left;
97 case horizontal_alignment::center: return alignment::top_center;
98 case horizontal_alignment::right: return alignment::top_right;
99 default: tt_no_default();
100 }
101 case vertical_alignment::middle:
102 switch (rhs) {
103 case horizontal_alignment::left: return alignment::middle_left;
104 case horizontal_alignment::center: return alignment::middle_center;
105 case horizontal_alignment::right: return alignment::middle_right;
106 default: tt_no_default();
107 }
108 case vertical_alignment::bottom:
109 switch (rhs) {
110 case horizontal_alignment::left: return alignment::bottom_left;
111 case horizontal_alignment::center: return alignment::bottom_center;
112 case horizontal_alignment::right: return alignment::bottom_right;
113 default: tt_no_default();
114 }
115 default: tt_no_default();
116 }
117}
118
126{
127 return rhs | lhs;
128}
129
136constexpr bool operator==(alignment lhs, horizontal_alignment rhs) noexcept
137{
138 switch (rhs) {
139 case horizontal_alignment::left:
140 return lhs == alignment::top_left || lhs == alignment::middle_left || lhs == alignment::bottom_left;
141
142 case horizontal_alignment::center:
143 return lhs == alignment::top_center || lhs == alignment::middle_center || lhs == alignment::bottom_center;
144
145 case horizontal_alignment::right:
146 return lhs == alignment::top_right || lhs == alignment::middle_right || lhs == alignment::bottom_right;
147
148 default: tt_no_default();
149 }
150}
151
158constexpr bool operator==(alignment lhs, vertical_alignment rhs) noexcept
159{
160 switch (rhs) {
161 case vertical_alignment::top:
162 return lhs == alignment::top_left || lhs == alignment::top_center || lhs == alignment::top_right;
163
164 case vertical_alignment::middle:
165 return lhs == alignment::middle_left || lhs == alignment::middle_center || lhs == alignment::middle_right;
166
167 case vertical_alignment::bottom:
168 return lhs == alignment::bottom_left || lhs == alignment::bottom_center || lhs == alignment::bottom_right;
169
170 default: tt_no_default();
171 }
172}
173
174} // namespace tt
horizontal_alignment
Horizontal alignment.
Definition alignment.hpp:31
@ center
Align to the horizontal-center.
alignment
Vertical and horizontal alignment.
Definition alignment.hpp:47
@ top_center
Align to the top and horizontal-center.
@ bottom_center
Align to the bottom and horizontal-center.
@ bottom_left
Align to the bottom and left.
@ top_left
Align to the top and left.
@ middle_left
Align to the vertical-middle and left.
@ bottom_right
Align to the bottom and right.
@ middle_center
Align to the vertical-middle and horizontal-center.
@ top_right
Align to the top and right.
@ middle_right
Align to the vertical-middle and right.
constexpr bool operator==(alignment lhs, horizontal_alignment rhs) noexcept
Check if the horizontal alignments are equal.
Definition alignment.hpp:136
constexpr alignment operator|(vertical_alignment lhs, horizontal_alignment rhs) noexcept
Combine vertical and horizontal alignment.
Definition alignment.hpp:91
vertical_alignment
Vertical alignment.
Definition alignment.hpp:15
@ middle
Align to the vertical-middle.
@ bottom
Align to the bottom.
@ top
Align to the top.