|
@@ -12,7 +12,7 @@ namespace rack { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static std::set<Model*> sFavoriteModels; |
|
|
static std::set<Model*> sFavoriteModels; |
|
|
static std::string sManufacturerFilter; |
|
|
|
|
|
|
|
|
static std::string sAuthorFilter; |
|
|
static ModelTag sTagFilter = NO_TAG; |
|
|
static ModelTag sTagFilter = NO_TAG; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -29,7 +29,7 @@ static bool isModelMatch(Model *model, std::string search) { |
|
|
std::string s; |
|
|
std::string s; |
|
|
s += model->plugin->slug; |
|
|
s += model->plugin->slug; |
|
|
s += " "; |
|
|
s += " "; |
|
|
s += model->manufacturer; |
|
|
|
|
|
|
|
|
s += model->author; |
|
|
s += " "; |
|
|
s += " "; |
|
|
s += model->name; |
|
|
s += model->name; |
|
|
s += " "; |
|
|
s += " "; |
|
@@ -98,7 +98,7 @@ struct BrowserListItem : OpaqueWidget { |
|
|
|
|
|
|
|
|
struct ModelItem : BrowserListItem { |
|
|
struct ModelItem : BrowserListItem { |
|
|
Model *model; |
|
|
Model *model; |
|
|
Label *manufacturerLabel; |
|
|
|
|
|
|
|
|
Label *authorLabel; |
|
|
|
|
|
|
|
|
void setModel(Model *model) { |
|
|
void setModel(Model *model) { |
|
|
clearChildren(); |
|
|
clearChildren(); |
|
@@ -109,10 +109,10 @@ struct ModelItem : BrowserListItem { |
|
|
nameLabel->text = model->name; |
|
|
nameLabel->text = model->name; |
|
|
addChild(nameLabel); |
|
|
addChild(nameLabel); |
|
|
|
|
|
|
|
|
manufacturerLabel = Widget::create<Label>(Vec(0, 0)); |
|
|
|
|
|
manufacturerLabel->alignment = Label::RIGHT_ALIGNMENT; |
|
|
|
|
|
manufacturerLabel->text = model->manufacturer; |
|
|
|
|
|
addChild(manufacturerLabel); |
|
|
|
|
|
|
|
|
authorLabel = Widget::create<Label>(Vec(0, 0)); |
|
|
|
|
|
authorLabel->alignment = Label::RIGHT_ALIGNMENT; |
|
|
|
|
|
authorLabel->text = model->author; |
|
|
|
|
|
addChild(authorLabel); |
|
|
|
|
|
|
|
|
SequentialLayout *layout2 = Widget::create<SequentialLayout>(Vec(7, BND_WIDGET_HEIGHT)); |
|
|
SequentialLayout *layout2 = Widget::create<SequentialLayout>(Vec(7, BND_WIDGET_HEIGHT)); |
|
|
layout2->spacing = 0; |
|
|
layout2->spacing = 0; |
|
@@ -147,7 +147,7 @@ struct ModelItem : BrowserListItem { |
|
|
|
|
|
|
|
|
void step() override { |
|
|
void step() override { |
|
|
BrowserListItem::step(); |
|
|
BrowserListItem::step(); |
|
|
manufacturerLabel->box.size.x = box.size.x - BND_SCROLLBAR_WIDTH; |
|
|
|
|
|
|
|
|
authorLabel->box.size.x = box.size.x - BND_SCROLLBAR_WIDTH; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onAction(EventAction &e) override { |
|
|
void onAction(EventAction &e) override { |
|
@@ -160,18 +160,18 @@ struct ModelItem : BrowserListItem { |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct ManufacturerItem : BrowserListItem { |
|
|
|
|
|
std::string manufacturer; |
|
|
|
|
|
|
|
|
struct AuthorItem : BrowserListItem { |
|
|
|
|
|
std::string author; |
|
|
|
|
|
|
|
|
void setManufacturer(std::string manufacturer) { |
|
|
|
|
|
|
|
|
void setAuthor(std::string author) { |
|
|
clearChildren(); |
|
|
clearChildren(); |
|
|
this->manufacturer = manufacturer; |
|
|
|
|
|
Label *manufacturerLabel = Widget::create<Label>(Vec(0, 0)); |
|
|
|
|
|
if (manufacturer.empty()) |
|
|
|
|
|
manufacturerLabel->text = "Show all modules"; |
|
|
|
|
|
|
|
|
this->author = author; |
|
|
|
|
|
Label *authorLabel = Widget::create<Label>(Vec(0, 0)); |
|
|
|
|
|
if (author.empty()) |
|
|
|
|
|
authorLabel->text = "Show all modules"; |
|
|
else |
|
|
else |
|
|
manufacturerLabel->text = manufacturer; |
|
|
|
|
|
addChild(manufacturerLabel); |
|
|
|
|
|
|
|
|
authorLabel->text = author; |
|
|
|
|
|
addChild(authorLabel); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void onAction(EventAction &e) override; |
|
|
void onAction(EventAction &e) override; |
|
@@ -292,7 +292,7 @@ struct ModuleBrowser : VirtualWidget { |
|
|
SearchModuleField *searchField; |
|
|
SearchModuleField *searchField; |
|
|
ScrollWidget *moduleScroll; |
|
|
ScrollWidget *moduleScroll; |
|
|
BrowserList *moduleList; |
|
|
BrowserList *moduleList; |
|
|
std::set<std::string> availableManufacturers; |
|
|
|
|
|
|
|
|
std::set<std::string> availableAuthors; |
|
|
std::set<ModelTag> availableTags; |
|
|
std::set<ModelTag> availableTags; |
|
|
|
|
|
|
|
|
ModuleBrowser() { |
|
|
ModuleBrowser() { |
|
@@ -314,12 +314,12 @@ struct ModuleBrowser : VirtualWidget { |
|
|
moduleScroll->container->addChild(moduleList); |
|
|
moduleScroll->container->addChild(moduleList); |
|
|
addChild(moduleScroll); |
|
|
addChild(moduleScroll); |
|
|
|
|
|
|
|
|
// Collect manufacturers |
|
|
|
|
|
|
|
|
// Collect authors |
|
|
for (Plugin *plugin : gPlugins) { |
|
|
for (Plugin *plugin : gPlugins) { |
|
|
for (Model *model : plugin->models) { |
|
|
for (Model *model : plugin->models) { |
|
|
// Insert manufacturer |
|
|
|
|
|
if (!model->manufacturer.empty()) |
|
|
|
|
|
availableManufacturers.insert(model->manufacturer); |
|
|
|
|
|
|
|
|
// Insert author |
|
|
|
|
|
if (!model->author.empty()) |
|
|
|
|
|
availableAuthors.insert(model->author); |
|
|
// Insert tag |
|
|
// Insert tag |
|
|
for (ModelTag tag : model->tags) { |
|
|
for (ModelTag tag : model->tags) { |
|
|
if (tag != NO_TAG) |
|
|
if (tag != NO_TAG) |
|
@@ -337,7 +337,7 @@ struct ModuleBrowser : VirtualWidget { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool isModelFiltered(Model *model) { |
|
|
bool isModelFiltered(Model *model) { |
|
|
if (!sManufacturerFilter.empty() && model->manufacturer != sManufacturerFilter) |
|
|
|
|
|
|
|
|
if (!sAuthorFilter.empty() && model->author != sAuthorFilter) |
|
|
return false; |
|
|
return false; |
|
|
if (sTagFilter != NO_TAG) { |
|
|
if (sTagFilter != NO_TAG) { |
|
|
auto it = std::find(model->tags.begin(), model->tags.end(), sTagFilter); |
|
|
auto it = std::find(model->tags.begin(), model->tags.end(), sTagFilter); |
|
@@ -366,18 +366,18 @@ struct ModuleBrowser : VirtualWidget { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Manufacturers |
|
|
|
|
|
if (sManufacturerFilter.empty() && sTagFilter == NO_TAG) { |
|
|
|
|
|
// Manufacturer items |
|
|
|
|
|
|
|
|
// Authors |
|
|
|
|
|
if (sAuthorFilter.empty() && sTagFilter == NO_TAG) { |
|
|
|
|
|
// Author items |
|
|
{ |
|
|
{ |
|
|
SeparatorItem *item = new SeparatorItem(); |
|
|
SeparatorItem *item = new SeparatorItem(); |
|
|
item->setText("Manufacturers"); |
|
|
|
|
|
|
|
|
item->setText("Authors"); |
|
|
moduleList->addChild(item); |
|
|
moduleList->addChild(item); |
|
|
} |
|
|
} |
|
|
for (std::string manufacturer : availableManufacturers) { |
|
|
|
|
|
if (isMatch(manufacturer, search)) { |
|
|
|
|
|
ManufacturerItem *item = new ManufacturerItem(); |
|
|
|
|
|
item->setManufacturer(manufacturer); |
|
|
|
|
|
|
|
|
for (std::string author : availableAuthors) { |
|
|
|
|
|
if (isMatch(author, search)) { |
|
|
|
|
|
AuthorItem *item = new AuthorItem(); |
|
|
|
|
|
item->setAuthor(author); |
|
|
moduleList->addChild(item); |
|
|
moduleList->addChild(item); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -401,7 +401,7 @@ struct ModuleBrowser : VirtualWidget { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Models |
|
|
// Models |
|
|
if (!sManufacturerFilter.empty() || sTagFilter != NO_TAG || !search.empty()) { |
|
|
|
|
|
|
|
|
if (!sAuthorFilter.empty() || sTagFilter != NO_TAG || !search.empty()) { |
|
|
{ |
|
|
{ |
|
|
SeparatorItem *item = new SeparatorItem(); |
|
|
SeparatorItem *item = new SeparatorItem(); |
|
|
item->setText("Modules"); |
|
|
item->setText("Modules"); |
|
@@ -433,9 +433,9 @@ struct ModuleBrowser : VirtualWidget { |
|
|
|
|
|
|
|
|
// Implementations of inline methods above |
|
|
// Implementations of inline methods above |
|
|
|
|
|
|
|
|
void ManufacturerItem::onAction(EventAction &e) { |
|
|
|
|
|
|
|
|
void AuthorItem::onAction(EventAction &e) { |
|
|
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); |
|
|
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); |
|
|
sManufacturerFilter = manufacturer; |
|
|
|
|
|
|
|
|
sAuthorFilter = author; |
|
|
moduleBrowser->clearSearch(); |
|
|
moduleBrowser->clearSearch(); |
|
|
moduleBrowser->refreshSearch(); |
|
|
moduleBrowser->refreshSearch(); |
|
|
e.consumed = false; |
|
|
e.consumed = false; |
|
@@ -451,7 +451,7 @@ void TagItem::onAction(EventAction &e) { |
|
|
|
|
|
|
|
|
void ClearFilterItem::onAction(EventAction &e) { |
|
|
void ClearFilterItem::onAction(EventAction &e) { |
|
|
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); |
|
|
ModuleBrowser *moduleBrowser = getAncestorOfType<ModuleBrowser>(); |
|
|
sManufacturerFilter = ""; |
|
|
|
|
|
|
|
|
sAuthorFilter = ""; |
|
|
sTagFilter = NO_TAG; |
|
|
sTagFilter = NO_TAG; |
|
|
moduleBrowser->clearSearch(); |
|
|
moduleBrowser->clearSearch(); |
|
|
moduleBrowser->refreshSearch(); |
|
|
moduleBrowser->refreshSearch(); |
|
|