Make project windows (possibly Linux) compatible
This commit is contained in:
@@ -23,7 +23,9 @@ public:
|
|||||||
LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
|
LookAndFeel::setDefaultLookAndFeel (&lookAndFeel);
|
||||||
|
|
||||||
mainWindow = new IconMenu();
|
mainWindow = new IconMenu();
|
||||||
|
#if JUCE_MAC
|
||||||
Process::setDockIconVisible(false);
|
Process::setDockIconVisible(false);
|
||||||
|
#endif
|
||||||
|
|
||||||
File fileToOpen;
|
File fileToOpen;
|
||||||
|
|
||||||
|
|||||||
+70
-5
@@ -10,6 +10,48 @@
|
|||||||
#include "IconMenu.hpp"
|
#include "IconMenu.hpp"
|
||||||
#include "PluginWindow.h"
|
#include "PluginWindow.h"
|
||||||
|
|
||||||
|
#if !JUCE_MAC
|
||||||
|
class IconMenu::PluginListWindow : public DocumentWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PluginListWindow(IconMenu& owner_, AudioPluginFormatManager& pluginFormatManager)
|
||||||
|
: DocumentWindow("Available Plugins", Colours::white,
|
||||||
|
DocumentWindow::minimiseButton | DocumentWindow::closeButton),
|
||||||
|
owner(owner_)
|
||||||
|
{
|
||||||
|
const File deadMansPedalFile(getAppProperties().getUserSettings()
|
||||||
|
->getFile().getSiblingFile("RecentlyCrashedPluginsList"));
|
||||||
|
|
||||||
|
setContentOwned(new PluginListComponent(pluginFormatManager,
|
||||||
|
owner.knownPluginList,
|
||||||
|
deadMansPedalFile,
|
||||||
|
getAppProperties().getUserSettings()), true);
|
||||||
|
|
||||||
|
setResizable(true, false);
|
||||||
|
setResizeLimits(300, 400, 800, 1500);
|
||||||
|
setTopLeftPosition(60, 60);
|
||||||
|
|
||||||
|
restoreWindowStateFromString(getAppProperties().getUserSettings()->getValue("listWindowPos"));
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
~PluginListWindow()
|
||||||
|
{
|
||||||
|
getAppProperties().getUserSettings()->setValue("listWindowPos", getWindowStateAsString());
|
||||||
|
|
||||||
|
clearContentComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
void closeButtonPressed()
|
||||||
|
{
|
||||||
|
owner.pluginListWindow = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
IconMenu& owner;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
IconMenu::IconMenu()
|
IconMenu::IconMenu()
|
||||||
{
|
{
|
||||||
// Initiialization
|
// Initiialization
|
||||||
@@ -32,10 +74,14 @@ IconMenu::IconMenu()
|
|||||||
loadActivePlugins();
|
loadActivePlugins();
|
||||||
activePluginList.addChangeListener(this);
|
activePluginList.addChangeListener(this);
|
||||||
// Set menu icon
|
// Set menu icon
|
||||||
|
#if JUCE_MAC
|
||||||
if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1)
|
if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1)
|
||||||
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize));
|
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize));
|
||||||
else
|
else
|
||||||
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
|
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
|
||||||
|
#else
|
||||||
|
setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize));
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
IconMenu::~IconMenu()
|
IconMenu::~IconMenu()
|
||||||
@@ -58,7 +104,8 @@ void IconMenu::loadActivePlugins()
|
|||||||
PluginDescription plugin = *activePluginList.getType(i);
|
PluginDescription plugin = *activePluginList.getType(i);
|
||||||
String errorMessage;
|
String errorMessage;
|
||||||
AudioPluginInstance* instance = formatManager.createPluginInstance(plugin, graph.getSampleRate(), graph.getBlockSize(), errorMessage);
|
AudioPluginInstance* instance = formatManager.createPluginInstance(plugin, graph.getSampleRate(), graph.getBlockSize(), errorMessage);
|
||||||
String pluginUid = "pluginState-" + std::to_string(i);
|
String pluginUid;
|
||||||
|
pluginUid << "pluginState-" << i;
|
||||||
String savedPluginState = getAppProperties().getUserSettings()->getValue(pluginUid);
|
String savedPluginState = getAppProperties().getUserSettings()->getValue(pluginUid);
|
||||||
MemoryBlock savedPluginBinary;
|
MemoryBlock savedPluginBinary;
|
||||||
savedPluginBinary.fromBase64Encoding(savedPluginState);
|
savedPluginBinary.fromBase64Encoding(savedPluginState);
|
||||||
@@ -108,6 +155,7 @@ void IconMenu::changeListenerCallback(ChangeBroadcaster* changed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if JUCE_MAC
|
||||||
std::string IconMenu::exec(const char* cmd)
|
std::string IconMenu::exec(const char* cmd)
|
||||||
{
|
{
|
||||||
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
|
std::shared_ptr<FILE> pipe(popen(cmd, "r"), pclose);
|
||||||
@@ -121,6 +169,7 @@ std::string IconMenu::exec(const char* cmd)
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void IconMenu::timerCallback()
|
void IconMenu::timerCallback()
|
||||||
{
|
{
|
||||||
@@ -153,7 +202,9 @@ void IconMenu::timerCallback()
|
|||||||
|
|
||||||
void IconMenu::mouseDown(const MouseEvent& e)
|
void IconMenu::mouseDown(const MouseEvent& e)
|
||||||
{
|
{
|
||||||
|
#if JUCE_MAC
|
||||||
Process::setDockIconVisible(true);
|
Process::setDockIconVisible(true);
|
||||||
|
#endif
|
||||||
Process::makeForegroundProcess();
|
Process::makeForegroundProcess();
|
||||||
menuIconLeftClicked = e.mods.isLeftButtonDown();
|
menuIconLeftClicked = e.mods.isLeftButtonDown();
|
||||||
startTimer(50);
|
startTimer(50);
|
||||||
@@ -167,9 +218,11 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
|
|||||||
im->savePluginStates();
|
im->savePluginStates();
|
||||||
return JUCEApplication::getInstance()->quit();
|
return JUCEApplication::getInstance()->quit();
|
||||||
}
|
}
|
||||||
|
#if JUCE_MAC
|
||||||
// Click elsewhere
|
// Click elsewhere
|
||||||
if (id == 0 && !PluginWindow::containsActiveWindows())
|
if (id == 0 && !PluginWindow::containsActiveWindows())
|
||||||
Process::setDockIconVisible(false);
|
Process::setDockIconVisible(false);
|
||||||
|
#endif
|
||||||
// Audio settings
|
// Audio settings
|
||||||
if (id == 1)
|
if (id == 1)
|
||||||
im->showAudioSettings();
|
im->showAudioSettings();
|
||||||
@@ -208,7 +261,8 @@ void IconMenu::deletePluginStates()
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
||||||
{
|
{
|
||||||
String pluginUid = "pluginState-" + std::to_string(i);
|
String pluginUid;
|
||||||
|
pluginUid << "pluginState-" << i;
|
||||||
getAppProperties().getUserSettings()->removeValue(pluginUid);
|
getAppProperties().getUserSettings()->removeValue(pluginUid);
|
||||||
getAppProperties().saveIfNeeded();
|
getAppProperties().saveIfNeeded();
|
||||||
}
|
}
|
||||||
@@ -219,7 +273,8 @@ void IconMenu::savePluginStates()
|
|||||||
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
||||||
{
|
{
|
||||||
AudioProcessor& processor = *graph.getNodeForId(i+3)->getProcessor();
|
AudioProcessor& processor = *graph.getNodeForId(i+3)->getProcessor();
|
||||||
String pluginUid = "pluginState-" + std::to_string(i);
|
String pluginUid;
|
||||||
|
pluginUid << "pluginState-" << i;
|
||||||
MemoryBlock savedStateBinary;
|
MemoryBlock savedStateBinary;
|
||||||
processor.getStateInformation(savedStateBinary);
|
processor.getStateInformation(savedStateBinary);
|
||||||
ScopedPointer<XmlElement> savedStateXml(XmlElement::createTextElement(savedStateBinary.toBase64Encoding()));
|
ScopedPointer<XmlElement> savedStateXml(XmlElement::createTextElement(savedStateBinary.toBase64Encoding()));
|
||||||
@@ -252,14 +307,22 @@ void IconMenu::showAudioSettings()
|
|||||||
|
|
||||||
void IconMenu::reloadPlugins()
|
void IconMenu::reloadPlugins()
|
||||||
{
|
{
|
||||||
NativeMessageBox::showOkCancelBox(AlertWindow::AlertIconType::InfoIcon, "Reload Plugins?", "Confirm scan and load of any new or updated plugins.", this, ModalCallbackFunction::forComponent(doReload, this));
|
#if JUCE_MAC
|
||||||
|
NativeMessageBox::showOkCancelBox(AlertWindow::AlertIconType::InfoIcon, "Reload Plugins?", "Confirm scan and load of any new or updated plugins.", this, ModalCallbackFunction::forComponent(doReloadWithDefaultLocations, this));
|
||||||
|
#else
|
||||||
|
if (pluginListWindow == nullptr)
|
||||||
|
pluginListWindow = new PluginListWindow(*this, formatManager);
|
||||||
|
pluginListWindow->toFront(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void IconMenu::doReload(int id, IconMenu* im)
|
void IconMenu::doReloadWithDefaultLocations(int id, IconMenu* im)
|
||||||
{
|
{
|
||||||
|
#if JUCE_MAC
|
||||||
// Canceled
|
// Canceled
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
return Process::setDockIconVisible(false);
|
return Process::setDockIconVisible(false);
|
||||||
|
#endif
|
||||||
// Scan
|
// Scan
|
||||||
const File deadMansPedalFile (getAppProperties().getUserSettings()->getFile().getSiblingFile("RecentlyCrashedPluginsList"));
|
const File deadMansPedalFile (getAppProperties().getUserSettings()->getFile().getSiblingFile("RecentlyCrashedPluginsList"));
|
||||||
String pluginName;
|
String pluginName;
|
||||||
@@ -280,5 +343,7 @@ void IconMenu::doReload(int id, IconMenu* im)
|
|||||||
im->knownPluginList.removeType(removeIndex[i] - i);
|
im->knownPluginList.removeType(removeIndex[i] - i);
|
||||||
// Finish
|
// Finish
|
||||||
NativeMessageBox::showMessageBox(AlertWindow::AlertIconType::InfoIcon, "Completed", "Plugins have been refreshed.");
|
NativeMessageBox::showMessageBox(AlertWindow::AlertIconType::InfoIcon, "Completed", "Plugins have been refreshed.");
|
||||||
|
#if JUCE_MAC
|
||||||
Process::setDockIconVisible(false);
|
Process::setDockIconVisible(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
+7
-3
@@ -18,10 +18,12 @@ public:
|
|||||||
~IconMenu();
|
~IconMenu();
|
||||||
void mouseDown(const MouseEvent&);
|
void mouseDown(const MouseEvent&);
|
||||||
static void menuInvocationCallback(int id, IconMenu*);
|
static void menuInvocationCallback(int id, IconMenu*);
|
||||||
static void doReload(int id, IconMenu*);
|
static void doReloadWithDefaultLocations(int id, IconMenu*);
|
||||||
void changeListenerCallback(ChangeBroadcaster* changed);
|
void changeListenerCallback(ChangeBroadcaster* changed);
|
||||||
private:
|
private:
|
||||||
|
#if JUCE_MAC
|
||||||
std::string exec(const char* cmd);
|
std::string exec(const char* cmd);
|
||||||
|
#endif
|
||||||
void timerCallback();
|
void timerCallback();
|
||||||
void reloadPlugins();
|
void reloadPlugins();
|
||||||
void showAudioSettings();
|
void showAudioSettings();
|
||||||
@@ -41,8 +43,10 @@ private:
|
|||||||
AudioProcessorPlayer player;
|
AudioProcessorPlayer player;
|
||||||
AudioProcessorGraph::Node *inputNode;
|
AudioProcessorGraph::Node *inputNode;
|
||||||
AudioProcessorGraph::Node *outputNode;
|
AudioProcessorGraph::Node *outputNode;
|
||||||
|
#if !JUCE_MAC
|
||||||
class ScanThread;
|
class PluginListWindow;
|
||||||
|
ScopedPointer<PluginListWindow> pluginListWindow;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* IconMenu_hpp */
|
#endif /* IconMenu_hpp */
|
||||||
|
|||||||
Reference in New Issue
Block a user