Browse Source

Rename ModuleBrowser to Browser.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
196e18ba0c
7 changed files with 66 additions and 68 deletions
  1. +1
    -1
      include/app/Browser.hpp
  2. +1
    -1
      include/app/Scene.hpp
  3. +9
    -9
      include/settings.hpp
  4. +39
    -39
      src/app/Browser.cpp
  5. +1
    -2
      src/app/RackWidget.cpp
  6. +5
    -5
      src/app/Scene.cpp
  7. +10
    -11
      src/settings.cpp

include/app/ModuleBrowser.hpp → include/app/Browser.hpp View File

@@ -7,7 +7,7 @@ namespace rack {
namespace app {


widget::Widget* moduleBrowserCreate();
widget::Widget* browserCreate();


} // namespace app

+ 1
- 1
include/app/Scene.hpp View File

@@ -17,7 +17,7 @@ struct Scene : widget::OpaqueWidget {
RackScrollWidget* rackScroll;
RackWidget* rack;
widget::Widget* menuBar;
widget::Widget* moduleBrowser;
widget::Widget* browser;

double lastAutosaveTime = 0.0;
/** The last mouse position in the Scene */


+ 9
- 9
include/settings.hpp View File

@@ -79,16 +79,16 @@ extern bool autoCheckUpdates;
extern bool showTipsOnLaunch;
extern int tipIndex;
extern bool discordUpdateActivity;
enum ModuleBrowserSort {
MODULE_BROWSER_SORT_UPDATED,
MODULE_BROWSER_SORT_LAST_USED,
MODULE_BROWSER_SORT_MOST_USED,
MODULE_BROWSER_SORT_BRAND,
MODULE_BROWSER_SORT_NAME,
MODULE_BROWSER_SORT_RANDOM,
enum BrowserSort {
BROWSER_SORT_UPDATED,
BROWSER_SORT_LAST_USED,
BROWSER_SORT_MOST_USED,
BROWSER_SORT_BRAND,
BROWSER_SORT_NAME,
BROWSER_SORT_RANDOM,
};
extern ModuleBrowserSort moduleBrowserSort;
extern float moduleBrowserZoom;
extern BrowserSort browserSort;
extern float browserZoom;

struct ModuleInfo {
bool enabled = true;


src/app/ModuleBrowser.cpp → src/app/Browser.cpp View File

@@ -2,7 +2,7 @@
#include <algorithm>
#include <thread>

#include <app/ModuleBrowser.hpp>
#include <app/Browser.hpp>
#include <widget/OpaqueWidget.hpp>
#include <widget/TransparentWidget.hpp>
#include <widget/ZoomWidget.hpp>
@@ -36,7 +36,7 @@

namespace rack {
namespace app {
namespace moduleBrowser {
namespace browser {


static fuzzysearch::Database<plugin::Model*> modelDb;
@@ -103,7 +103,7 @@ static ModuleWidget* chooseModel(plugin::Model* model) {
APP->history->push(h);

// Hide Module Browser
APP->scene->moduleBrowser->hide();
APP->scene->browser->hide();

return moduleWidget;
}
@@ -112,7 +112,7 @@ static ModuleWidget* chooseModel(plugin::Model* model) {
// Widgets


struct ModuleBrowser;
struct Browser;


struct BrowserOverlay : ui::MenuOverlay {
@@ -147,7 +147,7 @@ struct ModelBox : widget::OpaqueWidget {
}

void updateZoom() {
float zoom = std::pow(2.f, settings::moduleBrowserZoom);
float zoom = std::pow(2.f, settings::browserZoom);

if (previewWidget) {
fb->setDirty();
@@ -310,7 +310,7 @@ struct ModelBox : widget::OpaqueWidget {


struct BrowserSearchField : ui::TextField {
ModuleBrowser* browser;
Browser* browser;

void step() override {
// Steal focus when step is called
@@ -335,20 +335,20 @@ struct BrowserSearchField : ui::TextField {


struct FavoriteQuantity : Quantity {
ModuleBrowser* browser;
Browser* browser;
void setValue(float value) override;
float getValue() override;
};


struct ClearButton : ui::Button {
ModuleBrowser* browser;
Browser* browser;
void onAction(const ActionEvent& e) override;
};


struct BrandItem : ui::MenuItem {
ModuleBrowser* browser;
Browser* browser;
std::string brand;
void onAction(const ActionEvent& e) override;
void step() override;
@@ -356,7 +356,7 @@ struct BrandItem : ui::MenuItem {


struct BrandButton : ui::ChoiceButton {
ModuleBrowser* browser;
Browser* browser;

void onAction(const ActionEvent& e) override;
void step() override;
@@ -364,7 +364,7 @@ struct BrandButton : ui::ChoiceButton {


struct TagItem : ui::MenuItem {
ModuleBrowser* browser;
Browser* browser;
int tagId;
void onAction(const ActionEvent& e) override;
void step() override;
@@ -372,7 +372,7 @@ struct TagItem : ui::MenuItem {


struct TagButton : ui::ChoiceButton {
ModuleBrowser* browser;
Browser* browser;

void onAction(const ActionEvent& e) override;
void step() override;
@@ -390,28 +390,28 @@ static const std::string sortNames[] = {


struct SortItem : ui::MenuItem {
ModuleBrowser* browser;
settings::ModuleBrowserSort sort;
Browser* browser;
settings::BrowserSort sort;
void onAction(const ActionEvent& e) override;
void step() override {
rightText = CHECKMARK(settings::moduleBrowserSort == sort);
rightText = CHECKMARK(settings::browserSort == sort);
MenuItem::step();
}
};


struct SortButton : ui::ChoiceButton {
ModuleBrowser* browser;
Browser* browser;

void onAction(const ActionEvent& e) override {
ui::Menu* menu = createMenu();
menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y));
menu->box.size.x = box.size.x;

for (int sortId = 0; sortId <= settings::MODULE_BROWSER_SORT_RANDOM; sortId++) {
for (int sortId = 0; sortId <= settings::BROWSER_SORT_RANDOM; sortId++) {
SortItem* sortItem = new SortItem;
sortItem->text = sortNames[sortId];
sortItem->sort = (settings::ModuleBrowserSort) sortId;
sortItem->sort = (settings::BrowserSort) sortId;
sortItem->browser = browser;
menu->addChild(sortItem);
}
@@ -419,25 +419,25 @@ struct SortButton : ui::ChoiceButton {

void step() override {
text = "Sort: ";
text += sortNames[settings::moduleBrowserSort];
text += sortNames[settings::browserSort];
ChoiceButton::step();
}
};


struct ZoomItem : ui::MenuItem {
ModuleBrowser* browser;
Browser* browser;
float zoom;
void onAction(const ActionEvent& e) override;
void step() override {
rightText = CHECKMARK(settings::moduleBrowserZoom == zoom);
rightText = CHECKMARK(settings::browserZoom == zoom);
MenuItem::step();
}
};


struct ZoomButton : ui::ChoiceButton {
ModuleBrowser* browser;
Browser* browser;

void onAction(const ActionEvent& e) override {
ui::Menu* menu = createMenu();
@@ -455,7 +455,7 @@ struct ZoomButton : ui::ChoiceButton {

void step() override {
text = "Zoom: ";
text += string::f("%.0f%%", std::pow(2.f, settings::moduleBrowserZoom) * 100.f);
text += string::f("%.0f%%", std::pow(2.f, settings::browserZoom) * 100.f);
ChoiceButton::step();
}
};
@@ -469,7 +469,7 @@ struct UrlButton : ui::Button {
};


struct ModuleBrowser : widget::OpaqueWidget {
struct Browser : widget::OpaqueWidget {
ui::SequentialLayout* headerLayout;
BrowserSearchField* searchField;
BrandButton* brandButton;
@@ -492,7 +492,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
std::map<plugin::Model*, float> prefilteredModelScores;
std::map<plugin::Model*, int> modelOrders;

ModuleBrowser() {
Browser() {
const float margin = 10;

// Header
@@ -573,7 +573,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
clear();
}

~ModuleBrowser() {
~Browser() {
delete favoriteQuantity;
}

@@ -698,14 +698,14 @@ struct ModuleBrowser : widget::OpaqueWidget {
}

// Sort ModelBoxes
if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_UPDATED) {
if (settings::browserSort == settings::BROWSER_SORT_UPDATED) {
sortModels([this](ModelBox* m) {
plugin::Plugin* p = m->model->plugin;
int modelOrder = get(modelOrders, m->model, 0);
return std::make_tuple(-p->modifiedTimestamp, p->brand, p->name, modelOrder);
});
}
else if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_LAST_USED) {
else if (settings::browserSort == settings::BROWSER_SORT_LAST_USED) {
sortModels([this](ModelBox* m) {
plugin::Plugin* p = m->model->plugin;
const settings::ModuleInfo* mi = settings::getModuleInfo(p->slug, m->model->slug);
@@ -714,7 +714,7 @@ struct ModuleBrowser : widget::OpaqueWidget {
return std::make_tuple(-lastAdded, -p->modifiedTimestamp, p->brand, p->name, modelOrder);
});
}
else if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_MOST_USED) {
else if (settings::browserSort == settings::BROWSER_SORT_MOST_USED) {
sortModels([this](ModelBox* m) {
plugin::Plugin* p = m->model->plugin;
const settings::ModuleInfo* mi = settings::getModuleInfo(p->slug, m->model->slug);
@@ -724,20 +724,20 @@ struct ModuleBrowser : widget::OpaqueWidget {
return std::make_tuple(-added, -lastAdded, -p->modifiedTimestamp, p->brand, p->name, modelOrder);
});
}
else if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_BRAND) {
else if (settings::browserSort == settings::BROWSER_SORT_BRAND) {
sortModels([this](ModelBox* m) {
plugin::Plugin* p = m->model->plugin;
int modelOrder = get(modelOrders, m->model, 0);
return std::make_tuple(p->brand, p->name, modelOrder);
});
}
else if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_NAME) {
else if (settings::browserSort == settings::BROWSER_SORT_NAME) {
sortModels([](ModelBox* m) {
plugin::Plugin* p = m->model->plugin;
return std::make_tuple(m->model->name, p->brand);
});
}
else if (settings::moduleBrowserSort == settings::MODULE_BROWSER_SORT_RANDOM) {
else if (settings::browserSort == settings::BROWSER_SORT_RANDOM) {
std::map<ModelBox*, uint64_t> randomOrder;
for (Widget* w : modelContainer->children) {
ModelBox* m = reinterpret_cast<ModelBox*>(w);
@@ -994,26 +994,26 @@ inline void TagButton::step() {
}

inline void SortItem::onAction(const ActionEvent& e) {
settings::moduleBrowserSort = sort;
settings::browserSort = sort;
browser->refresh();
}

inline void ZoomItem::onAction(const ActionEvent& e) {
if (zoom != settings::moduleBrowserZoom) {
settings::moduleBrowserZoom = zoom;
if (zoom != settings::browserZoom) {
settings::browserZoom = zoom;
browser->updateZoom();
}
}


} // namespace moduleBrowser
} // namespace browser


widget::Widget* moduleBrowserCreate() {
moduleBrowser::BrowserOverlay* overlay = new moduleBrowser::BrowserOverlay;
widget::Widget* browserCreate() {
browser::BrowserOverlay* overlay = new browser::BrowserOverlay;
overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33);

moduleBrowser::ModuleBrowser* browser = new moduleBrowser::ModuleBrowser;
browser::Browser* browser = new browser::Browser;
overlay->addChild(browser);

return overlay;

+ 1
- 2
src/app/RackWidget.cpp View File

@@ -9,7 +9,6 @@
#include <widget/TransparentWidget.hpp>
#include <app/RailWidget.hpp>
#include <app/Scene.hpp>
#include <app/ModuleBrowser.hpp>
#include <settings.hpp>
#include <plugin.hpp>
#include <engine/Engine.hpp>
@@ -148,7 +147,7 @@ void RackWidget::onButton(const ButtonEvent& e) {
return;

if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
APP->scene->moduleBrowser->show();
APP->scene->browser->show();
e.consume(this);
}
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) {


+ 5
- 5
src/app/Scene.cpp View File

@@ -3,7 +3,7 @@
#include <osdialog.h>

#include <app/Scene.hpp>
#include <app/ModuleBrowser.hpp>
#include <app/Browser.hpp>
#include <app/TipWindow.hpp>
#include <app/MenuBar.hpp>
#include <context.hpp>
@@ -59,9 +59,9 @@ Scene::Scene() {
menuBar = createMenuBar();
addChild(menuBar);

moduleBrowser = moduleBrowserCreate();
moduleBrowser->hide();
addChild(moduleBrowser);
browser = browserCreate();
browser->hide();
addChild(browser);

if (settings::showTipsOnLaunch) {
addChild(tipWindowCreate());
@@ -183,7 +183,7 @@ void Scene::onHoverKey(const HoverKeyEvent& e) {
e.consume(this);
}
if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && (e.mods & RACK_MOD_MASK) == 0) {
moduleBrowser->show();
browser->show();
e.consume(this);
}
if (e.key == GLFW_KEY_F1 && (e.mods & RACK_MOD_MASK) == 0) {


+ 10
- 11
src/settings.cpp View File

@@ -4,7 +4,6 @@
#include <Window.hpp>
#include <plugin.hpp>
#include <app/Scene.hpp>
#include <app/ModuleBrowser.hpp>
#include <engine/Engine.hpp>
#include <context.hpp>
#include <patch.hpp>
@@ -62,8 +61,8 @@ bool autoCheckUpdates = true;
bool showTipsOnLaunch = true;
int tipIndex = -1;
bool discordUpdateActivity = true;
ModuleBrowserSort moduleBrowserSort = MODULE_BROWSER_SORT_UPDATED;
float moduleBrowserZoom = -1.f;
BrowserSort browserSort = BROWSER_SORT_UPDATED;
float browserZoom = -1.f;
std::map<std::string, std::map<std::string, ModuleInfo>> moduleInfos;


@@ -164,9 +163,9 @@ json_t* toJson() {
if (!discordUpdateActivity)
json_object_set_new(rootJ, "discordUpdateActivity", json_boolean(discordUpdateActivity));

json_object_set_new(rootJ, "moduleBrowserSort", json_integer((int) moduleBrowserSort));
json_object_set_new(rootJ, "browserSort", json_integer((int) browserSort));

json_object_set_new(rootJ, "moduleBrowserZoom", json_real(moduleBrowserZoom));
json_object_set_new(rootJ, "browserZoom", json_real(browserZoom));

json_t* moduleInfosJ = json_object();
for (const auto& pluginPair : moduleInfos) {
@@ -341,13 +340,13 @@ void fromJson(json_t* rootJ) {
if (discordUpdateActivityJ)
discordUpdateActivity = json_boolean_value(discordUpdateActivityJ);

json_t* moduleBrowserSortJ = json_object_get(rootJ, "moduleBrowserSort");
if (moduleBrowserSortJ)
moduleBrowserSort = (ModuleBrowserSort) json_integer_value(moduleBrowserSortJ);
json_t* browserSortJ = json_object_get(rootJ, "browserSort");
if (browserSortJ)
browserSort = (BrowserSort) json_integer_value(browserSortJ);

json_t* moduleBrowserZoomJ = json_object_get(rootJ, "moduleBrowserZoom");
if (moduleBrowserZoomJ)
moduleBrowserZoom = json_number_value(moduleBrowserZoomJ);
json_t* browserZoomJ = json_object_get(rootJ, "browserZoom");
if (browserZoomJ)
browserZoom = json_number_value(browserZoomJ);

moduleInfos.clear();
json_t* moduleInfosJ = json_object_get(rootJ, "moduleInfos");


Loading…
Cancel
Save