1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

ResizableWindow: Disable resizing border for desktop windows

This commit is contained in:
reuk 2024-05-30 17:48:23 +01:00
parent 659de5842f
commit f764026626
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
4 changed files with 25 additions and 4 deletions

View file

@ -374,4 +374,13 @@ bool Desktop::isHeadless() const noexcept
return displays->displays.isEmpty();
}
bool Desktop::supportsBorderlessNonClientResize() const
{
#if JUCE_WINDOWS || JUCE_MAC
return true;
#else
return false;
#endif
}
} // namespace juce

View file

@ -412,6 +412,12 @@ public:
static bool isOSXDarkModeActive() { return Desktop::getInstance().isDarkModeActive(); }
#endif
/** Returns true if the desktop environment allows resizing the window by clicking and dragging
just on/outside the window border.
MacOS and Windows 10+ both support this. Linux doesn't seem to. Mobile platforms do not.
*/
bool supportsBorderlessNonClientResize() const;
//==============================================================================
/** Returns true on a headless system where there are no connected displays. */
bool isHeadless() const noexcept;

View file

@ -254,6 +254,8 @@ void ResizableWindow::activeWindowStatusChanged()
void ResizableWindow::setResizable (const bool shouldBeResizable,
const bool useBottomRightCornerResizer)
{
resizable = shouldBeResizable;
if (shouldBeResizable)
{
if (useBottomRightCornerResizer)
@ -271,7 +273,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
{
resizableCorner.reset();
if (resizableBorder == nullptr)
if (resizableBorder == nullptr && (! isOnDesktop() || ! Desktop::getInstance().supportsBorderlessNonClientResize()))
{
resizableBorder.reset (new ResizableBorderComponent (this, constrainer));
Component::addChildComponent (resizableBorder.get());
@ -293,8 +295,7 @@ void ResizableWindow::setResizable (const bool shouldBeResizable,
bool ResizableWindow::isResizable() const noexcept
{
return resizableCorner != nullptr
|| resizableBorder != nullptr;
return resizable;
}
void ResizableWindow::setResizeLimits (int newMinimumWidth,

View file

@ -401,7 +401,12 @@ protected:
private:
//==============================================================================
Component::SafePointer<Component> contentComponent;
bool ownsContentComponent = false, resizeToFitContent = false, fullscreen = false, canDrag = true, dragStarted = false;
bool ownsContentComponent = false;
bool resizeToFitContent = false;
bool fullscreen = false;
bool canDrag = true;
bool dragStarted = false;
bool resizable = false;
ComponentDragger dragger;
Rectangle<int> lastNonFullScreenPos;
ComponentBoundsConstrainer defaultConstrainer;