From 4201b76d15c590bb76c129b0e54ac19c6be29cca Mon Sep 17 00:00:00 2001 From: reuk Date: Thu, 23 May 2024 15:54:55 +0100 Subject: [PATCH] ResizableWindow: Add const to virtual members --- BREAKING_CHANGES.md | 21 +++++++++++++++++++ .../AudioPluginHost/Source/UI/PluginWindow.h | 2 +- .../windows/juce_DocumentWindow.cpp | 7 +------ .../windows/juce_DocumentWindow.h | 4 +--- .../windows/juce_ResizableWindow.cpp | 4 ++-- .../windows/juce_ResizableWindow.h | 4 ++-- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index cb7cdc8e88..55c63dd634 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -2,6 +2,27 @@ # Version 8.0.0 +## Change + +The virtual functions ResizableWindow::getBorderThickness() and +ResizableWindow::getContentComponentBorder() are now const. + +**Possible Issues** + +Classes overriding these functions will fail to compile. + +**Workaround** + +Add 'const' to overriding functions. + +**Rationale** + +Omitting 'const' from these functions implies that they may change the state of +the ResizableWindow, which would be unexpected behaviour for getter functions. +It also means that the functions cannot be called from const member functions, +which limits their usefulness. + + ## Change As part of the Unicode upgrades TextLayout codepaths have been unified across diff --git a/extras/AudioPluginHost/Source/UI/PluginWindow.h b/extras/AudioPluginHost/Source/UI/PluginWindow.h index 418e1673c2..161d81012e 100644 --- a/extras/AudioPluginHost/Source/UI/PluginWindow.h +++ b/extras/AudioPluginHost/Source/UI/PluginWindow.h @@ -233,7 +233,7 @@ public: const AudioProcessorGraph::Node::Ptr node; const Type type; - BorderSize getBorderThickness() override + BorderSize getBorderThickness() const override { #if JUCE_IOS || JUCE_ANDROID const int border = 10; diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 60b16803c7..7a6263d0f9 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -247,12 +247,7 @@ void DocumentWindow::resized() titleBarArea.getWidth(), menuBarHeight); } -BorderSize DocumentWindow::getBorderThickness() -{ - return ResizableWindow::getBorderThickness(); -} - -BorderSize DocumentWindow::getContentComponentBorder() +BorderSize DocumentWindow::getContentComponentBorder() const { auto border = getBorderThickness(); diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 2d93465fa2..43116882e3 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -279,9 +279,7 @@ public: /** @internal */ void lookAndFeelChanged() override; /** @internal */ - BorderSize getBorderThickness() override; - /** @internal */ - BorderSize getContentComponentBorder() override; + BorderSize getContentComponentBorder() const override; /** @internal */ void mouseDoubleClick (const MouseEvent&) override; /** @internal */ diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index bfd9e356fc..fddb30b721 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -160,7 +160,7 @@ void ResizableWindow::setContentComponentSize (int width, int height) height + border.getTopAndBottom()); } -BorderSize ResizableWindow::getBorderThickness() +BorderSize ResizableWindow::getBorderThickness() const { if (isUsingNativeTitleBar() || isKioskMode()) return {}; @@ -168,7 +168,7 @@ BorderSize ResizableWindow::getBorderThickness() return BorderSize ((resizableBorder != nullptr && ! isFullScreen()) ? 4 : 1); } -BorderSize ResizableWindow::getContentComponentBorder() +BorderSize ResizableWindow::getContentComponentBorder() const { return getBorderThickness(); } diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 50f70d9560..2542590049 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -301,12 +301,12 @@ public: /** Returns the width of the frame to use around the window. @see getContentComponentBorder */ - virtual BorderSize getBorderThickness(); + virtual BorderSize getBorderThickness() const; /** Returns the insets to use when positioning the content component. @see getBorderThickness */ - virtual BorderSize getContentComponentBorder(); + virtual BorderSize getContentComponentBorder() const; //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the window.