Browse Source

Add Widget::addChildBottom(). Change ModuleWidget::setPanel behavior. Improve event docstrings. Temporarily disable glibc 2.23 header on Linux.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
212404c664
11 changed files with 43 additions and 29 deletions
  1. +1
    -1
      helper.py
  2. +1
    -2
      include/app/ModuleWidget.hpp
  3. +11
    -11
      include/event.hpp
  4. +1
    -1
      include/plugin/Model.hpp
  5. +2
    -2
      include/plugin/Plugin.hpp
  6. +1
    -1
      include/rack0.hpp
  7. +1
    -0
      include/widget/Widget.hpp
  8. +1
    -1
      plugin.mk
  9. +0
    -5
      src/Core/Blank.cpp
  10. +14
    -5
      src/app/ModuleWidget.cpp
  11. +10
    -0
      src/widget/Widget.cpp

+ 1
- 1
helper.py View File

@@ -211,7 +211,7 @@ def create_module(slug, panel_filename=None, source_filename=None):
with open(manifest_filename, "w") as f:
json.dump(manifest, f, indent=" ")

print(f"Added {slug} to plugin.json")
print(f"Added {slug} to {manifest_filename}")

# Check filenames
if panel_filename and source_filename:


+ 1
- 2
include/app/ModuleWidget.hpp View File

@@ -4,7 +4,6 @@
#include "ui/Menu.hpp"
#include "app/PortWidget.hpp"
#include "app/ParamWidget.hpp"
#include "app/SvgPanel.hpp"
#include "plugin/Model.hpp"
#include "engine/Module.hpp"

@@ -19,7 +18,7 @@ struct ModuleWidget : widget::OpaqueWidget {
/** Owned. */
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.
*/
std::vector<ParamWidget*> params;


+ 11
- 11
include/event.hpp View File

@@ -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.
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 {
};
@@ -175,28 +175,28 @@ struct HoverScroll : Base, PositionBase {


/** 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 {
};


/** 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 {
};


/** 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 {
};


/** 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 {
};
@@ -222,21 +222,21 @@ struct DragBase : Base {
};

/** 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 {
};


/** 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 {
};


/** 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 {
/** 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.
Must set the DragHover target to receive this event.
Must consume the DragHover event to receive this event.
*/
struct DragEnter : DragBase {
/** The dragged widget */
@@ -264,7 +264,7 @@ struct DragEnter : DragBase {


/** 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 {
/** The dragged widget */
@@ -273,7 +273,7 @@ struct DragLeave : DragBase {


/** 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 {
/** The dragged widget */


+ 1
- 1
include/plugin/Model.hpp View File

@@ -25,7 +25,7 @@ struct Model {
Plugin *plugin = NULL;
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.
*/
std::string slug;


+ 2
- 2
include/plugin/Plugin.hpp View File

@@ -15,12 +15,12 @@ struct Model;
struct Plugin {
/** A list of the models available by this plugin, add with addModel() */
std::vector<Model*> models;
/** The file path of the plugin's directory */
/** The file path to the plugin's directory */
std::string path;
/** OS-dependent library handle */
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"
*/
std::string slug;


+ 1
- 1
include/rack0.hpp View File

@@ -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 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 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 cmultf(float *cr, float *ci, float ar, float ai, float br, float bi) {return complexMult(ar, ai, br, bi, cr, ci);}

////////////////////
// random


+ 1
- 0
include/widget/Widget.hpp View File

@@ -71,6 +71,7 @@ struct Widget {
Gives ownership of widget to this widget instance.
*/
void addChild(Widget *child);
void addChildBottom(Widget *child);
/** Removes widget from list of children if it exists.
Does not delete widget but transfers ownership to caller
*/


+ 1
- 1
plugin.mk View File

@@ -24,7 +24,7 @@ ifdef ARCH_LIN
TARGET := plugin.so
RACK_USER_DIR ?= $(HOME)/.Rack
# 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

ifdef ARCH_MAC


+ 0
- 5
src/Core/Blank.cpp View File

@@ -99,11 +99,6 @@ struct BlankWidget : ModuleWidget {
setModule(module);
box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT);

// Delete SvgPanel
removeChild(panel);
delete panel;
panel = NULL;

blankPanel = new BlankPanel;
addChild(blankPanel);



+ 14
- 5
src/app/ModuleWidget.cpp View File

@@ -2,6 +2,7 @@
#include "app/Scene.hpp"
#include "engine/Engine.hpp"
#include "plugin/Plugin.hpp"
#include "app/SvgPanel.hpp"
#include "system.hpp"
#include "asset.hpp"
#include "helpers.hpp"
@@ -242,9 +243,6 @@ struct ModuleDeleteItem : ui::MenuItem {

ModuleWidget::ModuleWidget() {
box.size = math::Vec(0, RACK_GRID_HEIGHT);

panel = new SvgPanel;
addChild(panel);
}

ModuleWidget::~ModuleWidget() {
@@ -424,8 +422,19 @@ void ModuleWidget::setModule(engine::Module *module) {
}

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
box.size.x = std::round(panel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH;
}


+ 10
- 0
src/widget/Widget.cpp View File

@@ -94,6 +94,16 @@ void Widget::addChild(Widget *child) {
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) {
assert(child);
// Make sure `this` is the child's parent


Loading…
Cancel
Save