header_utils
Loading...
Searching...
No Matches
Alignment

Types and functions for geometric alignments - relative positionings on a line. More...

Enumerations

enum class  ghassanpl::horizontal_align : int {
  ghassanpl::horizontal_align::left , ghassanpl::horizontal_align::center , ghassanpl::horizontal_align::centre , ghassanpl::horizontal_align::right ,
  ghassanpl::horizontal_align::justify
}
 Represents an alignment on a horizontal line. More...
enum class  ghassanpl::vertical_align : int {
  ghassanpl::vertical_align::top , ghassanpl::vertical_align::middle , ghassanpl::vertical_align::center , ghassanpl::vertical_align::centre ,
  ghassanpl::vertical_align::bottom , ghassanpl::vertical_align::justify
}
 Represents an alignment on a vertical line. More...
enum class  ghassanpl::align {
  ghassanpl::align::top_left , ghassanpl::align::top_center , top_centre , center_top ,
  centre_top , ghassanpl::align::top_right , ghassanpl::align::middle_left , center_left ,
  centre_left , ghassanpl::align::middle_center , center , centre ,
  ghassanpl::align::middle_right , center_right , centre_right , ghassanpl::align::bottom_left ,
  ghassanpl::align::bottom_center , bottom_centre , center_bottom , centre_bottom ,
  ghassanpl::align::bottom_right
}
 Represents an alignment in both axes (horizontal and veritcal). More...

Functions

constexpr align ghassanpl::operator| (horizontal_align first, vertical_align second) noexcept
 You can use the | operator to create an align from a horizontal_align and a vertical_align.
constexpr align ghassanpl::operator| (vertical_align first, horizontal_align second) noexcept
 You can use the | operator to create an align from a horizontal_align and a vertical_align.
constexpr align & ghassanpl::operator|= (align &first, horizontal_align second) noexcept
constexpr align & ghassanpl::operator|= (align &first, vertical_align second) noexcept
constexpr const char * ghassanpl::to_name (horizontal_align h) noexcept
 Get alignment name.
constexpr const char * ghassanpl::to_name (vertical_align v) noexcept
 Get alignment name.
constexpr const char * ghassanpl::to_name (align a) noexcept
 Get alignment name.
constexpr const char * ghassanpl::to_natural_name (align a) noexcept
 Get natural alignment name.
constexpr vertical_align ghassanpl::to_vertical (horizontal_align alignment) noexcept
 Returns alignment as if it was on a vertical line.
constexpr vertical_align ghassanpl::to_vertical (vertical_align alignment) noexcept
 Returns alignment as if it was on a vertical line.
constexpr horizontal_align ghassanpl::to_horizontal (vertical_align alignment) noexcept
 Returns alignment as if it was on a horizontal line.
constexpr horizontal_align ghassanpl::to_horizontal (horizontal_align alignment) noexcept
 Returns alignment as if it was on a horizontal line.
constexpr vertical_align ghassanpl::vertical_from (align alignment) noexcept
 Gets just the vertical component from the align (as a vertical_align).
constexpr horizontal_align ghassanpl::horizontal_from (align alignment) noexcept
 Gets just the horizontal component from the align (as a horizontal_align).
constexpr align ghassanpl::only_vertical (align alignment) noexcept
 Gets a mew align that only has the vertical component.
constexpr align ghassanpl::only_horizontal (align alignment) noexcept
 Gets a mew align that only has the horizontal component.
constexpr vertical_align ghassanpl::to_opposite (vertical_align alignment) noexcept
 Returns the opposite aligment.
constexpr horizontal_align ghassanpl::to_opposite (horizontal_align alignment) noexcept
 Returns the opposite aligment.
constexpr align ghassanpl::to_opposite (align alignment) noexcept
 Gets an align that is opposite on bost axes.
constexpr align ghassanpl::rotated_clockwise (align alignment) noexcept
 Returns the 2D alignment rotated clockwise.
constexpr align ghassanpl::rotated_counter_clockwise (align alignment) noexcept
 Like rotated_clockwise but counter clockwise.
constexpr align ghassanpl::flipped_horizontally (align alignment) noexcept
constexpr align ghassanpl::flipped_vertically (align alignment) noexcept
template<typename T>
constexpr T ghassanpl::aligned (const T &width, const T &max_width, horizontal_align align) noexcept
template<typename T>
constexpr T ghassanpl::aligned (const T &width, const T &max_width, vertical_align align) noexcept

Variables

constexpr align ghassanpl::aligns_in_order []
 Alignments in order, first left-to-right, then top-to-bottom.
constexpr align ghassanpl::aligns_clockwise []
 Alignments in clockwise order.
