Added plugin reordering
This commit is contained in:
+51
-6
@@ -59,7 +59,7 @@ private:
|
|||||||
IconMenu& owner;
|
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
|
// Initiialization
|
||||||
formatManager.addDefaultFormats();
|
formatManager.addDefaultFormats();
|
||||||
@@ -224,6 +224,7 @@ void IconMenu::timerCallback()
|
|||||||
menu.addItem(1, "Preferences");
|
menu.addItem(1, "Preferences");
|
||||||
menu.addItem(2, "Edit Plugins");
|
menu.addItem(2, "Edit Plugins");
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.addSectionHeader("Active Plugins");
|
||||||
// Active plugins
|
// Active plugins
|
||||||
int time = 0;
|
int time = 0;
|
||||||
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
for (int i = 0; i < activePluginList.getNumTypes(); i++)
|
||||||
@@ -234,17 +235,24 @@ void IconMenu::timerCallback()
|
|||||||
String key = getKey("bypass", timeSorted[i]);
|
String key = getKey("bypass", timeSorted[i]);
|
||||||
bool bypass = getAppProperties().getUserSettings()->getBoolValue(key);
|
bool bypass = getAppProperties().getUserSettings()->getBoolValue(key);
|
||||||
options.addItem(INDEX_BYPASS + i, "Bypass", true, bypass);
|
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");
|
options.addItem(INDEX_DELETE + i, "Delete");
|
||||||
PluginDescription plugin = getNextPluginOlderThanTime(time);
|
PluginDescription plugin = getNextPluginOlderThanTime(time);
|
||||||
menu.addSubMenu(plugin.name, options);
|
menu.addSubMenu(plugin.name, options);
|
||||||
}
|
}
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
menu.addSectionHeader("Avaliable Plugins");
|
||||||
// All plugins
|
// All plugins
|
||||||
knownPluginList.addToMenu(menu, pluginSortMethod);
|
knownPluginList.addToMenu(menu, pluginSortMethod);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menu.addItem(1, "Quit");
|
menu.addItem(1, "Quit");
|
||||||
|
menu.addSeparator();
|
||||||
|
menu.addItem(2, "Delete Plugin States");
|
||||||
}
|
}
|
||||||
#if JUCE_MAC || JUCE_LINUX
|
#if JUCE_MAC || JUCE_LINUX
|
||||||
menu.showMenuAsync(PopupMenu::Options().withTargetComponent(this), ModalCallbackFunction::forComponent(menuInvocationCallback, this));
|
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)
|
void IconMenu::menuInvocationCallback(int id, IconMenu* im)
|
||||||
{
|
{
|
||||||
// Right click
|
// Right click
|
||||||
if ((!im->menuIconLeftClicked) && id == 1)
|
if ((!im->menuIconLeftClicked))
|
||||||
|
{
|
||||||
|
if (id == 1)
|
||||||
{
|
{
|
||||||
im->savePluginStates();
|
im->savePluginStates();
|
||||||
return JUCEApplication::getInstance()->quit();
|
return JUCEApplication::getInstance()->quit();
|
||||||
|
}
|
||||||
|
if (id == 2)
|
||||||
|
{
|
||||||
|
im->deletePluginStates();
|
||||||
|
return im->loadActivePlugins();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#if JUCE_MAC
|
#if JUCE_MAC
|
||||||
// Click elsewhere
|
// Click elsewhere
|
||||||
@@ -330,8 +346,6 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
|
|||||||
// Add plugin
|
// Add plugin
|
||||||
else if (im->knownPluginList.getIndexChosenByMenu(id) > -1)
|
else if (im->knownPluginList.getIndexChosenByMenu(id) > -1)
|
||||||
{
|
{
|
||||||
im->deletePluginStates();
|
|
||||||
|
|
||||||
PluginDescription plugin = *im->knownPluginList.getType(im->knownPluginList.getIndexChosenByMenu(id));
|
PluginDescription plugin = *im->knownPluginList.getType(im->knownPluginList.getIndexChosenByMenu(id));
|
||||||
String key = getKey("order", plugin);
|
String key = getKey("order", plugin);
|
||||||
int t = time(0);
|
int t = time(0);
|
||||||
@@ -345,8 +359,6 @@ void IconMenu::menuInvocationCallback(int id, IconMenu* im)
|
|||||||
// Bypass plugin
|
// Bypass plugin
|
||||||
else if (id >= im->INDEX_BYPASS && id < im->INDEX_BYPASS + 1000000)
|
else if (id >= im->INDEX_BYPASS && id < im->INDEX_BYPASS + 1000000)
|
||||||
{
|
{
|
||||||
im->deletePluginStates();
|
|
||||||
|
|
||||||
int index = id - im->INDEX_BYPASS;
|
int index = id - im->INDEX_BYPASS;
|
||||||
std::vector<PluginDescription> timeSorted = im->getTimeSortedList();
|
std::vector<PluginDescription> timeSorted = im->getTimeSortedList();
|
||||||
String key = getKey("bypass", timeSorted[index]);
|
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))
|
if (PluginWindow* const w = PluginWindow::getWindowFor(f, PluginWindow::Normal))
|
||||||
w->toFront(true);
|
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<PluginDescription> 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<PluginDescription> 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
|
// Update menu
|
||||||
im->startTimer(50);
|
im->startTimer(50);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ public:
|
|||||||
void changeListenerCallback(ChangeBroadcaster* changed);
|
void changeListenerCallback(ChangeBroadcaster* changed);
|
||||||
static String getKey(String type, PluginDescription plugin);
|
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:
|
private:
|
||||||
#if JUCE_MAC
|
#if JUCE_MAC
|
||||||
std::string exec(const char* cmd);
|
std::string exec(const char* cmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user