Browse Source

Add metadata to Plugins class and Add Module menu

tags/v0.4.0
Andrew Belt 7 years ago
parent
commit
c4a8f8e0fd
3 changed files with 47 additions and 2 deletions
  1. +5
    -2
      include/plugin.hpp
  2. +41
    -0
      src/app/RackWidget.cpp
  3. +1
    -0
      src/core/core.cpp

+ 5
- 2
include/plugin.hpp View File

@@ -17,12 +17,15 @@ struct Plugin {
std::string slug; std::string slug;
/** Human readable name for your plugin, e.g. "Foo Modular" */ /** Human readable name for your plugin, e.g. "Foo Modular" */
std::string name; std::string name;
/** The file path of the plugins directory */
std::string path;
/** A list of the models made available by this plugin */ /** A list of the models made available by this plugin */
std::list<Model*> models; std::list<Model*> models;
/** The file path of the plugins directory */
std::string path;
/** OS-dependent library handle */ /** OS-dependent library handle */
void *handle = NULL; void *handle = NULL;
/** Optional metadata for the Add Module context menu */
std::string homepageUrl;
std::string manualUrl;
}; };


struct Model { struct Model {


+ 41
- 0
src/app/RackWidget.cpp View File

@@ -366,10 +366,18 @@ struct AddModuleMenuItem : MenuItem {
} }
}; };


struct UrlItem : MenuItem {
std::string url;
void onAction() {
openBrowser(url);
}
};

struct AddPluginMenuItem : MenuItem { struct AddPluginMenuItem : MenuItem {
Plugin *plugin; Plugin *plugin;
Vec modulePos; Vec modulePos;
Menu *createChildMenu() { Menu *createChildMenu() {
// Model items
Menu *menu = new Menu(); Menu *menu = new Menu();
for (Model *model : plugin->models) { for (Model *model : plugin->models) {
AddModuleMenuItem *item = new AddModuleMenuItem(); AddModuleMenuItem *item = new AddModuleMenuItem();
@@ -378,6 +386,39 @@ struct AddPluginMenuItem : MenuItem {
item->modulePos = modulePos; item->modulePos = modulePos;
menu->pushChild(item); menu->pushChild(item);
} }

// Metadata items
{
MenuLabel *label = new MenuLabel();
menu->pushChild(label);
}
{
MenuLabel *label = new MenuLabel();
label->text = plugin->name;
menu->pushChild(label);
}

if (!plugin->homepageUrl.empty()) {
UrlItem *item = new UrlItem();
item->text = "Homepage";
item->url = plugin->homepageUrl;
menu->pushChild(item);
}

if (!plugin->manualUrl.empty()) {
UrlItem *item = new UrlItem();
item->text = "Manual";
item->url = plugin->manualUrl;
menu->pushChild(item);
}

if (!plugin->path.empty()) {
UrlItem *item = new UrlItem();
item->text = "Browse Directory";
item->url = plugin->path;
menu->pushChild(item);
}

return menu; return menu;
} }
}; };


+ 1
- 0
src/core/core.cpp View File

@@ -4,6 +4,7 @@
void init(rack::Plugin *plugin) { void init(rack::Plugin *plugin) {
plugin->slug = "Core"; plugin->slug = "Core";
plugin->name = "Core"; plugin->name = "Core";
plugin->homepageUrl = "https://vcvrack.com/";
createModel<AudioInterfaceWidget>(plugin, "AudioInterface", "Audio Interface"); createModel<AudioInterfaceWidget>(plugin, "AudioInterface", "Audio Interface");
createModel<MidiInterfaceWidget>(plugin, "MidiInterface", "MIDI Interface"); createModel<MidiInterfaceWidget>(plugin, "MidiInterface", "MIDI Interface");
} }

Loading…
Cancel
Save