constexpr align ghassanpl::aligns_counter_clockwise []
 Alignments in counter-clockwise order.
constexpr horizontal_align ghassanpl::horizontal_aligns_in_order []
 Horizontal alignments in order.
constexpr vertical_align ghassanpl::vertical_aligns_in_order []
 Vertical alignments in order.
constexpr const char * ghassanpl::horizontal_align_names []
constexpr const char * ghassanpl::vertical_align_names []
constexpr const char * ghassanpl::align_names []
constexpr const char * ghassanpl::align_names_natural []

Detailed Description

Types and functions for geometric alignments - relative positionings on a line.

The align class stores alignment in 4 bits - the least significant bits contain the horizontal alignment, and the next 2 bits contain the vertical alignment. You can then use the | operator to combine them, which combines the bits.

Enumeration Type Documentation

◆ align

enum class ghassanpl::align
strong

Represents an alignment in both axes (horizontal and veritcal).

Enumerator
top_left 

Top left.

top_center 

Top center.

top_right 

Top right.

middle_left 

Middle left.

middle_center 

Middle center.

middle_right 

Middle right.

bottom_left 

Bottom left.

bottom_center 

Bottom center.

bottom_right 

Bottom right.

Definition at line 51 of file align.h.

◆ horizontal_align

enum class ghassanpl::horizontal_align : int
strong

Represents an alignment on a horizontal line.

Enumerator
left 

Left.

center 

Center.

centre 

Same as center.

right 

Right.

justify 

Justify.

Definition at line 23 of file align.h.

◆ vertical_align

enum class ghassanpl::vertical_align : int
strong

Represents an alignment on a vertical line.

Enumerator
top 

Top.

middle 

Middle.

center 

Same as middle.

centre 

Same as middle.

bottom 

Bottom.

justify 

Justify.

Definition at line 33 of file align.h.

Function Documentation

◆ aligned() [1/2]

template<typename T>
T ghassanpl::aligned ( const T & width,
const T & max_width,
horizontal_align align )
nodiscardconstexprnoexcept

Definition at line 175 of file align.h.

◆ aligned() [2/2]

template<typename T>
T ghassanpl::aligned ( const T & width,
const T & max_width,
vertical_align align )
nodiscardconstexprnoexcept

Definition at line 185 of file align.h.

◆ flipped_horizontally()

align ghassanpl::flipped_horizontally ( align alignment)
nodiscardconstexprnoexcept

Definition at line 171 of file align.h.

◆ flipped_vertically()

align ghassanpl::flipped_vertically ( align alignment)
nodiscardconstexprnoexcept

Definition at line 172 of file align.h.

◆ horizontal_from()

horizontal_align ghassanpl::horizontal_from ( align alignment)
nodiscardconstexprnoexcept

Gets just the horizontal component from the align (as a horizontal_align).

Definition at line 130 of file align.h.

◆ only_horizontal()

align ghassanpl::only_horizontal ( align alignment)
nodiscardconstexprnoexcept

Gets a mew align that only has the horizontal component.

Definition at line 135 of file align.h.

◆ only_vertical()

align ghassanpl::only_vertical ( align alignment)
nodiscardconstexprnoexcept

Gets a mew align that only has the vertical component.

Definition at line 133 of file align.h.

◆ operator|() [1/2]

align ghassanpl::operator| ( horizontal_align first,
vertical_align second )
nodiscardconstexprnoexcept

You can use the | operator to create an align from a horizontal_align and a vertical_align.

Definition at line 46 of file align.h.

◆ operator|() [2/2]

align ghassanpl::operator| ( vertical_align first,
horizontal_align second )
nodiscardconstexprnoexcept

You can use the | operator to create an align from a horizontal_align and a vertical_align.

Definition at line 48 of file align.h.

◆ operator|=() [1/2]

align & ghassanpl::operator|= ( align & first,
horizontal_align second )
constexprnoexcept

Definition at line 87 of file align.h.

◆ operator|=() [2/2]

align & ghassanpl::operator|= ( align & first,
vertical_align second )
constexprnoexcept

Definition at line 88 of file align.h.

◆ rotated_clockwise()

align ghassanpl::rotated_clockwise ( align alignment)
nodiscardconstexprnoexcept

Returns the 2D alignment rotated clockwise.

Imagine the align as a point on a perimeter of a square:

TL-----TC-----TR
| |
| |
| |
ML MC MR
| |
| |
| |
BL-----BC-----BR

Rotating an align is like rotating the square - so, for example top_center becomes middle_right

See also
rotated_counter_clockwise

Definition at line 165 of file align.h.

◆ rotated_counter_clockwise()

align ghassanpl::rotated_counter_clockwise ( align alignment)
nodiscardconstexprnoexcept

