40template <
typename ValueType>
43 auto tie()
const {
return std::tie (top, left, bottom, right); }
84 bool isEmpty()
const noexcept {
return left + right + top + bottom == ValueType(); }
105 original.getWidth() - (left + right),
106 original.getHeight() - (top + bottom) };
120 original.getWidth() + (left + right),
121 original.getHeight() + (top + bottom) };
127 rectangle =
addedTo (rectangle);
133 return {
other.top - top,
135 other.bottom - bottom,
136 other.right - right };
142 return {
other.top + top,
144 other.bottom + bottom,
145 other.right + right };
149 template <
typename ScalarType>
152 return {
static_cast<ValueType
> (
scalar * top),
153 static_cast<ValueType
> (
scalar * left),
154 static_cast<ValueType
> (
scalar * bottom),
155 static_cast<ValueType
> (
scalar * right) };
164 ValueType top{}, left{}, bottom{}, right{};
Specifies a set of gaps to be left around the sides of a rectangle.
void setTop(ValueType newTopGap) noexcept
Changes the top gap.
void setRight(ValueType newRightGap) noexcept
Changes the right gap.
BorderSize()=default
Creates a null border.
ValueType getTopAndBottom() const noexcept
Returns the sum of the top and bottom gaps.
BorderSize(ValueType topGap, ValueType leftGap, ValueType bottomGap, ValueType rightGap) noexcept
Creates a border with the given gaps.
BorderSize(ValueType allGaps) noexcept
Creates a border with the given gap on all sides.
ValueType getTop() const noexcept
Returns the gap that should be left at the top of the region.
bool isEmpty() const noexcept
Returns true if this border has no thickness along any edge.
BorderSize< ValueType > addedTo(const BorderSize< ValueType > &other) const noexcept
Adds this border to another border.
ValueType getLeft() const noexcept
Returns the gap that should be left at the left of the region.
BorderSize< ValueType > subtractedFrom(const BorderSize< ValueType > &other) const noexcept
Removes this border from another border.
Rectangle< ValueType > addedTo(const Rectangle< ValueType > &original) const noexcept
Returns a rectangle with these borders added around it.
BorderSize< ValueType > multipliedBy(ScalarType scalar) const noexcept
Multiplies each member of the border by a scalar.
Rectangle< ValueType > subtractedFrom(const Rectangle< ValueType > &original) const noexcept
Returns a rectangle with these borders removed from it.
ValueType getLeftAndRight() const noexcept
Returns the sum of the left and right gaps.
void subtractFrom(Rectangle< ValueType > &rectangle) const noexcept
Removes this border from a given rectangle.
ValueType getRight() const noexcept
Returns the gap that should be left at the right of the region.
void addTo(Rectangle< ValueType > &rectangle) const noexcept
Adds this border around a given rectangle.
void setBottom(ValueType newBottomGap) noexcept
Changes the bottom gap.
void setLeft(ValueType newLeftGap) noexcept
Changes the left gap.
ValueType getBottom() const noexcept
Returns the gap that should be left at the bottom of the region.
Manages a rectangle and allows geometric operations to be performed on it.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...