mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
StandaloneFilterWindow: Account for native frame size in constrainer
This commit is contained in:
parent
ee06a2364b
commit
ae646dde16
2 changed files with 37 additions and 19 deletions
|
|
@ -940,11 +940,17 @@ private:
|
|||
|
||||
BorderSize<int> computeBorder() const
|
||||
{
|
||||
const auto outer = owner.getContentComponentBorder();
|
||||
return { outer.getTop() + (shouldShowNotification ? NotificationArea::height : 0),
|
||||
outer.getLeft(),
|
||||
outer.getBottom(),
|
||||
outer.getRight() };
|
||||
const auto nativeFrame = [&]() -> BorderSize<int>
|
||||
{
|
||||
if (auto* peer = owner.getPeer())
|
||||
if (const auto frameSize = peer->getFrameSizeIfPresent())
|
||||
return *frameSize;
|
||||
|
||||
return {};
|
||||
}();
|
||||
|
||||
return nativeFrame.addedTo (owner.getContentComponentBorder())
|
||||
.addedTo (BorderSize<int> { shouldShowNotification ? NotificationArea::height : 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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{};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue