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

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

enum class  ghassanpl::horizontal_align {
  ghassanpl::horizontal_align::left , ghassanpl::horizontal_align::center , ghassanpl::horizontal_align::centre , ghassanpl::horizontal_align::right ,
  ghassanpl::horizontal_align::justify
}
 
enum class  ghassanpl::vertical_align {
  ghassanpl::top , ghassanpl::middle , ghassanpl::center , ghassanpl::centre ,
  ghassanpl::bottom , ghassanpl::justify
}
 Represents an alignment on a vertical line. More...
 
enum class  ghassanpl::align {
  ghassanpl::top_left , ghassanpl::top_center , top_centre , center_top ,
  centre_top , ghassanpl::top_right , ghassanpl::middle_left , center_left ,
  centre_left , ghassanpl::middle_center , center , centre ,
  ghassanpl::middle_right , center_right , centre_right , ghassanpl::bottom_left ,
  ghassanpl::bottom_center , bottom_centre , center_bottom , centre_bottom ,
  ghassanpl::bottom_right
}
 Represents an alignment in both axes (horizontal and veritcal) More...
 
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 charghassanpl::horizontal_align_names []
 
constexpr const charghassanpl::vertical_align_names []
 
constexpr const charghassanpl::align_names []
 
constexpr const charghassanpl::align_names_natural []
 
constexpr align ghassanpl::operator| (horizontal_align first, vertical_align second)
 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)
 You can use the | operator to create an align from a horizontal_align and a vertical_align.
 
constexpr const charghassanpl::to_name (horizontal_align h)
 Get alignment name.
 
constexpr const charghassanpl::to_name (vertical_align v)
 Get alignment name.
 
constexpr const charghassanpl::to_name (align a)
 Get alignment name.
 
constexpr const charghassanpl::to_natural_name (align a)
 Get natural alignment name.
 
constexpr vertical_align ghassanpl::to_vertical (horizontal_align alignment)
 Returns alignment as if it was on a vertical line.
 
constexpr vertical_align ghassanpl::to_vertical (vertical_align alignment)
 Returns alignment as if it was on a vertical line.
 
constexpr horizontal_align ghassanpl::to_horizontal (vertical_align alignment)
 Returns alignment as if it was on a horizontal line.
 
constexpr horizontal_align ghassanpl::to_horizontal (horizontal_align alignment)
 Returns alignment as if it was on a horizontal line.
 
constexpr vertical_align ghassanpl::vertical_from (align alignment)
 Gets just the vertical component from the align (as a vertical_align)
 
constexpr horizontal_align ghassanpl::horizontal_from (align alignment)
 Gets just the horizontal component from the align (as a horizontal_align)
 
constexpr align ghassanpl::only_vertical (align alignment)
 Gets a mew align that only has the vertical component.
 
constexpr align ghassanpl::only_horizontal (align alignment)
 Gets a mew align that only has the horizontal component.
 
constexpr vertical_align ghassanpl::to_opposite (vertical_align alignment)
 Returns the opposite aligment.
 
constexpr horizontal_align ghassanpl::to_opposite (horizontal_align alignment)
 Returns the opposite aligment.
 
constexpr align ghassanpl::to_opposite (align alignment)
 Gets an align that is opposite on bost axes.
 
constexpr align ghassanpl::rotated_clockwise (align alignment)
 Returns the 2D alignment rotated clockwise.
 
constexpr align ghassanpl::rotated_counter_clockwise (align alignment)
 Like rotated_clockwise but counter clockwise.
 
constexpr align ghassanpl::flipped_horizontally (align alignment)
 
constexpr align ghassanpl::flipped_vertically (align alignment)
 
template<typename T >
constexprghassanpl::aligned (const T &width, const T &max_width, horizontal_align align)
 
template<typename T >
constexprghassanpl::aligned (const T &width, const T &max_width, vertical_align align)
 

Detailed Description

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

Enumeration Type Documentation

◆ align

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 46 of file align.h.

◆ horizontal_align

Represents an alignment on a horizontal line

Enumerator
left 

Left.

center 

Center.

centre 

Same as center

right 

Right.

justify 

Justify.

Definition at line 18 of file align.h.

◆ vertical_align

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 28 of file align.h.

Function Documentation

◆ aligned() [1/2]

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

Definition at line 170 of file align.h.

◆ aligned() [2/2]

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

Definition at line 180 of file align.h.

◆ flipped_horizontally()

constexpr align ghassanpl::flipped_horizontally ( align  alignment)
constexpr

Definition at line 166 of file align.h.

◆ flipped_vertically()

constexpr align ghassanpl::flipped_vertically ( align  alignment)
constexpr

Definition at line 167 of file align.h.

◆ horizontal_from()

constexpr horizontal_align ghassanpl::horizontal_from ( align  alignment)
constexpr

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

