From db81016abcd3cebb275482e8de5063b92e34e58c Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Mon, 25 Jan 2016 18:51:20 -0700 Subject: [PATCH 1/7] Fixed wrong plugin being removed --- Source/IconMenu.cpp | 31 ++++++++++++++++++++++++++++--- Source/IconMenu.hpp | 1 + 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Source/IconMenu.cpp b/Source/IconMenu.cpp index 25ac00f..e15b049 100644 --- a/Source/IconMenu.cpp +++ b/Source/IconMenu.cpp @@ -286,12 +286,27 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) im->deletePluginStates(); int index = id - im->activePluginList.getNumTypes() - 3; - PluginDescription plugin = *im->activePluginList.getType(index); - String key = "pluginOrder-" + plugin.descriptiveName + plugin.version + plugin.pluginFormatName; + std::vector timeSorted = im->getTimeSortedList(); + String key = "pluginOrder-" + timeSorted[index].descriptiveName + timeSorted[index].version + timeSorted[index].pluginFormatName; + int unsortedIndex = 0; + for (int i = 0; im->activePluginList.getNumTypes(); i++) + { + PluginDescription current = *im->activePluginList.getType(i); + if (key.equalsIgnoreCase("pluginOrder-" + current.descriptiveName + current.version + current.pluginFormatName)) + { + unsortedIndex = i; + break; + } + } + + // Remove plugin order getAppProperties().getUserSettings()->removeValue(key); getAppProperties().saveIfNeeded(); - im->activePluginList.removeType(index); + + // Remove plugin from list + im->activePluginList.removeType(unsortedIndex); + // Save current states im->savePluginStates(); im->loadActivePlugins(); } @@ -322,6 +337,16 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) } } +std::vector IconMenu::getTimeSortedList() +{ + int time = 0; + std::vector list; + for (int i = 0; i < activePluginList.getNumTypes(); i++) + list.push_back(getNextPluginOlderThanTime(time)); + return list; + +} + void IconMenu::deletePluginStates() { for (int i = 0; i < activePluginList.getNumTypes(); i++) diff --git a/Source/IconMenu.hpp b/Source/IconMenu.hpp index ada8d31..c191c5e 100644 --- a/Source/IconMenu.hpp +++ b/Source/IconMenu.hpp @@ -31,6 +31,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis void deletePluginStates(); PluginDescription getNextPluginOlderThanTime(int &time); void removePluginsLackingInputOutput(); + std::vector getTimeSortedList(); AudioDeviceManager deviceManager; AudioPluginFormatManager formatManager; From bb67537e88a291128f2d7c1d6a7341d64bc10028 Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Thu, 26 May 2016 16:18:28 -0700 Subject: [PATCH 2/7] Update JUCE --- LightHost.jucer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LightHost.jucer b/LightHost.jucer index 09ad20b..8e4e805 100644 --- a/LightHost.jucer +++ b/LightHost.jucer @@ -10,7 +10,7 @@ pluginSilenceInIsSilenceOut="0" pluginTailLength="0" pluginEditorRequiresKeys="0" pluginAUExportPrefix="JuceProjectAU" pluginAUViewClass="JuceProjectAU_V1" pluginRTASCategory="" bundleIdentifier="com.rolandoislas.lighthost" - jucerVersion="4.1.0" companyName="Rolando Islas" includeBinaryInAppConfig="1" + jucerVersion="4.2.1" companyName="Rolando Islas" includeBinaryInAppConfig="1" companyWebsite="https://www.rolandoislas.com" companyEmail="admin@rolandoislas.com"> Date: Thu, 26 May 2016 21:13:45 -0700 Subject: [PATCH 3/7] Added bypass --- Source/IconMenu.cpp | 97 ++++++++++++++++++++++++++++++--------------- Source/IconMenu.hpp | 2 + 2 files changed, 68 insertions(+), 31 deletions(-) diff --git a/Source/IconMenu.cpp b/Source/IconMenu.cpp index e15b049..28dcec2 100644 --- a/Source/IconMenu.cpp +++ b/Source/IconMenu.cpp @@ -59,7 +59,7 @@ class IconMenu::PluginListWindow : public DocumentWindow IconMenu& owner; }; -IconMenu::IconMenu() +IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(3000000) { // Initiialization formatManager.addDefaultFormats(); @@ -97,21 +97,29 @@ IconMenu::IconMenu() IconMenu::~IconMenu() { - + savePluginStates(); } void IconMenu::loadActivePlugins() { + const int INPUT = 1000000; + const int OUTPUT = INPUT + 1; + const int CHANNEL_ONE = 0; + const int CHANNEL_TWO = 1; + PluginWindow::closeAllCurrentlyOpenWindows(); graph.clear(); - inputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode), 1); - outputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode), 2); + inputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioInputNode), INPUT); + outputNode = graph.addNode(new AudioProcessorGraph::AudioGraphIOProcessor(AudioProcessorGraph::AudioGraphIOProcessor::audioOutputNode), OUTPUT); if (activePluginList.getNumTypes() == 0) { - graph.addConnection(1, 0, 2, 0); - graph.addConnection(1, 1, 2, 1); + graph.addConnection(INPUT, CHANNEL_ONE, OUTPUT, CHANNEL_ONE); + graph.addConnection(INPUT, CHANNEL_TWO, OUTPUT, CHANNEL_TWO); } int pluginTime = 0; - for (int i = 0; i < activePluginList.getNumTypes(); i++) + int lastId = 0; + bool hasInputConnected = false; + // NOTE: Node ids cannot begin at 0. + for (int i = 1; i <= activePluginList.getNumTypes(); i++) { PluginDescription plugin = getNextPluginOlderThanTime(pluginTime); String errorMessage; @@ -122,26 +130,31 @@ void IconMenu::loadActivePlugins() MemoryBlock savedPluginBinary; savedPluginBinary.fromBase64Encoding(savedPluginState); instance->setStateInformation(savedPluginBinary.getData(), savedPluginBinary.getSize()); - graph.addNode(instance, i+3); + graph.addNode(instance, i); + String key = "pluginBypass-" + plugin.descriptiveName + plugin.version + plugin.pluginFormatName; + bool bypass = getAppProperties().getUserSettings()->getBoolValue(key, false); // Input to plugin - if (i == 0) - { - graph.addConnection(1, 0, i+3, 0); - graph.addConnection(1, 1, i+3, 1); - } - // Plugin to output - if (i == activePluginList.getNumTypes() - 1) + if ((!hasInputConnected) && (!bypass)) { - graph.addConnection(i+3, 0, 2, 0); - graph.addConnection(i+3, 1, 2, 1); + graph.addConnection(INPUT, CHANNEL_ONE, i, CHANNEL_ONE); + graph.addConnection(INPUT, CHANNEL_TWO, i, CHANNEL_TWO); + hasInputConnected = true; } // Connect previous plugin to current - if (i > 0) + else if (!bypass) { - graph.addConnection(i+2, 0, i+3, 0); - graph.addConnection(i+2, 1, i+3, 1); + graph.addConnection(lastId, CHANNEL_ONE, i, CHANNEL_ONE); + graph.addConnection(lastId, CHANNEL_TWO, i, CHANNEL_TWO); } + if (!bypass) + lastId = i; } + if (lastId > 0) + { + // Last active plugin to output + graph.addConnection(lastId, CHANNEL_ONE, OUTPUT, CHANNEL_ONE); + graph.addConnection(lastId, CHANNEL_TWO, OUTPUT, CHANNEL_TWO); + } } PluginDescription IconMenu::getNextPluginOlderThanTime(int &time) @@ -217,9 +230,12 @@ void IconMenu::timerCallback() for (int i = 0; i < activePluginList.getNumTypes(); i++) { PopupMenu options; - options.addItem(i+3, "Edit"); - options.addItem(activePluginList.getNumTypes()+i+3, "Delete"); - // TODO bypass + options.addItem(INDEX_EDIT + i, "Edit"); + std::vector timeSorted = getTimeSortedList(); + String key = "pluginBypass-" + timeSorted[i].descriptiveName + timeSorted[i].version + timeSorted[i].pluginFormatName; + bool bypass = getAppProperties().getUserSettings()->getBoolValue(key); + options.addItem(INDEX_BYPASS + i, "Bypass", true, bypass); + options.addItem(INDEX_DELETE + i, "Delete"); PluginDescription plugin = getNextPluginOlderThanTime(time); menu.addSubMenu(plugin.name, options); } @@ -281,11 +297,11 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) if (id > 2) { // Delete plugin - if (id > im->activePluginList.getNumTypes() + 2 && id <= im->activePluginList.getNumTypes() * 2 + 2) + if (id >= im->INDEX_DELETE && id < im->INDEX_DELETE + 1000000) { im->deletePluginStates(); - int index = id - im->activePluginList.getNumTypes() - 3; + int index = id - im->INDEX_DELETE; std::vector timeSorted = im->getTimeSortedList(); String key = "pluginOrder-" + timeSorted[index].descriptiveName + timeSorted[index].version + timeSorted[index].pluginFormatName; int unsortedIndex = 0; @@ -301,6 +317,8 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) // Remove plugin order getAppProperties().getUserSettings()->removeValue(key); + // Remove bypass entry + getAppProperties().getUserSettings()->removeValue(key.replace("Order", "Bypass")); getAppProperties().saveIfNeeded(); // Remove plugin from list @@ -311,7 +329,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) im->loadActivePlugins(); } // Add plugin - else if (id > im->activePluginList.getNumTypes() + 2) + else if (im->knownPluginList.getIndexChosenByMenu(id) > -1) { im->deletePluginStates(); @@ -325,10 +343,27 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) im->savePluginStates(); im->loadActivePlugins(); } + // Bypass plugin + else if (id >= im->INDEX_BYPASS && id < im->INDEX_BYPASS + 1000000) + { + im->deletePluginStates(); + + int index = id - im->INDEX_BYPASS; + std::vector timeSorted = im->getTimeSortedList(); + String key = "pluginBypass-" + timeSorted[index].descriptiveName + timeSorted[index].version + timeSorted[index].pluginFormatName; + + // Set bypass flag + bool bypassed = getAppProperties().getUserSettings()->getBoolValue(key); + getAppProperties().getUserSettings()->setValue(key, !bypassed); + getAppProperties().saveIfNeeded(); + + im->savePluginStates(); + im->loadActivePlugins(); + } // Show active plugin GUI - else + else if (id >= im->INDEX_EDIT && id < im->INDEX_EDIT + 1000000) { - if (const AudioProcessorGraph::Node::Ptr f = im->graph.getNodeForId(id)) + if (const AudioProcessorGraph::Node::Ptr f = im->graph.getNodeForId(id - im->INDEX_EDIT + 1)) if (PluginWindow* const w = PluginWindow::getWindowFor(f, PluginWindow::Normal)) w->toFront(true); } @@ -349,7 +384,7 @@ std::vector IconMenu::getTimeSortedList() void IconMenu::deletePluginStates() { - for (int i = 0; i < activePluginList.getNumTypes(); i++) + for (int i = 1; i <= activePluginList.getNumTypes(); i++) { String pluginUid; pluginUid << "pluginState-" << i; @@ -360,9 +395,9 @@ void IconMenu::deletePluginStates() void IconMenu::savePluginStates() { - for (int i = 0; i < activePluginList.getNumTypes(); i++) + for (int i = 1; i <= activePluginList.getNumTypes(); i++) { - AudioProcessorGraph::Node* node = graph.getNodeForId(i+3); + AudioProcessorGraph::Node* node = graph.getNodeForId(i); if (node == nullptr) break; AudioProcessor& processor = *node->getProcessor(); diff --git a/Source/IconMenu.hpp b/Source/IconMenu.hpp index c191c5e..b761b5c 100644 --- a/Source/IconMenu.hpp +++ b/Source/IconMenu.hpp @@ -19,6 +19,8 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis void mouseDown(const MouseEvent&); static void menuInvocationCallback(int id, IconMenu*); void changeListenerCallback(ChangeBroadcaster* changed); + + const int INDEX_EDIT, INDEX_BYPASS, INDEX_DELETE; private: #if JUCE_MAC std::string exec(const char* cmd); From 2a407bc74179fbbf17931f806b675881ecc3e029 Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Fri, 27 May 2016 12:58:10 -0700 Subject: [PATCH 4/7] Standardize stored keys --- Source/IconMenu.cpp | 39 ++++++++++++++++++++++----------------- Source/IconMenu.hpp | 1 + 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Source/IconMenu.cpp b/Source/IconMenu.cpp index 28dcec2..cb0049f 100644 --- a/Source/IconMenu.cpp +++ b/Source/IconMenu.cpp @@ -124,14 +124,13 @@ void IconMenu::loadActivePlugins() PluginDescription plugin = getNextPluginOlderThanTime(pluginTime); String errorMessage; AudioPluginInstance* instance = formatManager.createPluginInstance(plugin, graph.getSampleRate(), graph.getBlockSize(), errorMessage); - String pluginUid; - pluginUid << "pluginState-" << i; + String pluginUid = getKey("state", plugin); String savedPluginState = getAppProperties().getUserSettings()->getValue(pluginUid); MemoryBlock savedPluginBinary; savedPluginBinary.fromBase64Encoding(savedPluginState); instance->setStateInformation(savedPluginBinary.getData(), savedPluginBinary.getSize()); graph.addNode(instance, i); - String key = "pluginBypass-" + plugin.descriptiveName + plugin.version + plugin.pluginFormatName; + String key = getKey("bypass", plugin); bool bypass = getAppProperties().getUserSettings()->getBoolValue(key, false); // Input to plugin if ((!hasInputConnected) && (!bypass)) @@ -165,7 +164,7 @@ PluginDescription IconMenu::getNextPluginOlderThanTime(int &time) for (int i = 0; i < activePluginList.getNumTypes(); i++) { PluginDescription plugin = *activePluginList.getType(i); - String key = "pluginOrder-" + plugin.descriptiveName + plugin.version + plugin.pluginFormatName; + String key = getKey("order", plugin); String pluginTimeString = getAppProperties().getUserSettings()->getValue(key); int pluginTime = atoi(pluginTimeString.toStdString().c_str()); if (pluginTime > timeStatic && abs(timeStatic - pluginTime) < diff) @@ -232,7 +231,7 @@ void IconMenu::timerCallback() PopupMenu options; options.addItem(INDEX_EDIT + i, "Edit"); std::vector timeSorted = getTimeSortedList(); - String key = "pluginBypass-" + timeSorted[i].descriptiveName + timeSorted[i].version + timeSorted[i].pluginFormatName; + String key = getKey("bypass", timeSorted[i]); bool bypass = getAppProperties().getUserSettings()->getBoolValue(key); options.addItem(INDEX_BYPASS + i, "Bypass", true, bypass); options.addItem(INDEX_DELETE + i, "Delete"); @@ -303,12 +302,12 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) int index = id - im->INDEX_DELETE; std::vector timeSorted = im->getTimeSortedList(); - String key = "pluginOrder-" + timeSorted[index].descriptiveName + timeSorted[index].version + timeSorted[index].pluginFormatName; + String key = getKey("order", timeSorted[index]); int unsortedIndex = 0; for (int i = 0; im->activePluginList.getNumTypes(); i++) { PluginDescription current = *im->activePluginList.getType(i); - if (key.equalsIgnoreCase("pluginOrder-" + current.descriptiveName + current.version + current.pluginFormatName)) + if (key.equalsIgnoreCase(getKey("order", current))) { unsortedIndex = i; break; @@ -318,7 +317,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) // Remove plugin order getAppProperties().getUserSettings()->removeValue(key); // Remove bypass entry - getAppProperties().getUserSettings()->removeValue(key.replace("Order", "Bypass")); + getAppProperties().getUserSettings()->removeValue(getKey("bypass", timeSorted[index])); getAppProperties().saveIfNeeded(); // Remove plugin from list @@ -334,7 +333,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) im->deletePluginStates(); PluginDescription plugin = *im->knownPluginList.getType(im->knownPluginList.getIndexChosenByMenu(id)); - String key = "pluginOrder-" + plugin.descriptiveName + plugin.version + plugin.pluginFormatName; + String key = getKey("order", plugin); int t = time(0); getAppProperties().getUserSettings()->setValue(key, t); getAppProperties().saveIfNeeded(); @@ -350,7 +349,7 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) int index = id - im->INDEX_BYPASS; std::vector timeSorted = im->getTimeSortedList(); - String key = "pluginBypass-" + timeSorted[index].descriptiveName + timeSorted[index].version + timeSorted[index].pluginFormatName; + String key = getKey("bypass", timeSorted[index]); // Set bypass flag bool bypassed = getAppProperties().getUserSettings()->getBoolValue(key); @@ -382,12 +381,18 @@ std::vector IconMenu::getTimeSortedList() } +String IconMenu::getKey(String type, PluginDescription plugin) +{ + String key = "plugin-" + type.toLowerCase() + "-" + plugin.name + plugin.version + plugin.pluginFormatName; + return key; +} + void IconMenu::deletePluginStates() { - for (int i = 1; i <= activePluginList.getNumTypes(); i++) + std::vector list = getTimeSortedList(); + for (int i = 0; i < activePluginList.getNumTypes(); i++) { - String pluginUid; - pluginUid << "pluginState-" << i; + String pluginUid = getKey("state", list[i]); getAppProperties().getUserSettings()->removeValue(pluginUid); getAppProperties().saveIfNeeded(); } @@ -395,14 +400,14 @@ void IconMenu::deletePluginStates() void IconMenu::savePluginStates() { - for (int i = 1; i <= activePluginList.getNumTypes(); i++) + std::vector list = getTimeSortedList(); + for (int i = 0; i < activePluginList.getNumTypes(); i++) { - AudioProcessorGraph::Node* node = graph.getNodeForId(i); + AudioProcessorGraph::Node* node = graph.getNodeForId(i + 1); if (node == nullptr) break; AudioProcessor& processor = *node->getProcessor(); - String pluginUid; - pluginUid << "pluginState-" << i; + String pluginUid = getKey("state", list[i]); MemoryBlock savedStateBinary; processor.getStateInformation(savedStateBinary); getAppProperties().getUserSettings()->setValue(pluginUid, savedStateBinary.toBase64Encoding()); diff --git a/Source/IconMenu.hpp b/Source/IconMenu.hpp index b761b5c..c256e64 100644 --- a/Source/IconMenu.hpp +++ b/Source/IconMenu.hpp @@ -19,6 +19,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis void mouseDown(const MouseEvent&); static void menuInvocationCallback(int id, IconMenu*); void changeListenerCallback(ChangeBroadcaster* changed); + static String getKey(String type, PluginDescription plugin); const int INDEX_EDIT, INDEX_BYPASS, INDEX_DELETE; private: From 6f2ed283ed7a8e33e9c6a42db52cf97c2aa8a810 Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Fri, 27 May 2016 14:48:06 -0700 Subject: [PATCH 5/7] Added plugin reordering --- Source/IconMenu.cpp | 61 +++++++++++++++++++++++++++++++++++++++------ Source/IconMenu.hpp | 2 +- 2 files changed, 54 insertions(+), 9 deletions(-) diff --git a/Source/IconMenu.cpp b/Source/IconMenu.cpp index cb0049f..1041b2d 100644 --- a/Source/IconMenu.cpp +++ b/Source/IconMenu.cpp @@ -59,7 +59,7 @@ class IconMenu::PluginListWindow : public DocumentWindow IconMenu& owner; }; -IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(3000000) +IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE(3000000), INDEX_MOVE_UP(4000000), INDEX_MOVE_DOWN(5000000) { // Initiialization formatManager.addDefaultFormats(); @@ -224,6 +224,7 @@ void IconMenu::timerCallback() menu.addItem(1, "Preferences"); menu.addItem(2, "Edit Plugins"); menu.addSeparator(); + menu.addSectionHeader("Active Plugins"); // Active plugins int time = 0; for (int i = 0; i < activePluginList.getNumTypes(); i++) @@ -234,17 +235,24 @@ void IconMenu::timerCallback() String key = getKey("bypass", timeSorted[i]); bool bypass = getAppProperties().getUserSettings()->getBoolValue(key); options.addItem(INDEX_BYPASS + i, "Bypass", true, bypass); + options.addSeparator(); + options.addItem(INDEX_MOVE_UP + i, "Move Up", i > 0); + options.addItem(INDEX_MOVE_DOWN + i, "Move Down", i < timeSorted.size() - 1); + options.addSeparator(); options.addItem(INDEX_DELETE + i, "Delete"); PluginDescription plugin = getNextPluginOlderThanTime(time); menu.addSubMenu(plugin.name, options); } menu.addSeparator(); + menu.addSectionHeader("Avaliable Plugins"); // All plugins knownPluginList.addToMenu(menu, pluginSortMethod); } else { menu.addItem(1, "Quit"); + menu.addSeparator(); + menu.addItem(2, "Delete Plugin States"); } #if JUCE_MAC || JUCE_LINUX menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), ModalCallbackFunction::forComponent(menuInvocationCallback, this)); @@ -276,10 +284,18 @@ void IconMenu::mouseDown(const MouseEvent& e) void IconMenu::menuInvocationCallback(int id, IconMenu* im) { // Right click - if ((!im->menuIconLeftClicked) && id == 1) + if ((!im->menuIconLeftClicked)) { - im->savePluginStates(); - return JUCEApplication::getInstance()->quit(); + if (id == 1) + { + im->savePluginStates(); + return JUCEApplication::getInstance()->quit(); + } + if (id == 2) + { + im->deletePluginStates(); + return im->loadActivePlugins(); + } } #if JUCE_MAC // Click elsewhere @@ -330,8 +346,6 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) // Add plugin else if (im->knownPluginList.getIndexChosenByMenu(id) > -1) { - im->deletePluginStates(); - PluginDescription plugin = *im->knownPluginList.getType(im->knownPluginList.getIndexChosenByMenu(id)); String key = getKey("order", plugin); int t = time(0); @@ -345,8 +359,6 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) // Bypass plugin else if (id >= im->INDEX_BYPASS && id < im->INDEX_BYPASS + 1000000) { - im->deletePluginStates(); - int index = id - im->INDEX_BYPASS; std::vector timeSorted = im->getTimeSortedList(); String key = getKey("bypass", timeSorted[index]); @@ -366,6 +378,39 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) if (PluginWindow* const w = PluginWindow::getWindowFor(f, PluginWindow::Normal)) w->toFront(true); } + // Move plugin up the list + else if (id >= im->INDEX_MOVE_UP && id < im->INDEX_MOVE_UP + 1000000) + { + im->savePluginStates(); + std::vector timeSorted = im->getTimeSortedList(); + PluginDescription toMove = timeSorted[id - im->INDEX_MOVE_UP]; + for (int i = 0; i < timeSorted.size(); i++) + { + bool move = getKey("move", toMove).equalsIgnoreCase(getKey("move", timeSorted[i])); + getAppProperties().getUserSettings()->setValue(getKey("order", timeSorted[i]), move ? i : i+1); + if (move) + getAppProperties().getUserSettings()->setValue(getKey("order", timeSorted[i-1]), i+1); + } + im->loadActivePlugins(); + } + // Move plugin down the list + else if (id >= im->INDEX_MOVE_DOWN && id < im->INDEX_MOVE_DOWN + 1000000) + { + im->savePluginStates(); + std::vector timeSorted = im->getTimeSortedList(); + PluginDescription toMove = timeSorted[id - im->INDEX_MOVE_DOWN]; + for (int i = 0; i < timeSorted.size(); i++) + { + bool move = getKey("move", toMove).equalsIgnoreCase(getKey("move", timeSorted[i])); + getAppProperties().getUserSettings()->setValue(getKey("order", timeSorted[i]), move ? i+2 : i+1); + if (move) + { + getAppProperties().getUserSettings()->setValue(getKey("order", timeSorted[i + 1]), i + 1); + i++; + } + } + im->loadActivePlugins(); + } // Update menu im->startTimer(50); } diff --git a/Source/IconMenu.hpp b/Source/IconMenu.hpp index c256e64..98ea96c 100644 --- a/Source/IconMenu.hpp +++ b/Source/IconMenu.hpp @@ -21,7 +21,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis void changeListenerCallback(ChangeBroadcaster* changed); static String getKey(String type, PluginDescription plugin); - const int INDEX_EDIT, INDEX_BYPASS, INDEX_DELETE; + const int INDEX_EDIT, INDEX_BYPASS, INDEX_DELETE, INDEX_MOVE_UP, INDEX_MOVE_DOWN; private: #if JUCE_MAC std::string exec(const char* cmd); From e2ce3e4c68a5dd0d3436d6a9e17634ebfff5cf9c Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Fri, 27 May 2016 15:43:01 -0700 Subject: [PATCH 6/7] Change default icon color in Windows and allow toggling --- Source/IconMenu.cpp | 46 ++++++++++++++++++++++++++++++++++++--------- Source/IconMenu.hpp | 1 + 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/Source/IconMenu.cpp b/Source/IconMenu.cpp index 1041b2d..ac66b44 100644 --- a/Source/IconMenu.cpp +++ b/Source/IconMenu.cpp @@ -83,15 +83,7 @@ IconMenu::IconMenu() : INDEX_EDIT(1000000), INDEX_BYPASS(2000000), INDEX_DELETE( activePluginList.recreateFromXml(*savedPluginListActive); loadActivePlugins(); activePluginList.addChangeListener(this); - // Set menu icon - #if JUCE_MAC - if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1) - setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize)); - else - setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize)); - #else - setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize)); - #endif + setIcon(); setIconTooltip(JUCEApplication::getInstance()->getApplicationName()); }; @@ -100,6 +92,33 @@ IconMenu::~IconMenu() savePluginStates(); } +void IconMenu::setIcon() +{ + // Set menu icon + #if JUCE_MAC + if (exec("defaults read -g AppleInterfaceStyle").compare("Dark") == 1) + setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize)); + else + setIconImage(ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize)); + #else + String defaultColor; + #if JUCE_WINDOWS + defaultColor = "white"; + #elif JUCE_LINUX + defaultColor = "black"; + #endif + if (!getAppProperties().getUserSettings()->containsKey("icon")) + getAppProperties().getUserSettings()->setValue("icon", defaultColor); + String color = getAppProperties().getUserSettings()->getValue("icon"); + Image icon; + if (color.equalsIgnoreCase("white")) + icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_white_png, BinaryData::menu_icon_white_pngSize); + else if (color.equalsIgnoreCase("black")) + icon = ImageFileFormat::loadFrom(BinaryData::menu_icon_png, BinaryData::menu_icon_pngSize); + setIconImage(icon); + #endif +} + void IconMenu::loadActivePlugins() { const int INPUT = 1000000; @@ -253,6 +272,9 @@ void IconMenu::timerCallback() menu.addItem(1, "Quit"); menu.addSeparator(); menu.addItem(2, "Delete Plugin States"); + #if !JUCE_MAC + menu.addItem(3, "Invert Icon Color"); + #endif } #if JUCE_MAC || JUCE_LINUX menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), ModalCallbackFunction::forComponent(menuInvocationCallback, this)); @@ -296,6 +318,12 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im) im->deletePluginStates(); return im->loadActivePlugins(); } + if (id == 3) + { + String color = getAppProperties().getUserSettings()->getValue("icon"); + getAppProperties().getUserSettings()->setValue("icon", color.equalsIgnoreCase("black") ? "white" : "black"); + return im->setIcon(); + } } #if JUCE_MAC // Click elsewhere diff --git a/Source/IconMenu.hpp b/Source/IconMenu.hpp index 98ea96c..f16c0ed 100644 --- a/Source/IconMenu.hpp +++ b/Source/IconMenu.hpp @@ -35,6 +35,7 @@ class IconMenu : public SystemTrayIconComponent, private Timer, public ChangeLis PluginDescription getNextPluginOlderThanTime(int &time); void removePluginsLackingInputOutput(); std::vector getTimeSortedList(); + void setIcon(); AudioDeviceManager deviceManager; AudioPluginFormatManager formatManager; From 97784065163df046f04ae1fe45c571efdb78ff39 Mon Sep 17 00:00:00 2001 From: Rolando Islas Date: Fri, 27 May 2016 16:48:34 -0700 Subject: [PATCH 7/7] Update version --- LightHost.jucer | 2 +- readme.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LightHost.jucer b/LightHost.jucer index 8e4e805..83acad4 100644 --- a/LightHost.jucer +++ b/LightHost.jucer @@ -1,6 +1,6 @@ -