Like rotated_clockwise but counter clockwise.

See also
rotated_clockwise

Definition at line 169 of file align.h.

◆ to_horizontal() [1/2]

horizontal_align ghassanpl::to_horizontal ( horizontal_align alignment)
nodiscardconstexprnoexcept

Returns alignment as if it was on a horizontal line.

Definition at line 125 of file align.h.

◆ to_horizontal() [2/2]

horizontal_align ghassanpl::to_horizontal ( vertical_align alignment)
nodiscardconstexprnoexcept

Returns alignment as if it was on a horizontal line.

Definition at line 123 of file align.h.

◆ to_name() [1/3]

const char * ghassanpl::to_name ( align a)
nodiscardconstexprnoexcept

Get alignment name.

Returns
Nul-terminated string with the name of the alignment (the same as the enum value name)
See also
align_names

Definition at line 106 of file align.h.

◆ to_name() [2/3]

const char * ghassanpl::to_name ( horizontal_align h)
nodiscardconstexprnoexcept

Get alignment name.

Returns
Nul-terminated string with the name of the alignment (the same as the enum value name)
See also
horizontal_align_names

Definition at line 98 of file align.h.

◆ to_name() [3/3]

const char * ghassanpl::to_name ( vertical_align v)
nodiscardconstexprnoexcept

Get alignment name.

Returns
Nul-terminated string with the name of the alignment (the same as the enum value name)
See also
vertical_align_names

Definition at line 102 of file align.h.

◆ to_natural_name()

const char * ghassanpl::to_natural_name ( align a)
nodiscardconstexprnoexcept

Get natural alignment name.

Returns
Nul-terminated string with the natural name of the alignment (containg spaces)
See also
align_names_natural

Definition at line 110 of file align.h.

◆ to_opposite() [1/3]

align ghassanpl::to_opposite ( align alignment)
nodiscardconstexprnoexcept

Gets an align that is opposite on bost axes.

Note
The opposite of justify is justify

Definition at line 147 of file align.h.

◆ to_opposite() [2/3]

horizontal_align ghassanpl::to_opposite ( horizontal_align alignment)
nodiscardconstexprnoexcept

Returns the opposite aligment.

Note
The opposite of justify is justify

Definition at line 143 of file align.h.

◆ to_opposite() [3/3]

vertical_align ghassanpl::to_opposite ( vertical_align alignment)
nodiscardconstexprnoexcept

Returns the opposite aligment.

Note
The opposite of justify is justify

Definition at line 139 of file align.h.

◆ to_vertical() [1/2]

vertical_align ghassanpl::to_vertical ( horizontal_align alignment)
nodiscardconstexprnoexcept

Returns alignment as if it was on a vertical line.

Definition at line 119 of file align.h.

◆ to_vertical() [2/2]

vertical_align ghassanpl::to_vertical ( vertical_align alignment)
nodiscardconstexprnoexcept

Returns alignment as if it was on a vertical line.

Definition at line 121 of file align.h.

◆ vertical_from()

vertical_align ghassanpl::vertical_from ( align alignment)
nodiscardconstexprnoexcept

Gets just the vertical component from the align (as a vertical_align).

Definition at line 128 of file align.h.

Variable Documentation

◆ align_names

const char* ghassanpl::align_names[]
inlineconstexpr

Definition at line 92 of file align.h.

◆ align_names_natural

const char* ghassanpl::align_names_natural[]
inlineconstexpr

Definition at line 93 of file align.h.

◆ aligns_clockwise

align ghassanpl::aligns_clockwise[]
inlineconstexpr

Alignments in clockwise order.

Definition at line 78 of file align.h.

◆ aligns_counter_clockwise

align ghassanpl::aligns_counter_clockwise[]
inlineconstexpr

Alignments in counter-clockwise order.

Definition at line 80 of file align.h.

◆ aligns_in_order

align ghassanpl::aligns_in_order[]
inlineconstexpr

Alignments in order, first left-to-right, then top-to-bottom.

Definition at line 76 of file align.h.

◆ horizontal_align_names

const char* ghassanpl::horizontal_align_names[]
inlineconstexpr

Definition at line 90 of file align.h.

◆ horizontal_aligns_in_order

horizontal_align ghassanpl::horizontal_aligns_in_order[]
inlineconstexpr

Horizontal alignments in order.

Definition at line 83 of file align.h.

◆ vertical_align_names

const char* ghassanpl::vertical_align_names[]
inlineconstexpr

Definition at line 91 of file align.h.

◆ vertical_aligns_in_order

vertical_align ghassanpl::vertical_aligns_in_order[]
inlineconstexpr

Vertical alignments in order.

Definition at line 85 of file align.h.