@ -26,10 +26,11 @@
*/
/** @file
* @ brief Enum @ ref Magnum : : Text : : Alignment
* @ brief Enum @ ref Magnum : : Text : : Alignment , function @ ref Magnum : : Text : : alignmentForDirection ( )
*/
# include "Magnum/Magnum.h"
# include "Magnum/Text/Text.h"
# include "Magnum/Text/visibility.h"
namespace Magnum { namespace Text {
@ -42,16 +43,20 @@ namespace Implementation {
AlignmentLeft = 0 ,
AlignmentCenter = 1 < < 0 ,
AlignmentRight = 2 < < 0 ,
AlignmentHorizontal = AlignmentLeft | AlignmentCenter | AlignmentRight ,
/* Start and End is Left or Right based on ShapeDirection, and possibly
also Top / Bottom eventually for vertical text */
AlignmentStart = 3 < < 0 ,
AlignmentEnd = 4 < < 0 ,
AlignmentHorizontal = AlignmentLeft | AlignmentCenter | AlignmentRight | AlignmentStart | AlignmentEnd ,
AlignmentLine = 0 ,
AlignmentBottom = 1 < < 2 ,
AlignmentMiddle = 2 < < 2 ,
AlignmentTop = 3 < < 2 ,
AlignmentBottom = 1 < < 4 ,
AlignmentMiddle = 2 < < 4 ,
AlignmentTop = 3 < < 4 ,
AlignmentVertical = AlignmentLine | AlignmentBottom | AlignmentMiddle | AlignmentTop ,
AlignmentIntegral = 1 < < 4 ,
AlignmentGlyphBounds = 1 < < 5
AlignmentIntegral = 1 < < 6 ,
AlignmentGlyphBounds = 1 < < 7
} ;
}
@ -71,19 +76,31 @@ positioned on whole pixels as well in order to avoid making them blurry. These
are only needed for ` * Middle ` and ` * Center ` alignments as they may result in
the bounding rectangle to have odd dimensions , which would then result in
half - pixel shifts when divided by 2.
@ see @ ref Renderer : : render ( ) , @ ref Renderer : : Renderer ( )
The ` * Start ` and ` * End ` values behave the same as ` * Left ` and ` * Right ` ,
respectively , if @ ref ShapeDirection : : LeftToRight is passed to
@ ref AbstractShaper : : setDirection ( ) , or if it ' s
@ ref ShapeDirection : : Unspecified and the particular font plugin doesn ' t detect
@ ref ShapeDirection : : RightToLeft when shaping . If
@ ref ShapeDirection : : RightToLeft is set ( or detected for
@ ref ShapeDirection : : Unspecified ) , they ' re swapped , i . e . ` * Start ` becomes
` * Right ` and ` * End ` becomes ` * Left ` .
@ see @ ref Renderer : : render ( ) , @ ref Renderer : : Renderer ( ) ,
@ see @ ref alignmentForDirection ( )
*/
enum class Alignment : UnsignedByte {
/**
* Leftmost cursor position and vertical line position is at origin .
* @ see @ ref Alignment : : LineLeftGlyphBounds
* @ see @ ref Alignment : : LineLeftGlyphBounds , @ ref Alignment : : LineStart ,
* @ ref Alignment : : LineEnd
*/
LineLeft = Implementation : : AlignmentLine | Implementation : : AlignmentLeft ,
/**
* Left side of the glyph bounding rectangle and vertical line position is
* at origin .
* @ see @ ref Alignment : : LineLeft
* @ see @ ref Alignment : : LineLeft , @ ref Alignment : : LineStartGlyphBounds ,
* @ ref Alignment : : LineEndGlyphBounds
* @ m_since_latest
*/
LineLeftGlyphBounds = LineLeft | Implementation : : AlignmentGlyphBounds ,
@ -126,28 +143,68 @@ enum class Alignment: UnsignedByte {
/**
* Rightmost cursor position and vertical line position is at origin .
* @ see @ ref Alignment : : LineRightGlyphBounds
* @ see @ ref Alignment : : LineRightGlyphBounds , @ ref Alignment : : LineEnd ,
* @ ref Alignment : : LineStart
* @ see @ ref alignmentForDirection ( )
*/
LineRight = Implementation : : AlignmentLine | Implementation : : AlignmentRight ,
/**
* Right side of the glyph bounding rectangle and vertical line position is
* at origin .
* @ see @ ref Alignment : : LineRight
* @ see @ ref Alignment : : LineRight , @ ref Alignment : : LineEndGlyphBounds ,
* @ ref Alignment : : LineStartGlyphBounds
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
LineRightGlyphBounds = LineRight | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : LineRight for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : LineLeft otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
LineStart = Implementation : : AlignmentLine | Implementation : : AlignmentStart ,
/**
* @ ref Alignment : : LineRightGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : LineLeftGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
LineStartGlyphBounds = LineStart | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : LineLeft for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : LineRight otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
LineEnd = Implementation : : AlignmentLine | Implementation : : AlignmentEnd ,
/**
* @ ref Alignment : : LineLeftGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : LineRightGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
LineEndGlyphBounds = LineEnd | Implementation : : AlignmentGlyphBounds ,
/**
* Leftmost cursor position and bottommost line descent is at origin .
* @ see @ ref Alignment : : BottomLeftGlyphBounds
* @ see @ ref Alignment : : BottomLeftGlyphBounds , @ ref Alignment : : BottomStart ,
* @ ref Alignment : : BottomEnd
* @ m_since_latest
*/
BottomLeft = Implementation : : AlignmentBottom | Implementation : : AlignmentLeft ,
/**
* Bottom left corner of the glyph bounding rectangle is at origin .
* @ see @ ref Alignment : : BottomLeft
* @ see @ ref Alignment : : BottomLeft , @ ref Alignment : : BottomStartGlyphBounds ,
* @ ref Alignment : : BottomEndGlyphBounds
* @ m_since_latest
*/
BottomLeftGlyphBounds = BottomLeft | Implementation : : AlignmentGlyphBounds ,
@ -191,23 +248,60 @@ enum class Alignment: UnsignedByte {
/**
* Rightmost cursor position and bottommost line descent is at origin .
* @ see @ ref Alignment : : BottomRightGlyphBounds
* @ see @ ref Alignment : : BottomRightGlyphBounds , @ ref Alignment : : BottomEnd ,
* @ ref Alignment : : BottomStart
* @ m_since_latest
*/
BottomRight = Implementation : : AlignmentBottom | Implementation : : AlignmentRight ,
/**
* Bottom right corner of the glyph bounding rectangle is at origin .
* @ see @ ref Alignment : : BottomRight
* @ see @ ref Alignment : : BottomRight , @ ref Alignment : : BottomEndGlyphBounds ,
* @ ref Alignment : : BottomStartGlyphBounds
* @ m_since_latest
*/
BottomRightGlyphBounds = BottomRight | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : BottomRight for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : BottomLeft otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
BottomStart = Implementation : : AlignmentBottom | Implementation : : AlignmentStart ,
/**
* @ ref Alignment : : BottomRightGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : BottomLeftGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
BottomStartGlyphBounds = BottomStart | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : BottomLeft for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : BottomRight otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
BottomEnd = Implementation : : AlignmentBottom | Implementation : : AlignmentEnd ,
/**
* @ ref Alignment : : BottomLeftGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : BottomRightGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
BottomEndGlyphBounds = BottomEnd | Implementation : : AlignmentGlyphBounds ,
/**
* Leftmost cursor position and a midpoint between topmost line ascent and
* bottommost line descent is at origin .
* @ see @ ref Alignment : : MiddleLeftGlyphBounds ,
* @ ref Alignment : : MiddleLeftIntegral
* @ ref Alignment : : MiddleLeftIntegral , @ ref Alignment : : MiddleStart ,
* @ ref Alignment : : MiddleEnd
*/
MiddleLeft = Implementation : : AlignmentMiddle | Implementation : : AlignmentLeft ,
@ -216,7 +310,9 @@ enum class Alignment: UnsignedByte {
* bottommost line descent is at origin , with the vertical offset rounded
* to whole units .
* @ see @ ref Alignment : : MiddleLeft ,
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleStartIntegral ,
* @ ref Alignment : : MiddleEndIntegral
*/
MiddleLeftIntegral = MiddleLeft | Implementation : : AlignmentIntegral ,
@ -224,7 +320,9 @@ enum class Alignment: UnsignedByte {
* Left side and vertical center of the glyph bounding rectangle is at
* origin .
* @ see @ ref Alignment : : MiddleLeft ,
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleStartGlyphBounds ,
* @ ref Alignment : : MiddleEndGlyphBounds
* @ m_since_latest
*/
MiddleLeftGlyphBounds = MiddleLeft | Implementation : : AlignmentGlyphBounds ,
@ -233,7 +331,9 @@ enum class Alignment: UnsignedByte {
* Left side and vertical center of the glyph bounding rectangle is at
* origin , with the vertical offset rounded to whole units .
* @ see @ ref Alignment : : MiddleLeftGlyphBounds ,
* @ ref Alignment : : MiddleLeftIntegral
* @ ref Alignment : : MiddleLeftIntegral ,
* @ ref Alignment : : MiddleStartGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleEndGlyphBoundsIntegral
* @ m_since_latest
*/
MiddleLeftGlyphBoundsIntegral = MiddleLeftGlyphBounds | Implementation : : AlignmentIntegral ,
@ -278,7 +378,8 @@ enum class Alignment: UnsignedByte {
* Rightmost cursor position and a midpoint between topmost line ascent and
* bottommost line descent is at origin .
* @ see @ ref Alignment : : MiddleRightGlyphBounds ,
* @ ref Alignment : : MiddleRightIntegral
* @ ref Alignment : : MiddleRightIntegral , @ ref Alignment : : MiddleEnd ,
* @ ref Alignment : : MiddleStart
*/
MiddleRight = Implementation : : AlignmentMiddle | Implementation : : AlignmentRight ,
@ -287,7 +388,9 @@ enum class Alignment: UnsignedByte {
* bottommost line descent is at origin , with the vertical offset rounded
* to whole units .
* @ see @ ref Alignment : : MiddleRight ,
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleEndIntegral ,
* @ ref Alignment : : MiddleStartIntegral
*/
MiddleRightIntegral = MiddleRight | Implementation : : AlignmentIntegral ,
@ -295,7 +398,9 @@ enum class Alignment: UnsignedByte {
* Right side and vertical center of the glyph bounding rectangle is at
* origin .
* @ see @ ref Alignment : : MiddleRight ,
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleEndGlyphBounds ,
* @ ref Alignment : : MiddleStartGlyphBounds
* @ m_since_latest
*/
MiddleRightGlyphBounds = MiddleRight | Implementation : : AlignmentGlyphBounds ,
@ -304,20 +409,94 @@ enum class Alignment: UnsignedByte {
* Right side and vertical center of the glyph bounding rectangle is at
* origin , with the vertical offset rounded to whole units .
* @ see @ ref Alignment : : MiddleRightGlyphBounds ,
* @ ref Alignment : : MiddleRightIntegral
* @ ref Alignment : : MiddleRightIntegral ,
* @ ref Alignment : : MiddleEndGlyphBoundsIntegral ,
* @ ref Alignment : : MiddleStartGlyphBoundsIntegral
* @ m_since_latest
*/
MiddleRightGlyphBoundsIntegral = MiddleRightGlyphBounds | Implementation : : AlignmentIntegral ,
/**
* @ ref Alignment : : MiddleRight for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : MiddleLeft otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleStart = Implementation : : AlignmentMiddle | Implementation : : AlignmentStart ,
/**
* @ ref Alignment : : MiddleRightIntegral for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : MiddleLeftIntegral
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleStartIntegral = MiddleStart | Implementation : : AlignmentIntegral ,
/**
* @ ref Alignment : : MiddleRightGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : MiddleLeftGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleStartGlyphBounds = MiddleStart | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral for
* @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleStartGlyphBoundsIntegral = MiddleStartGlyphBounds | Implementation : : AlignmentIntegral ,
/**
* @ ref Alignment : : MiddleLeft for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : MiddleRight otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleEnd = Implementation : : AlignmentMiddle | Implementation : : AlignmentEnd ,
/**
* @ ref Alignment : : MiddleLeftIntegral for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : MiddleRightIntegral
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleEndIntegral = MiddleEnd | Implementation : : AlignmentIntegral ,
/**
* @ ref Alignment : : MiddleLeftGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : MiddleRightGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleEndGlyphBounds = MiddleEnd | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : MiddleLeftGlyphBoundsIntegral for
* @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : MiddleRightGlyphBoundsIntegral otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
MiddleEndGlyphBoundsIntegral = MiddleEndGlyphBounds | Implementation : : AlignmentIntegral ,
/**
* Leftmost cursor position and topmost line ascent is at origin .
* @ see @ ref Alignment : : TopLeftGlyphBounds
* @ see @ ref Alignment : : TopLeftGlyphBounds , @ ref Alignment : : TopStart ,
* @ ref Alignment : : TopEnd
*/
TopLeft = Implementation : : AlignmentTop | Implementation : : AlignmentLeft ,
/**
* Top left corner of the glyph bounding rectangle is at origin .
* @ see @ ref Alignment : : TopLeft
* @ see @ ref Alignment : : TopLeft , @ ref Alignment : : TopStartGlyphBounds ,
* @ ref Alignment : : TopEndGlyphBounds
* @ m_since_latest
*/
TopLeftGlyphBounds = TopLeft | Implementation : : AlignmentGlyphBounds ,
@ -359,21 +538,72 @@ enum class Alignment: UnsignedByte {
/**
* Rightmost cursor position and topmost line ascent is at origin .
* @ see @ ref Alignment : : TopRightGlyphBounds
* @ see @ ref Alignment : : TopRightGlyphBounds , @ ref Alignment : : TopEnd ,
* @ ref Alignment : : TopStart
*/
TopRight = Implementation : : AlignmentTop | Implementation : : AlignmentRight ,
/**
* Top right corner of the glyph bounding rectangle is at origin .
* @ see @ ref Alignment : : TopRight
* @ see @ ref Alignment : : TopRight , @ ref Alignment : : TopEndGlyphBounds ,
* @ ref Alignment : : TopStartGlyphBounds
* @ m_since_latest
*/
TopRightGlyphBounds = TopRight | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : TopRight for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : TopLeft otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
TopStart = Implementation : : AlignmentTop | Implementation : : AlignmentStart ,
/**
* @ ref Alignment : : TopRightGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : TopLeftGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
TopStartGlyphBounds = TopStart | Implementation : : AlignmentGlyphBounds ,
/**
* @ ref Alignment : : TopLeft for @ ref ShapeDirection : : RightToLeft ,
* @ ref Alignment : : TopRight otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
TopEnd = Implementation : : AlignmentTop | Implementation : : AlignmentEnd ,
/**
* @ ref Alignment : : TopLeftGlyphBounds for
* @ ref ShapeDirection : : RightToLeft , @ ref Alignment : : TopRightGlyphBounds
* otherwise .
* @ see @ ref alignmentForDirection ( )
* @ m_since_latest
*/
TopEndGlyphBounds = TopEnd | Implementation : : AlignmentGlyphBounds ,
} ;
/** @debugoperatorenum{Alignment} */
MAGNUM_TEXT_EXPORT Debug & operator < < ( Debug & debug , Alignment value ) ;
/**
@ brief Alignment for layout and shape direction
@ m_since_latest
The @ p layoutDirection is currently expected to always be
@ ref LayoutDirection : : HorizontalTopToBottom and @ p shapeDirection never
@ ref ShapeDirection : : TopToBottom or @ ref ShapeDirection : : BottomToTop . Then , if
@ p alignment is ` * Start ` or ` * End ` , it ' s converted to ` * Left ` or ` * Right ` ,
respectively , if @ p shapeDirection is @ ref ShapeDirection : : LeftToRight or
@ ref ShapeDirection : : Unspecified , and ` * Right ` or ` * Left ` , respectively , if
@ p shapeDirection is @ ref ShapeDirection : : RightToLeft .
*/
MAGNUM_TEXT_EXPORT Alignment alignmentForDirection ( Alignment alignment , LayoutDirection layoutDirection , ShapeDirection shapeDirection ) ;
} }
# endif