@@ -2,6 +2,10 @@ | |||||
#include "common.hpp" | #include "common.hpp" | ||||
/** Accesses the global App pointer */ | |||||
#define APP rack::app::get() | |||||
namespace rack { | namespace rack { | ||||
@@ -45,9 +49,5 @@ void destroy(); | |||||
App *get(); | App *get(); | ||||
/** Accesses the global App pointer */ | |||||
#define APP rack::app::get() | |||||
} // namespace app | } // namespace app | ||||
} // namespace rack | } // namespace rack |
@@ -13,7 +13,7 @@ namespace app { | |||||
struct ModuleWidget : widget::OpaqueWidget { | struct ModuleWidget : widget::OpaqueWidget { | ||||
Model *model = NULL; | |||||
plugin::Model *model = NULL; | |||||
/** Owns the module pointer */ | /** Owns the module pointer */ | ||||
Module *module = NULL; | Module *module = NULL; | ||||
@@ -4,7 +4,11 @@ | |||||
namespace rack { | namespace rack { | ||||
struct Plugin; | |||||
namespace plugin { | |||||
struct Plugin; | |||||
} // namespace plugin | |||||
namespace asset { | namespace asset { | ||||
@@ -15,7 +19,7 @@ std::string system(std::string filename); | |||||
/** Returns the path of a user resource. Can read and write files to this location. */ | /** Returns the path of a user resource. Can read and write files to this location. */ | ||||
std::string user(std::string filename); | std::string user(std::string filename); | ||||
/** Returns the path of a resource in the plugin's folder. Should only read files from this location. */ | /** Returns the path of a resource in the plugin's folder. Should only read files from this location. */ | ||||
std::string plugin(Plugin *plugin, std::string filename); | |||||
std::string plugin(plugin::Plugin *plugin, std::string filename); | |||||
extern std::string systemDir; | extern std::string systemDir; | ||||
@@ -15,8 +15,8 @@ namespace rack { | |||||
template <class TModule, class TModuleWidget, typename... Tags> | template <class TModule, class TModuleWidget, typename... Tags> | ||||
Model *createModel(std::string slug) { | |||||
struct TModel : Model { | |||||
plugin::Model *createModel(std::string slug) { | |||||
struct TModel : plugin::Model { | |||||
Module *createModule() override { | Module *createModule() override { | ||||
TModule *o = new TModule; | TModule *o = new TModule; | ||||
return o; | return o; | ||||
@@ -34,7 +34,7 @@ Model *createModel(std::string slug) { | |||||
} | } | ||||
}; | }; | ||||
Model *o = new TModel; | |||||
plugin::Model *o = new TModel; | |||||
o->slug = slug; | o->slug = slug; | ||||
return o; | return o; | ||||
} | } | ||||
@@ -57,7 +57,7 @@ struct ModuleAction : Action { | |||||
struct ModuleAdd : ModuleAction { | struct ModuleAdd : ModuleAction { | ||||
Model *model; | |||||
plugin::Model *model; | |||||
math::Vec pos; | math::Vec pos; | ||||
json_t *moduleJ; | json_t *moduleJ; | ||||
~ModuleAdd(); | ~ModuleAdd(); | ||||
@@ -1,6 +1,17 @@ | |||||
#pragma once | #pragma once | ||||
/** Example usage: | |||||
DEBUG("error: %d", errno); | |||||
will print something like | |||||
[0.123 debug myfile.cpp:45] error: 67 | |||||
*/ | |||||
#define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define INFO(format, ...) rack::logger::log(rack::logger::INFO_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define WARN(format, ...) rack::logger::log(rack::logger::WARN_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define FATAL(format, ...) rack::logger::log(rack::logger::FATAL_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
namespace rack { | namespace rack { | ||||
namespace logger { | namespace logger { | ||||
@@ -18,16 +29,5 @@ void destroy(); | |||||
void log(Level level, const char *filename, int line, const char *format, ...); | void log(Level level, const char *filename, int line, const char *format, ...); | ||||
/** Example usage: | |||||
DEBUG("error: %d", errno); | |||||
will print something like | |||||
[0.123 debug myfile.cpp:45] error: 67 | |||||
*/ | |||||
#define DEBUG(format, ...) rack::logger::log(rack::logger::DEBUG_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define INFO(format, ...) rack::logger::log(rack::logger::INFO_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define WARN(format, ...) rack::logger::log(rack::logger::WARN_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
#define FATAL(format, ...) rack::logger::log(rack::logger::FATAL_LEVEL, __FILE__, __LINE__, format, ##__VA_ARGS__) | |||||
} // namespace logger | } // namespace logger | ||||
} // namespace rack | } // namespace rack |
@@ -12,9 +12,13 @@ namespace app { | |||||
struct ModuleWidget; | struct ModuleWidget; | ||||
} // namespace app | } // namespace app | ||||
struct Module; | struct Module; | ||||
namespace plugin { | |||||
struct Model { | struct Model { | ||||
Plugin *plugin = NULL; | Plugin *plugin = NULL; | ||||
@@ -41,4 +45,5 @@ struct Model { | |||||
}; | }; | ||||
} // namespace plugin | |||||
} // namespace rack | } // namespace rack |
@@ -5,6 +5,7 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace plugin { | |||||
struct Model; | struct Model; | ||||
@@ -46,4 +47,5 @@ struct Plugin { | |||||
}; | }; | ||||
} // namespace plugin | |||||
} // namespace rack | } // namespace rack |
@@ -6,4 +6,4 @@ | |||||
You must implement this in your plugin | You must implement this in your plugin | ||||
*/ | */ | ||||
extern "C" | extern "C" | ||||
void init(rack::Plugin *plugin); | |||||
void init(rack::plugin::Plugin *plugin); |
@@ -97,6 +97,8 @@ using namespace math; | |||||
using namespace widget; | using namespace widget; | ||||
using namespace ui; | using namespace ui; | ||||
using namespace app; | using namespace app; | ||||
using plugin::Plugin; | |||||
using plugin::Model; | |||||
} // namespace rack | } // namespace rack |
@@ -10,7 +10,6 @@ DISTRIBUTABLES += plugin.json | |||||
FLAGS += -fPIC | FLAGS += -fPIC | ||||
FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include | FLAGS += -I$(RACK_DIR)/include -I$(RACK_DIR)/dep/include | ||||
include $(RACK_DIR)/arch.mk | include $(RACK_DIR)/arch.mk | ||||
ifdef ARCH_LIN | ifdef ARCH_LIN | ||||
@@ -21,7 +21,7 @@ namespace rack { | |||||
namespace app { | namespace app { | ||||
static std::set<Model*> sFavoriteModels; | |||||
static std::set<plugin::Model*> sFavoriteModels; | |||||
struct BrowserOverlay : widget::OpaqueWidget { | struct BrowserOverlay : widget::OpaqueWidget { | ||||
@@ -57,13 +57,13 @@ struct BrowserOverlay : widget::OpaqueWidget { | |||||
struct ModuleBox : widget::OpaqueWidget { | struct ModuleBox : widget::OpaqueWidget { | ||||
Model *model; | |||||
plugin::Model *model; | |||||
/** Lazily created */ | /** Lazily created */ | ||||
widget::Widget *previewWidget = NULL; | widget::Widget *previewWidget = NULL; | ||||
/** Number of frames since draw() has been called */ | /** Number of frames since draw() has been called */ | ||||
int visibleFrames = 0; | int visibleFrames = 0; | ||||
void setModel(Model *model) { | |||||
void setModel(plugin::Model *model) { | |||||
this->model = model; | this->model = model; | ||||
box.size.x = 70.f; | box.size.x = 70.f; | ||||
@@ -173,8 +173,8 @@ struct ModuleBrowser : widget::OpaqueWidget { | |||||
moduleLayout->spacing = math::Vec(10, 10); | moduleLayout->spacing = math::Vec(10, 10); | ||||
moduleScroll->container->addChild(moduleLayout); | moduleScroll->container->addChild(moduleLayout); | ||||
for (Plugin *plugin : plugin::plugins) { | |||||
for (Model *model : plugin->models) { | |||||
for (plugin::Plugin *plugin : plugin::plugins) { | |||||
for (plugin::Model *model : plugin->models) { | |||||
ModuleBox *moduleBox = new ModuleBox; | ModuleBox *moduleBox = new ModuleBox; | ||||
moduleBox->setModel(model); | moduleBox->setModel(model); | ||||
moduleLayout->addChild(moduleBox); | moduleLayout->addChild(moduleBox); | ||||
@@ -244,7 +244,7 @@ json_t *moduleBrowserToJson() { | |||||
json_t *rootJ = json_object(); | json_t *rootJ = json_object(); | ||||
json_t *favoritesJ = json_array(); | json_t *favoritesJ = json_array(); | ||||
for (Model *model : sFavoriteModels) { | |||||
for (plugin::Model *model : sFavoriteModels) { | |||||
json_t *modelJ = json_object(); | json_t *modelJ = json_object(); | ||||
json_object_set_new(modelJ, "plugin", json_string(model->plugin->slug.c_str())); | json_object_set_new(modelJ, "plugin", json_string(model->plugin->slug.c_str())); | ||||
json_object_set_new(modelJ, "model", json_string(model->slug.c_str())); | json_object_set_new(modelJ, "model", json_string(model->slug.c_str())); | ||||
@@ -267,7 +267,7 @@ void moduleBrowserFromJson(json_t *rootJ) { | |||||
continue; | continue; | ||||
std::string pluginSlug = json_string_value(pluginJ); | std::string pluginSlug = json_string_value(pluginJ); | ||||
std::string modelSlug = json_string_value(modelJ); | std::string modelSlug = json_string_value(modelJ); | ||||
Model *model = plugin::getModel(pluginSlug, modelSlug); | |||||
plugin::Model *model = plugin::getModel(pluginSlug, modelSlug); | |||||
if (!model) | if (!model) | ||||
continue; | continue; | ||||
sFavoriteModels.insert(model); | sFavoriteModels.insert(model); | ||||
@@ -30,7 +30,7 @@ static ModuleWidget *moduleFromJson(json_t *moduleJ) { | |||||
std::string modelSlug = json_string_value(modelSlugJ); | std::string modelSlug = json_string_value(modelSlugJ); | ||||
// Get Model | // Get Model | ||||
Model *model = plugin::getModel(pluginSlug, modelSlug); | |||||
plugin::Model *model = plugin::getModel(pluginSlug, modelSlug); | |||||
if (!model) | if (!model) | ||||
return NULL; | return NULL; | ||||
@@ -105,7 +105,7 @@ std::string user(std::string filename) { | |||||
} | } | ||||
std::string plugin(Plugin *plugin, std::string filename) { | |||||
std::string plugin(plugin::Plugin *plugin, std::string filename) { | |||||
assert(plugin); | assert(plugin); | ||||
return plugin->path + "/" + filename; | return plugin->path + "/" + filename; | ||||
} | } | ||||
@@ -2,6 +2,7 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace plugin { | |||||
void Model::fromJson(json_t *rootJ) { | void Model::fromJson(json_t *rootJ) { | ||||
@@ -25,4 +26,5 @@ void Model::fromJson(json_t *rootJ) { | |||||
} | } | ||||
} // namespace plugin | |||||
} // namespace rack | } // namespace rack |
@@ -3,6 +3,7 @@ | |||||
namespace rack { | namespace rack { | ||||
namespace plugin { | |||||
Plugin::~Plugin() { | Plugin::~Plugin() { | ||||
@@ -88,4 +89,5 @@ void Plugin::fromJson(json_t *rootJ) { | |||||
} | } | ||||
} // namespace plugin | |||||
} // namespace rack | } // namespace rack |