@@ -211,7 +211,7 @@ def create_module(slug, panel_filename=None, source_filename=None): | |||||
with open(manifest_filename, "w") as f: | with open(manifest_filename, "w") as f: | ||||
json.dump(manifest, f, indent=" ") | json.dump(manifest, f, indent=" ") | ||||
print(f"Added {slug} to plugin.json") | |||||
print(f"Added {slug} to {manifest_filename}") | |||||
# Check filenames | # Check filenames | ||||
if panel_filename and source_filename: | if panel_filename and source_filename: | ||||
@@ -4,7 +4,6 @@ | |||||
#include "ui/Menu.hpp" | #include "ui/Menu.hpp" | ||||
#include "app/PortWidget.hpp" | #include "app/PortWidget.hpp" | ||||
#include "app/ParamWidget.hpp" | #include "app/ParamWidget.hpp" | ||||
#include "app/SvgPanel.hpp" | |||||
#include "plugin/Model.hpp" | #include "plugin/Model.hpp" | ||||
#include "engine/Module.hpp" | #include "engine/Module.hpp" | ||||
@@ -19,7 +18,7 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
/** Owned. */ | /** Owned. */ | ||||
engine::Module *module = NULL; | engine::Module *module = NULL; | ||||
SvgPanel *panel = NULL; | |||||
widget::Widget *panel = NULL; | |||||
/** Note that the indexes of these vectors do not necessarily correspond with the indexes of `Module::params` etc. | /** Note that the indexes of these vectors do not necessarily correspond with the indexes of `Module::params` etc. | ||||
*/ | */ | ||||
std::vector<ParamWidget*> params; | std::vector<ParamWidget*> params; | ||||
@@ -145,7 +145,7 @@ struct Button : Base, PositionBase { | |||||
/** Occurs when the left mouse button is pressed a second time on the same Widget within a time duration. | /** Occurs when the left mouse button is pressed a second time on the same Widget within a time duration. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on left button press) to receive this event. | |||||
*/ | */ | ||||
struct DoubleClick : Base { | struct DoubleClick : Base { | ||||
}; | }; | ||||
@@ -175,28 +175,28 @@ struct HoverScroll : Base, PositionBase { | |||||
/** Occurs when a Widget begins consuming the Hover event. | /** Occurs when a Widget begins consuming the Hover event. | ||||
Must set the Hover target to receive this event. | |||||
Must consume the Hover event to receive this event. | |||||
*/ | */ | ||||
struct Enter : Base { | struct Enter : Base { | ||||
}; | }; | ||||
/** Occurs when a different Widget is entered. | /** Occurs when a different Widget is entered. | ||||
Must set the Hover target to receive this event. | |||||
Must consume the Hover event (when a Widget is entered) to receive this event. | |||||
*/ | */ | ||||
struct Leave : Base { | struct Leave : Base { | ||||
}; | }; | ||||
/** Occurs when a Widget begins consuming the Button press event for the left mouse button. | /** Occurs when a Widget begins consuming the Button press event for the left mouse button. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on left button press) to receive this event. | |||||
*/ | */ | ||||
struct Select : Base { | struct Select : Base { | ||||
}; | }; | ||||
/** Occurs when a different Widget is selected. | /** Occurs when a different Widget is selected. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on left button press, when the Widget is selected) to receive this event. | |||||
*/ | */ | ||||
struct Deselect : Base { | struct Deselect : Base { | ||||
}; | }; | ||||
@@ -222,21 +222,21 @@ struct DragBase : Base { | |||||
}; | }; | ||||
/** Occurs when a Widget begins being dragged. | /** Occurs when a Widget begins being dragged. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on press) to receive this event. | |||||
*/ | */ | ||||
struct DragStart : DragBase { | struct DragStart : DragBase { | ||||
}; | }; | ||||
/** Occurs when a Widget stops being dragged by releasing the mouse button. | /** Occurs when a Widget stops being dragged by releasing the mouse button. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on press, when the Widget drag begins) to receive this event. | |||||
*/ | */ | ||||
struct DragEnd : DragBase { | struct DragEnd : DragBase { | ||||
}; | }; | ||||
/** Occurs every frame on the dragged Widget. | /** Occurs every frame on the dragged Widget. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on press, when the Widget drag begins) to receive this event. | |||||
*/ | */ | ||||
struct DragMove : DragBase { | struct DragMove : DragBase { | ||||
/** Change in mouse position since the last frame. Can be zero. */ | /** Change in mouse position since the last frame. Can be zero. */ | ||||
@@ -255,7 +255,7 @@ struct DragHover : DragBase, PositionBase { | |||||
}; | }; | ||||
/** Occurs when the mouse enters a Widget while dragging. | /** Occurs when the mouse enters a Widget while dragging. | ||||
Must set the DragHover target to receive this event. | |||||
Must consume the DragHover event to receive this event. | |||||
*/ | */ | ||||
struct DragEnter : DragBase { | struct DragEnter : DragBase { | ||||
/** The dragged widget */ | /** The dragged widget */ | ||||
@@ -264,7 +264,7 @@ struct DragEnter : DragBase { | |||||
/** Occurs when the mouse leaves a Widget while dragging. | /** Occurs when the mouse leaves a Widget while dragging. | ||||
Must set the DragHover target to receive this event. | |||||
Must consume the DragHover event (when the Widget is entered) to receive this event. | |||||
*/ | */ | ||||
struct DragLeave : DragBase { | struct DragLeave : DragBase { | ||||
/** The dragged widget */ | /** The dragged widget */ | ||||
@@ -273,7 +273,7 @@ struct DragLeave : DragBase { | |||||
/** Occurs when the mouse button is released over a Widget while dragging. | /** Occurs when the mouse button is released over a Widget while dragging. | ||||
Must set the Button target to receive this event. | |||||
Must consume the Button event (on release) to receive this event. | |||||
*/ | */ | ||||
struct DragDrop : DragBase { | struct DragDrop : DragBase { | ||||
/** The dragged widget */ | /** The dragged widget */ | ||||
@@ -25,7 +25,7 @@ struct Model { | |||||
Plugin *plugin = NULL; | Plugin *plugin = NULL; | ||||
std::vector<std::string> presetPaths; | std::vector<std::string> presetPaths; | ||||
/** Must be unique. Used for saving patches. Never change this. | |||||
/** Must be unique. Used for saving patches. Never change this after releasing your module. | |||||
The model slug must be unique within your plugin, but it doesn't need to be unique among different plugins. | The model slug must be unique within your plugin, but it doesn't need to be unique among different plugins. | ||||
*/ | */ | ||||
std::string slug; | std::string slug; | ||||
@@ -15,12 +15,12 @@ struct Model; | |||||
struct Plugin { | struct Plugin { | ||||
/** A list of the models available by this plugin, add with addModel() */ | /** A list of the models available by this plugin, add with addModel() */ | ||||
std::vector<Model*> models; | std::vector<Model*> models; | ||||
/** The file path of the plugin's directory */ | |||||
/** The file path to the plugin's directory */ | |||||
std::string path; | std::string path; | ||||
/** OS-dependent library handle */ | /** OS-dependent library handle */ | ||||
void *handle = NULL; | void *handle = NULL; | ||||
/** Must be unique. Used for saving patches. Never change this. | |||||
/** Must be unique. Used for saving patches. Never change this after releasing your plugin. | |||||
To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin" | To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin" | ||||
*/ | */ | ||||
std::string slug; | std::string slug; | ||||
@@ -44,8 +44,8 @@ DEPRECATED inline float chopf(float x, float eps) {return chop(x, eps);} | |||||
DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {return math::rescale(x, a, b, yMin, yMax);} | DEPRECATED inline float rescalef(float x, float a, float b, float yMin, float yMax) {return math::rescale(x, a, b, yMin, yMax);} | ||||
DEPRECATED inline float crossf(float a, float b, float frac) {return crossfade(a, b, frac);} | DEPRECATED inline float crossf(float a, float b, float frac) {return crossfade(a, b, frac);} | ||||
DEPRECATED inline float interpf(const float *p, float x) {return interpolateLinear(p, x);} | DEPRECATED inline float interpf(const float *p, float x) {return interpolateLinear(p, x);} | ||||
DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(cr, ci, ar, ai, br, bi);} | |||||
DEPRECATED inline void complexMult(float *cr, float *ci, float ar, float ai, float br, float bi) {complexMult(ar, ai, br, bi, cr, ci);} | DEPRECATED inline void complexMult(float *cr, float *ci, float ar, float ai, float br, float bi) {complexMult(ar, ai, br, bi, cr, ci);} | ||||
DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(ar, ai, br, bi, cr, ci);} | |||||
//////////////////// | //////////////////// | ||||
// random | // random | ||||
@@ -71,6 +71,7 @@ struct Widget { | |||||
Gives ownership of widget to this widget instance. | Gives ownership of widget to this widget instance. | ||||
*/ | */ | ||||
void addChild(Widget *child); | void addChild(Widget *child); | ||||
void addChildBottom(Widget *child); | |||||
/** Removes widget from list of children if it exists. | /** Removes widget from list of children if it exists. | ||||
Does not delete widget but transfers ownership to caller | Does not delete widget but transfers ownership to caller | ||||
*/ | */ | ||||
@@ -24,7 +24,7 @@ ifdef ARCH_LIN | |||||
TARGET := plugin.so | TARGET := plugin.so | ||||
RACK_USER_DIR ?= $(HOME)/.Rack | RACK_USER_DIR ?= $(HOME)/.Rack | ||||
# Link to glibc 2.23 | # Link to glibc 2.23 | ||||
FLAGS += -include $(RACK_DIR)/include/force_link_glibc_2.23.h | |||||
# FLAGS += -include $(RACK_DIR)/include/force_link_glibc_2.23.h | |||||
endif | endif | ||||
ifdef ARCH_MAC | ifdef ARCH_MAC | ||||
@@ -99,11 +99,6 @@ struct BlankWidget : ModuleWidget { | |||||
setModule(module); | setModule(module); | ||||
box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); | box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); | ||||
// Delete SvgPanel | |||||
removeChild(panel); | |||||
delete panel; | |||||
panel = NULL; | |||||
blankPanel = new BlankPanel; | blankPanel = new BlankPanel; | ||||
addChild(blankPanel); | addChild(blankPanel); | ||||
@@ -2,6 +2,7 @@ | |||||
#include "app/Scene.hpp" | #include "app/Scene.hpp" | ||||
#include "engine/Engine.hpp" | #include "engine/Engine.hpp" | ||||
#include "plugin/Plugin.hpp" | #include "plugin/Plugin.hpp" | ||||
#include "app/SvgPanel.hpp" | |||||
#include "system.hpp" | #include "system.hpp" | ||||
#include "asset.hpp" | #include "asset.hpp" | ||||
#include "helpers.hpp" | #include "helpers.hpp" | ||||
@@ -242,9 +243,6 @@ struct ModuleDeleteItem : ui::MenuItem { | |||||
ModuleWidget::ModuleWidget() { | ModuleWidget::ModuleWidget() { | ||||
box.size = math::Vec(0, RACK_GRID_HEIGHT); | box.size = math::Vec(0, RACK_GRID_HEIGHT); | ||||
panel = new SvgPanel; | |||||
addChild(panel); | |||||
} | } | ||||
ModuleWidget::~ModuleWidget() { | ModuleWidget::~ModuleWidget() { | ||||
@@ -424,8 +422,19 @@ void ModuleWidget::setModule(engine::Module *module) { | |||||
} | } | ||||
void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) { | void ModuleWidget::setPanel(std::shared_ptr<Svg> svg) { | ||||
assert(panel); | |||||
panel->setBackground(svg); | |||||
// Remove existing panel | |||||
if (panel) { | |||||
removeChild(panel); | |||||
delete panel; | |||||
panel = NULL; | |||||
} | |||||
// Create SvgPanel | |||||
SvgPanel *svgPanel = new SvgPanel; | |||||
svgPanel->setBackground(svg); | |||||
panel = svgPanel; | |||||
addChildBottom(panel); | |||||
// Set ModuleWidget size based on panel | // Set ModuleWidget size based on panel | ||||
box.size.x = std::round(panel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | box.size.x = std::round(panel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; | ||||
} | } | ||||
@@ -94,6 +94,16 @@ void Widget::addChild(Widget *child) { | |||||
child->onAdd(eAdd); | child->onAdd(eAdd); | ||||
} | } | ||||
void Widget::addChildBottom(Widget *child) { | |||||
assert(child); | |||||
assert(!child->parent); | |||||
child->parent = this; | |||||
children.push_front(child); | |||||
// event::Add | |||||
event::Add eAdd; | |||||
child->onAdd(eAdd); | |||||
} | |||||
void Widget::removeChild(Widget *child) { | void Widget::removeChild(Widget *child) { | ||||
assert(child); | assert(child); | ||||
// Make sure `this` is the child's parent | // Make sure `this` is the child's parent | ||||