From 3816b095a8b6051521613baec8923392dfa669fc Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 22 Feb 2023 21:02:41 +0000 Subject: [PATCH] MessageBoxOptions: DRY implementation --- .../windows/juce_MessageBoxOptions.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/modules/juce_gui_basics/windows/juce_MessageBoxOptions.h b/modules/juce_gui_basics/windows/juce_MessageBoxOptions.h index eac1f76afe..003184562c 100644 --- a/modules/juce_gui_basics/windows/juce_MessageBoxOptions.h +++ b/modules/juce_gui_basics/windows/juce_MessageBoxOptions.h @@ -68,13 +68,13 @@ public: //============================================================================== /** Sets the type of icon that should be used for the dialog box. */ - [[nodiscard]] MessageBoxOptions withIconType (MessageBoxIconType type) const { return with (*this, &MessageBoxOptions::iconType, type); } + [[nodiscard]] MessageBoxOptions withIconType (MessageBoxIconType type) const { return withMember (*this, &MessageBoxOptions::iconType, type); } /** Sets the title of the dialog box. */ - [[nodiscard]] MessageBoxOptions withTitle (const String& boxTitle) const { return with (*this, &MessageBoxOptions::title, boxTitle); } + [[nodiscard]] MessageBoxOptions withTitle (const String& boxTitle) const { return withMember (*this, &MessageBoxOptions::title, boxTitle); } /** Sets the message that should be displayed in the dialog box. */ - [[nodiscard]] MessageBoxOptions withMessage (const String& boxMessage) const { return with (*this, &MessageBoxOptions::message, boxMessage); } + [[nodiscard]] MessageBoxOptions withMessage (const String& boxMessage) const { return withMember (*this, &MessageBoxOptions::message, boxMessage); } /** If the string passed in is not empty, this will add a button to the dialog box with the specified text. @@ -85,14 +85,14 @@ public: [[nodiscard]] MessageBoxOptions withButton (const String& text) const { auto copy = *this; copy.buttons.add (text); return copy; } /** The component that the dialog box should be associated with. */ - [[nodiscard]] MessageBoxOptions withAssociatedComponent (Component* component) const { return with (*this, &MessageBoxOptions::associatedComponent, component); } + [[nodiscard]] MessageBoxOptions withAssociatedComponent (Component* component) const { return withMember (*this, &MessageBoxOptions::associatedComponent, component); } /** The component that will contain the message box (e.g. the AudioProcessorEditor in a plugin). This will only affect JUCE AlertWindows. It won't affect the drawing of native message boxes. This is mainly intended for use in AU plugins, where opening additional windows can be problematic. */ - [[nodiscard]] MessageBoxOptions withParentComponent (Component* component) const { return with (*this, &MessageBoxOptions::parentComponent, component); } + [[nodiscard]] MessageBoxOptions withParentComponent (Component* component) const { return withMember (*this, &MessageBoxOptions::parentComponent, component); } //============================================================================== /** Returns the icon type of the dialog box. @@ -182,14 +182,6 @@ public: Component* associatedComponent = nullptr); private: - //============================================================================== - template - static MessageBoxOptions with (MessageBoxOptions options, Member&& member, Item&& item) - { - options.*member = std::forward (item); - return options; - } - //============================================================================== MessageBoxIconType iconType = MessageBoxIconType::InfoIcon; String title, message;