Browse Source

Text: rename Alignment::*Start to *Begin.

The naming was adopted from CSS direction-aware alignment and it took me
quite a while to realize it feels alien, since everything else is using
"begin" and "end", not "start" and "end". So I'm renaming for
consistency.

These enums were originally introduced about 8 months ago but I don't
think anyone is using these yet, since they're not really advertised
anywhere and the existing to-be-deprecated high-level text renderer API
is so shitty that I don't expect it to be used for BIDI text and such,
at all. Sorry if you do, heh.
pull/651/merge
Vladimír Vondruš 1 year ago
parent
commit
9c852767c8
  1. 22
      src/Magnum/Text/Alignment.cpp
  2. 72
      src/Magnum/Text/Alignment.h
  3. 4
      src/Magnum/Text/Renderer.cpp
  4. 6
      src/Magnum/Text/Test/AlignmentTest.cpp
  5. 16
      src/Magnum/Text/Test/RendererTest.cpp

22
src/Magnum/Text/Alignment.cpp

@ -47,8 +47,8 @@ Debug& operator<<(Debug& debug, const Alignment value) {
_c(LineCenterGlyphBoundsIntegral) _c(LineCenterGlyphBoundsIntegral)
_c(LineRight) _c(LineRight)
_c(LineRightGlyphBounds) _c(LineRightGlyphBounds)
_c(LineStart) _c(LineBegin)
_c(LineStartGlyphBounds) _c(LineBeginGlyphBounds)
_c(LineEnd) _c(LineEnd)
_c(LineEndGlyphBounds) _c(LineEndGlyphBounds)
_c(BottomLeft) _c(BottomLeft)
@ -59,8 +59,8 @@ Debug& operator<<(Debug& debug, const Alignment value) {
_c(BottomCenterGlyphBoundsIntegral) _c(BottomCenterGlyphBoundsIntegral)
_c(BottomRight) _c(BottomRight)
_c(BottomRightGlyphBounds) _c(BottomRightGlyphBounds)
_c(BottomStart) _c(BottomBegin)
_c(BottomStartGlyphBounds) _c(BottomBeginGlyphBounds)
_c(BottomEnd) _c(BottomEnd)
_c(BottomEndGlyphBounds) _c(BottomEndGlyphBounds)
_c(MiddleLeft) _c(MiddleLeft)
@ -75,10 +75,10 @@ Debug& operator<<(Debug& debug, const Alignment value) {
_c(MiddleRightIntegral) _c(MiddleRightIntegral)
_c(MiddleRightGlyphBounds) _c(MiddleRightGlyphBounds)
_c(MiddleRightGlyphBoundsIntegral) _c(MiddleRightGlyphBoundsIntegral)
_c(MiddleStart) _c(MiddleBegin)
_c(MiddleStartIntegral) _c(MiddleBeginIntegral)
_c(MiddleStartGlyphBounds) _c(MiddleBeginGlyphBounds)
_c(MiddleStartGlyphBoundsIntegral) _c(MiddleBeginGlyphBoundsIntegral)
_c(MiddleEnd) _c(MiddleEnd)
_c(MiddleEndIntegral) _c(MiddleEndIntegral)
_c(MiddleEndGlyphBounds) _c(MiddleEndGlyphBounds)
@ -91,8 +91,8 @@ Debug& operator<<(Debug& debug, const Alignment value) {
_c(TopCenterGlyphBoundsIntegral) _c(TopCenterGlyphBoundsIntegral)
_c(TopRight) _c(TopRight)
_c(TopRightGlyphBounds) _c(TopRightGlyphBounds)
_c(TopStart) _c(TopBegin)
_c(TopStartGlyphBounds) _c(TopBeginGlyphBounds)
_c(TopEnd) _c(TopEnd)
_c(TopEndGlyphBounds) _c(TopEndGlyphBounds)
#undef _c #undef _c
@ -114,7 +114,7 @@ Alignment alignmentForDirection(const Alignment alignment, const LayoutDirection
const UnsignedByte horizontal = UnsignedByte(alignment) & Implementation::AlignmentHorizontal; const UnsignedByte horizontal = UnsignedByte(alignment) & Implementation::AlignmentHorizontal;
const UnsignedByte exceptHorizontal = UnsignedByte(alignment) & ~Implementation::AlignmentHorizontal; const UnsignedByte exceptHorizontal = UnsignedByte(alignment) & ~Implementation::AlignmentHorizontal;
if(horizontal == Implementation::AlignmentStart) if(horizontal == Implementation::AlignmentBegin)
return Alignment((shapeDirection == ShapeDirection::RightToLeft ? return Alignment((shapeDirection == ShapeDirection::RightToLeft ?
Implementation::AlignmentRight : Implementation::AlignmentRight :
Implementation::AlignmentLeft)|exceptHorizontal); Implementation::AlignmentLeft)|exceptHorizontal);

72
src/Magnum/Text/Alignment.h

@ -44,11 +44,11 @@ namespace Implementation {
AlignmentLeft = 0, AlignmentLeft = 0,
AlignmentCenter = 1 << 0, AlignmentCenter = 1 << 0,
AlignmentRight = 2 << 0, AlignmentRight = 2 << 0,
/* Start and End is Left or Right based on ShapeDirection, and possibly /* Begin and End is Left or Right based on ShapeDirection, and possibly
also Top / Bottom eventually for vertical text */ also Top / Bottom eventually for vertical text */
AlignmentStart = 3 << 0, AlignmentBegin = 3 << 0,
AlignmentEnd = 4 << 0, AlignmentEnd = 4 << 0,
AlignmentHorizontal = AlignmentLeft|AlignmentCenter|AlignmentRight|AlignmentStart|AlignmentEnd, AlignmentHorizontal = AlignmentLeft|AlignmentCenter|AlignmentRight|AlignmentBegin|AlignmentEnd,
AlignmentLine = 0, AlignmentLine = 0,
AlignmentBottom = 1 << 4, AlignmentBottom = 1 << 4,
@ -78,13 +78,13 @@ 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 the bounding rectangle to have odd dimensions, which would then result in
half-pixel shifts when divided by 2. half-pixel shifts when divided by 2.
The `*Start` and `*End` values behave the same as `*Left` and `*Right`, The `*Begin` and `*End` values behave the same as `*Left` and `*Right`,
respectively, if @ref ShapeDirection::LeftToRight is passed to respectively, if @ref ShapeDirection::LeftToRight is passed to
@ref AbstractShaper::setDirection(), or if it's @ref AbstractShaper::setDirection(), or if it's
@ref ShapeDirection::Unspecified and the particular font plugin doesn't detect @ref ShapeDirection::Unspecified and the particular font plugin doesn't detect
@ref ShapeDirection::RightToLeft when shaping. If @ref ShapeDirection::RightToLeft when shaping. If
@ref ShapeDirection::RightToLeft is set (or detected for @ref ShapeDirection::RightToLeft is set (or detected for
@ref ShapeDirection::Unspecified), they're swapped, i.e. `*Start` becomes @ref ShapeDirection::Unspecified), they're swapped, i.e. `*Begin` becomes
`*Right` and `*End` becomes `*Left`. `*Right` and `*End` becomes `*Left`.
@see @ref Renderer::render(), @ref Renderer::Renderer(), @see @ref Renderer::render(), @ref Renderer::Renderer(),
@see @ref alignmentForDirection() @see @ref alignmentForDirection()
@ -92,7 +92,7 @@ respectively, if @ref ShapeDirection::LeftToRight is passed to
enum class Alignment: UnsignedByte { enum class Alignment: UnsignedByte {
/** /**
* Leftmost cursor position and vertical line position is at origin. * Leftmost cursor position and vertical line position is at origin.
* @see @ref Alignment::LineLeftGlyphBounds, @ref Alignment::LineStart, * @see @ref Alignment::LineLeftGlyphBounds, @ref Alignment::LineBegin,
* @ref Alignment::LineEnd * @ref Alignment::LineEnd
*/ */
LineLeft = Implementation::AlignmentLine|Implementation::AlignmentLeft, LineLeft = Implementation::AlignmentLine|Implementation::AlignmentLeft,
@ -100,7 +100,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Left side of the glyph bounding rectangle and vertical line position is * Left side of the glyph bounding rectangle and vertical line position is
* at origin. * at origin.
* @see @ref Alignment::LineLeft, @ref Alignment::LineStartGlyphBounds, * @see @ref Alignment::LineLeft, @ref Alignment::LineBeginGlyphBounds,
* @ref Alignment::LineEndGlyphBounds * @ref Alignment::LineEndGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
@ -145,7 +145,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Rightmost cursor position and vertical line position is at origin. * Rightmost cursor position and vertical line position is at origin.
* @see @ref Alignment::LineRightGlyphBounds, @ref Alignment::LineEnd, * @see @ref Alignment::LineRightGlyphBounds, @ref Alignment::LineEnd,
* @ref Alignment::LineStart * @ref Alignment::LineBegin
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
*/ */
LineRight = Implementation::AlignmentLine|Implementation::AlignmentRight, LineRight = Implementation::AlignmentLine|Implementation::AlignmentRight,
@ -154,7 +154,7 @@ enum class Alignment: UnsignedByte {
* Right side of the glyph bounding rectangle and vertical line position is * Right side of the glyph bounding rectangle and vertical line position is
* at origin. * at origin.
* @see @ref Alignment::LineRight, @ref Alignment::LineEndGlyphBounds, * @see @ref Alignment::LineRight, @ref Alignment::LineEndGlyphBounds,
* @ref Alignment::LineStartGlyphBounds * @ref Alignment::LineBeginGlyphBounds
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
@ -166,7 +166,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
LineStart = Implementation::AlignmentLine|Implementation::AlignmentStart, LineBegin = Implementation::AlignmentLine|Implementation::AlignmentBegin,
/** /**
* @ref Alignment::LineRightGlyphBounds for * @ref Alignment::LineRightGlyphBounds for
@ -175,7 +175,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
LineStartGlyphBounds = LineStart|Implementation::AlignmentGlyphBounds, LineBeginGlyphBounds = LineBegin|Implementation::AlignmentGlyphBounds,
/** /**
* @ref Alignment::LineLeft for @ref ShapeDirection::RightToLeft, * @ref Alignment::LineLeft for @ref ShapeDirection::RightToLeft,
@ -196,7 +196,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Leftmost cursor position and bottommost line descent is at origin. * Leftmost cursor position and bottommost line descent is at origin.
* @see @ref Alignment::BottomLeftGlyphBounds, @ref Alignment::BottomStart, * @see @ref Alignment::BottomLeftGlyphBounds, @ref Alignment::BottomBegin,
* @ref Alignment::BottomEnd * @ref Alignment::BottomEnd
* @m_since_latest * @m_since_latest
*/ */
@ -204,7 +204,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Bottom left corner of the glyph bounding rectangle is at origin. * Bottom left corner of the glyph bounding rectangle is at origin.
* @see @ref Alignment::BottomLeft, @ref Alignment::BottomStartGlyphBounds, * @see @ref Alignment::BottomLeft, @ref Alignment::BottomBeginGlyphBounds,
* @ref Alignment::BottomEndGlyphBounds * @ref Alignment::BottomEndGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
@ -250,7 +250,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Rightmost cursor position and bottommost line descent is at origin. * Rightmost cursor position and bottommost line descent is at origin.
* @see @ref Alignment::BottomRightGlyphBounds, @ref Alignment::BottomEnd, * @see @ref Alignment::BottomRightGlyphBounds, @ref Alignment::BottomEnd,
* @ref Alignment::BottomStart * @ref Alignment::BottomBegin
* @m_since_latest * @m_since_latest
*/ */
BottomRight = Implementation::AlignmentBottom|Implementation::AlignmentRight, BottomRight = Implementation::AlignmentBottom|Implementation::AlignmentRight,
@ -258,7 +258,7 @@ enum class Alignment: UnsignedByte {
/** /**
* Bottom right corner of the glyph bounding rectangle is at origin. * Bottom right corner of the glyph bounding rectangle is at origin.
* @see @ref Alignment::BottomRight, @ref Alignment::BottomEndGlyphBounds, * @see @ref Alignment::BottomRight, @ref Alignment::BottomEndGlyphBounds,
* @ref Alignment::BottomStartGlyphBounds * @ref Alignment::BottomBeginGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
BottomRightGlyphBounds = BottomRight|Implementation::AlignmentGlyphBounds, BottomRightGlyphBounds = BottomRight|Implementation::AlignmentGlyphBounds,
@ -269,7 +269,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
BottomStart = Implementation::AlignmentBottom|Implementation::AlignmentStart, BottomBegin = Implementation::AlignmentBottom|Implementation::AlignmentBegin,
/** /**
* @ref Alignment::BottomRightGlyphBounds for * @ref Alignment::BottomRightGlyphBounds for
@ -278,7 +278,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
BottomStartGlyphBounds = BottomStart|Implementation::AlignmentGlyphBounds, BottomBeginGlyphBounds = BottomBegin|Implementation::AlignmentGlyphBounds,
/** /**
* @ref Alignment::BottomLeft for @ref ShapeDirection::RightToLeft, * @ref Alignment::BottomLeft for @ref ShapeDirection::RightToLeft,
@ -301,7 +301,7 @@ enum class Alignment: UnsignedByte {
* Leftmost cursor position and a midpoint between topmost line ascent and * Leftmost cursor position and a midpoint between topmost line ascent and
* bottommost line descent is at origin. * bottommost line descent is at origin.
* @see @ref Alignment::MiddleLeftGlyphBounds, * @see @ref Alignment::MiddleLeftGlyphBounds,
* @ref Alignment::MiddleLeftIntegral, @ref Alignment::MiddleStart, * @ref Alignment::MiddleLeftIntegral, @ref Alignment::MiddleBegin,
* @ref Alignment::MiddleEnd * @ref Alignment::MiddleEnd
*/ */
MiddleLeft = Implementation::AlignmentMiddle|Implementation::AlignmentLeft, MiddleLeft = Implementation::AlignmentMiddle|Implementation::AlignmentLeft,
@ -312,7 +312,7 @@ enum class Alignment: UnsignedByte {
* to whole units. * to whole units.
* @see @ref Alignment::MiddleLeft, * @see @ref Alignment::MiddleLeft,
* @ref Alignment::MiddleLeftGlyphBoundsIntegral, * @ref Alignment::MiddleLeftGlyphBoundsIntegral,
* @ref Alignment::MiddleStartIntegral, * @ref Alignment::MiddleBeginIntegral,
* @ref Alignment::MiddleEndIntegral * @ref Alignment::MiddleEndIntegral
*/ */
MiddleLeftIntegral = MiddleLeft|Implementation::AlignmentIntegral, MiddleLeftIntegral = MiddleLeft|Implementation::AlignmentIntegral,
@ -322,7 +322,7 @@ enum class Alignment: UnsignedByte {
* origin. * origin.
* @see @ref Alignment::MiddleLeft, * @see @ref Alignment::MiddleLeft,
* @ref Alignment::MiddleLeftGlyphBoundsIntegral, * @ref Alignment::MiddleLeftGlyphBoundsIntegral,
* @ref Alignment::MiddleStartGlyphBounds, * @ref Alignment::MiddleBeginGlyphBounds,
* @ref Alignment::MiddleEndGlyphBounds * @ref Alignment::MiddleEndGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
@ -333,7 +333,7 @@ enum class Alignment: UnsignedByte {
* origin, with the vertical offset rounded to whole units. * origin, with the vertical offset rounded to whole units.
* @see @ref Alignment::MiddleLeftGlyphBounds, * @see @ref Alignment::MiddleLeftGlyphBounds,
* @ref Alignment::MiddleLeftIntegral, * @ref Alignment::MiddleLeftIntegral,
* @ref Alignment::MiddleStartGlyphBoundsIntegral, * @ref Alignment::MiddleBeginGlyphBoundsIntegral,
* @ref Alignment::MiddleEndGlyphBoundsIntegral * @ref Alignment::MiddleEndGlyphBoundsIntegral
* @m_since_latest * @m_since_latest
*/ */
@ -380,7 +380,7 @@ enum class Alignment: UnsignedByte {
* bottommost line descent is at origin. * bottommost line descent is at origin.
* @see @ref Alignment::MiddleRightGlyphBounds, * @see @ref Alignment::MiddleRightGlyphBounds,
* @ref Alignment::MiddleRightIntegral, @ref Alignment::MiddleEnd, * @ref Alignment::MiddleRightIntegral, @ref Alignment::MiddleEnd,
* @ref Alignment::MiddleStart * @ref Alignment::MiddleBegin
*/ */
MiddleRight = Implementation::AlignmentMiddle|Implementation::AlignmentRight, MiddleRight = Implementation::AlignmentMiddle|Implementation::AlignmentRight,
@ -391,7 +391,7 @@ enum class Alignment: UnsignedByte {
* @see @ref Alignment::MiddleRight, * @see @ref Alignment::MiddleRight,
* @ref Alignment::MiddleRightGlyphBoundsIntegral, * @ref Alignment::MiddleRightGlyphBoundsIntegral,
* @ref Alignment::MiddleEndIntegral, * @ref Alignment::MiddleEndIntegral,
* @ref Alignment::MiddleStartIntegral * @ref Alignment::MiddleBeginIntegral
*/ */
MiddleRightIntegral = MiddleRight|Implementation::AlignmentIntegral, MiddleRightIntegral = MiddleRight|Implementation::AlignmentIntegral,
@ -401,7 +401,7 @@ enum class Alignment: UnsignedByte {
* @see @ref Alignment::MiddleRight, * @see @ref Alignment::MiddleRight,
* @ref Alignment::MiddleRightGlyphBoundsIntegral, * @ref Alignment::MiddleRightGlyphBoundsIntegral,
* @ref Alignment::MiddleEndGlyphBounds, * @ref Alignment::MiddleEndGlyphBounds,
* @ref Alignment::MiddleStartGlyphBounds * @ref Alignment::MiddleBeginGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
MiddleRightGlyphBounds = MiddleRight|Implementation::AlignmentGlyphBounds, MiddleRightGlyphBounds = MiddleRight|Implementation::AlignmentGlyphBounds,
@ -412,7 +412,7 @@ enum class Alignment: UnsignedByte {
* @see @ref Alignment::MiddleRightGlyphBounds, * @see @ref Alignment::MiddleRightGlyphBounds,
* @ref Alignment::MiddleRightIntegral, * @ref Alignment::MiddleRightIntegral,
* @ref Alignment::MiddleEndGlyphBoundsIntegral, * @ref Alignment::MiddleEndGlyphBoundsIntegral,
* @ref Alignment::MiddleStartGlyphBoundsIntegral * @ref Alignment::MiddleBeginGlyphBoundsIntegral
* @m_since_latest * @m_since_latest
*/ */
MiddleRightGlyphBoundsIntegral = MiddleRightGlyphBounds|Implementation::AlignmentIntegral, MiddleRightGlyphBoundsIntegral = MiddleRightGlyphBounds|Implementation::AlignmentIntegral,
@ -423,7 +423,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
MiddleStart = Implementation::AlignmentMiddle|Implementation::AlignmentStart, MiddleBegin = Implementation::AlignmentMiddle|Implementation::AlignmentBegin,
/** /**
* @ref Alignment::MiddleRightIntegral for * @ref Alignment::MiddleRightIntegral for
@ -432,7 +432,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
MiddleStartIntegral = MiddleStart|Implementation::AlignmentIntegral, MiddleBeginIntegral = MiddleBegin|Implementation::AlignmentIntegral,
/** /**
* @ref Alignment::MiddleRightGlyphBounds for * @ref Alignment::MiddleRightGlyphBounds for
@ -441,7 +441,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
MiddleStartGlyphBounds = MiddleStart|Implementation::AlignmentGlyphBounds, MiddleBeginGlyphBounds = MiddleBegin|Implementation::AlignmentGlyphBounds,
/** /**
* @ref Alignment::MiddleRightGlyphBoundsIntegral for * @ref Alignment::MiddleRightGlyphBoundsIntegral for
@ -450,7 +450,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
MiddleStartGlyphBoundsIntegral = MiddleStartGlyphBounds|Implementation::AlignmentIntegral, MiddleBeginGlyphBoundsIntegral = MiddleBeginGlyphBounds|Implementation::AlignmentIntegral,
/** /**
* @ref Alignment::MiddleLeft for @ref ShapeDirection::RightToLeft, * @ref Alignment::MiddleLeft for @ref ShapeDirection::RightToLeft,
@ -489,14 +489,14 @@ enum class Alignment: UnsignedByte {
/** /**
* Leftmost cursor position and topmost line ascent is at origin. * Leftmost cursor position and topmost line ascent is at origin.
* @see @ref Alignment::TopLeftGlyphBounds, @ref Alignment::TopStart, * @see @ref Alignment::TopLeftGlyphBounds, @ref Alignment::TopBegin,
* @ref Alignment::TopEnd * @ref Alignment::TopEnd
*/ */
TopLeft = Implementation::AlignmentTop|Implementation::AlignmentLeft, TopLeft = Implementation::AlignmentTop|Implementation::AlignmentLeft,
/** /**
* Top left corner of the glyph bounding rectangle is at origin. * Top left corner of the glyph bounding rectangle is at origin.
* @see @ref Alignment::TopLeft, @ref Alignment::TopStartGlyphBounds, * @see @ref Alignment::TopLeft, @ref Alignment::TopBeginGlyphBounds,
* @ref Alignment::TopEndGlyphBounds * @ref Alignment::TopEndGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
@ -540,14 +540,14 @@ enum class Alignment: UnsignedByte {
/** /**
* Rightmost cursor position and topmost line ascent is at origin. * Rightmost cursor position and topmost line ascent is at origin.
* @see @ref Alignment::TopRightGlyphBounds, @ref Alignment::TopEnd, * @see @ref Alignment::TopRightGlyphBounds, @ref Alignment::TopEnd,
* @ref Alignment::TopStart * @ref Alignment::TopBegin
*/ */
TopRight = Implementation::AlignmentTop|Implementation::AlignmentRight, TopRight = Implementation::AlignmentTop|Implementation::AlignmentRight,
/** /**
* Top right corner of the glyph bounding rectangle is at origin. * Top right corner of the glyph bounding rectangle is at origin.
* @see @ref Alignment::TopRight, @ref Alignment::TopEndGlyphBounds, * @see @ref Alignment::TopRight, @ref Alignment::TopEndGlyphBounds,
* @ref Alignment::TopStartGlyphBounds * @ref Alignment::TopBeginGlyphBounds
* @m_since_latest * @m_since_latest
*/ */
TopRightGlyphBounds = TopRight|Implementation::AlignmentGlyphBounds, TopRightGlyphBounds = TopRight|Implementation::AlignmentGlyphBounds,
@ -558,7 +558,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
TopStart = Implementation::AlignmentTop|Implementation::AlignmentStart, TopBegin = Implementation::AlignmentTop|Implementation::AlignmentBegin,
/** /**
* @ref Alignment::TopRightGlyphBounds for * @ref Alignment::TopRightGlyphBounds for
@ -567,7 +567,7 @@ enum class Alignment: UnsignedByte {
* @see @ref alignmentForDirection() * @see @ref alignmentForDirection()
* @m_since_latest * @m_since_latest
*/ */
TopStartGlyphBounds = TopStart|Implementation::AlignmentGlyphBounds, TopBeginGlyphBounds = TopBegin|Implementation::AlignmentGlyphBounds,
/** /**
* @ref Alignment::TopLeft for @ref ShapeDirection::RightToLeft, * @ref Alignment::TopLeft for @ref ShapeDirection::RightToLeft,
@ -597,7 +597,7 @@ MAGNUM_TEXT_EXPORT Debug& operator<<(Debug& debug, Alignment value);
The @p layoutDirection is currently expected to always be The @p layoutDirection is currently expected to always be
@ref LayoutDirection::HorizontalTopToBottom and @p shapeDirection never @ref LayoutDirection::HorizontalTopToBottom and @p shapeDirection never
@ref ShapeDirection::TopToBottom or @ref ShapeDirection::BottomToTop. Then, if @ref ShapeDirection::TopToBottom or @ref ShapeDirection::BottomToTop. Then, if
@p alignment is `*Start` or `*End`, it's converted to `*Left` or `*Right`, @p alignment is `*Begin` or `*End`, it's converted to `*Left` or `*Right`,
respectively, if @p shapeDirection is @ref ShapeDirection::LeftToRight or respectively, if @p shapeDirection is @ref ShapeDirection::LeftToRight or
@ref ShapeDirection::Unspecified, and `*Right` or `*Left`, respectively, if @ref ShapeDirection::Unspecified, and `*Right` or `*Left`, respectively, if
@p shapeDirection is @ref ShapeDirection::RightToLeft. @p shapeDirection is @ref ShapeDirection::RightToLeft.

4
src/Magnum/Text/Renderer.cpp

@ -192,7 +192,7 @@ Range2D alignRenderedLine(const Range2D& lineRectangle, const LayoutDirection di
CORRADE_ASSERT(direction == LayoutDirection::HorizontalTopToBottom, CORRADE_ASSERT(direction == LayoutDirection::HorizontalTopToBottom,
"Text::alignRenderedLine(): only" << LayoutDirection::HorizontalTopToBottom << "is supported right now, got" << direction, {}); "Text::alignRenderedLine(): only" << LayoutDirection::HorizontalTopToBottom << "is supported right now, got" << direction, {});
CORRADE_ASSERT( CORRADE_ASSERT(
(UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentStart && (UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentBegin &&
(UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentEnd, (UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentEnd,
"Text::alignRenderedLine():" << alignment << "has to be resolved to *Left / *Right before being passed to this function", {}); "Text::alignRenderedLine():" << alignment << "has to be resolved to *Left / *Right before being passed to this function", {});
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT
@ -226,7 +226,7 @@ Range2D alignRenderedBlock(const Range2D& blockRectangle, const LayoutDirection
CORRADE_ASSERT(direction == LayoutDirection::HorizontalTopToBottom, CORRADE_ASSERT(direction == LayoutDirection::HorizontalTopToBottom,
"Text::alignRenderedBlock(): only" << LayoutDirection::HorizontalTopToBottom << "is supported right now, got" << direction, {}); "Text::alignRenderedBlock(): only" << LayoutDirection::HorizontalTopToBottom << "is supported right now, got" << direction, {});
CORRADE_ASSERT( CORRADE_ASSERT(
(UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentStart && (UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentBegin &&
(UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentEnd, (UnsignedByte(alignment) & Implementation::AlignmentHorizontal) != Implementation::AlignmentEnd,
"Text::alignRenderedBlock():" << alignment << "has to be resolved to *Left / *Right before being passed to this function", {}); "Text::alignRenderedBlock():" << alignment << "has to be resolved to *Left / *Right before being passed to this function", {});
#ifdef CORRADE_NO_ASSERT #ifdef CORRADE_NO_ASSERT

6
src/Magnum/Text/Test/AlignmentTest.cpp

@ -76,7 +76,7 @@ void AlignmentTest::forDirection() {
/* For Start / End it resolves based on ShapeDirection, keeping all extra /* For Start / End it resolves based on ShapeDirection, keeping all extra
bits as well */ bits as well */
CORRADE_COMPARE(alignmentForDirection( CORRADE_COMPARE(alignmentForDirection(
Alignment::TopStart, Alignment::TopBegin,
LayoutDirection::HorizontalTopToBottom, LayoutDirection::HorizontalTopToBottom,
ShapeDirection::LeftToRight ShapeDirection::LeftToRight
), Alignment::TopLeft); ), Alignment::TopLeft);
@ -86,7 +86,7 @@ void AlignmentTest::forDirection() {
ShapeDirection::LeftToRight ShapeDirection::LeftToRight
), Alignment::MiddleRightIntegral); ), Alignment::MiddleRightIntegral);
CORRADE_COMPARE(alignmentForDirection( CORRADE_COMPARE(alignmentForDirection(
Alignment::MiddleStartGlyphBoundsIntegral, Alignment::MiddleBeginGlyphBoundsIntegral,
LayoutDirection::HorizontalTopToBottom, LayoutDirection::HorizontalTopToBottom,
ShapeDirection::RightToLeft ShapeDirection::RightToLeft
), Alignment::MiddleRightGlyphBoundsIntegral); ), Alignment::MiddleRightGlyphBoundsIntegral);
@ -98,7 +98,7 @@ void AlignmentTest::forDirection() {
/* Unspecified ShapeDirection behaves same as LeftToRight */ /* Unspecified ShapeDirection behaves same as LeftToRight */
CORRADE_COMPARE(alignmentForDirection( CORRADE_COMPARE(alignmentForDirection(
Alignment::BottomStart, Alignment::BottomBegin,
LayoutDirection::HorizontalTopToBottom, LayoutDirection::HorizontalTopToBottom,
ShapeDirection::Unspecified ShapeDirection::Unspecified
), Alignment::BottomLeft); ), Alignment::BottomLeft);

16
src/Magnum/Text/Test/RendererTest.cpp

@ -222,11 +222,11 @@ const struct {
{"bottom right, glyph bounds", {"bottom right, glyph bounds",
Alignment::BottomRightGlyphBounds, ShapeDirection::Unspecified, Alignment::BottomRightGlyphBounds, ShapeDirection::Unspecified,
{-12.5f, -3.75f}}, {-12.5f, -3.75f}},
{"line start, direction unspecified", {"line begin, direction unspecified",
Alignment::LineStart, ShapeDirection::Unspecified, Alignment::LineBegin, ShapeDirection::Unspecified,
{}}, /* Same as line left, thus no shift */ {}}, /* Same as line left, thus no shift */
{"bottom start, LTR", {"bottom begin, LTR",
Alignment::BottomStart, ShapeDirection::LeftToRight, Alignment::BottomBegin, ShapeDirection::LeftToRight,
{0.0f, 1.25f}}, /* Same as bottom left */ {0.0f, 1.25f}}, /* Same as bottom left */
{"line end, RTL", {"line end, RTL",
Alignment::LineEnd, ShapeDirection::RightToLeft, Alignment::LineEnd, ShapeDirection::RightToLeft,
@ -237,8 +237,8 @@ const struct {
{"top end, LTR", {"top end, LTR",
Alignment::TopEnd, ShapeDirection::LeftToRight, Alignment::TopEnd, ShapeDirection::LeftToRight,
{-3.0f, -2.25f}}, /* Same as top right */ {-3.0f, -2.25f}}, /* Same as top right */
{"line start, RTL", {"line begin, RTL",
Alignment::LineStart, ShapeDirection::RightToLeft, Alignment::LineBegin, ShapeDirection::RightToLeft,
{-3.0f, 0.0f}}, /* Same as line right */ {-3.0f, 0.0f}}, /* Same as line right */
{"line left, RTL", {"line left, RTL",
Alignment::LineLeft, ShapeDirection::RightToLeft, Alignment::LineLeft, ShapeDirection::RightToLeft,
@ -935,10 +935,10 @@ void RendererTest::alignBlockInvalidDirection() {
Containers::String out; Containers::String out;
Error redirectError{&out}; Error redirectError{&out};
alignRenderedBlock({}, LayoutDirection::VerticalRightToLeft, Alignment::LineLeft, nullptr); alignRenderedBlock({}, LayoutDirection::VerticalRightToLeft, Alignment::LineLeft, nullptr);
alignRenderedBlock({}, LayoutDirection::HorizontalTopToBottom, Alignment::LineStartGlyphBounds, nullptr); alignRenderedBlock({}, LayoutDirection::HorizontalTopToBottom, Alignment::LineBeginGlyphBounds, nullptr);
CORRADE_COMPARE_AS(out, CORRADE_COMPARE_AS(out,
"Text::alignRenderedBlock(): only Text::LayoutDirection::HorizontalTopToBottom is supported right now, got Text::LayoutDirection::VerticalRightToLeft\n" "Text::alignRenderedBlock(): only Text::LayoutDirection::HorizontalTopToBottom is supported right now, got Text::LayoutDirection::VerticalRightToLeft\n"
"Text::alignRenderedBlock(): Text::Alignment::LineStartGlyphBounds has to be resolved to *Left / *Right before being passed to this function\n", "Text::alignRenderedBlock(): Text::Alignment::LineBeginGlyphBounds has to be resolved to *Left / *Right before being passed to this function\n",
TestSuite::Compare::String); TestSuite::Compare::String);
} }

Loading…
Cancel
Save