45 Justification (
int justificationFlags) noexcept : flags (justificationFlags) {}
53 bool operator== (
const Justification& other)
const noexcept {
return flags == other.flags; }
54 bool operator!= (
const Justification& other)
const noexcept {
return flags != other.flags; }
58 inline int getFlags() const noexcept {
return flags; }
63 inline bool testFlags (
int flagsToTest)
const noexcept {
return (flags & flagsToTest) != 0; }
77 template <
typename ValueType>
79 ValueType spaceX, ValueType spaceY, ValueType spaceW, ValueType spaceH)
const noexcept
83 else if ((flags &
right) != 0) x += spaceW - w;
87 else if ((flags &
bottom) != 0) y += spaceH - h;
92 template <
typename ValueType>
96 ValueType x = areaToAdjust.getX(), y = areaToAdjust.getY();
98 targetSpace.getX(), targetSpace.getY(), targetSpace.getWidth(), targetSpace.getHeight());
99 return areaToAdjust.withPosition (x, y);
Represents a type of justification to be used when positioning graphical items.
Flags
Flag values that can be combined and used in the constructor.
@ centredRight
Indicates that the item should be centred vertically but placed on the right hand side.
@ horizontallyJustified
Indicates that lines of text should be spread out to fill the maximum width available,...
@ centredBottom
Indicates that the item should be centred horizontally and placed at the bottom.
@ centred
Indicates that the item should be centred vertically and horizontally.
@ left
Indicates that the item should be aligned against the left edge of the available space.
@ centredLeft
Indicates that the item should be centred vertically but placed on the left hand side.
@ horizontallyCentred
Indicates that the item should be placed in the centre between the left and right sides of the availa...
@ centredTop
Indicates that the item should be centred horizontally and placed at the top.
@ bottom
Indicates that the item should be aligned against the bottom edge of the available space.
@ verticallyCentred
Indicates that the item should be placed in the centre between the top and bottom sides of the availa...
@ top
Indicates that the item should be aligned against the top edge of the available space.
@ right
Indicates that the item should be aligned against the right edge of the available space.
@ bottomLeft
Indicates that the item should be placed in the bottom-left corner.
@ bottomRight
Indicates that the item should be placed in the bottom-left corner.
@ topLeft
Indicates that the item should be placed in the top-left corner.
@ topRight
Indicates that the item should be placed in the top-right corner.
const Rectangle< ValueType > appliedToRectangle(const Rectangle< ValueType > &areaToAdjust, const Rectangle< ValueType > &targetSpace) const noexcept
Returns the new position of a rectangle that has been justified to fit within a given space.
void applyToRectangle(ValueType &x, ValueType &y, ValueType w, ValueType h, ValueType spaceX, ValueType spaceY, ValueType spaceW, ValueType spaceH) const noexcept
Adjusts the position of a rectangle to fit it into a space.
int getOnlyVerticalFlags() const noexcept
Returns just the flags from this object that deal with vertical layout.
Justification(const Justification &)=default
Creates a copy of another Justification object.
int getOnlyHorizontalFlags() const noexcept
Returns just the flags from this object that deal with horizontal layout.
Justification & operator=(const Justification &)=default
Copies another Justification object.
int getFlags() const noexcept
Returns the raw flags that are set for this Justification object.
Justification(int justificationFlags) noexcept
Creates a Justification object using a combination of flags from the Flags enum.
bool testFlags(int flagsToTest) const noexcept
Tests a set of flags for this object.
Manages a rectangle and allows geometric operations to be performed on it.