|
|
@@ -42,6 +42,7 @@ plugin::Model* createModel(const std::string& slug) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TWidget> |
|
|
|
TWidget* createWidget(math::Vec pos) { |
|
|
|
TWidget* o = new TWidget; |
|
|
@@ -49,6 +50,7 @@ TWidget* createWidget(math::Vec pos) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TWidget> |
|
|
|
TWidget* createWidgetCentered(math::Vec pos) { |
|
|
|
TWidget* o = createWidget<TWidget>(pos); |
|
|
@@ -56,6 +58,7 @@ TWidget* createWidgetCentered(math::Vec pos) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline app::SvgPanel* createPanel(std::string svgPath) { |
|
|
|
app::SvgPanel* panel = new app::SvgPanel; |
|
|
|
std::shared_ptr<Svg> svg = Svg::load(svgPath); |
|
|
@@ -63,6 +66,7 @@ inline app::SvgPanel* createPanel(std::string svgPath) { |
|
|
|
return panel; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TParamWidget> |
|
|
|
TParamWidget* createParam(math::Vec pos, engine::Module* module, int paramId) { |
|
|
|
TParamWidget* o = new TParamWidget; |
|
|
@@ -73,6 +77,7 @@ TParamWidget* createParam(math::Vec pos, engine::Module* module, int paramId) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TParamWidget> |
|
|
|
TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) { |
|
|
|
TParamWidget* o = createParam<TParamWidget>(pos, module, paramId); |
|
|
@@ -80,6 +85,7 @@ TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int par |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TPortWidget> |
|
|
|
TPortWidget* createInput(math::Vec pos, engine::Module* module, int inputId) { |
|
|
|
TPortWidget* o = new TPortWidget; |
|
|
@@ -90,6 +96,7 @@ TPortWidget* createInput(math::Vec pos, engine::Module* module, int inputId) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TPortWidget> |
|
|
|
TPortWidget* createInputCentered(math::Vec pos, engine::Module* module, int inputId) { |
|
|
|
TPortWidget* o = createInput<TPortWidget>(pos, module, inputId); |
|
|
@@ -97,6 +104,7 @@ TPortWidget* createInputCentered(math::Vec pos, engine::Module* module, int inpu |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TPortWidget> |
|
|
|
TPortWidget* createOutput(math::Vec pos, engine::Module* module, int outputId) { |
|
|
|
TPortWidget* o = new TPortWidget; |
|
|
@@ -107,6 +115,7 @@ TPortWidget* createOutput(math::Vec pos, engine::Module* module, int outputId) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TPortWidget> |
|
|
|
TPortWidget* createOutputCentered(math::Vec pos, engine::Module* module, int outputId) { |
|
|
|
TPortWidget* o = createOutput<TPortWidget>(pos, module, outputId); |
|
|
@@ -114,6 +123,7 @@ TPortWidget* createOutputCentered(math::Vec pos, engine::Module* module, int out |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TModuleLightWidget> |
|
|
|
TModuleLightWidget* createLight(math::Vec pos, engine::Module* module, int firstLightId) { |
|
|
|
TModuleLightWidget* o = new TModuleLightWidget; |
|
|
@@ -123,6 +133,7 @@ TModuleLightWidget* createLight(math::Vec pos, engine::Module* module, int first |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TModuleLightWidget> |
|
|
|
TModuleLightWidget* createLightCentered(math::Vec pos, engine::Module* module, int firstLightId) { |
|
|
|
TModuleLightWidget* o = createLight<TModuleLightWidget>(pos, module, firstLightId); |
|
|
@@ -130,6 +141,7 @@ TModuleLightWidget* createLightCentered(math::Vec pos, engine::Module* module, i |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Creates a param with a light and calls setFirstLightId() on it. */ |
|
|
|
template <class TParamWidget> |
|
|
|
TParamWidget* createLightParam(math::Vec pos, engine::Module* module, int paramId, int firstLightId) { |
|
|
@@ -138,6 +150,7 @@ TParamWidget* createLightParam(math::Vec pos, engine::Module* module, int paramI |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TParamWidget> |
|
|
|
TParamWidget* createLightParamCentered(math::Vec pos, engine::Module* module, int paramId, int firstLightId) { |
|
|
|
TParamWidget* o = createLightParam<TParamWidget>(pos, module, paramId, firstLightId); |
|
|
@@ -145,6 +158,7 @@ TParamWidget* createLightParamCentered(math::Vec pos, engine::Module* module, in |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TMenuLabel = ui::MenuLabel> |
|
|
|
TMenuLabel* createMenuLabel(std::string text) { |
|
|
|
TMenuLabel* o = new TMenuLabel; |
|
|
@@ -152,6 +166,7 @@ TMenuLabel* createMenuLabel(std::string text) { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TMenuItem = ui::MenuItem> |
|
|
|
TMenuItem* createMenuItem(std::string text, std::string rightText = "") { |
|
|
|
TMenuItem* o = new TMenuItem; |
|
|
@@ -160,6 +175,7 @@ TMenuItem* createMenuItem(std::string text, std::string rightText = "") { |
|
|
|
return o; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class TMenu = ui::Menu> |
|
|
|
TMenu* createMenu() { |
|
|
|
TMenu* o = new TMenu; |
|
|
@@ -173,4 +189,37 @@ TMenu* createMenu() { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <typename T = int> |
|
|
|
ui::MenuItem* createIndexMenuItem(T* ptr, std::string name, std::vector<std::string> labels) { |
|
|
|
struct IndexItem : ui::MenuItem { |
|
|
|
T* ptr; |
|
|
|
T index; |
|
|
|
void onAction(const event::Action& e) override { |
|
|
|
*ptr = index; |
|
|
|
} |
|
|
|
}; |
|
|
|
struct Item : ui::MenuItem { |
|
|
|
T* ptr; |
|
|
|
std::vector<std::string> labels; |
|
|
|
ui::Menu* createChildMenu() override { |
|
|
|
ui::Menu* menu = new ui::Menu; |
|
|
|
for (T i = 0; i < (T) labels.size(); i++) { |
|
|
|
IndexItem* item = createMenuItem<IndexItem>(labels[i], CHECKMARK(*ptr == i)); |
|
|
|
item->ptr = ptr; |
|
|
|
item->index = i; |
|
|
|
menu->addChild(item); |
|
|
|
} |
|
|
|
return menu; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
T index = *ptr; |
|
|
|
std::string label = (0 <= index && index < (T) labels.size()) ? labels[index] : ""; |
|
|
|
Item* item = createMenuItem<Item>(name, label + " " + RIGHT_ARROW); |
|
|
|
item->ptr = ptr; |
|
|
|
item->labels = labels; |
|
|
|
return item; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace rack |