| @@ -48,9 +48,13 @@ public: | |||||
| /** Opens the Bluetooth MIDI pairing dialogue, if it is available. | /** Opens the Bluetooth MIDI pairing dialogue, if it is available. | ||||
| @param exitCallback A callback which will be called when the modal | |||||
| bluetooth dialog is closed. | |||||
| @return true if the dialogue was opened, false on error. | @return true if the dialogue was opened, false on error. | ||||
| @see ModalComponentManager::Callback | |||||
| */ | */ | ||||
| static bool open(); | |||||
| static bool open (ModalComponentManager::Callback* exitCallback = nullptr); | |||||
| /** Checks if a Bluetooth MIDI pairing dialogue is available on this | /** Checks if a Bluetooth MIDI pairing dialogue is available on this | ||||
| platform. | platform. | ||||
| @@ -362,8 +362,10 @@ private: | |||||
| class BluetoothMidiSelectorOverlay : public Component | class BluetoothMidiSelectorOverlay : public Component | ||||
| { | { | ||||
| public: | public: | ||||
| BluetoothMidiSelectorOverlay() | |||||
| BluetoothMidiSelectorOverlay (ModalComponentManager::Callback* exitCallbackToUse) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> exitCallback (exitCallbackToUse); | |||||
| setAlwaysOnTop (true); | setAlwaysOnTop (true); | ||||
| setVisible (true); | setVisible (true); | ||||
| addToDesktop (ComponentPeer::windowHasDropShadow); | addToDesktop (ComponentPeer::windowHasDropShadow); | ||||
| @@ -371,7 +373,7 @@ public: | |||||
| toFront (true); | toFront (true); | ||||
| addAndMakeVisible (bluetoothDevicesList); | addAndMakeVisible (bluetoothDevicesList); | ||||
| enterModalState (true, nullptr, true); | |||||
| enterModalState (true, exitCallback.release(), true); | |||||
| } | } | ||||
| void paint (Graphics& g) override | void paint (Graphics& g) override | ||||
| @@ -424,8 +426,10 @@ private: | |||||
| }; | }; | ||||
| //============================================================================== | //============================================================================== | ||||
| bool BluetoothMidiDevicePairingDialogue::open() | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallbackPtr) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> exitCallback (exitCallbackPtr); | |||||
| if (! RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi)) | if (! RuntimePermissions::isGranted (RuntimePermissions::bluetoothMidi)) | ||||
| { | { | ||||
| // If you hit this assert, you probably forgot to get RuntimePermissions::bluetoothMidi. | // If you hit this assert, you probably forgot to get RuntimePermissions::bluetoothMidi. | ||||
| @@ -435,7 +439,7 @@ bool BluetoothMidiDevicePairingDialogue::open() | |||||
| return false; | return false; | ||||
| } | } | ||||
| BluetoothMidiSelectorOverlay* overlay = new BluetoothMidiSelectorOverlay; | |||||
| BluetoothMidiSelectorOverlay* overlay = new BluetoothMidiSelectorOverlay (exitCallback.release()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -40,8 +40,10 @@ namespace juce | |||||
| class BluetoothMidiSelectorOverlay : public Component | class BluetoothMidiSelectorOverlay : public Component | ||||
| { | { | ||||
| public: | public: | ||||
| BluetoothMidiSelectorOverlay() | |||||
| BluetoothMidiSelectorOverlay (ModalComponentManager::Callback* exitCallbackToUse) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> exitCallback; | |||||
| setAlwaysOnTop (true); | setAlwaysOnTop (true); | ||||
| setVisible (true); | setVisible (true); | ||||
| addToDesktop (ComponentPeer::windowHasDropShadow); | addToDesktop (ComponentPeer::windowHasDropShadow); | ||||
| @@ -53,7 +55,7 @@ public: | |||||
| addAndMakeVisible (nativeSelectorComponent); | addAndMakeVisible (nativeSelectorComponent); | ||||
| enterModalState (true, nullptr, true); | |||||
| enterModalState (true, exitCallback.release(), true); | |||||
| } | } | ||||
| ~BluetoothMidiSelectorOverlay() | ~BluetoothMidiSelectorOverlay() | ||||
| @@ -96,11 +98,13 @@ private: | |||||
| JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BluetoothMidiSelectorOverlay) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BluetoothMidiSelectorOverlay) | ||||
| }; | }; | ||||
| bool BluetoothMidiDevicePairingDialogue::open() | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> cb (exitCallback); | |||||
| if (isAvailable()) | if (isAvailable()) | ||||
| { | { | ||||
| new BluetoothMidiSelectorOverlay(); | |||||
| new BluetoothMidiSelectorOverlay (cb.release()); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -115,7 +119,11 @@ bool BluetoothMidiDevicePairingDialogue::isAvailable() | |||||
| //============================================================================== | //============================================================================== | ||||
| #else | #else | ||||
| bool BluetoothMidiDevicePairingDialogue::open() { return false; } | |||||
| bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) | |||||
| { | |||||
| ScopedPointer<ModalComponentManager::Callback> cb (exitCallback); | |||||
| return false; | |||||
| } | |||||
| bool BluetoothMidiDevicePairingDialogue::isAvailable() { return false; } | |||||
| #endif | #endif | ||||
| @@ -22,8 +22,9 @@ | |||||
| ============================================================================== | ============================================================================== | ||||
| */ | */ | ||||
| bool BluetoothMidiDevicePairingDialogue::open() | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> cb (exitCallback); | |||||
| // not implemented on Linux yet! | // not implemented on Linux yet! | ||||
| // You should check whether the dialogue is available on your system | // You should check whether the dialogue is available on your system | ||||
| // using isAvailable() before calling open(). | // using isAvailable() before calling open(). | ||||
| @@ -22,8 +22,9 @@ | |||||
| ============================================================================== | ============================================================================== | ||||
| */ | */ | ||||
| bool BluetoothMidiDevicePairingDialogue::open() | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> cb (exitCallback); | |||||
| // Do not call this on OSX. Instead, you should pair Bluetooth MIDI devices | // Do not call this on OSX. Instead, you should pair Bluetooth MIDI devices | ||||
| // using the "Audio MIDI Setup" app (located in /Applications/Utilities). | // using the "Audio MIDI Setup" app (located in /Applications/Utilities). | ||||
| jassertfalse; | jassertfalse; | ||||
| @@ -22,8 +22,9 @@ | |||||
| ============================================================================== | ============================================================================== | ||||
| */ | */ | ||||
| bool BluetoothMidiDevicePairingDialogue::open() | |||||
| bool BluetoothMidiDevicePairingDialogue::open (ModalComponentManager::Callback* exitCallback) | |||||
| { | { | ||||
| ScopedPointer<ModalComponentManager::Callback> cb (exitCallback); | |||||
| // not implemented on Windows yet! | // not implemented on Windows yet! | ||||
| // You should check whether the dialogue is available on your system | // You should check whether the dialogue is available on your system | ||||
| // using isAvailable() before calling open(). | // using isAvailable() before calling open(). | ||||