|
|
|
@@ -40,6 +40,8 @@ namespace juce |
|
|
|
template <typename ValueType>
|
|
|
|
class BorderSize
|
|
|
|
{
|
|
|
|
auto tie() const { return std::tie (top, left, bottom, right); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
//==============================================================================
|
|
|
|
/** Creates a null border.
|
|
|
|
@@ -98,10 +100,10 @@ public: |
|
|
|
/** Returns a rectangle with these borders removed from it. */
|
|
|
|
Rectangle<ValueType> subtractedFrom (const Rectangle<ValueType>& original) const noexcept
|
|
|
|
{
|
|
|
|
return Rectangle<ValueType> (original.getX() + left,
|
|
|
|
original.getY() + top,
|
|
|
|
original.getWidth() - (left + right),
|
|
|
|
original.getHeight() - (top + bottom));
|
|
|
|
return { original.getX() + left,
|
|
|
|
original.getY() + top,
|
|
|
|
original.getWidth() - (left + right),
|
|
|
|
original.getHeight() - (top + bottom) };
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Removes this border from a given rectangle. */
|
|
|
|
@@ -113,30 +115,40 @@ public: |
|
|
|
/** Returns a rectangle with these borders added around it. */
|
|
|
|
Rectangle<ValueType> addedTo (const Rectangle<ValueType>& original) const noexcept
|
|
|
|
{
|
|
|
|
return Rectangle<ValueType> (original.getX() - left,
|
|
|
|
original.getY() - top,
|
|
|
|
original.getWidth() + (left + right),
|
|
|
|
original.getHeight() + (top + bottom));
|
|
|
|
return { original.getX() - left,
|
|
|
|
original.getY() - top,
|
|
|
|
original.getWidth() + (left + right),
|
|
|
|
original.getHeight() + (top + bottom) };
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Adds this border around a given rectangle. */
|
|
|
|
void addTo (Rectangle<ValueType>& rectangle) const noexcept
|
|
|
|
{
|
|
|
|
rectangle = addedTo (rectangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
bool operator== (const BorderSize& other) const noexcept
|
|
|
|
/** Removes this border from another border. */
|
|
|
|
BorderSize<ValueType> subtractedFrom (const BorderSize<ValueType>& other) const noexcept
|
|
|
|
{
|
|
|
|
return top == other.top && left == other.left && bottom == other.bottom && right == other.right;
|
|
|
|
return { other.top - top,
|
|
|
|
other.left - left,
|
|
|
|
other.bottom - bottom,
|
|
|
|
other.right - right };
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator!= (const BorderSize& other) const noexcept
|
|
|
|
/** Adds this border to another border. */
|
|
|
|
BorderSize<ValueType> addedTo (const BorderSize<ValueType>& other) const noexcept
|
|
|
|
{
|
|
|
|
return ! operator== (other);
|
|
|
|
return { other.top + top,
|
|
|
|
other.left + left,
|
|
|
|
other.bottom + bottom,
|
|
|
|
other.right + right };
|
|
|
|
}
|
|
|
|
|
|
|
|
//==============================================================================
|
|
|
|
bool operator== (const BorderSize& other) const noexcept { return tie() == other.tie(); }
|
|
|
|
bool operator!= (const BorderSize& other) const noexcept { return tie() != other.tie(); }
|
|
|
|
|
|
|
|
private:
|
|
|
|
//==============================================================================
|
|
|
|
ValueType top{}, left{}, bottom{}, right{};
|
|
|
|
|