Browse Source

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

tags/v1.0.0
Andrew Belt 5 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.
*/
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.
*/
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.
*/
std::string author;
@@ -41,12 +45,12 @@ struct Plugin {
std::string authorEmail;
/** Homepage featuring the plugin itself.
*/
std::string pluginUrl;
/** Homepage of the author.
*/
std::string authorUrl;
/** The manual of your plugin. HTML, PDF, or GitHub readme/wiki are fine.
*/
std::string pluginUrl;
/** Homepage of the author.
*/
std::string manualUrl;
/** 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) {
p->slug = "Core";
p->version = TOSTRING(VERSION);
p->license = "BSD-3-Clause";
p->name = "Core";
p->brand = "Core";
p->author = "VCV";
p->license = "BSD-3-Clause";
p->authorEmail = "contact@vcvrack.com";
p->pluginUrl = "https://vcvrack.com/";
p->authorUrl = "https://vcvrack.com/";
p->pluginUrl = "https://vcvrack.com/";
p->manualUrl = "https://vcvrack.com/manual/Core.html";
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;
s += model->plugin->slug;
s += " ";
s += model->plugin->author;
s += model->plugin->brand;
s += " ";
s += model->plugin->name;
s += " ";
@@ -215,7 +215,7 @@ struct ModelBox : widget::OpaqueWidget {

void onEnter(const event::Enter &e) override {
ui::Tooltip *tooltip = new ui::Tooltip;
tooltip->text = model->plugin->author;
tooltip->text = model->plugin->brand;
tooltip->text += " " + model->name;
if (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 step() override;
};
@@ -309,9 +309,9 @@ struct BrowserSidebar : widget::Widget {
BrowserSearchField *searchField;
ClearButton *clearButton;
ShowFavoritesButton *favoriteButton;
ui::Label *authorLabel;
ui::List *authorList;
ui::ScrollWidget *authorScroll;
ui::Label *brandLabel;
ui::List *brandList;
ui::ScrollWidget *brandScroll;
ui::Label *tagLabel;
ui::List *tagList;
ui::ScrollWidget *tagScroll;
@@ -328,28 +328,28 @@ struct BrowserSidebar : widget::Widget {
dynamic_cast<ShowFavoritesQuantity*>(favoriteButton->quantity)->widget = 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
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) {
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;
@@ -382,14 +382,14 @@ struct BrowserSidebar : widget::Widget {
float listHeight = (box.size.y - favoriteButton->box.getBottom()) / 2;
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;
tagScroll->box.pos = tagLabel->box.getBottomLeft();
tagScroll->box.size.y = listHeight - tagLabel->box.size.y;
@@ -409,7 +409,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
ui::SequentialLayout *modelContainer;

std::string search;
std::string author;
std::string brand;
std::string tag;
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) {
if (!w->visible)
continue;
ModelBox *m = dynamic_cast<ModelBox*>(w);
assert(m);
if (m->model->plugin->author != author)
if (m->model->plugin->brand != brand)
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;

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

int tagsLen = 0;
for (Widget *w : sidebar->tagList->children) {
@@ -592,7 +592,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
void clear() {
search = "";
sidebar->searchField->setText("");
author = "";
brand = "";
tag = "";
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>();
if (browser->author == text)
browser->author = "";
if (browser->brand == text)
browser->brand = "";
else
browser->author = text;
browser->brand = text;
browser->refresh();
}

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

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)
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");
if (authorJ)
author = json_string_value(authorJ);


Loading…
Cancel
Save