Browse Source

Added an exit callback to BluetoothMidiDevicePairingDialogue::open()

tags/2021-05-28
XmasRights 9 years ago
parent
commit
4b881b0765
6 changed files with 33 additions and 14 deletions
  1. +5
    -1
      modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h
  2. +8
    -4
      modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp
  3. +14
    -6
      modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm
  4. +2
    -1
      modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp
  5. +2
    -1
      modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm
  6. +2
    -1
      modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp

+ 5
- 1
modules/juce_audio_utils/gui/juce_BluetoothMidiDevicePairingDialogue.h View File

@@ -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.


+ 8
- 4
modules/juce_audio_utils/native/juce_android_BluetoothMidiDevicePairingDialogue.cpp View File

@@ -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;
} }


+ 14
- 6
modules/juce_audio_utils/native/juce_ios_BluetoothMidiDevicePairingDialogue.mm View File

@@ -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

+ 2
- 1
modules/juce_audio_utils/native/juce_linux_BluetoothMidiDevicePairingDialogue.cpp View File

@@ -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().


+ 2
- 1
modules/juce_audio_utils/native/juce_mac_BluetoothMidiDevicePairingDialogue.mm View File

@@ -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;


+ 2
- 1
modules/juce_audio_utils/native/juce_win_BluetoothMidiDevicePairingDialogue.cpp View File

@@ -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().


Loading…
Cancel
Save