Browse Source

Add brand to plugin::Plugin and plugin manifest. Use brand instead of author in Module Browser.

tags/v1.0.0
Andrew Belt 6 years ago
parent
commit
5b3c9b36af
4 changed files with 69 additions and 57 deletions
  1. +9
    -5
      include/plugin/Plugin.hpp
  2. +3
    -2
      src/Core/plugin.cpp
  3. +50
    -50
      src/app/ModuleBrowser.cpp
  4. +7
    -0
      src/plugin/Plugin.cpp

+ 9
- 5
include/plugin/Plugin.hpp View File

@@ -27,12 +27,16 @@ struct Plugin {
/** Your plugin's latest version, using the guidelines at https://github.com/VCVRack/Rack/issues/266. Do not include the "v" prefix. /** Your plugin's latest version, using the guidelines at https://github.com/VCVRack/Rack/issues/266. Do not include the "v" prefix.
*/ */
std::string version; std::string version;
/** The license type of your plugin. Use "proprietary" if all rights are reserved. If your license is in the [SPDX license list](https://spdx.org/licenses/), use its abbreviation in the "Identifier" column.
*/
std::string license;
/** Human-readable display name for your plugin. You can change this on a whim, unlike slugs. /** Human-readable display name for your plugin. You can change this on a whim, unlike slugs.
*/ */
std::string name; std::string name;
/** The license type of your plugin. Use "proprietary" if all rights are reserved. If your license is in the [SPDX license list](https://spdx.org/licenses/), use its abbreviation in the "Identifier" column.
/** Prefix of each module name in the Module Browser.
If blank, `name` is used.
*/ */
std::string license;
std::string brand;
/** Your name, company, alias, or GitHub username. /** Your name, company, alias, or GitHub username.
*/ */
std::string author; std::string author;
@@ -41,12 +45,12 @@ struct Plugin {
std::string authorEmail; std::string authorEmail;
/** Homepage featuring the plugin itself. /** Homepage featuring the plugin itself.
*/ */
std::string pluginUrl;
/** Homepage of the author.
*/
std::string authorUrl; std::string authorUrl;
/** The manual of your plugin. HTML, PDF, or GitHub readme/wiki are fine. /** The manual of your plugin. HTML, PDF, or GitHub readme/wiki are fine.
*/ */
std::string pluginUrl;
/** Homepage of the author.
*/
std::string manualUrl; std::string manualUrl;
/** The source code homepage. E.g. GitHub repo. /** The source code homepage. E.g. GitHub repo.
*/ */


+ 3
- 2
src/Core/plugin.cpp View File

@@ -4,12 +4,13 @@
void init(rack::Plugin *p) { void init(rack::Plugin *p) {
p->slug = "Core"; p->slug = "Core";
p->version = TOSTRING(VERSION); p->version = TOSTRING(VERSION);
p->license = "BSD-3-Clause";
p->name = "Core"; p->name = "Core";
p->brand = "Core";
p->author = "VCV"; p->author = "VCV";
p->license = "BSD-3-Clause";
p->authorEmail = "contact@vcvrack.com"; p->authorEmail = "contact@vcvrack.com";
p->pluginUrl = "https://vcvrack.com/";
p->authorUrl = "https://vcvrack.com/"; p->authorUrl = "https://vcvrack.com/";
p->pluginUrl = "https://vcvrack.com/";
p->manualUrl = "https://vcvrack.com/manual/Core.html"; p->manualUrl = "https://vcvrack.com/manual/Core.html";
p->sourceUrl = "https://github.com/VCVRack/Rack"; p->sourceUrl = "https://github.com/VCVRack/Rack";




+ 50
- 50
src/app/ModuleBrowser.cpp View File

@@ -37,7 +37,7 @@ static float modelScore(plugin::Model *model, const std::string &search) {
std::string s; std::string s;
s += model->plugin->slug; s += model->plugin->slug;
s += " "; s += " ";
s += model->plugin->author;
s += model->plugin->brand;
s += " "; s += " ";
s += model->plugin->name; s += model->plugin->name;
s += " "; s += " ";
@@ -215,7 +215,7 @@ struct ModelBox : widget::OpaqueWidget {


void onEnter(const event::Enter &e) override { void onEnter(const event::Enter &e) override {
ui::Tooltip *tooltip = new ui::Tooltip; ui::Tooltip *tooltip = new ui::Tooltip;
tooltip->text = model->plugin->author;
tooltip->text = model->plugin->brand;
tooltip->text += " " + model->name; tooltip->text += " " + model->name;
if (model->description != "") if (model->description != "")
tooltip->text += "\n" + model->description; tooltip->text += "\n" + model->description;
@@ -228,7 +228,7 @@ struct ModelBox : widget::OpaqueWidget {
}; };




struct AuthorItem : ui::MenuItem {
struct BrandItem : ui::MenuItem {
void onAction(const event::Action &e) override; void onAction(const event::Action &e) override;
void step() override; void step() override;
}; };
@@ -309,9 +309,9 @@ struct BrowserSidebar : widget::Widget {
BrowserSearchField *searchField; BrowserSearchField *searchField;
ClearButton *clearButton; ClearButton *clearButton;
ShowFavoritesButton *favoriteButton; ShowFavoritesButton *favoriteButton;
ui::Label *authorLabel;
ui::List *authorList;
ui::ScrollWidget *authorScroll;
ui::Label *brandLabel;
ui::List *brandList;
ui::ScrollWidget *brandScroll;
ui::Label *tagLabel; ui::Label *tagLabel;
ui::List *tagList; ui::List *tagList;
ui::ScrollWidget *tagScroll; ui::ScrollWidget *tagScroll;
@@ -328,28 +328,28 @@ struct BrowserSidebar : widget::Widget {
dynamic_cast<ShowFavoritesQuantity*>(favoriteButton->quantity)->widget = favoriteButton; dynamic_cast<ShowFavoritesQuantity*>(favoriteButton->quantity)->widget = favoriteButton;
addChild(favoriteButton); addChild(favoriteButton);


authorLabel = new ui::Label;
// authorLabel->fontSize = 16;
authorLabel->color = nvgRGB(0x80, 0x80, 0x80);
authorLabel->text = "Authors";
addChild(authorLabel);
brandLabel = new ui::Label;
// brandLabel->fontSize = 16;
brandLabel->color = nvgRGB(0x80, 0x80, 0x80);
brandLabel->text = "Brands";
addChild(brandLabel);


// Plugin list // Plugin list
authorScroll = new ui::ScrollWidget;
addChild(authorScroll);
brandScroll = new ui::ScrollWidget;
addChild(brandScroll);


authorList = new ui::List;
authorScroll->container->addChild(authorList);
brandList = new ui::List;
brandScroll->container->addChild(brandList);


std::set<std::string, string::CaseInsensitiveCompare> authorNames;
std::set<std::string, string::CaseInsensitiveCompare> brands;
for (plugin::Plugin *plugin : plugin::plugins) { for (plugin::Plugin *plugin : plugin::plugins) {
authorNames.insert(plugin->author);
brands.insert(plugin->brand);
} }


for (const std::string &authorName : authorNames) {
AuthorItem *item = new AuthorItem;
item->text = authorName;
authorList->addChild(item);
for (const std::string &brand : brands) {
BrandItem *item = new BrandItem;
item->text = brand;
brandList->addChild(item);
} }


tagLabel = new ui::Label; tagLabel = new ui::Label;
@@ -382,14 +382,14 @@ struct BrowserSidebar : widget::Widget {
float listHeight = (box.size.y - favoriteButton->box.getBottom()) / 2; float listHeight = (box.size.y - favoriteButton->box.getBottom()) / 2;
listHeight = std::floor(listHeight); listHeight = std::floor(listHeight);


authorLabel->box.pos = favoriteButton->box.getBottomLeft();
authorLabel->box.size.x = box.size.x;
authorScroll->box.pos = authorLabel->box.getBottomLeft();
authorScroll->box.size.y = listHeight - authorLabel->box.size.y;
authorScroll->box.size.x = box.size.x;
authorList->box.size.x = authorScroll->box.size.x;
brandLabel->box.pos = favoriteButton->box.getBottomLeft();
brandLabel->box.size.x = box.size.x;
brandScroll->box.pos = brandLabel->box.getBottomLeft();
brandScroll->box.size.y = listHeight - brandLabel->box.size.y;
brandScroll->box.size.x = box.size.x;
brandList->box.size.x = brandScroll->box.size.x;


tagLabel->box.pos = authorScroll->box.getBottomLeft();
tagLabel->box.pos = brandScroll->box.getBottomLeft();
tagLabel->box.size.x = box.size.x; tagLabel->box.size.x = box.size.x;
tagScroll->box.pos = tagLabel->box.getBottomLeft(); tagScroll->box.pos = tagLabel->box.getBottomLeft();
tagScroll->box.size.y = listHeight - tagLabel->box.size.y; tagScroll->box.size.y = listHeight - tagLabel->box.size.y;
@@ -409,7 +409,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
ui::SequentialLayout *modelContainer; ui::SequentialLayout *modelContainer;


std::string search; std::string search;
std::string author;
std::string brand;
std::string tag; std::string tag;
bool favorites = false; bool favorites = false;


@@ -511,14 +511,14 @@ struct ModuleBrowser : widget::OpaqueWidget {
}); });
} }


// Filter ModelBoxes by author
if (!author.empty()) {
// Filter ModelBoxes by brand
if (!brand.empty()) {
for (Widget *w : modelContainer->children) { for (Widget *w : modelContainer->children) {
if (!w->visible) if (!w->visible)
continue; continue;
ModelBox *m = dynamic_cast<ModelBox*>(w); ModelBox *m = dynamic_cast<ModelBox*>(w);
assert(m); assert(m);
if (m->model->plugin->author != author)
if (m->model->plugin->brand != brand)
m->visible = false; m->visible = false;
} }
} }
@@ -542,16 +542,16 @@ struct ModuleBrowser : widget::OpaqueWidget {
} }
} }


std::set<std::string> enabledAuthors;
std::set<std::string> enabledBrands;
std::set<std::string> enabledTags; std::set<std::string> enabledTags;


// Get list of enabled authors and tags for sidebar
// Get list of enabled brands and tags for sidebar
for (Widget *w : modelContainer->children) { for (Widget *w : modelContainer->children) {
ModelBox *m = dynamic_cast<ModelBox*>(w); ModelBox *m = dynamic_cast<ModelBox*>(w);
assert(m); assert(m);
if (!m->visible) if (!m->visible)
continue; continue;
enabledAuthors.insert(m->model->plugin->author);
enabledBrands.insert(m->model->plugin->brand);
for (const std::string &tag : m->model->tags) { for (const std::string &tag : m->model->tags) {
enabledTags.insert(tag); enabledTags.insert(tag);
} }
@@ -565,17 +565,17 @@ struct ModuleBrowser : widget::OpaqueWidget {
} }
modelLabel->text = string::f("Modules (%d)", modelsLen); modelLabel->text = string::f("Modules (%d)", modelsLen);


// Enable author and tag items that are available in visible ModelBoxes
int authorsLen = 0;
for (Widget *w : sidebar->authorList->children) {
AuthorItem *item = dynamic_cast<AuthorItem*>(w);
// Enable brand and tag items that are available in visible ModelBoxes
int brandsLen = 0;
for (Widget *w : sidebar->brandList->children) {
BrandItem *item = dynamic_cast<BrandItem*>(w);
assert(item); assert(item);
auto it = enabledAuthors.find(item->text);
item->disabled = (it == enabledAuthors.end());
auto it = enabledBrands.find(item->text);
item->disabled = (it == enabledBrands.end());
if (!item->disabled) if (!item->disabled)
authorsLen++;
brandsLen++;
} }
sidebar->authorLabel->text = string::f("Authors (%d)", authorsLen);
sidebar->brandLabel->text = string::f("Brands (%d)", brandsLen);


int tagsLen = 0; int tagsLen = 0;
for (Widget *w : sidebar->tagList->children) { for (Widget *w : sidebar->tagList->children) {
@@ -592,7 +592,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
void clear() { void clear() {
search = ""; search = "";
sidebar->searchField->setText(""); sidebar->searchField->setText("");
author = "";
brand = "";
tag = ""; tag = "";
refresh(); refresh();
} }
@@ -632,19 +632,19 @@ inline void ModelBox::onButton(const event::Button &e) {
} }




inline void AuthorItem::onAction(const event::Action &e) {
inline void BrandItem::onAction(const event::Action &e) {
ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>(); ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>();
if (browser->author == text)
browser->author = "";
if (browser->brand == text)
browser->brand = "";
else else
browser->author = text;
browser->brand = text;
browser->refresh(); browser->refresh();
} }


inline void AuthorItem::step() {
inline void BrandItem::step() {
MenuItem::step(); MenuItem::step();
ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>(); ModuleBrowser *browser = getAncestorOfType<ModuleBrowser>();
active = (browser->author == text);
active = (browser->brand == text);
} }


inline void TagItem::onAction(const event::Action &e) { inline void TagItem::onAction(const event::Action &e) {


+ 7
- 0
src/plugin/Plugin.cpp View File

@@ -40,6 +40,13 @@ void Plugin::fromJson(json_t *rootJ) {
if (nameJ) if (nameJ)
name = json_string_value(nameJ); name = json_string_value(nameJ);


json_t *brandJ = json_object_get(rootJ, "brand");
if (brandJ)
brand = json_string_value(brandJ);
// Use name for brand name by default
if (brand == "")
brand = name;

json_t *authorJ = json_object_get(rootJ, "author"); json_t *authorJ = json_object_get(rootJ, "author");
if (authorJ) if (authorJ)
author = json_string_value(authorJ); author = json_string_value(authorJ);


Loading…
Cancel
Save