Browse Source

StandaloneFilterWindow: Account for native frame size in constrainer

pull/22/head
reuk 3 years ago
parent
commit
ae646dde16
No known key found for this signature in database GPG Key ID: 9ADCD339CFC98A11
2 changed files with 37 additions and 19 deletions
  1. +11
    -5
      modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h
  2. +26
    -14
      modules/juce_graphics/geometry/juce_BorderSize.h

+ 11
- 5
modules/juce_audio_plugin_client/Standalone/juce_StandaloneFilterWindow.h View File

@@ -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:


+ 26
- 14
modules/juce_graphics/geometry/juce_BorderSize.h View File

@@ -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…
Cancel
Save