| @@ -104,23 +104,29 @@ void ComponentBoundsConstrainer::setBoundsForComponent (Component* component, | |||||
| { | { | ||||
| jassert (component != nullptr); | jassert (component != nullptr); | ||||
| Rectangle<int> limits, bounds (targetBounds); | |||||
| BorderSize<int> border; | |||||
| auto bounds = targetBounds; | |||||
| if (auto* parent = component->getParentComponent()) | |||||
| auto limits = [&]() -> Rectangle<int> | |||||
| { | { | ||||
| limits.setSize (parent->getWidth(), parent->getHeight()); | |||||
| } | |||||
| else | |||||
| { | |||||
| if (auto* peer = component->getPeer()) | |||||
| if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
| border = *frameSize; | |||||
| if (auto* parent = component->getParentComponent()) | |||||
| return { parent->getWidth(), parent->getHeight() }; | |||||
| auto screenBounds = Desktop::getInstance().getDisplays().getDisplayForPoint (targetBounds.getCentre())->userArea; | |||||
| if (auto* display = Desktop::getInstance().getDisplays().getDisplayForPoint (targetBounds.getCentre())) | |||||
| return component->getLocalArea (nullptr, display->userArea) + component->getPosition(); | |||||
| limits = component->getLocalArea (nullptr, screenBounds) + component->getPosition(); | |||||
| } | |||||
| const auto max = std::numeric_limits<int>::max(); | |||||
| return { max, max }; | |||||
| }(); | |||||
| auto border = [&]() -> BorderSize<int> | |||||
| { | |||||
| if (component->getParentComponent() == nullptr) | |||||
| if (auto* peer = component->getPeer()) | |||||
| if (const auto frameSize = peer->getFrameSizeIfPresent()) | |||||
| return *frameSize; | |||||
| return {}; | |||||
| }(); | |||||
| border.addTo (bounds); | border.addTo (bounds); | ||||