Definition at line 125 of file align.h.

◆ only_horizontal()

constexpr align ghassanpl::only_horizontal ( align  alignment)
constexpr

Gets a mew align that only has the horizontal component.

Definition at line 130 of file align.h.

◆ only_vertical()

constexpr align ghassanpl::only_vertical ( align  alignment)
constexpr

Gets a mew align that only has the vertical component.

Definition at line 128 of file align.h.

◆ operator|() [1/2]

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

Definition at line 41 of file align.h.

◆ operator|() [2/2]

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

Definition at line 43 of file align.h.

◆ rotated_clockwise()

constexpr align ghassanpl::rotated_clockwise ( align  alignment)
constexpr

Returns the 2D alignment rotated clockwise.

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

TL-----TC-----TR
| |
| |
| |
| |
| |
| |
BL-----BC-----BR
constexpr auto bit_count
Equal to the number of bits in the type.
Definition bits.h:33

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

See also
rotated_counter_clockwise

Definition at line 160 of file align.h.

◆ rotated_counter_clockwise()

constexpr align ghassanpl::rotated_counter_clockwise ( align  alignment)
constexpr

Like rotated_clockwise but counter clockwise.

See also
rotated_clockwise

Definition at line 164 of file align.h.

◆ to_horizontal() [1/2]

constexpr horizontal_align ghassanpl::to_horizontal ( horizontal_align  alignment)
constexpr

Returns alignment as if it was on a horizontal line.

Definition at line 120 of file align.h.

◆ to_horizontal() [2/2]

constexpr horizontal_align ghassanpl::to_horizontal ( vertical_align  alignment)
constexpr

Returns alignment as if it was on a horizontal line.

Definition at line 118 of file align.h.

◆ to_name() [1/3]

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

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 101 of file align.h.

◆ to_name() [2/3]

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

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 93 of file align.h.

◆ to_name() [3/3]

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

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 97 of file align.h.

◆ to_natural_name()

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

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 105 of file align.h.

◆ to_opposite() [1/3]

constexpr align ghassanpl::to_opposite ( align  alignment)
constexpr

Gets an align that is opposite on bost axes.

Note
The opposite of justify is justify

Definition at line 142 of file align.h.

◆ to_opposite() [2/3]

constexpr horizontal_align ghassanpl::to_opposite ( horizontal_align  alignment)
constexpr

Returns the opposite aligment.

Note
The opposite of justify is justify

Definition at line 138 of file align.h.

◆ to_opposite() [3/3]

constexpr vertical_align ghassanpl::to_opposite ( vertical_align  alignment)
constexpr

Returns the opposite aligment.

Note
The opposite of justify is justify

Definition at line 134 of file align.h.

◆ to_vertical() [1/2]

constexpr vertical_align ghassanpl::to_vertical ( horizontal_align  alignment)
constexpr

Returns alignment as if it was on a vertical line.

Definition at line 114 of file align.h.

◆ to_vertical() [2/2]

constexpr vertical_align ghassanpl::to_vertical ( vertical_align  alignment)
constexpr

Returns alignment as if it was on a vertical line.

Definition at line 116 of file align.h.

◆ vertical_from()

constexpr vertical_align ghassanpl::vertical_from ( align  alignment)
constexpr

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

Definition at line 123 of file align.h.

Variable Documentation

◆ align_names

constexpr const char* ghassanpl::align_names[]
inlineconstexpr

Definition at line 87 of file align.h.

◆ align_names_natural

constexpr const char* ghassanpl::align_names_natural[]
inlineconstexpr

Definition at line 88 of file align.h.

◆ aligns_clockwise

constexpr align ghassanpl::aligns_clockwise[]
inlineconstexpr

Alignments in clockwise order.

Definition at line 73 of file align.h.

◆ aligns_counter_clockwise

constexpr align ghassanpl::aligns_counter_clockwise[]
inlineconstexpr

Alignments in counter-clockwise order.

Definition at line 75 of file align.h.

◆ aligns_in_order

constexpr align ghassanpl::aligns_in_order[]
inlineconstexpr

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

Definition at line 71 of file align.h.

◆ horizontal_align_names

constexpr const char* ghassanpl::horizontal_align_names[]
inlineconstexpr

Definition at line 85 of file align.h.

◆ horizontal_aligns_in_order

constexpr horizontal_align ghassanpl::horizontal_aligns_in_order[]
inlineconstexpr

Horizontal alignments in order.

Definition at line 78 of file align.h.

◆ vertical_align_names

constexpr const char* ghassanpl::vertical_align_names[]
inlineconstexpr

Definition at line 86 of file align.h.

◆ vertical_aligns_in_order

constexpr vertical_align ghassanpl::vertical_aligns_in_order[]
inlineconstexpr

Vertical alignments in order.

Definition at line 80 of file align.h.