| @@ -19,24 +19,36 @@ struct Quantity { | |||||
| /** Returns the value | /** Returns the value | ||||
| Override this to return the state of your subclass. | Override this to return the state of your subclass. | ||||
| */ | */ | ||||
| virtual float getValue() {return 0.f;} | |||||
| virtual float getValue() { | |||||
| return 0.f; | |||||
| } | |||||
| /** Returns the minimum allowed value */ | /** Returns the minimum allowed value */ | ||||
| virtual float getMinValue() {return 0.f;} | |||||
| virtual float getMinValue() { | |||||
| return 0.f; | |||||
| } | |||||
| /** Returns the maximum allowed value */ | /** Returns the maximum allowed value */ | ||||
| virtual float getMaxValue() {return 1.f;} | |||||
| virtual float getMaxValue() { | |||||
| return 1.f; | |||||
| } | |||||
| /** Returns the default value, for resetting */ | /** Returns the default value, for resetting */ | ||||
| virtual float getDefaultValue() {return 0.f;} | |||||
| virtual float getDefaultValue() { | |||||
| return 0.f; | |||||
| } | |||||
| /** Returns the value, possibly transformed for displaying | /** Returns the value, possibly transformed for displaying | ||||
| Useful for logarithmic scaling, multiplying by 100 for percentages, etc. | Useful for logarithmic scaling, multiplying by 100 for percentages, etc. | ||||
| */ | */ | ||||
| virtual float getDisplayValue() {return getValue();} | |||||
| virtual float getDisplayValue() { | |||||
| return getValue(); | |||||
| } | |||||
| /** Inversely transforms the display value and sets the value */ | /** Inversely transforms the display value and sets the value */ | ||||
| virtual void setDisplayValue(float displayValue) {setValue(displayValue);} | |||||
| virtual void setDisplayValue(float displayValue) { | |||||
| setValue(displayValue); | |||||
| } | |||||
| /** The number of total decimal places for generating the display value string | /** The number of total decimal places for generating the display value string | ||||
| */ | */ | ||||
| @@ -48,12 +60,16 @@ struct Quantity { | |||||
| virtual void setDisplayValueString(std::string s); | virtual void setDisplayValueString(std::string s); | ||||
| /** The name of the quantity */ | /** The name of the quantity */ | ||||
| virtual std::string getLabel() {return "";} | |||||
| virtual std::string getLabel() { | |||||
| return ""; | |||||
| } | |||||
| /** The unit abbreviation of the quantity | /** The unit abbreviation of the quantity | ||||
| Include an initial space character if you want a space after the number, e.g. "440 Hz". This allows space-less units, like "100%". | Include an initial space character if you want a space after the number, e.g. "440 Hz". This allows space-less units, like "100%". | ||||
| */ | */ | ||||
| virtual std::string getUnit() {return "";} | |||||
| virtual std::string getUnit() { | |||||
| return ""; | |||||
| } | |||||
| /** Returns a string representation of the quantity */ | /** Returns a string representation of the quantity */ | ||||
| virtual std::string getString(); | virtual std::string getString(); | ||||
| @@ -6,12 +6,12 @@ namespace rack { | |||||
| namespace history { | namespace history { | ||||
| struct State; | |||||
| struct State; | |||||
| } // namespace history | } // namespace history | ||||
| namespace engine { | namespace engine { | ||||
| struct Engine; | |||||
| struct Engine; | |||||
| } // namespace engine | } // namespace engine | ||||
| @@ -20,23 +20,23 @@ struct PatchManager; | |||||
| namespace event { | namespace event { | ||||
| struct State; | |||||
| struct State; | |||||
| } // namespace event | } // namespace event | ||||
| namespace app { | namespace app { | ||||
| struct Scene; | |||||
| struct Scene; | |||||
| } // namespace app | } // namespace app | ||||
| /** Contains the application state */ | /** Contains the application state */ | ||||
| struct App { | struct App { | ||||
| event::State *event = NULL; | |||||
| app::Scene *scene = NULL; | |||||
| engine::Engine *engine = NULL; | |||||
| Window *window = NULL; | |||||
| history::State *history = NULL; | |||||
| PatchManager *patch = NULL; | |||||
| event::State* event = NULL; | |||||
| app::Scene* scene = NULL; | |||||
| engine::Engine* engine = NULL; | |||||
| Window* window = NULL; | |||||
| history::State* history = NULL; | |||||
| PatchManager* patch = NULL; | |||||
| void init(); | void init(); | ||||
| ~App(); | ~App(); | ||||
| @@ -46,7 +46,7 @@ struct App { | |||||
| void appInit(); | void appInit(); | ||||
| void appDestroy(); | void appDestroy(); | ||||
| /** Returns the global App pointer */ | /** Returns the global App pointer */ | ||||
| App *appGet(); | |||||
| App* appGet(); | |||||
| /** Accesses the global App pointer */ | /** Accesses the global App pointer */ | ||||
| #define APP appGet() | #define APP appGet() | ||||
| @@ -9,14 +9,14 @@ namespace app { | |||||
| struct AudioWidget : LedDisplay { | struct AudioWidget : LedDisplay { | ||||
| LedDisplayChoice *driverChoice; | |||||
| LedDisplaySeparator *driverSeparator; | |||||
| LedDisplayChoice *deviceChoice; | |||||
| LedDisplaySeparator *deviceSeparator; | |||||
| LedDisplayChoice *sampleRateChoice; | |||||
| LedDisplaySeparator *sampleRateSeparator; | |||||
| LedDisplayChoice *bufferSizeChoice; | |||||
| void setAudioPort(audio::Port *port); | |||||
| LedDisplayChoice* driverChoice; | |||||
| LedDisplaySeparator* driverSeparator; | |||||
| LedDisplayChoice* deviceChoice; | |||||
| LedDisplaySeparator* deviceSeparator; | |||||
| LedDisplayChoice* sampleRateChoice; | |||||
| LedDisplaySeparator* sampleRateSeparator; | |||||
| LedDisplayChoice* bufferSizeChoice; | |||||
| void setAudioPort(audio::Port* port); | |||||
| }; | }; | ||||
| @@ -12,25 +12,25 @@ namespace app { | |||||
| struct CableWidget : widget::OpaqueWidget { | struct CableWidget : widget::OpaqueWidget { | ||||
| PortWidget *outputPort = NULL; | |||||
| PortWidget *inputPort = NULL; | |||||
| PortWidget *hoveredOutputPort = NULL; | |||||
| PortWidget *hoveredInputPort = NULL; | |||||
| PortWidget* outputPort = NULL; | |||||
| PortWidget* inputPort = NULL; | |||||
| PortWidget* hoveredOutputPort = NULL; | |||||
| PortWidget* hoveredInputPort = NULL; | |||||
| /** Owned. */ | /** Owned. */ | ||||
| engine::Cable *cable; | |||||
| engine::Cable* cable; | |||||
| NVGcolor color; | NVGcolor color; | ||||
| CableWidget(); | CableWidget(); | ||||
| ~CableWidget(); | ~CableWidget(); | ||||
| bool isComplete(); | bool isComplete(); | ||||
| void setOutput(PortWidget *outputPort); | |||||
| void setInput(PortWidget *inputPort); | |||||
| void setOutput(PortWidget* outputPort); | |||||
| void setInput(PortWidget* inputPort); | |||||
| math::Vec getOutputPos(); | math::Vec getOutputPos(); | ||||
| math::Vec getInputPos(); | math::Vec getInputPos(); | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| void draw(const DrawArgs &args) override; | |||||
| void drawPlugs(const DrawArgs &args); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| void draw(const DrawArgs& args) override; | |||||
| void drawPlugs(const DrawArgs& args); | |||||
| }; | }; | ||||
| @@ -12,7 +12,7 @@ struct CircularShadow : widget::TransparentWidget { | |||||
| float opacity; | float opacity; | ||||
| CircularShadow(); | CircularShadow(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -20,11 +20,11 @@ struct Knob : ParamWidget { | |||||
| /** Drag horizontally instead of vertically */ | /** Drag horizontally instead of vertically */ | ||||
| bool horizontal = false; | bool horizontal = false; | ||||
| void onHover(const event::Hover &e) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDragMove(const event::DragMove &e) override; | |||||
| void onHover(const event::Hover& e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDragMove(const event::DragMove& e) override; | |||||
| void reset() override; | void reset() override; | ||||
| void randomize() override; | void randomize() override; | ||||
| }; | }; | ||||
| @@ -10,12 +10,12 @@ namespace app { | |||||
| struct LedDisplay : widget::OpaqueWidget { | struct LedDisplay : widget::OpaqueWidget { | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| struct LedDisplaySeparator : widget::Widget { | struct LedDisplaySeparator : widget::Widget { | ||||
| LedDisplaySeparator(); | LedDisplaySeparator(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| struct LedDisplayChoice : widget::OpaqueWidget { | struct LedDisplayChoice : widget::OpaqueWidget { | ||||
| @@ -25,8 +25,8 @@ struct LedDisplayChoice : widget::OpaqueWidget { | |||||
| NVGcolor color; | NVGcolor color; | ||||
| NVGcolor bgColor; | NVGcolor bgColor; | ||||
| LedDisplayChoice(); | LedDisplayChoice(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| }; | }; | ||||
| struct LedDisplayTextField : ui::TextField { | struct LedDisplayTextField : ui::TextField { | ||||
| @@ -34,7 +34,7 @@ struct LedDisplayTextField : ui::TextField { | |||||
| math::Vec textOffset; | math::Vec textOffset; | ||||
| NVGcolor color; | NVGcolor color; | ||||
| LedDisplayTextField(); | LedDisplayTextField(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| int getTextPosition(math::Vec mousePos) override; | int getTextPosition(math::Vec mousePos) override; | ||||
| }; | }; | ||||
| @@ -12,9 +12,9 @@ struct LightWidget : widget::TransparentWidget { | |||||
| NVGcolor color = nvgRGBA(0, 0, 0, 0); | NVGcolor color = nvgRGBA(0, 0, 0, 0); | ||||
| NVGcolor borderColor = nvgRGBA(0, 0, 0, 0); | NVGcolor borderColor = nvgRGBA(0, 0, 0, 0); | ||||
| void draw(const DrawArgs &args) override; | |||||
| virtual void drawLight(const DrawArgs &args); | |||||
| virtual void drawHalo(const DrawArgs &args); | |||||
| void draw(const DrawArgs& args) override; | |||||
| virtual void drawLight(const DrawArgs& args); | |||||
| virtual void drawHalo(const DrawArgs& args); | |||||
| }; | }; | ||||
| @@ -8,11 +8,11 @@ namespace app { | |||||
| struct MenuBar : widget::OpaqueWidget { | struct MenuBar : widget::OpaqueWidget { | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| MenuBar *createMenuBar(); | |||||
| MenuBar* createMenuBar(); | |||||
| } // namespace app | } // namespace app | ||||
| @@ -9,12 +9,12 @@ namespace app { | |||||
| struct MidiWidget : LedDisplay { | struct MidiWidget : LedDisplay { | ||||
| LedDisplayChoice *driverChoice; | |||||
| LedDisplaySeparator *driverSeparator; | |||||
| LedDisplayChoice *deviceChoice; | |||||
| LedDisplaySeparator *deviceSeparator; | |||||
| LedDisplayChoice *channelChoice; | |||||
| void setMidiPort(midi::Port *port); | |||||
| LedDisplayChoice* driverChoice; | |||||
| LedDisplaySeparator* driverSeparator; | |||||
| LedDisplayChoice* deviceChoice; | |||||
| LedDisplaySeparator* deviceSeparator; | |||||
| LedDisplayChoice* channelChoice; | |||||
| void setMidiPort(midi::Port* port); | |||||
| }; | }; | ||||
| @@ -7,7 +7,7 @@ namespace rack { | |||||
| namespace app { | namespace app { | ||||
| widget::Widget *moduleBrowserCreate(); | |||||
| widget::Widget* moduleBrowserCreate(); | |||||
| } // namespace app | } // namespace app | ||||
| @@ -12,7 +12,7 @@ namespace app { | |||||
| Will access firstLightId, firstLightId + 1, etc. for each added color | Will access firstLightId, firstLightId + 1, etc. for each added color | ||||
| */ | */ | ||||
| struct ModuleLightWidget : MultiLightWidget { | struct ModuleLightWidget : MultiLightWidget { | ||||
| engine::Module *module = NULL; | |||||
| engine::Module* module = NULL; | |||||
| int firstLightId; | int firstLightId; | ||||
| void step() override; | void step() override; | ||||
| @@ -14,11 +14,11 @@ namespace app { | |||||
| /** Manages an engine::Module in the rack. */ | /** Manages an engine::Module in the rack. */ | ||||
| struct ModuleWidget : widget::OpaqueWidget { | struct ModuleWidget : widget::OpaqueWidget { | ||||
| plugin::Model *model = NULL; | |||||
| plugin::Model* model = NULL; | |||||
| /** Owned. */ | /** Owned. */ | ||||
| engine::Module *module = NULL; | |||||
| engine::Module* module = NULL; | |||||
| widget::Widget *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; | ||||
| @@ -29,39 +29,39 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
| math::Vec oldPos; | math::Vec oldPos; | ||||
| ModuleWidget(); | ModuleWidget(); | ||||
| DEPRECATED ModuleWidget(engine::Module *module) : ModuleWidget() { | |||||
| DEPRECATED ModuleWidget(engine::Module* module) : ModuleWidget() { | |||||
| setModule(module); | setModule(module); | ||||
| } | } | ||||
| ~ModuleWidget(); | ~ModuleWidget(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void drawShadow(const DrawArgs &args); | |||||
| void draw(const DrawArgs& args) override; | |||||
| void drawShadow(const DrawArgs& args); | |||||
| void onButton(const event::Button &e) override; | |||||
| void onHoverKey(const event::HoverKey &e) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDragMove(const event::DragMove &e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onHoverKey(const event::HoverKey& e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDragMove(const event::DragMove& e) override; | |||||
| /** Associates this ModuleWidget with the Module | /** Associates this ModuleWidget with the Module | ||||
| Transfers ownership | Transfers ownership | ||||
| */ | */ | ||||
| void setModule(engine::Module *module); | |||||
| void setModule(engine::Module* module); | |||||
| void setPanel(std::shared_ptr<Svg> svg); | void setPanel(std::shared_ptr<Svg> svg); | ||||
| /** Convenience functions for adding special widgets (calls addChild()) */ | /** Convenience functions for adding special widgets (calls addChild()) */ | ||||
| void addParam(ParamWidget *param); | |||||
| void addOutput(PortWidget *output); | |||||
| void addInput(PortWidget *input); | |||||
| ParamWidget *getParam(int paramId); | |||||
| PortWidget *getOutput(int outputId); | |||||
| PortWidget *getInput(int inputId); | |||||
| void addParam(ParamWidget* param); | |||||
| void addOutput(PortWidget* output); | |||||
| void addInput(PortWidget* input); | |||||
| ParamWidget* getParam(int paramId); | |||||
| PortWidget* getOutput(int outputId); | |||||
| PortWidget* getInput(int inputId); | |||||
| /** Overriding these is deprecated. | /** Overriding these is deprecated. | ||||
| Use Module::dataToJson() and dataFromJson() instead | Use Module::dataToJson() and dataFromJson() instead | ||||
| */ | */ | ||||
| virtual json_t *toJson(); | |||||
| virtual void fromJson(json_t *rootJ); | |||||
| virtual json_t* toJson(); | |||||
| virtual void fromJson(json_t* rootJ); | |||||
| /** Serializes/unserializes the module state */ | /** Serializes/unserializes the module state */ | ||||
| void copyClipboard(); | void copyClipboard(); | ||||
| @@ -93,7 +93,7 @@ struct ModuleWidget : widget::OpaqueWidget { | |||||
| /** Override to add context menu entries to your subclass. | /** Override to add context menu entries to your subclass. | ||||
| It is recommended to add a blank ui::MenuEntry first for spacing. | It is recommended to add a blank ui::MenuEntry first for spacing. | ||||
| */ | */ | ||||
| virtual void appendContextMenu(ui::Menu *menu) {} | |||||
| virtual void appendContextMenu(ui::Menu* menu) {} | |||||
| }; | }; | ||||
| @@ -14,7 +14,7 @@ struct MultiLightWidget : LightWidget { | |||||
| void addBaseColor(NVGcolor baseColor); | void addBaseColor(NVGcolor baseColor); | ||||
| /** Sets the color to a linear combination of the baseColors with the given weights */ | /** Sets the color to a linear combination of the baseColors with the given weights */ | ||||
| void setBrightnesses(const std::vector<float> &brightnesses); | |||||
| void setBrightnesses(const std::vector<float>& brightnesses); | |||||
| }; | }; | ||||
| @@ -12,20 +12,20 @@ namespace app { | |||||
| /** Manages an engine::Param on a ModuleWidget. */ | /** Manages an engine::Param on a ModuleWidget. */ | ||||
| struct ParamWidget : widget::OpaqueWidget { | struct ParamWidget : widget::OpaqueWidget { | ||||
| engine::ParamQuantity *paramQuantity = NULL; | |||||
| engine::ParamQuantity* paramQuantity = NULL; | |||||
| float dirtyValue = NAN; | float dirtyValue = NAN; | ||||
| ui::Tooltip *tooltip = NULL; | |||||
| ui::Tooltip* tooltip = NULL; | |||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void onDoubleClick(const event::DoubleClick &e) override; | |||||
| void onEnter(const event::Enter &e) override; | |||||
| void onLeave(const event::Leave &e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onDoubleClick(const event::DoubleClick& e) override; | |||||
| void onEnter(const event::Enter& e) override; | |||||
| void onLeave(const event::Leave& e) override; | |||||
| /** For legacy patch loading */ | /** For legacy patch loading */ | ||||
| void fromJson(json_t *rootJ); | |||||
| void fromJson(json_t* rootJ); | |||||
| void createContextMenu(); | void createContextMenu(); | ||||
| void resetAction(); | void resetAction(); | ||||
| virtual void reset() {} | virtual void reset() {} | ||||
| @@ -11,7 +11,7 @@ namespace app { | |||||
| /** Manages an engine::Port on a ModuleWidget. */ | /** Manages an engine::Port on a ModuleWidget. */ | ||||
| struct PortWidget : widget::OpaqueWidget { | struct PortWidget : widget::OpaqueWidget { | ||||
| engine::Module *module = NULL; | |||||
| engine::Module* module = NULL; | |||||
| int portId; | int portId; | ||||
| bool hovered = false; | bool hovered = false; | ||||
| @@ -20,22 +20,22 @@ struct PortWidget : widget::OpaqueWidget { | |||||
| INPUT | INPUT | ||||
| }; | }; | ||||
| Type type; | Type type; | ||||
| MultiLightWidget *plugLight; | |||||
| MultiLightWidget* plugLight; | |||||
| PortWidget(); | PortWidget(); | ||||
| ~PortWidget(); | ~PortWidget(); | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void onEnter(const event::Enter &e) override; | |||||
| void onLeave(const event::Leave &e) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDragDrop(const event::DragDrop &e) override; | |||||
| void onDragEnter(const event::DragEnter &e) override; | |||||
| void onDragLeave(const event::DragLeave &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onEnter(const event::Enter& e) override; | |||||
| void onLeave(const event::Leave& e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDragDrop(const event::DragDrop& e) override; | |||||
| void onDragEnter(const event::DragEnter& e) override; | |||||
| void onDragLeave(const event::DragLeave& e) override; | |||||
| }; | }; | ||||
| @@ -11,7 +11,7 @@ struct RackRail : widget::TransparentWidget { | |||||
| std::shared_ptr<Svg> busBoardSvg; | std::shared_ptr<Svg> busBoardSvg; | ||||
| RackRail(); | RackRail(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -10,17 +10,17 @@ namespace app { | |||||
| struct RackScrollWidget : ui::ScrollWidget { | struct RackScrollWidget : ui::ScrollWidget { | ||||
| widget::ZoomWidget *zoomWidget; | |||||
| RackWidget *rackWidget; | |||||
| widget::ZoomWidget* zoomWidget; | |||||
| RackWidget* rackWidget; | |||||
| /** The pivot point for zooming */ | /** The pivot point for zooming */ | ||||
| math::Vec zoomPos; | math::Vec zoomPos; | ||||
| math::Vec oldOffset; | math::Vec oldOffset; | ||||
| RackScrollWidget(); | RackScrollWidget(); | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onHoverKey(const event::HoverKey &e) override; | |||||
| void onHoverScroll(const event::HoverScroll &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onHoverKey(const event::HoverKey& e) override; | |||||
| void onHoverScroll(const event::HoverScroll& e) override; | |||||
| void reset(); | void reset(); | ||||
| }; | }; | ||||
| @@ -16,13 +16,13 @@ namespace app { | |||||
| /** Container for ModuleWidget and CableWidget. */ | /** Container for ModuleWidget and CableWidget. */ | ||||
| struct RackWidget : widget::OpaqueWidget { | struct RackWidget : widget::OpaqueWidget { | ||||
| widget::Widget *moduleContainer; | |||||
| widget::Widget *cableContainer; | |||||
| CableWidget *incompleteCable = NULL; | |||||
| widget::FramebufferWidget *railFb; | |||||
| widget::Widget* moduleContainer; | |||||
| widget::Widget* cableContainer; | |||||
| CableWidget* incompleteCable = NULL; | |||||
| widget::FramebufferWidget* railFb; | |||||
| /** The last mouse position in the RackWidget */ | /** The last mouse position in the RackWidget */ | ||||
| math::Vec mousePos; | math::Vec mousePos; | ||||
| ParamWidget *touchedParam = NULL; | |||||
| ParamWidget* touchedParam = NULL; | |||||
| std::map<int, math::Vec> moduleDragPositions; | std::map<int, math::Vec> moduleDragPositions; | ||||
| int nextCableColorId = 0; | int nextCableColorId = 0; | ||||
| @@ -30,17 +30,17 @@ struct RackWidget : widget::OpaqueWidget { | |||||
| ~RackWidget(); | ~RackWidget(); | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onHover(const event::Hover &e) override; | |||||
| void onHoverKey(const event::HoverKey &e) override; | |||||
| void onDragHover(const event::DragHover &e) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void onHover(const event::Hover& e) override; | |||||
| void onHoverKey(const event::HoverKey& e) override; | |||||
| void onDragHover(const event::DragHover& e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| /** Completely clear the rack's modules and cables */ | /** Completely clear the rack's modules and cables */ | ||||
| void clear(); | void clear(); | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| void pastePresetClipboardAction(); | void pastePresetClipboardAction(); | ||||
| // Module methods | // Module methods | ||||
| @@ -48,39 +48,39 @@ struct RackWidget : widget::OpaqueWidget { | |||||
| /** Adds a module and adds it to the Engine | /** Adds a module and adds it to the Engine | ||||
| Ownership rules work like add/removeChild() | Ownership rules work like add/removeChild() | ||||
| */ | */ | ||||
| void addModule(ModuleWidget *mw); | |||||
| void addModuleAtMouse(ModuleWidget *mw); | |||||
| void addModule(ModuleWidget* mw); | |||||
| void addModuleAtMouse(ModuleWidget* mw); | |||||
| /** Removes the module and transfers ownership to the caller */ | /** Removes the module and transfers ownership to the caller */ | ||||
| void removeModule(ModuleWidget *mw); | |||||
| void removeModule(ModuleWidget* mw); | |||||
| /** Sets a module's box if non-colliding. Returns true if set */ | /** Sets a module's box if non-colliding. Returns true if set */ | ||||
| bool requestModulePos(ModuleWidget *mw, math::Vec pos); | |||||
| bool requestModulePos(ModuleWidget* mw, math::Vec pos); | |||||
| /** Moves a module to the closest non-colliding position */ | /** Moves a module to the closest non-colliding position */ | ||||
| void setModulePosNearest(ModuleWidget *mw, math::Vec pos); | |||||
| void setModulePosForce(ModuleWidget *mw, math::Vec pos); | |||||
| ModuleWidget *getModule(int moduleId); | |||||
| void setModulePosNearest(ModuleWidget* mw, math::Vec pos); | |||||
| void setModulePosForce(ModuleWidget* mw, math::Vec pos); | |||||
| ModuleWidget* getModule(int moduleId); | |||||
| bool isEmpty(); | bool isEmpty(); | ||||
| void updateModuleDragPositions(); | void updateModuleDragPositions(); | ||||
| history::ComplexAction *getModuleDragAction(); | |||||
| history::ComplexAction* getModuleDragAction(); | |||||
| // Cable methods | // Cable methods | ||||
| void clearCables(); | void clearCables(); | ||||
| void clearCablesAction(); | void clearCablesAction(); | ||||
| /** Removes all complete cables connected to the port */ | /** Removes all complete cables connected to the port */ | ||||
| void clearCablesOnPort(PortWidget *port); | |||||
| void clearCablesOnPort(PortWidget* port); | |||||
| /** Adds a complete cable and adds it to the Engine. | /** Adds a complete cable and adds it to the Engine. | ||||
| Ownership rules work like add/removeChild() | Ownership rules work like add/removeChild() | ||||
| */ | */ | ||||
| void addCable(CableWidget *w); | |||||
| void removeCable(CableWidget *w); | |||||
| void addCable(CableWidget* w); | |||||
| void removeCable(CableWidget* w); | |||||
| /** Takes ownership of `w` and adds it as a child if it isn't already */ | /** Takes ownership of `w` and adds it as a child if it isn't already */ | ||||
| void setIncompleteCable(CableWidget *w); | |||||
| CableWidget *releaseIncompleteCable(); | |||||
| void setIncompleteCable(CableWidget* w); | |||||
| CableWidget* releaseIncompleteCable(); | |||||
| /** Returns the most recently added complete cable connected to the given Port, i.e. the top of the stack */ | /** Returns the most recently added complete cable connected to the given Port, i.e. the top of the stack */ | ||||
| CableWidget *getTopCable(PortWidget *port); | |||||
| CableWidget *getCable(int cableId); | |||||
| CableWidget* getTopCable(PortWidget* port); | |||||
| CableWidget* getCable(int cableId); | |||||
| /** Returns all cables attached to port, complete or not */ | /** Returns all cables attached to port, complete or not */ | ||||
| std::list<CableWidget*> getCablesOnPort(PortWidget *port); | |||||
| std::list<CableWidget*> getCablesOnPort(PortWidget* port); | |||||
| }; | }; | ||||
| @@ -12,10 +12,10 @@ namespace app { | |||||
| struct Scene : widget::OpaqueWidget { | struct Scene : widget::OpaqueWidget { | ||||
| // Convenience variables for accessing important widgets | // Convenience variables for accessing important widgets | ||||
| RackScrollWidget *rackScroll; | |||||
| RackWidget *rack; | |||||
| MenuBar *menuBar; | |||||
| widget::Widget *moduleBrowser; | |||||
| RackScrollWidget* rackScroll; | |||||
| RackWidget* rack; | |||||
| MenuBar* menuBar; | |||||
| widget::Widget* moduleBrowser; | |||||
| double lastAutosaveTime = 0.0; | double lastAutosaveTime = 0.0; | ||||
| @@ -27,9 +27,9 @@ struct Scene : widget::OpaqueWidget { | |||||
| Scene(); | Scene(); | ||||
| ~Scene(); | ~Scene(); | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onHoverKey(const event::HoverKey &e) override; | |||||
| void onPathDrop(const event::PathDrop &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onHoverKey(const event::HoverKey& e) override; | |||||
| void onPathDrop(const event::PathDrop& e) override; | |||||
| void runCheckVersion(); | void runCheckVersion(); | ||||
| }; | }; | ||||
| @@ -9,10 +9,10 @@ namespace app { | |||||
| struct SliderKnob : Knob { | struct SliderKnob : Knob { | ||||
| // Bypass Knob's circular hitbox detection | // Bypass Knob's circular hitbox detection | ||||
| void onHover(const event::Hover &e) override { | |||||
| void onHover(const event::Hover& e) override { | |||||
| ParamWidget::onHover(e); | ParamWidget::onHover(e); | ||||
| } | } | ||||
| void onButton(const event::Button &e) override { | |||||
| void onButton(const event::Button& e) override { | |||||
| ParamWidget::onButton(e); | ParamWidget::onButton(e); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -11,16 +11,16 @@ namespace app { | |||||
| struct SvgButton : widget::OpaqueWidget { | struct SvgButton : widget::OpaqueWidget { | ||||
| widget::FramebufferWidget *fb; | |||||
| CircularShadow *shadow; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fb; | |||||
| CircularShadow* shadow; | |||||
| widget::SvgWidget* sw; | |||||
| std::vector<std::shared_ptr<Svg>> frames; | std::vector<std::shared_ptr<Svg>> frames; | ||||
| SvgButton(); | SvgButton(); | ||||
| void addFrame(std::shared_ptr<Svg> svg); | void addFrame(std::shared_ptr<Svg> svg); | ||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDragDrop(const event::DragDrop &e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDragDrop(const event::DragDrop& e) override; | |||||
| }; | }; | ||||
| @@ -13,18 +13,20 @@ namespace app { | |||||
| /** A knob which rotates an SVG and caches it in a framebuffer */ | /** A knob which rotates an SVG and caches it in a framebuffer */ | ||||
| struct SvgKnob : Knob { | struct SvgKnob : Knob { | ||||
| widget::FramebufferWidget *fb; | |||||
| CircularShadow *shadow; | |||||
| widget::TransformWidget *tw; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fb; | |||||
| CircularShadow* shadow; | |||||
| widget::TransformWidget* tw; | |||||
| widget::SvgWidget* sw; | |||||
| /** Angles in radians */ | /** Angles in radians */ | ||||
| float minAngle = 0.f; | float minAngle = 0.f; | ||||
| float maxAngle = M_PI; | float maxAngle = M_PI; | ||||
| SvgKnob(); | SvgKnob(); | ||||
| void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
| void onChange(const event::Change &e) override; | |||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) { | |||||
| setSvg(svg); | |||||
| } | |||||
| void onChange(const event::Change& e) override; | |||||
| }; | }; | ||||
| @@ -11,7 +11,7 @@ namespace app { | |||||
| struct PanelBorder : widget::TransparentWidget { | struct PanelBorder : widget::TransparentWidget { | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -11,13 +11,15 @@ namespace app { | |||||
| struct SvgPort : PortWidget { | struct SvgPort : PortWidget { | ||||
| widget::FramebufferWidget *fb; | |||||
| CircularShadow *shadow; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fb; | |||||
| CircularShadow* shadow; | |||||
| widget::SvgWidget* sw; | |||||
| SvgPort(); | SvgPort(); | ||||
| void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) { | |||||
| setSvg(svg); | |||||
| } | |||||
| }; | }; | ||||
| @@ -11,8 +11,8 @@ namespace app { | |||||
| /** If you don't add these to your ModuleWidget, they will fall out of the rack... */ | /** If you don't add these to your ModuleWidget, they will fall out of the rack... */ | ||||
| struct SvgScrew : widget::Widget { | struct SvgScrew : widget::Widget { | ||||
| widget::FramebufferWidget *fb; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fb; | |||||
| widget::SvgWidget* sw; | |||||
| SvgScrew(); | SvgScrew(); | ||||
| void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
| @@ -13,19 +13,23 @@ namespace app { | |||||
| Can be used for horizontal or vertical linear faders. | Can be used for horizontal or vertical linear faders. | ||||
| */ | */ | ||||
| struct SvgSlider : app::SliderKnob { | struct SvgSlider : app::SliderKnob { | ||||
| widget::FramebufferWidget *fb; | |||||
| widget::SvgWidget *background; | |||||
| widget::SvgWidget *handle; | |||||
| widget::FramebufferWidget* fb; | |||||
| widget::SvgWidget* background; | |||||
| widget::SvgWidget* handle; | |||||
| /** Intermediate positions will be interpolated between these positions */ | /** Intermediate positions will be interpolated between these positions */ | ||||
| math::Vec minHandlePos, maxHandlePos; | math::Vec minHandlePos, maxHandlePos; | ||||
| SvgSlider(); | SvgSlider(); | ||||
| void setBackgroundSvg(std::shared_ptr<Svg> svg); | void setBackgroundSvg(std::shared_ptr<Svg> svg); | ||||
| void setHandleSvg(std::shared_ptr<Svg> svg); | void setHandleSvg(std::shared_ptr<Svg> svg); | ||||
| void onChange(const event::Change &e) override; | |||||
| void onChange(const event::Change& e) override; | |||||
| DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | |||||
| DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) {setBackgroundSvg(svg);} | |||||
| DEPRECATED void setBackgroundSVG(std::shared_ptr<Svg> svg) { | |||||
| setBackgroundSvg(svg); | |||||
| } | |||||
| DEPRECATED void setHandleSVG(std::shared_ptr<Svg> svg) { | |||||
| setBackgroundSvg(svg); | |||||
| } | |||||
| DEPRECATED void setSVGs(std::shared_ptr<Svg> backgroundSvg, std::shared_ptr<Svg> handleSvg) { | DEPRECATED void setSVGs(std::shared_ptr<Svg> backgroundSvg, std::shared_ptr<Svg> handleSvg) { | ||||
| setBackgroundSvg(backgroundSvg); | setBackgroundSvg(backgroundSvg); | ||||
| setHandleSvg(handleSvg); | setHandleSvg(handleSvg); | ||||
| @@ -12,15 +12,15 @@ namespace app { | |||||
| /** A ParamWidget with multiple frames corresponding to its value */ | /** A ParamWidget with multiple frames corresponding to its value */ | ||||
| struct SvgSwitch : Switch { | struct SvgSwitch : Switch { | ||||
| widget::FramebufferWidget *fb; | |||||
| CircularShadow *shadow; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fb; | |||||
| CircularShadow* shadow; | |||||
| widget::SvgWidget* sw; | |||||
| std::vector<std::shared_ptr<Svg>> frames; | std::vector<std::shared_ptr<Svg>> frames; | ||||
| SvgSwitch(); | SvgSwitch(); | ||||
| /** Adds an SVG file to represent the next switch position */ | /** Adds an SVG file to represent the next switch position */ | ||||
| void addFrame(std::shared_ptr<Svg> svg); | void addFrame(std::shared_ptr<Svg> svg); | ||||
| void onChange(const event::Change &e) override; | |||||
| void onChange(const event::Change& e) override; | |||||
| }; | }; | ||||
| @@ -20,9 +20,9 @@ struct Switch : ParamWidget { | |||||
| bool momentaryReleased = false; | bool momentaryReleased = false; | ||||
| void step() override; | void step() override; | ||||
| void onDoubleClick(const event::DoubleClick &e) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDoubleClick(const event::DoubleClick& e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void reset() override; | void reset() override; | ||||
| void randomize() override; | void randomize() override; | ||||
| }; | }; | ||||
| @@ -6,7 +6,7 @@ namespace rack { | |||||
| namespace plugin { | namespace plugin { | ||||
| struct Plugin; | |||||
| struct Plugin; | |||||
| } // namespace plugin | } // namespace plugin | ||||
| @@ -19,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 *plugin, std::string filename); | |||||
| std::string plugin(plugin::Plugin* plugin, std::string filename); | |||||
| // Set these before calling init() to override the default paths | // Set these before calling init() to override the default paths | ||||
| @@ -4,7 +4,7 @@ | |||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||
| #ifndef __clang__ | #ifndef __clang__ | ||||
| #pragma GCC diagnostic ignored "-Wsuggest-override" | |||||
| #pragma GCC diagnostic ignored "-Wsuggest-override" | |||||
| #endif | #endif | ||||
| #include <RtAudio.h> | #include <RtAudio.h> | ||||
| #pragma GCC diagnostic pop | #pragma GCC diagnostic pop | ||||
| @@ -28,7 +28,7 @@ struct Port { | |||||
| int blockSize = 256; | int blockSize = 256; | ||||
| int numOutputs = 0; | int numOutputs = 0; | ||||
| int numInputs = 0; | int numInputs = 0; | ||||
| RtAudio *rtAudio = NULL; | |||||
| RtAudio* rtAudio = NULL; | |||||
| /** Cached */ | /** Cached */ | ||||
| RtAudio::DeviceInfo deviceInfo; | RtAudio::DeviceInfo deviceInfo; | ||||
| @@ -40,7 +40,7 @@ struct Port { | |||||
| void setDriverId(int driverId); | void setDriverId(int driverId); | ||||
| int getDeviceCount(); | int getDeviceCount(); | ||||
| bool getDeviceInfo(int deviceId, RtAudio::DeviceInfo *deviceInfo); | |||||
| bool getDeviceInfo(int deviceId, RtAudio::DeviceInfo* deviceInfo); | |||||
| /** Returns the number of inputs or outputs, whichever is greater */ | /** Returns the number of inputs or outputs, whichever is greater */ | ||||
| int getDeviceChannels(int deviceId); | int getDeviceChannels(int deviceId); | ||||
| std::string getDeviceName(int deviceId); | std::string getDeviceName(int deviceId); | ||||
| @@ -58,12 +58,12 @@ struct Port { | |||||
| void openStream(); | void openStream(); | ||||
| void closeStream(); | void closeStream(); | ||||
| virtual void processStream(const float *input, float *output, int frames) {} | |||||
| virtual void processStream(const float* input, float* output, int frames) {} | |||||
| virtual void onCloseStream() {} | virtual void onCloseStream() {} | ||||
| virtual void onOpenStream() {} | virtual void onOpenStream() {} | ||||
| virtual void onChannelsChange() {} | virtual void onChannelsChange() {} | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| }; | }; | ||||
| @@ -8,8 +8,8 @@ namespace rack { | |||||
| void bridgeInit(); | void bridgeInit(); | ||||
| void bridgeDestroy(); | void bridgeDestroy(); | ||||
| void bridgeAudioSubscribe(int channel, audio::Port *port); | |||||
| void bridgeAudioUnsubscribe(int channel, audio::Port *port); | |||||
| void bridgeAudioSubscribe(int channel, audio::Port* port); | |||||
| void bridgeAudioUnsubscribe(int channel, audio::Port* port); | |||||
| } // namespace rack | } // namespace rack | ||||
| @@ -120,13 +120,13 @@ Example: | |||||
| Foo *foo = construct<Foo>(&Foo::greeting, "Hello world", &Foo::legs, 2); | Foo *foo = construct<Foo>(&Foo::greeting, "Hello world", &Foo::legs, 2); | ||||
| */ | */ | ||||
| template <typename T> | template <typename T> | ||||
| T *construct() { | |||||
| T* construct() { | |||||
| return new T; | return new T; | ||||
| } | } | ||||
| template <typename T, typename F, typename V, typename... Args> | template <typename T, typename F, typename V, typename... Args> | ||||
| T *construct(F f, V v, Args... args) { | |||||
| T *o = construct<T>(args...); | |||||
| T* construct(F f, V v, Args... args) { | |||||
| T* o = construct<T>(args...); | |||||
| o->*f = v; | o->*f = v; | ||||
| return o; | return o; | ||||
| } | } | ||||
| @@ -144,7 +144,9 @@ template <typename F> | |||||
| struct DeferWrapper { | struct DeferWrapper { | ||||
| F f; | F f; | ||||
| DeferWrapper(F f) : f(f) {} | DeferWrapper(F f) : f(f) {} | ||||
| ~DeferWrapper() { f(); } | |||||
| ~DeferWrapper() { | |||||
| f(); | |||||
| } | |||||
| }; | }; | ||||
| template <typename F> | template <typename F> | ||||
| @@ -157,7 +159,7 @@ DeferWrapper<F> deferWrapper(F f) { | |||||
| /** An exception meant to be shown to the user */ | /** An exception meant to be shown to the user */ | ||||
| struct UserException : std::runtime_error { | struct UserException : std::runtime_error { | ||||
| UserException(const std::string &msg) : std::runtime_error(msg) {} | |||||
| UserException(const std::string& msg) : std::runtime_error(msg) {} | |||||
| }; | }; | ||||
| @@ -45,8 +45,8 @@ static const NVGcolor SCHEME_DARK_GRAY = nvgRGB(0x17, 0x17, 0x17); | |||||
| struct RoundKnob : app::SvgKnob { | struct RoundKnob : app::SvgKnob { | ||||
| RoundKnob() { | RoundKnob() { | ||||
| minAngle = -0.83*M_PI; | |||||
| maxAngle = 0.83*M_PI; | |||||
| minAngle = -0.83 * M_PI; | |||||
| maxAngle = 0.83 * M_PI; | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -83,8 +83,8 @@ struct RoundBlackSnapKnob : RoundBlackKnob { | |||||
| struct Davies1900hKnob : app::SvgKnob { | struct Davies1900hKnob : app::SvgKnob { | ||||
| Davies1900hKnob() { | Davies1900hKnob() { | ||||
| minAngle = -0.83*M_PI; | |||||
| maxAngle = 0.83*M_PI; | |||||
| minAngle = -0.83 * M_PI; | |||||
| maxAngle = 0.83 * M_PI; | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -127,8 +127,8 @@ struct Davies1900hLargeRedKnob : Davies1900hKnob { | |||||
| struct Rogan : app::SvgKnob { | struct Rogan : app::SvgKnob { | ||||
| Rogan() { | Rogan() { | ||||
| minAngle = -0.83*M_PI; | |||||
| maxAngle = 0.83*M_PI; | |||||
| minAngle = -0.83 * M_PI; | |||||
| maxAngle = 0.83 * M_PI; | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -297,12 +297,12 @@ struct Rogan1PWhite : Rogan { | |||||
| struct SynthTechAlco : app::SvgKnob { | struct SynthTechAlco : app::SvgKnob { | ||||
| SynthTechAlco() { | SynthTechAlco() { | ||||
| minAngle = -0.82*M_PI; | |||||
| maxAngle = 0.82*M_PI; | |||||
| minAngle = -0.82 * M_PI; | |||||
| maxAngle = 0.82 * M_PI; | |||||
| setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg"))); | setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco.svg"))); | ||||
| // Add cap | // Add cap | ||||
| widget::FramebufferWidget *capFb = new widget::FramebufferWidget; | |||||
| widget::SvgWidget *cap = new widget::SvgWidget; | |||||
| widget::FramebufferWidget* capFb = new widget::FramebufferWidget; | |||||
| widget::SvgWidget* cap = new widget::SvgWidget; | |||||
| cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | cap->setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/SynthTechAlco_cap.svg"))); | ||||
| capFb->addChild(cap); | capFb->addChild(cap); | ||||
| addChild(capFb); | addChild(capFb); | ||||
| @@ -311,16 +311,16 @@ struct SynthTechAlco : app::SvgKnob { | |||||
| struct Trimpot : app::SvgKnob { | struct Trimpot : app::SvgKnob { | ||||
| Trimpot() { | Trimpot() { | ||||
| minAngle = -0.75*M_PI; | |||||
| maxAngle = 0.75*M_PI; | |||||
| minAngle = -0.75 * M_PI; | |||||
| maxAngle = 0.75 * M_PI; | |||||
| setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg"))); | setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/Trimpot.svg"))); | ||||
| } | } | ||||
| }; | }; | ||||
| struct BefacoBigKnob : app::SvgKnob { | struct BefacoBigKnob : app::SvgKnob { | ||||
| BefacoBigKnob() { | BefacoBigKnob() { | ||||
| minAngle = -0.75*M_PI; | |||||
| maxAngle = 0.75*M_PI; | |||||
| minAngle = -0.75 * M_PI; | |||||
| maxAngle = 0.75 * M_PI; | |||||
| setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg"))); | setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoBigKnob.svg"))); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -333,8 +333,8 @@ struct BefacoBigSnapKnob : BefacoBigKnob { | |||||
| struct BefacoTinyKnob : app::SvgKnob { | struct BefacoTinyKnob : app::SvgKnob { | ||||
| BefacoTinyKnob() { | BefacoTinyKnob() { | ||||
| minAngle = -0.75*M_PI; | |||||
| maxAngle = 0.75*M_PI; | |||||
| minAngle = -0.75 * M_PI; | |||||
| maxAngle = 0.75 * M_PI; | |||||
| setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | setSvg(APP->window->loadSvg(asset::system("res/ComponentLibrary/BefacoTinyKnob.svg"))); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -53,23 +53,23 @@ T dbToAmplitude(T db) { | |||||
| template <typename T> | template <typename T> | ||||
| T quadraticBipolar(T x) { | T quadraticBipolar(T x) { | ||||
| return simd::sgn(x) * (x*x); | |||||
| return simd::sgn(x) * (x * x); | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| T cubic(T x) { | T cubic(T x) { | ||||
| return x*x*x; | |||||
| return x * x * x; | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| T quarticBipolar(T x) { | T quarticBipolar(T x) { | ||||
| return simd::sgn(x) * (x*x*x*x); | |||||
| return simd::sgn(x) * (x * x * x * x); | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| T quintic(T x) { | T quintic(T x) { | ||||
| // optimal with -fassociative-math | // optimal with -fassociative-math | ||||
| return x*x*x*x*x; | |||||
| return x * x * x * x * x; | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| @@ -13,7 +13,7 @@ Wrapper for [PFFFT](https://bitbucket.org/jpommier/pffft/) | |||||
| Buffers must be aligned to 16-byte boundaries. new[] and malloc() do this for you. | Buffers must be aligned to 16-byte boundaries. new[] and malloc() do this for you. | ||||
| */ | */ | ||||
| struct RealFFT { | struct RealFFT { | ||||
| PFFFT_Setup *setup; | |||||
| PFFFT_Setup* setup; | |||||
| int length; | int length; | ||||
| RealFFT(size_t length) { | RealFFT(size_t length) { | ||||
| @@ -31,7 +31,7 @@ struct RealFFT { | |||||
| Output is arbitrarily ordered for performance reasons. | Output is arbitrarily ordered for performance reasons. | ||||
| However, this ordering is consistent, so element-wise multiplication with line up with other results, and the inverse FFT will return a correctly ordered result. | However, this ordering is consistent, so element-wise multiplication with line up with other results, and the inverse FFT will return a correctly ordered result. | ||||
| */ | */ | ||||
| void rfftUnordered(const float *input, float *output) { | |||||
| void rfftUnordered(const float* input, float* output) { | |||||
| pffft_transform(setup, input, output, NULL, PFFFT_FORWARD); | pffft_transform(setup, input, output, NULL, PFFFT_FORWARD); | ||||
| } | } | ||||
| @@ -39,7 +39,7 @@ struct RealFFT { | |||||
| Input is `2*length` elements. Output is `length` elements. | Input is `2*length` elements. Output is `length` elements. | ||||
| Scaling is such that IRFFT(RFFT(x)) = N*x. | Scaling is such that IRFFT(RFFT(x)) = N*x. | ||||
| */ | */ | ||||
| void irfftUnordered(const float *input, float *output) { | |||||
| void irfftUnordered(const float* input, float* output) { | |||||
| pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD); | pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD); | ||||
| } | } | ||||
| @@ -54,17 +54,17 @@ struct RealFFT { | |||||
| output[length - 2] = real(F(n/2 - 1)) | output[length - 2] = real(F(n/2 - 1)) | ||||
| output[length - 1] = imag(F(n/2 - 1)) | output[length - 1] = imag(F(n/2 - 1)) | ||||
| */ | */ | ||||
| void rfft(const float *input, float *output) { | |||||
| void rfft(const float* input, float* output) { | |||||
| pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD); | pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD); | ||||
| } | } | ||||
| void irfft(const float *input, float *output) { | |||||
| void irfft(const float* input, float* output) { | |||||
| pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD); | pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD); | ||||
| } | } | ||||
| /** Scales the RFFT so that `scale(IFFT(FFT(x))) = x`. | /** Scales the RFFT so that `scale(IFFT(FFT(x))) = x`. | ||||
| */ | */ | ||||
| void scale(float *x) { | |||||
| void scale(float* x) { | |||||
| float a = 1.f / length; | float a = 1.f / length; | ||||
| for (int i = 0; i < length; i++) { | for (int i = 0; i < length; i++) { | ||||
| x[i] *= a; | x[i] *= a; | ||||
| @@ -77,7 +77,7 @@ struct RealFFT { | |||||
| `length` must be a multiple of 16. | `length` must be a multiple of 16. | ||||
| */ | */ | ||||
| struct ComplexFFT { | struct ComplexFFT { | ||||
| PFFFT_Setup *setup; | |||||
| PFFFT_Setup* setup; | |||||
| int length; | int length; | ||||
| ComplexFFT(size_t length) { | ComplexFFT(size_t length) { | ||||
| @@ -93,7 +93,7 @@ struct ComplexFFT { | |||||
| Input and output must be aligned using the above align*() functions. | Input and output must be aligned using the above align*() functions. | ||||
| Input is `2*length` elements. Output is `2*length` elements. | Input is `2*length` elements. Output is `2*length` elements. | ||||
| */ | */ | ||||
| void fftUnordered(const float *input, float *output) { | |||||
| void fftUnordered(const float* input, float* output) { | |||||
| pffft_transform(setup, input, output, NULL, PFFFT_FORWARD); | pffft_transform(setup, input, output, NULL, PFFFT_FORWARD); | ||||
| } | } | ||||
| @@ -101,23 +101,23 @@ struct ComplexFFT { | |||||
| Input is `2*length` elements. Output is `2*length` elements. | Input is `2*length` elements. Output is `2*length` elements. | ||||
| Scaling is such that FFT(IFFT(x)) = N*x. | Scaling is such that FFT(IFFT(x)) = N*x. | ||||
| */ | */ | ||||
| void ifftUnordered(const float *input, float *output) { | |||||
| void ifftUnordered(const float* input, float* output) { | |||||
| pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD); | pffft_transform(setup, input, output, NULL, PFFFT_BACKWARD); | ||||
| } | } | ||||
| void fft(const float *input, float *output) { | |||||
| void fft(const float* input, float* output) { | |||||
| pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD); | pffft_transform_ordered(setup, input, output, NULL, PFFFT_FORWARD); | ||||
| } | } | ||||
| void ifft(const float *input, float *output) { | |||||
| void ifft(const float* input, float* output) { | |||||
| pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD); | pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD); | ||||
| } | } | ||||
| void scale(float *x) { | |||||
| void scale(float* x) { | |||||
| float a = 1.f / length; | float a = 1.f / length; | ||||
| for (int i = 0; i < length; i++) { | for (int i = 0; i < length; i++) { | ||||
| x[2*i+0] *= a; | |||||
| x[2*i+1] *= a; | |||||
| x[2 * i + 0] *= a; | |||||
| x[2 * i + 1] *= a; | |||||
| } | } | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -214,7 +214,7 @@ struct TBiquadFilter { | |||||
| T process(T in) { | T process(T in) { | ||||
| // Advance IIR | // Advance IIR | ||||
| T out = b[0] * in + b[1] * x[0] + b[2] * x[1] | T out = b[0] * in + b[1] * x[0] + b[2] * x[1] | ||||
| - a[0] * y[0] - a[1] * y[1]; | |||||
| - a[0] * y[0] - a[1] * y[1]; | |||||
| // Push input | // Push input | ||||
| x[1] = x[0]; | x[1] = x[0]; | ||||
| x[0] = in; | x[0] = in; | ||||
| @@ -348,7 +348,7 @@ struct TBiquadFilter { | |||||
| } | } | ||||
| } | } | ||||
| void copyParameters(const TBiquadFilter<T> &from) { | |||||
| void copyParameters(const TBiquadFilter<T>& from) { | |||||
| b[0] = from.b[0]; | b[0] = from.b[0]; | ||||
| b[1] = from.b[1]; | b[1] = from.b[1]; | ||||
| b[2] = from.b[2]; | b[2] = from.b[2]; | ||||
| @@ -8,7 +8,7 @@ namespace dsp { | |||||
| /** Performs a direct sum convolution */ | /** Performs a direct sum convolution */ | ||||
| inline float convolveNaive(const float *in, const float *kernel, int len) { | |||||
| inline float convolveNaive(const float* in, const float* kernel, int len) { | |||||
| float y = 0.f; | float y = 0.f; | ||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| y += in[len - 1 - i] * kernel[i]; | y += in[len - 1 - i] * kernel[i]; | ||||
| @@ -17,7 +17,7 @@ inline float convolveNaive(const float *in, const float *kernel, int len) { | |||||
| } | } | ||||
| /** Computes the impulse response of a boxcar lowpass filter */ | /** Computes the impulse response of a boxcar lowpass filter */ | ||||
| inline void boxcarLowpassIR(float *out, int len, float cutoff = 0.5f) { | |||||
| inline void boxcarLowpassIR(float* out, int len, float cutoff = 0.5f) { | |||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| float t = i - (len - 1) / 2.f; | float t = i - (len - 1) / 2.f; | ||||
| out[i] = 2 * cutoff * sinc(2 * cutoff * t); | out[i] = 2 * cutoff * sinc(2 * cutoff * t); | ||||
| @@ -28,23 +28,23 @@ inline void boxcarLowpassIR(float *out, int len, float cutoff = 0.5f) { | |||||
| struct RealTimeConvolver { | struct RealTimeConvolver { | ||||
| // `kernelBlocks` number of contiguous FFT blocks of size `blockSize` | // `kernelBlocks` number of contiguous FFT blocks of size `blockSize` | ||||
| // indexed by [i * blockSize*2 + j] | // indexed by [i * blockSize*2 + j] | ||||
| float *kernelFfts = NULL; | |||||
| float *inputFfts = NULL; | |||||
| float *outputTail = NULL; | |||||
| float *tmpBlock = NULL; | |||||
| float* kernelFfts = NULL; | |||||
| float* inputFfts = NULL; | |||||
| float* outputTail = NULL; | |||||
| float* tmpBlock = NULL; | |||||
| size_t blockSize; | size_t blockSize; | ||||
| size_t kernelBlocks = 0; | size_t kernelBlocks = 0; | ||||
| size_t inputPos = 0; | size_t inputPos = 0; | ||||
| PFFFT_Setup *pffft; | |||||
| PFFFT_Setup* pffft; | |||||
| /** `blockSize` is the size of each FFT block. It should be >=32 and a power of 2. */ | /** `blockSize` is the size of each FFT block. It should be >=32 and a power of 2. */ | ||||
| RealTimeConvolver(size_t blockSize) { | RealTimeConvolver(size_t blockSize) { | ||||
| this->blockSize = blockSize; | this->blockSize = blockSize; | ||||
| pffft = pffft_new_setup(blockSize*2, PFFFT_REAL); | |||||
| pffft = pffft_new_setup(blockSize * 2, PFFFT_REAL); | |||||
| outputTail = new float[blockSize]; | outputTail = new float[blockSize]; | ||||
| std::memset(outputTail, 0, blockSize * sizeof(float)); | std::memset(outputTail, 0, blockSize * sizeof(float)); | ||||
| tmpBlock = new float[blockSize*2]; | |||||
| std::memset(tmpBlock, 0, blockSize*2 * sizeof(float)); | |||||
| tmpBlock = new float[blockSize * 2]; | |||||
| std::memset(tmpBlock, 0, blockSize * 2 * sizeof(float)); | |||||
| } | } | ||||
| ~RealTimeConvolver() { | ~RealTimeConvolver() { | ||||
| @@ -54,7 +54,7 @@ struct RealTimeConvolver { | |||||
| pffft_destroy_setup(pffft); | pffft_destroy_setup(pffft); | ||||
| } | } | ||||
| void setKernel(const float *kernel, size_t length) { | |||||
| void setKernel(const float* kernel, size_t length) { | |||||
| // Clear existing kernel | // Clear existing kernel | ||||
| if (kernelFfts) { | if (kernelFfts) { | ||||
| pffft_aligned_free(kernelFfts); | pffft_aligned_free(kernelFfts); | ||||
| @@ -72,17 +72,17 @@ struct RealTimeConvolver { | |||||
| kernelBlocks = (length - 1) / blockSize + 1; | kernelBlocks = (length - 1) / blockSize + 1; | ||||
| // Allocate blocks | // Allocate blocks | ||||
| kernelFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize*2 * kernelBlocks); | |||||
| inputFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize*2 * kernelBlocks); | |||||
| std::memset(inputFfts, 0, sizeof(float) * blockSize*2 * kernelBlocks); | |||||
| kernelFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize * 2 * kernelBlocks); | |||||
| inputFfts = (float*) pffft_aligned_malloc(sizeof(float) * blockSize * 2 * kernelBlocks); | |||||
| std::memset(inputFfts, 0, sizeof(float) * blockSize * 2 * kernelBlocks); | |||||
| for (size_t i = 0; i < kernelBlocks; i++) { | for (size_t i = 0; i < kernelBlocks; i++) { | ||||
| // Pad each block with zeros | // Pad each block with zeros | ||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize*2); | |||||
| size_t len = std::min((int) blockSize, (int) (length - i*blockSize)); | |||||
| std::memcpy(tmpBlock, &kernel[i*blockSize], sizeof(float)*len); | |||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2); | |||||
| size_t len = std::min((int) blockSize, (int)(length - i * blockSize)); | |||||
| std::memcpy(tmpBlock, &kernel[i * blockSize], sizeof(float)*len); | |||||
| // Compute fft | // Compute fft | ||||
| pffft_transform(pffft, tmpBlock, &kernelFfts[blockSize*2 * i], NULL, PFFFT_FORWARD); | |||||
| pffft_transform(pffft, tmpBlock, &kernelFfts[blockSize * 2 * i], NULL, PFFFT_FORWARD); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -90,7 +90,7 @@ struct RealTimeConvolver { | |||||
| /** Applies reverb to input | /** Applies reverb to input | ||||
| input and output must be of size `blockSize` | input and output must be of size `blockSize` | ||||
| */ | */ | ||||
| void processBlock(const float *input, float *output) { | |||||
| void processBlock(const float* input, float* output) { | |||||
| if (kernelBlocks == 0) { | if (kernelBlocks == 0) { | ||||
| std::memset(output, 0, sizeof(float) * blockSize); | std::memset(output, 0, sizeof(float) * blockSize); | ||||
| return; | return; | ||||
| @@ -99,17 +99,17 @@ struct RealTimeConvolver { | |||||
| // Step input position | // Step input position | ||||
| inputPos = (inputPos + 1) % kernelBlocks; | inputPos = (inputPos + 1) % kernelBlocks; | ||||
| // Pad block with zeros | // Pad block with zeros | ||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize*2); | |||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2); | |||||
| std::memcpy(tmpBlock, input, sizeof(float) * blockSize); | std::memcpy(tmpBlock, input, sizeof(float) * blockSize); | ||||
| // Compute input fft | // Compute input fft | ||||
| pffft_transform(pffft, tmpBlock, &inputFfts[blockSize*2 * inputPos], NULL, PFFFT_FORWARD); | |||||
| pffft_transform(pffft, tmpBlock, &inputFfts[blockSize * 2 * inputPos], NULL, PFFFT_FORWARD); | |||||
| // Create output fft | // Create output fft | ||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize*2); | |||||
| std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2); | |||||
| // convolve input fft by kernel fft | // convolve input fft by kernel fft | ||||
| // Note: This is the CPU bottleneck loop | // Note: This is the CPU bottleneck loop | ||||
| for (size_t i = 0; i < kernelBlocks; i++) { | for (size_t i = 0; i < kernelBlocks; i++) { | ||||
| size_t pos = (inputPos - i + kernelBlocks) % kernelBlocks; | size_t pos = (inputPos - i + kernelBlocks) % kernelBlocks; | ||||
| pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize*2 * i], &inputFfts[blockSize*2 * pos], tmpBlock, 1.f); | |||||
| pffft_zconvolve_accumulate(pffft, &kernelFfts[blockSize * 2 * i], &inputFfts[blockSize * 2 * pos], tmpBlock, 1.f); | |||||
| } | } | ||||
| // Compute output | // Compute output | ||||
| pffft_transform(pffft, tmpBlock, tmpBlock, NULL, PFFFT_BACKWARD); | pffft_transform(pffft, tmpBlock, tmpBlock, NULL, PFFFT_BACKWARD); | ||||
| @@ -118,7 +118,7 @@ struct RealTimeConvolver { | |||||
| tmpBlock[i] += outputTail[i]; | tmpBlock[i] += outputTail[i]; | ||||
| } | } | ||||
| // Copy output block to output | // Copy output block to output | ||||
| float scale = 1.f / (blockSize*2); | |||||
| float scale = 1.f / (blockSize * 2); | |||||
| for (size_t i = 0; i < blockSize; i++) { | for (size_t i = 0; i < blockSize; i++) { | ||||
| // Scale based on FFT | // Scale based on FFT | ||||
| output[i] = tmpBlock[i] * scale; | output[i] = tmpBlock[i] * scale; | ||||
| @@ -12,7 +12,7 @@ o: oversample factor | |||||
| output: must be length `2 * z * o`. | output: must be length `2 * z * o`. | ||||
| https://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf | https://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf | ||||
| */ | */ | ||||
| void minBlepImpulse(int z, int o, float *output); | |||||
| void minBlepImpulse(int z, int o, float* output); | |||||
| template <int Z, int O, typename T = float> | template <int Z, int O, typename T = float> | ||||
| @@ -15,7 +15,7 @@ namespace dsp { | |||||
| /** Resamples by a fixed rational factor. */ | /** Resamples by a fixed rational factor. */ | ||||
| template <int MAX_CHANNELS> | template <int MAX_CHANNELS> | ||||
| struct SampleRateConverter { | struct SampleRateConverter { | ||||
| SpeexResamplerState *st = NULL; | |||||
| SpeexResamplerState* st = NULL; | |||||
| int channels = MAX_CHANNELS; | int channels = MAX_CHANNELS; | ||||
| int quality = SPEEX_RESAMPLER_QUALITY_DEFAULT; | int quality = SPEEX_RESAMPLER_QUALITY_DEFAULT; | ||||
| int inRate = 44100; | int inRate = 44100; | ||||
| @@ -73,7 +73,7 @@ struct SampleRateConverter { | |||||
| } | } | ||||
| /** `in` and `out` are interlaced with the number of channels */ | /** `in` and `out` are interlaced with the number of channels */ | ||||
| void process(const Frame<MAX_CHANNELS> *in, int *inFrames, Frame<MAX_CHANNELS> *out, int *outFrames) { | |||||
| void process(const Frame<MAX_CHANNELS>* in, int* inFrames, Frame<MAX_CHANNELS>* out, int* outFrames) { | |||||
| assert(in); | assert(in); | ||||
| assert(inFrames); | assert(inFrames); | ||||
| assert(out); | assert(out); | ||||
| @@ -105,13 +105,13 @@ struct SampleRateConverter { | |||||
| /** Downsamples by an integer factor. */ | /** Downsamples by an integer factor. */ | ||||
| template <int OVERSAMPLE, int QUALITY, typename T = float> | template <int OVERSAMPLE, int QUALITY, typename T = float> | ||||
| struct Decimator { | struct Decimator { | ||||
| T inBuffer[OVERSAMPLE*QUALITY]; | |||||
| float kernel[OVERSAMPLE*QUALITY]; | |||||
| T inBuffer[OVERSAMPLE * QUALITY]; | |||||
| float kernel[OVERSAMPLE * QUALITY]; | |||||
| int inIndex; | int inIndex; | ||||
| Decimator(float cutoff = 0.9f) { | Decimator(float cutoff = 0.9f) { | ||||
| boxcarLowpassIR(kernel, OVERSAMPLE*QUALITY, cutoff * 0.5f / OVERSAMPLE); | |||||
| blackmanHarrisWindow(kernel, OVERSAMPLE*QUALITY); | |||||
| boxcarLowpassIR(kernel, OVERSAMPLE * QUALITY, cutoff * 0.5f / OVERSAMPLE); | |||||
| blackmanHarrisWindow(kernel, OVERSAMPLE * QUALITY); | |||||
| reset(); | reset(); | ||||
| } | } | ||||
| void reset() { | void reset() { | ||||
| @@ -119,17 +119,17 @@ struct Decimator { | |||||
| std::memset(inBuffer, 0, sizeof(inBuffer)); | std::memset(inBuffer, 0, sizeof(inBuffer)); | ||||
| } | } | ||||
| /** `in` must be length OVERSAMPLE */ | /** `in` must be length OVERSAMPLE */ | ||||
| T process(T *in) { | |||||
| T process(T* in) { | |||||
| // Copy input to buffer | // Copy input to buffer | ||||
| std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE*sizeof(T)); | |||||
| std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE * sizeof(T)); | |||||
| // Advance index | // Advance index | ||||
| inIndex += OVERSAMPLE; | inIndex += OVERSAMPLE; | ||||
| inIndex %= OVERSAMPLE*QUALITY; | |||||
| inIndex %= OVERSAMPLE * QUALITY; | |||||
| // Perform naive convolution | // Perform naive convolution | ||||
| T out = 0.f; | T out = 0.f; | ||||
| for (int i = 0; i < OVERSAMPLE*QUALITY; i++) { | |||||
| for (int i = 0; i < OVERSAMPLE * QUALITY; i++) { | |||||
| int index = inIndex - 1 - i; | int index = inIndex - 1 - i; | ||||
| index = (index + OVERSAMPLE*QUALITY) % (OVERSAMPLE*QUALITY); | |||||
| index = (index + OVERSAMPLE * QUALITY) % (OVERSAMPLE * QUALITY); | |||||
| out += kernel[i] * inBuffer[index]; | out += kernel[i] * inBuffer[index]; | ||||
| } | } | ||||
| return out; | return out; | ||||
| @@ -141,12 +141,12 @@ struct Decimator { | |||||
| template <int OVERSAMPLE, int QUALITY> | template <int OVERSAMPLE, int QUALITY> | ||||
| struct Upsampler { | struct Upsampler { | ||||
| float inBuffer[QUALITY]; | float inBuffer[QUALITY]; | ||||
| float kernel[OVERSAMPLE*QUALITY]; | |||||
| float kernel[OVERSAMPLE * QUALITY]; | |||||
| int inIndex; | int inIndex; | ||||
| Upsampler(float cutoff = 0.9f) { | Upsampler(float cutoff = 0.9f) { | ||||
| boxcarLowpassIR(kernel, OVERSAMPLE*QUALITY, cutoff * 0.5f / OVERSAMPLE); | |||||
| blackmanHarrisWindow(kernel, OVERSAMPLE*QUALITY); | |||||
| boxcarLowpassIR(kernel, OVERSAMPLE * QUALITY, cutoff * 0.5f / OVERSAMPLE); | |||||
| blackmanHarrisWindow(kernel, OVERSAMPLE * QUALITY); | |||||
| reset(); | reset(); | ||||
| } | } | ||||
| void reset() { | void reset() { | ||||
| @@ -154,7 +154,7 @@ struct Upsampler { | |||||
| std::memset(inBuffer, 0, sizeof(inBuffer)); | std::memset(inBuffer, 0, sizeof(inBuffer)); | ||||
| } | } | ||||
| /** `out` must be length OVERSAMPLE */ | /** `out` must be length OVERSAMPLE */ | ||||
| void process(float in, float *out) { | |||||
| void process(float in, float* out) { | |||||
| // Zero-stuff input buffer | // Zero-stuff input buffer | ||||
| inBuffer[inIndex] = OVERSAMPLE * in; | inBuffer[inIndex] = OVERSAMPLE * in; | ||||
| // Advance index | // Advance index | ||||
| @@ -18,13 +18,13 @@ struct RingBuffer { | |||||
| size_t end = 0; | size_t end = 0; | ||||
| size_t mask(size_t i) const { | size_t mask(size_t i) const { | ||||
| return i & (S - 1); | |||||
| return i & (S - 1); | |||||
| } | } | ||||
| void push(T t) { | void push(T t) { | ||||
| size_t i = mask(end++); | size_t i = mask(end++); | ||||
| data[i] = t; | data[i] = t; | ||||
| } | } | ||||
| void pushBuffer(const T *t, int n) { | |||||
| void pushBuffer(const T* t, int n) { | |||||
| size_t i = mask(end); | size_t i = mask(end); | ||||
| size_t e1 = i + n; | size_t e1 = i + n; | ||||
| size_t e2 = (e1 < S) ? e1 : S; | size_t e2 = (e1 < S) ? e1 : S; | ||||
| @@ -37,7 +37,7 @@ struct RingBuffer { | |||||
| T shift() { | T shift() { | ||||
| return data[mask(start++)]; | return data[mask(start++)]; | ||||
| } | } | ||||
| void shiftBuffer(T *t, size_t n) { | |||||
| void shiftBuffer(T* t, size_t n) { | |||||
| size_t i = mask(start); | size_t i = mask(start); | ||||
| size_t s1 = i + n; | size_t s1 = i + n; | ||||
| size_t s2 = (s1 < S) ? s1 : S; | size_t s2 = (s1 < S) ? s1 : S; | ||||
| @@ -70,7 +70,7 @@ Thread-safe for single producers and consumers? | |||||
| */ | */ | ||||
| template <typename T, size_t S> | template <typename T, size_t S> | ||||
| struct DoubleRingBuffer { | struct DoubleRingBuffer { | ||||
| T data[S*2]; | |||||
| T data[S * 2]; | |||||
| size_t start = 0; | size_t start = 0; | ||||
| size_t end = 0; | size_t end = 0; | ||||
| @@ -104,7 +104,7 @@ struct DoubleRingBuffer { | |||||
| If any data is appended, you must call endIncr afterwards. | If any data is appended, you must call endIncr afterwards. | ||||
| Pointer is invalidated when any other method is called. | Pointer is invalidated when any other method is called. | ||||
| */ | */ | ||||
| T *endData() { | |||||
| T* endData() { | |||||
| return &data[mask(end)]; | return &data[mask(end)]; | ||||
| } | } | ||||
| void endIncr(size_t n) { | void endIncr(size_t n) { | ||||
| @@ -123,7 +123,7 @@ struct DoubleRingBuffer { | |||||
| /** Returns a pointer to S consecutive elements for consumption | /** Returns a pointer to S consecutive elements for consumption | ||||
| If any data is consumed, call startIncr afterwards. | If any data is consumed, call startIncr afterwards. | ||||
| */ | */ | ||||
| const T *startData() const { | |||||
| const T* startData() const { | |||||
| return &data[mask(start)]; | return &data[mask(start)]; | ||||
| } | } | ||||
| void startIncr(size_t n) { | void startIncr(size_t n) { | ||||
| @@ -174,7 +174,7 @@ struct AppleRingBuffer { | |||||
| } | } | ||||
| /** Returns a pointer to S consecutive elements for appending, requesting to append n elements. | /** Returns a pointer to S consecutive elements for appending, requesting to append n elements. | ||||
| */ | */ | ||||
| T *endData(size_t n) { | |||||
| T* endData(size_t n) { | |||||
| if (end + n > N) { | if (end + n > N) { | ||||
| returnBuffer(); | returnBuffer(); | ||||
| } | } | ||||
| @@ -189,7 +189,7 @@ struct AppleRingBuffer { | |||||
| /** Returns a pointer to S consecutive elements for consumption | /** Returns a pointer to S consecutive elements for consumption | ||||
| If any data is consumed, call startIncr afterwards. | If any data is consumed, call startIncr afterwards. | ||||
| */ | */ | ||||
| const T *startData() const { | |||||
| const T* startData() const { | |||||
| return &data[start]; | return &data[start]; | ||||
| } | } | ||||
| void startIncr(size_t n) { | void startIncr(size_t n) { | ||||
| @@ -16,7 +16,7 @@ inline T hann(T p) { | |||||
| } | } | ||||
| /** Multiplies the Hann window by a signal `x` of length `len` in-place. */ | /** Multiplies the Hann window by a signal `x` of length `len` in-place. */ | ||||
| inline void hannWindow(float *x, int len) { | |||||
| inline void hannWindow(float* x, int len) { | |||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| x[i] *= hann(float(i) / (len - 1)); | x[i] *= hann(float(i) / (len - 1)); | ||||
| } | } | ||||
| @@ -29,12 +29,12 @@ A typical alpha value is 0.16. | |||||
| template <typename T> | template <typename T> | ||||
| inline T blackman(T alpha, T p) { | inline T blackman(T alpha, T p) { | ||||
| return | return | ||||
| + (1 - alpha) / 2 | |||||
| - T(1) / 2 * simd::cos(2 * T(M_PI) * p) | |||||
| + alpha / 2 * simd::cos(4 * T(M_PI) * p); | |||||
| + (1 - alpha) / 2 | |||||
| - T(1) / 2 * simd::cos(2 * T(M_PI) * p) | |||||
| + alpha / 2 * simd::cos(4 * T(M_PI) * p); | |||||
| } | } | ||||
| inline void blackmanWindow(float alpha, float *x, int len) { | |||||
| inline void blackmanWindow(float alpha, float* x, int len) { | |||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| x[i] *= blackman(alpha, float(i) / (len - 1)); | x[i] *= blackman(alpha, float(i) / (len - 1)); | ||||
| } | } | ||||
| @@ -47,13 +47,13 @@ https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Nuttall_window | |||||
| template <typename T> | template <typename T> | ||||
| inline T blackmanNuttall(T p) { | inline T blackmanNuttall(T p) { | ||||
| return | return | ||||
| + T(0.3635819) | |||||
| - T(0.4891775) * simd::cos(2 * T(M_PI) * p) | |||||
| + T(0.1365995) * simd::cos(4 * T(M_PI) * p) | |||||
| - T(0.0106411) * simd::cos(6 * T(M_PI) * p); | |||||
| + T(0.3635819) | |||||
| - T(0.4891775) * simd::cos(2 * T(M_PI) * p) | |||||
| + T(0.1365995) * simd::cos(4 * T(M_PI) * p) | |||||
| - T(0.0106411) * simd::cos(6 * T(M_PI) * p); | |||||
| } | } | ||||
| inline void blackmanNuttallWindow(float *x, int len) { | |||||
| inline void blackmanNuttallWindow(float* x, int len) { | |||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| x[i] *= blackmanNuttall(float(i) / (len - 1)); | x[i] *= blackmanNuttall(float(i) / (len - 1)); | ||||
| } | } | ||||
| @@ -65,13 +65,13 @@ https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window | |||||
| template <typename T> | template <typename T> | ||||
| inline T blackmanHarris(T p) { | inline T blackmanHarris(T p) { | ||||
| return | return | ||||
| + T(0.35875) | |||||
| - T(0.48829) * simd::cos(2 * T(M_PI) * p) | |||||
| + T(0.14128) * simd::cos(4 * T(M_PI) * p) | |||||
| - T(0.01168) * simd::cos(6 * T(M_PI) * p); | |||||
| + T(0.35875) | |||||
| - T(0.48829) * simd::cos(2 * T(M_PI) * p) | |||||
| + T(0.14128) * simd::cos(4 * T(M_PI) * p) | |||||
| - T(0.01168) * simd::cos(6 * T(M_PI) * p); | |||||
| } | } | ||||
| inline void blackmanHarrisWindow(float *x, int len) { | |||||
| inline void blackmanHarrisWindow(float* x, int len) { | |||||
| for (int i = 0; i < len; i++) { | for (int i = 0; i < len; i++) { | ||||
| x[i] *= blackmanHarris(float(i) / (len - 1)); | x[i] *= blackmanHarris(float(i) / (len - 1)); | ||||
| } | } | ||||
| @@ -9,9 +9,9 @@ namespace engine { | |||||
| struct Cable { | struct Cable { | ||||
| int id = -1; | int id = -1; | ||||
| Module *outputModule = NULL; | |||||
| Module* outputModule = NULL; | |||||
| int outputId; | int outputId; | ||||
| Module *inputModule = NULL; | |||||
| Module* inputModule = NULL; | |||||
| int inputId; | int inputId; | ||||
| }; | }; | ||||
| @@ -12,7 +12,7 @@ namespace engine { | |||||
| struct Engine { | struct Engine { | ||||
| struct Internal; | struct Internal; | ||||
| Internal *internal; | |||||
| Internal* internal; | |||||
| Engine(); | Engine(); | ||||
| ~Engine(); | ~Engine(); | ||||
| @@ -37,12 +37,12 @@ struct Engine { | |||||
| If the module ID is -1, an ID is automatically assigned. | If the module ID is -1, an ID is automatically assigned. | ||||
| Does not transfer pointer ownership. | Does not transfer pointer ownership. | ||||
| */ | */ | ||||
| void addModule(Module *module); | |||||
| void removeModule(Module *module); | |||||
| Module *getModule(int moduleId); | |||||
| void resetModule(Module *module); | |||||
| void randomizeModule(Module *module); | |||||
| void bypassModule(Module *module, bool bypass); | |||||
| void addModule(Module* module); | |||||
| void removeModule(Module* module); | |||||
| Module* getModule(int moduleId); | |||||
| void resetModule(Module* module); | |||||
| void randomizeModule(Module* module); | |||||
| void bypassModule(Module* module, bool bypass); | |||||
| // Cables | // Cables | ||||
| /** Adds a cable to the rack engine. | /** Adds a cable to the rack engine. | ||||
| @@ -50,26 +50,26 @@ struct Engine { | |||||
| If the cable ID is -1, an ID is automatically assigned. | If the cable ID is -1, an ID is automatically assigned. | ||||
| Does not transfer pointer ownership. | Does not transfer pointer ownership. | ||||
| */ | */ | ||||
| void addCable(Cable *cable); | |||||
| void removeCable(Cable *cable); | |||||
| void addCable(Cable* cable); | |||||
| void removeCable(Cable* cable); | |||||
| // Params | // Params | ||||
| void setParam(Module *module, int paramId, float value); | |||||
| float getParam(Module *module, int paramId); | |||||
| void setSmoothParam(Module *module, int paramId, float value); | |||||
| float getSmoothParam(Module *module, int paramId); | |||||
| void setParam(Module* module, int paramId, float value); | |||||
| float getParam(Module* module, int paramId); | |||||
| void setSmoothParam(Module* module, int paramId, float value); | |||||
| float getSmoothParam(Module* module, int paramId); | |||||
| // ParamHandles | // ParamHandles | ||||
| void addParamHandle(ParamHandle *paramHandle); | |||||
| void removeParamHandle(ParamHandle *paramHandle); | |||||
| void addParamHandle(ParamHandle* paramHandle); | |||||
| void removeParamHandle(ParamHandle* paramHandle); | |||||
| /** Returns the unique ParamHandle for the given paramId */ | /** Returns the unique ParamHandle for the given paramId */ | ||||
| ParamHandle *getParamHandle(int moduleId, int paramId); | |||||
| ParamHandle* getParamHandle(int moduleId, int paramId); | |||||
| /** Use getParamHandle(int, int) instead. */ | /** Use getParamHandle(int, int) instead. */ | ||||
| DEPRECATED ParamHandle *getParamHandle(Module *module, int paramId); | |||||
| DEPRECATED ParamHandle* getParamHandle(Module* module, int paramId); | |||||
| /** Sets the ParamHandle IDs and module pointer. | /** Sets the ParamHandle IDs and module pointer. | ||||
| If `overwrite` is true and another ParamHandle points to the same param, unsets that one and replaces it with the given handle. | If `overwrite` is true and another ParamHandle points to the same param, unsets that one and replaces it with the given handle. | ||||
| */ | */ | ||||
| void updateParamHandle(ParamHandle *paramHandle, int moduleId, int paramId, bool overwrite = true); | |||||
| void updateParamHandle(ParamHandle* paramHandle, int moduleId, int paramId, bool overwrite = true); | |||||
| }; | }; | ||||
| @@ -14,7 +14,7 @@ namespace rack { | |||||
| namespace plugin { | namespace plugin { | ||||
| struct Model; | |||||
| struct Model; | |||||
| } | } | ||||
| @@ -23,7 +23,7 @@ namespace engine { | |||||
| /** DSP processor instance for your module. */ | /** DSP processor instance for your module. */ | ||||
| struct Module { | struct Module { | ||||
| plugin::Model *model = NULL; /** Unique ID for referring to the module in the engine. | |||||
| plugin::Model* model = NULL; /** Unique ID for referring to the module in the engine. | |||||
| Assigned when added to the engine. | Assigned when added to the engine. | ||||
| */ | */ | ||||
| int id = -1; | int id = -1; | ||||
| @@ -42,7 +42,7 @@ struct Module { | |||||
| /** ID of the expander module, or -1 if nonexistent. */ | /** ID of the expander module, or -1 if nonexistent. */ | ||||
| int moduleId = -1; | int moduleId = -1; | ||||
| /** Pointer to the expander Module, or NULL if nonexistent. */ | /** Pointer to the expander Module, or NULL if nonexistent. */ | ||||
| Module *module = NULL; | |||||
| Module* module = NULL; | |||||
| /** Double buffer for receiving messages from the expander module. | /** Double buffer for receiving messages from the expander module. | ||||
| If you intend to receive messages from an expander, allocate both message buffers with identical blocks of memory (arrays, structs, etc). | If you intend to receive messages from an expander, allocate both message buffers with identical blocks of memory (arrays, structs, etc). | ||||
| Remember to free the buffer in the Module destructor. | Remember to free the buffer in the Module destructor. | ||||
| @@ -63,8 +63,8 @@ struct Module { | |||||
| You may choose for your Module to instead write to its own message buffer for consumption by other modules, i.e. the expander "pulls" rather than this module "pushing". | You may choose for your Module to instead write to its own message buffer for consumption by other modules, i.e. the expander "pulls" rather than this module "pushing". | ||||
| As long as this convention is followed by the other module, this is fine. | As long as this convention is followed by the other module, this is fine. | ||||
| */ | */ | ||||
| void *producerMessage = NULL; | |||||
| void *consumerMessage = NULL; | |||||
| void* producerMessage = NULL; | |||||
| void* consumerMessage = NULL; | |||||
| bool messageFlipRequested = false; | bool messageFlipRequested = false; | ||||
| }; | }; | ||||
| @@ -97,10 +97,10 @@ struct Module { | |||||
| if (paramQuantities[paramId]) | if (paramQuantities[paramId]) | ||||
| delete paramQuantities[paramId]; | delete paramQuantities[paramId]; | ||||
| Param *p = ¶ms[paramId]; | |||||
| Param* p = ¶ms[paramId]; | |||||
| p->value = defaultValue; | p->value = defaultValue; | ||||
| ParamQuantity *q = new TParamQuantity; | |||||
| ParamQuantity* q = new TParamQuantity; | |||||
| q->module = this; | q->module = this; | ||||
| q->paramId = paramId; | q->paramId = paramId; | ||||
| q->minValue = minValue; | q->minValue = minValue; | ||||
| @@ -125,7 +125,7 @@ struct Module { | |||||
| /** Advances the module by one audio sample. | /** Advances the module by one audio sample. | ||||
| Override this method to read Inputs and Params and to write Outputs and Lights. | Override this method to read Inputs and Params and to write Outputs and Lights. | ||||
| */ | */ | ||||
| virtual void process(const ProcessArgs &args) { | |||||
| virtual void process(const ProcessArgs& args) { | |||||
| #pragma GCC diagnostic push | #pragma GCC diagnostic push | ||||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||||
| step(); | step(); | ||||
| @@ -145,12 +145,14 @@ struct Module { | |||||
| /** Called when the Module is removed from the Engine */ | /** Called when the Module is removed from the Engine */ | ||||
| virtual void onRemove() {} | virtual void onRemove() {} | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| /** Override to store extra internal data in the "data" property of the module's JSON object. */ | /** Override to store extra internal data in the "data" property of the module's JSON object. */ | ||||
| virtual json_t *dataToJson() { return NULL; } | |||||
| virtual void dataFromJson(json_t *root) {} | |||||
| virtual json_t* dataToJson() { | |||||
| return NULL; | |||||
| } | |||||
| virtual void dataFromJson(json_t* root) {} | |||||
| }; | }; | ||||
| @@ -16,7 +16,7 @@ struct ParamHandle { | |||||
| */ | */ | ||||
| int moduleId = -1; | int moduleId = -1; | ||||
| int paramId = 0; | int paramId = 0; | ||||
| Module *module = NULL; | |||||
| Module* module = NULL; | |||||
| std::string text; | std::string text; | ||||
| NVGcolor color; | NVGcolor color; | ||||
| @@ -12,7 +12,7 @@ struct Module; | |||||
| /** A Quantity that wraps an engine::Param. */ | /** A Quantity that wraps an engine::Param. */ | ||||
| struct ParamQuantity : Quantity { | struct ParamQuantity : Quantity { | ||||
| Module *module = NULL; | |||||
| Module* module = NULL; | |||||
| int paramId = 0; | int paramId = 0; | ||||
| /** The minimum allowed value. */ | /** The minimum allowed value. */ | ||||
| @@ -38,7 +38,7 @@ struct ParamQuantity : Quantity { | |||||
| /** An optional one-sentence description of the parameter. */ | /** An optional one-sentence description of the parameter. */ | ||||
| std::string description; | std::string description; | ||||
| Param *getParam(); | |||||
| Param* getParam(); | |||||
| /** Request to the engine to smoothly set the value */ | /** Request to the engine to smoothly set the value */ | ||||
| void setSmoothValue(float smoothValue); | void setSmoothValue(float smoothValue); | ||||
| float getSmoothValue(); | float getSmoothValue(); | ||||
| @@ -62,12 +62,12 @@ struct alignas(32) Port { | |||||
| /** Returns a pointer to the array of voltages beginning with firstChannel. | /** Returns a pointer to the array of voltages beginning with firstChannel. | ||||
| The pointer can be used for reading and writing. | The pointer can be used for reading and writing. | ||||
| */ | */ | ||||
| float *getVoltages(int firstChannel = 0) { | |||||
| float* getVoltages(int firstChannel = 0) { | |||||
| return &voltages[firstChannel]; | return &voltages[firstChannel]; | ||||
| } | } | ||||
| /** Copies the port's voltages to an array of size at least `channels`. */ | /** Copies the port's voltages to an array of size at least `channels`. */ | ||||
| void readVoltages(float *v) { | |||||
| void readVoltages(float* v) { | |||||
| for (int c = 0; c < channels; c++) { | for (int c = 0; c < channels; c++) { | ||||
| v[c] = voltages[c]; | v[c] = voltages[c]; | ||||
| } | } | ||||
| @@ -76,7 +76,7 @@ struct alignas(32) Port { | |||||
| /** Copies an array of size at least `channels` to the port's voltages. | /** Copies an array of size at least `channels` to the port's voltages. | ||||
| Remember to set the number of channels *before* calling this method. | Remember to set the number of channels *before* calling this method. | ||||
| */ | */ | ||||
| void writeVoltages(const float *v) { | |||||
| void writeVoltages(const float* v) { | |||||
| for (int c = 0; c < channels; c++) { | for (int c = 0; c < channels; c++) { | ||||
| voltages[c] = v[c]; | voltages[c] = v[c]; | ||||
| } | } | ||||
| @@ -105,7 +105,7 @@ struct alignas(32) Port { | |||||
| template <typename T> | template <typename T> | ||||
| T getPolyVoltageSimd(int firstChannel) { | T getPolyVoltageSimd(int firstChannel) { | ||||
| return isMonophonic() ? getVoltage(0) : getVoltageSimd<T>(firstChannel); | |||||
| return isMonophonic() ? getVoltage(0) : getVoltageSimd<T>(firstChannel); | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| @@ -31,7 +31,7 @@ namespace rack { | |||||
| namespace widget { | namespace widget { | ||||
| struct Widget; | |||||
| struct Widget; | |||||
| } | } | ||||
| @@ -47,46 +47,52 @@ struct Context { | |||||
| /** Whether the event has been consumed by an event handler and no more handlers should consume the event. */ | /** Whether the event has been consumed by an event handler and no more handlers should consume the event. */ | ||||
| bool consumed = false; | bool consumed = false; | ||||
| /** The widget that responded to the event. */ | /** The widget that responded to the event. */ | ||||
| widget::Widget *target = NULL; | |||||
| widget::Widget* target = NULL; | |||||
| }; | }; | ||||
| /** Base class for all events. */ | /** Base class for all events. */ | ||||
| struct Base { | struct Base { | ||||
| Context *context = NULL; | |||||
| Context* context = NULL; | |||||
| /** Prevents the event from being handled by more Widgets. | /** Prevents the event from being handled by more Widgets. | ||||
| */ | */ | ||||
| void stopPropagating() const { | void stopPropagating() const { | ||||
| if (!context) return; | |||||
| if (!context) | |||||
| return; | |||||
| context->propagating = false; | context->propagating = false; | ||||
| } | } | ||||
| bool isPropagating() const { | bool isPropagating() const { | ||||
| if (!context) return true; | |||||
| if (!context) | |||||
| return true; | |||||
| return context->propagating; | return context->propagating; | ||||
| } | } | ||||
| /** Tells the event handler that a particular Widget consumed the event. | /** Tells the event handler that a particular Widget consumed the event. | ||||
| You usually want to stop propagation as well, so call consume() instead. | You usually want to stop propagation as well, so call consume() instead. | ||||
| */ | */ | ||||
| void setTarget(widget::Widget *w) const { | |||||
| if (!context) return; | |||||
| void setTarget(widget::Widget* w) const { | |||||
| if (!context) | |||||
| return; | |||||
| context->target = w; | context->target = w; | ||||
| } | } | ||||
| widget::Widget *getTarget() const { | |||||
| if (!context) return NULL; | |||||
| widget::Widget* getTarget() const { | |||||
| if (!context) | |||||
| return NULL; | |||||
| return context->target; | return context->target; | ||||
| } | } | ||||
| /** Sets the target Widget and stops propagating. | /** Sets the target Widget and stops propagating. | ||||
| A NULL Widget may be passed to consume but not set a target. | A NULL Widget may be passed to consume but not set a target. | ||||
| */ | */ | ||||
| void consume(widget::Widget *w) const { | |||||
| if (!context) return; | |||||
| void consume(widget::Widget* w) const { | |||||
| if (!context) | |||||
| return; | |||||
| context->propagating = false; | context->propagating = false; | ||||
| context->consumed = true; | context->consumed = true; | ||||
| context->target = w; | context->target = w; | ||||
| } | } | ||||
| bool isConsumed() const { | bool isConsumed() const { | ||||
| if (!context) return false; | |||||
| if (!context) | |||||
| return false; | |||||
| return context->consumed; | return context->consumed; | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -256,7 +262,7 @@ Consume this event to allow DragEnter and DragLeave to occur. | |||||
| */ | */ | ||||
| struct DragHover : DragBase, PositionBase { | struct DragHover : DragBase, PositionBase { | ||||
| /** The dragged widget */ | /** The dragged widget */ | ||||
| widget::Widget *origin = NULL; | |||||
| widget::Widget* origin = NULL; | |||||
| /** Change in mouse position since the last frame. Can be zero. */ | /** Change in mouse position since the last frame. Can be zero. */ | ||||
| math::Vec mouseDelta; | math::Vec mouseDelta; | ||||
| }; | }; | ||||
| @@ -268,7 +274,7 @@ The target sets `draggedWidget`, which allows DragLeave to occur. | |||||
| */ | */ | ||||
| struct DragEnter : DragBase { | struct DragEnter : DragBase { | ||||
| /** The dragged widget */ | /** The dragged widget */ | ||||
| widget::Widget *origin = NULL; | |||||
| widget::Widget* origin = NULL; | |||||
| }; | }; | ||||
| @@ -277,7 +283,7 @@ Must consume the DragHover event (when the Widget is entered) to receive this ev | |||||
| */ | */ | ||||
| struct DragLeave : DragBase { | struct DragLeave : DragBase { | ||||
| /** The dragged widget */ | /** The dragged widget */ | ||||
| widget::Widget *origin = NULL; | |||||
| widget::Widget* origin = NULL; | |||||
| }; | }; | ||||
| @@ -286,7 +292,7 @@ Must consume the Button event (on release) to receive this event. | |||||
| */ | */ | ||||
| struct DragDrop : DragBase { | struct DragDrop : DragBase { | ||||
| /** The dragged widget */ | /** The dragged widget */ | ||||
| widget::Widget *origin = NULL; | |||||
| widget::Widget* origin = NULL; | |||||
| }; | }; | ||||
| @@ -294,10 +300,10 @@ struct DragDrop : DragBase { | |||||
| Recurses. | Recurses. | ||||
| */ | */ | ||||
| struct PathDrop : Base, PositionBase { | struct PathDrop : Base, PositionBase { | ||||
| PathDrop(const std::vector<std::string> &paths) : paths(paths) {} | |||||
| PathDrop(const std::vector<std::string>& paths) : paths(paths) {} | |||||
| /** List of file paths in the dropped selection */ | /** List of file paths in the dropped selection */ | ||||
| const std::vector<std::string> &paths; | |||||
| const std::vector<std::string>& paths; | |||||
| }; | }; | ||||
| @@ -361,32 +367,42 @@ struct Hide : Base { | |||||
| struct State { | struct State { | ||||
| widget::Widget *rootWidget = NULL; | |||||
| widget::Widget* rootWidget = NULL; | |||||
| /** State widgets | /** State widgets | ||||
| Don't set these directly unless you know what you're doing. Use the set*() methods instead. | Don't set these directly unless you know what you're doing. Use the set*() methods instead. | ||||
| */ | */ | ||||
| widget::Widget *hoveredWidget = NULL; | |||||
| widget::Widget *draggedWidget = NULL; | |||||
| widget::Widget* hoveredWidget = NULL; | |||||
| widget::Widget* draggedWidget = NULL; | |||||
| int dragButton = 0; | int dragButton = 0; | ||||
| widget::Widget *dragHoveredWidget = NULL; | |||||
| widget::Widget *selectedWidget = NULL; | |||||
| widget::Widget* dragHoveredWidget = NULL; | |||||
| widget::Widget* selectedWidget = NULL; | |||||
| /** For double-clicking */ | /** For double-clicking */ | ||||
| double lastClickTime = -INFINITY; | double lastClickTime = -INFINITY; | ||||
| widget::Widget *lastClickedWidget = NULL; | |||||
| widget::Widget* lastClickedWidget = NULL; | |||||
| std::set<int> heldKeys; | std::set<int> heldKeys; | ||||
| widget::Widget *getRootWidget() {return rootWidget;} | |||||
| widget::Widget *getHoveredWidget() {return hoveredWidget;} | |||||
| widget::Widget *getDraggedWidget() {return draggedWidget;} | |||||
| widget::Widget *getDragHoveredWidget() {return dragHoveredWidget;} | |||||
| widget::Widget *getSelectedWidget() {return selectedWidget;} | |||||
| widget::Widget* getRootWidget() { | |||||
| return rootWidget; | |||||
| } | |||||
| widget::Widget* getHoveredWidget() { | |||||
| return hoveredWidget; | |||||
| } | |||||
| widget::Widget* getDraggedWidget() { | |||||
| return draggedWidget; | |||||
| } | |||||
| widget::Widget* getDragHoveredWidget() { | |||||
| return dragHoveredWidget; | |||||
| } | |||||
| widget::Widget* getSelectedWidget() { | |||||
| return selectedWidget; | |||||
| } | |||||
| void setHovered(widget::Widget *w); | |||||
| void setDragged(widget::Widget *w, int button); | |||||
| void setDragHovered(widget::Widget *w); | |||||
| void setSelected(widget::Widget *w); | |||||
| void setHovered(widget::Widget* w); | |||||
| void setDragged(widget::Widget* w, int button); | |||||
| void setDragHovered(widget::Widget* w); | |||||
| void setSelected(widget::Widget* w); | |||||
| /** Prepares a widget for deletion */ | /** Prepares a widget for deletion */ | ||||
| void finalizeWidget(widget::Widget *w); | |||||
| void finalizeWidget(widget::Widget* w); | |||||
| bool handleButton(math::Vec pos, int button, int action, int mods); | bool handleButton(math::Vec pos, int button, int action, int mods); | ||||
| bool handleHover(math::Vec pos, math::Vec mouseDelta); | bool handleHover(math::Vec pos, math::Vec mouseDelta); | ||||
| @@ -394,7 +410,7 @@ struct State { | |||||
| bool handleScroll(math::Vec pos, math::Vec scrollDelta); | bool handleScroll(math::Vec pos, math::Vec scrollDelta); | ||||
| bool handleText(math::Vec pos, int codepoint); | bool handleText(math::Vec pos, int codepoint); | ||||
| bool handleKey(math::Vec pos, int key, int scancode, int action, int mods); | bool handleKey(math::Vec pos, int key, int scancode, int action, int mods); | ||||
| bool handleDrop(math::Vec pos, const std::vector<std::string> &paths); | |||||
| bool handleDrop(math::Vec pos, const std::vector<std::string>& paths); | |||||
| bool handleZoom(); | bool handleZoom(); | ||||
| }; | }; | ||||
| @@ -501,11 +501,11 @@ __asm__(".symver __progname_full,__progname_full@GLIBC_2.2.5"); | |||||
| __asm__(".symver __pthread_cleanup_routine,__pthread_cleanup_routine@GLIBC_2.3.3"); | __asm__(".symver __pthread_cleanup_routine,__pthread_cleanup_routine@GLIBC_2.3.3"); | ||||
| __asm__(".symver __pthread_getspecific,__pthread_getspecific@GLIBC_2.2.5"); | __asm__(".symver __pthread_getspecific,__pthread_getspecific@GLIBC_2.2.5"); | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver __pthread_key_create,__pthread_key_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver __pthread_key_create,__pthread_key_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #endif | #endif | ||||
| __asm__(".symver __pthread_mutex_destroy,__pthread_mutex_destroy@GLIBC_2.2.5"); | __asm__(".symver __pthread_mutex_destroy,__pthread_mutex_destroy@GLIBC_2.2.5"); | ||||
| __asm__(".symver __pthread_mutex_init,__pthread_mutex_init@GLIBC_2.2.5"); | __asm__(".symver __pthread_mutex_init,__pthread_mutex_init@GLIBC_2.2.5"); | ||||
| @@ -544,7 +544,7 @@ __asm__(".symver __realpath_chk,__realpath_chk@GLIBC_2.4"); | |||||
| __asm__(".symver __recv_chk,__recv_chk@GLIBC_2.4"); | __asm__(".symver __recv_chk,__recv_chk@GLIBC_2.4"); | ||||
| __asm__(".symver __recvfrom_chk,__recvfrom_chk@GLIBC_2.4"); | __asm__(".symver __recvfrom_chk,__recvfrom_chk@GLIBC_2.4"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2"); | |||||
| __asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2"); | |||||
| #endif | #endif | ||||
| __asm__(".symver __remainder_finite,__remainder_finite@GLIBC_2.15"); | __asm__(".symver __remainder_finite,__remainder_finite@GLIBC_2.15"); | ||||
| __asm__(".symver __remainderf_finite,__remainderf_finite@GLIBC_2.15"); | __asm__(".symver __remainderf_finite,__remainderf_finite@GLIBC_2.15"); | ||||
| @@ -2009,47 +2009,47 @@ __asm__(".symver pselect,pselect@GLIBC_2.2.5"); | |||||
| __asm__(".symver psiginfo,psiginfo@GLIBC_2.10"); | __asm__(".symver psiginfo,psiginfo@GLIBC_2.10"); | ||||
| __asm__(".symver psignal,psignal@GLIBC_2.2.5"); | __asm__(".symver psignal,psignal@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_destroy,pthread_attr_destroy@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_destroy,pthread_attr_destroy@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_getaffinity_np,pthread_attr_getaffinity_np@GLIBC_2.3.4"); | __asm__(".symver pthread_attr_getaffinity_np,pthread_attr_getaffinity_np@GLIBC_2.3.4"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_getdetachstate,pthread_attr_getdetachstate@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_getdetachstate,pthread_attr_getdetachstate@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_getguardsize,pthread_attr_getguardsize@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_getguardsize,pthread_attr_getguardsize@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_getinheritsched,pthread_attr_getinheritsched@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_getinheritsched,pthread_attr_getinheritsched@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_getschedparam,pthread_attr_getschedparam@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_getschedparam,pthread_attr_getschedparam@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_getschedpolicy,pthread_attr_getschedpolicy@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_getschedpolicy,pthread_attr_getschedpolicy@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_getscope,pthread_attr_getscope@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_getscope,pthread_attr_getscope@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_getstack,pthread_attr_getstack@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_getstack,pthread_attr_getstack@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_attr_getstackaddr,pthread_attr_getstackaddr@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_getstackaddr,pthread_attr_getstackaddr@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_attr_getstacksize,pthread_attr_getstacksize@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_getstacksize,pthread_attr_getstacksize@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_init,pthread_attr_init@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_init,pthread_attr_init@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_setaffinity_np,pthread_attr_setaffinity_np@GLIBC_2.3.4"); | __asm__(".symver pthread_attr_setaffinity_np,pthread_attr_setaffinity_np@GLIBC_2.3.4"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_setdetachstate,pthread_attr_setdetachstate@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_setdetachstate,pthread_attr_setdetachstate@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_setguardsize,pthread_attr_setguardsize@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_setguardsize,pthread_attr_setguardsize@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_setinheritsched,pthread_attr_setinheritsched@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_setinheritsched,pthread_attr_setinheritsched@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_setschedparam,pthread_attr_setschedparam@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_setschedparam,pthread_attr_setschedparam@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_setschedpolicy,pthread_attr_setschedpolicy@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_setschedpolicy,pthread_attr_setschedpolicy@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_attr_setscope,pthread_attr_setscope@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_attr_setscope,pthread_attr_setscope@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_attr_setstack,pthread_attr_setstack@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_setstack,pthread_attr_setstack@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_attr_setstackaddr,pthread_attr_setstackaddr@GLIBC_2.2.5"); | __asm__(".symver pthread_attr_setstackaddr,pthread_attr_setstackaddr@GLIBC_2.2.5"); | ||||
| @@ -2063,44 +2063,44 @@ __asm__(".symver pthread_barrierattr_init,pthread_barrierattr_init@GLIBC_2.2.5") | |||||
| __asm__(".symver pthread_barrierattr_setpshared,pthread_barrierattr_setpshared@GLIBC_2.2.5"); | __asm__(".symver pthread_barrierattr_setpshared,pthread_barrierattr_setpshared@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_cancel,pthread_cancel@GLIBC_2.2.5"); | __asm__(".symver pthread_cancel,pthread_cancel@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_cond_broadcast,pthread_cond_broadcast@GLIBC_2.3.2"); | |||||
| __asm__(".symver pthread_cond_broadcast,pthread_cond_broadcast@GLIBC_2.3.2"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_cond_destroy,pthread_cond_destroy@GLIBC_2.3.2"); | |||||
| __asm__(".symver pthread_cond_destroy,pthread_cond_destroy@GLIBC_2.3.2"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_cond_init,pthread_cond_init@GLIBC_2.3.2"); | |||||
| __asm__(".symver pthread_cond_init,pthread_cond_init@GLIBC_2.3.2"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_cond_signal,pthread_cond_signal@GLIBC_2.3.2"); | __asm__(".symver pthread_cond_signal,pthread_cond_signal@GLIBC_2.3.2"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_cond_timedwait,pthread_cond_timedwait@GLIBC_2.3.2"); | |||||
| __asm__(".symver pthread_cond_timedwait,pthread_cond_timedwait@GLIBC_2.3.2"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_cond_wait,pthread_cond_wait@GLIBC_2.3.2"); | __asm__(".symver pthread_cond_wait,pthread_cond_wait@GLIBC_2.3.2"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_condattr_destroy,pthread_condattr_destroy@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_condattr_destroy,pthread_condattr_destroy@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_condattr_getclock,pthread_condattr_getclock@GLIBC_2.3.3"); | __asm__(".symver pthread_condattr_getclock,pthread_condattr_getclock@GLIBC_2.3.3"); | ||||
| __asm__(".symver pthread_condattr_getpshared,pthread_condattr_getpshared@GLIBC_2.2.5"); | __asm__(".symver pthread_condattr_getpshared,pthread_condattr_getpshared@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_condattr_init,pthread_condattr_init@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_condattr_init,pthread_condattr_init@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_condattr_setclock,pthread_condattr_setclock@GLIBC_2.3.3"); | __asm__(".symver pthread_condattr_setclock,pthread_condattr_setclock@GLIBC_2.3.3"); | ||||
| __asm__(".symver pthread_condattr_setpshared,pthread_condattr_setpshared@GLIBC_2.2.5"); | __asm__(".symver pthread_condattr_setpshared,pthread_condattr_setpshared@GLIBC_2.2.5"); | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_create,pthread_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_create,pthread_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | #endif | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_detach,pthread_detach@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_detach,pthread_detach@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_getaffinity_np,pthread_getaffinity_np@GLIBC_2.3.4"); | __asm__(".symver pthread_getaffinity_np,pthread_getaffinity_np@GLIBC_2.3.4"); | ||||
| __asm__(".symver pthread_getattr_default_np,pthread_getattr_default_np@GLIBC_2.18"); | __asm__(".symver pthread_getattr_default_np,pthread_getattr_default_np@GLIBC_2.18"); | ||||
| @@ -2109,50 +2109,50 @@ __asm__(".symver pthread_getconcurrency,pthread_getconcurrency@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_getcpuclockid,pthread_getcpuclockid@GLIBC_2.2.5"); | __asm__(".symver pthread_getcpuclockid,pthread_getcpuclockid@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_getname_np,pthread_getname_np@GLIBC_2.12"); | __asm__(".symver pthread_getname_np,pthread_getname_np@GLIBC_2.12"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_getspecific,pthread_getspecific@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_getspecific,pthread_getspecific@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #endif | #endif | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_join,pthread_join@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_join,pthread_join@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | #endif | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_key_create,pthread_key_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_key_create,pthread_key_create@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #endif | #endif | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_key_delete,pthread_key_delete@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_key_delete,pthread_key_delete@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_kill,pthread_kill@GLIBC_2.2.5"); | __asm__(".symver pthread_kill,pthread_kill@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_mutex_consistent,pthread_mutex_consistent@GLIBC_2.12"); | __asm__(".symver pthread_mutex_consistent,pthread_mutex_consistent@GLIBC_2.12"); | ||||
| __asm__(".symver pthread_mutex_consistent_np,pthread_mutex_consistent_np@GLIBC_2.4"); | __asm__(".symver pthread_mutex_consistent_np,pthread_mutex_consistent_np@GLIBC_2.4"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_mutex_destroy,pthread_mutex_destroy@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_mutex_destroy,pthread_mutex_destroy@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_mutex_getprioceiling,pthread_mutex_getprioceiling@GLIBC_2.4"); | __asm__(".symver pthread_mutex_getprioceiling,pthread_mutex_getprioceiling@GLIBC_2.4"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_mutex_init,pthread_mutex_init@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_mutex_init,pthread_mutex_init@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_mutex_lock,pthread_mutex_lock@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_mutex_lock,pthread_mutex_lock@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_mutex_setprioceiling,pthread_mutex_setprioceiling@GLIBC_2.4"); | __asm__(".symver pthread_mutex_setprioceiling,pthread_mutex_setprioceiling@GLIBC_2.4"); | ||||
| __asm__(".symver pthread_mutex_timedlock,pthread_mutex_timedlock@GLIBC_2.2.5"); | __asm__(".symver pthread_mutex_timedlock,pthread_mutex_timedlock@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_mutex_trylock,pthread_mutex_trylock@GLIBC_2.2.5"); | __asm__(".symver pthread_mutex_trylock,pthread_mutex_trylock@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_mutex_unlock,pthread_mutex_unlock@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_mutex_unlock,pthread_mutex_unlock@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_mutexattr_destroy,pthread_mutexattr_destroy@GLIBC_2.2.5"); | __asm__(".symver pthread_mutexattr_destroy,pthread_mutexattr_destroy@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_mutexattr_getkind_np,pthread_mutexattr_getkind_np@GLIBC_2.2.5"); | __asm__(".symver pthread_mutexattr_getkind_np,pthread_mutexattr_getkind_np@GLIBC_2.2.5"); | ||||
| @@ -2171,11 +2171,11 @@ __asm__(".symver pthread_mutexattr_setrobust,pthread_mutexattr_setrobust@GLIBC_2 | |||||
| __asm__(".symver pthread_mutexattr_setrobust_np,pthread_mutexattr_setrobust_np@GLIBC_2.4"); | __asm__(".symver pthread_mutexattr_setrobust_np,pthread_mutexattr_setrobust_np@GLIBC_2.4"); | ||||
| __asm__(".symver pthread_mutexattr_settype,pthread_mutexattr_settype@GLIBC_2.2.5"); | __asm__(".symver pthread_mutexattr_settype,pthread_mutexattr_settype@GLIBC_2.2.5"); | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_once,pthread_once@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_once,pthread_once@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_rwlock_destroy,pthread_rwlock_destroy@GLIBC_2.2.5"); | __asm__(".symver pthread_rwlock_destroy,pthread_rwlock_destroy@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_rwlock_init,pthread_rwlock_init@GLIBC_2.2.5"); | __asm__(".symver pthread_rwlock_init,pthread_rwlock_init@GLIBC_2.2.5"); | ||||
| @@ -2193,28 +2193,28 @@ __asm__(".symver pthread_rwlockattr_init,pthread_rwlockattr_init@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_rwlockattr_setkind_np,pthread_rwlockattr_setkind_np@GLIBC_2.2.5"); | __asm__(".symver pthread_rwlockattr_setkind_np,pthread_rwlockattr_setkind_np@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_rwlockattr_setpshared,pthread_rwlockattr_setpshared@GLIBC_2.2.5"); | __asm__(".symver pthread_rwlockattr_setpshared,pthread_rwlockattr_setpshared@GLIBC_2.2.5"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_setaffinity_np,pthread_setaffinity_np@GLIBC_2.3.4"); | __asm__(".symver pthread_setaffinity_np,pthread_setaffinity_np@GLIBC_2.3.4"); | ||||
| __asm__(".symver pthread_setattr_default_np,pthread_setattr_default_np@GLIBC_2.18"); | __asm__(".symver pthread_setattr_default_np,pthread_setattr_default_np@GLIBC_2.18"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_setconcurrency,pthread_setconcurrency@GLIBC_2.2.5"); | __asm__(".symver pthread_setconcurrency,pthread_setconcurrency@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_setname_np,pthread_setname_np@GLIBC_2.12"); | __asm__(".symver pthread_setname_np,pthread_setname_np@GLIBC_2.12"); | ||||
| #ifdef _REENTRANT | #ifdef _REENTRANT | ||||
| __asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5"); | |||||
| __asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5"); | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_setschedprio,pthread_setschedprio@GLIBC_2.3.4"); | __asm__(".symver pthread_setschedprio,pthread_setschedprio@GLIBC_2.3.4"); | ||||
| #ifndef _GLIBCXX_SHARED | #ifndef _GLIBCXX_SHARED | ||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_setspecific,pthread_setspecific@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #ifndef IN_LIBGCC2 | |||||
| #ifdef _REENTRANT | |||||
| __asm__(".symver pthread_setspecific,pthread_setspecific@GLIBC_2.2.5"); | |||||
| #endif | |||||
| #endif | |||||
| #endif | #endif | ||||
| __asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2.5"); | __asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2.5"); | ||||
| __asm__(".symver pthread_sigqueue,pthread_sigqueue@GLIBC_2.11"); | __asm__(".symver pthread_sigqueue,pthread_sigqueue@GLIBC_2.11"); | ||||
| @@ -17,49 +17,49 @@ namespace rack { | |||||
| template <class TModule, class TModuleWidget, typename... Tags> | template <class TModule, class TModuleWidget, typename... Tags> | ||||
| plugin::Model *createModel(const std::string &slug) { | |||||
| plugin::Model* createModel(const std::string& slug) { | |||||
| struct TModel : plugin::Model { | struct TModel : plugin::Model { | ||||
| engine::Module *createModule() override { | |||||
| engine::Module *m = new TModule; | |||||
| engine::Module* createModule() override { | |||||
| engine::Module* m = new TModule; | |||||
| m->model = this; | m->model = this; | ||||
| return m; | return m; | ||||
| } | } | ||||
| app::ModuleWidget *createModuleWidget() override { | |||||
| TModule *m = new TModule; | |||||
| app::ModuleWidget* createModuleWidget() override { | |||||
| TModule* m = new TModule; | |||||
| m->engine::Module::model = this; | m->engine::Module::model = this; | ||||
| app::ModuleWidget *mw = new TModuleWidget(m); | |||||
| app::ModuleWidget* mw = new TModuleWidget(m); | |||||
| mw->model = this; | mw->model = this; | ||||
| return mw; | return mw; | ||||
| } | } | ||||
| app::ModuleWidget *createModuleWidgetNull() override { | |||||
| app::ModuleWidget *mw = new TModuleWidget(NULL); | |||||
| app::ModuleWidget* createModuleWidgetNull() override { | |||||
| app::ModuleWidget* mw = new TModuleWidget(NULL); | |||||
| mw->model = this; | mw->model = this; | ||||
| return mw; | return mw; | ||||
| } | } | ||||
| }; | }; | ||||
| plugin::Model *o = new TModel; | |||||
| plugin::Model* o = new TModel; | |||||
| o->slug = slug; | o->slug = slug; | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TWidget> | template <class TWidget> | ||||
| TWidget *createWidget(math::Vec pos) { | |||||
| TWidget *o = new TWidget; | |||||
| TWidget* createWidget(math::Vec pos) { | |||||
| TWidget* o = new TWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TWidget> | template <class TWidget> | ||||
| TWidget *createWidgetCentered(math::Vec pos) { | |||||
| TWidget *o = createWidget<TWidget>(pos); | |||||
| TWidget* createWidgetCentered(math::Vec pos) { | |||||
| TWidget* o = createWidget<TWidget>(pos); | |||||
| o->box.pos = o->box.pos.minus(o->box.size.div(2)); | o->box.pos = o->box.pos.minus(o->box.size.div(2)); | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TParamWidget> | template <class TParamWidget> | ||||
| TParamWidget *createParam(math::Vec pos, engine::Module *module, int paramId) { | |||||
| TParamWidget *o = new TParamWidget; | |||||
| TParamWidget* createParam(math::Vec pos, engine::Module* module, int paramId) { | |||||
| TParamWidget* o = new TParamWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| if (module) { | if (module) { | ||||
| o->paramQuantity = module->paramQuantities[paramId]; | o->paramQuantity = module->paramQuantities[paramId]; | ||||
| @@ -68,15 +68,15 @@ TParamWidget *createParam(math::Vec pos, engine::Module *module, int paramId) { | |||||
| } | } | ||||
| template <class TParamWidget> | template <class TParamWidget> | ||||
| TParamWidget *createParamCentered(math::Vec pos, engine::Module *module, int paramId) { | |||||
| TParamWidget *o = createParam<TParamWidget>(pos, module, paramId); | |||||
| TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) { | |||||
| TParamWidget* o = createParam<TParamWidget>(pos, module, paramId); | |||||
| o->box.pos = o->box.pos.minus(o->box.size.div(2)); | o->box.pos = o->box.pos.minus(o->box.size.div(2)); | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TPortWidget> | template <class TPortWidget> | ||||
| TPortWidget *createInput(math::Vec pos, engine::Module *module, int inputId) { | |||||
| TPortWidget *o = new TPortWidget; | |||||
| TPortWidget* createInput(math::Vec pos, engine::Module* module, int inputId) { | |||||
| TPortWidget* o = new TPortWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| o->module = module; | o->module = module; | ||||
| o->type = app::PortWidget::INPUT; | o->type = app::PortWidget::INPUT; | ||||
| @@ -85,15 +85,15 @@ TPortWidget *createInput(math::Vec pos, engine::Module *module, int inputId) { | |||||
| } | } | ||||
| template <class TPortWidget> | template <class TPortWidget> | ||||
| TPortWidget *createInputCentered(math::Vec pos, engine::Module *module, int inputId) { | |||||
| TPortWidget *o = createInput<TPortWidget>(pos, module, inputId); | |||||
| TPortWidget* createInputCentered(math::Vec pos, engine::Module* module, int inputId) { | |||||
| TPortWidget* o = createInput<TPortWidget>(pos, module, inputId); | |||||
| o->box.pos = o->box.pos.minus(o->box.size.div(2)); | o->box.pos = o->box.pos.minus(o->box.size.div(2)); | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TPortWidget> | template <class TPortWidget> | ||||
| TPortWidget *createOutput(math::Vec pos, engine::Module *module, int outputId) { | |||||
| TPortWidget *o = new TPortWidget; | |||||
| TPortWidget* createOutput(math::Vec pos, engine::Module* module, int outputId) { | |||||
| TPortWidget* o = new TPortWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| o->module = module; | o->module = module; | ||||
| o->type = app::PortWidget::OUTPUT; | o->type = app::PortWidget::OUTPUT; | ||||
| @@ -102,15 +102,15 @@ TPortWidget *createOutput(math::Vec pos, engine::Module *module, int outputId) { | |||||
| } | } | ||||
| template <class TPortWidget> | template <class TPortWidget> | ||||
| TPortWidget *createOutputCentered(math::Vec pos, engine::Module *module, int outputId) { | |||||
| TPortWidget *o = createOutput<TPortWidget>(pos, module, outputId); | |||||
| TPortWidget* createOutputCentered(math::Vec pos, engine::Module* module, int outputId) { | |||||
| TPortWidget* o = createOutput<TPortWidget>(pos, module, outputId); | |||||
| o->box.pos = o->box.pos.minus(o->box.size.div(2)); | o->box.pos = o->box.pos.minus(o->box.size.div(2)); | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TModuleLightWidget> | template <class TModuleLightWidget> | ||||
| TModuleLightWidget *createLight(math::Vec pos, engine::Module *module, int firstLightId) { | |||||
| TModuleLightWidget *o = new TModuleLightWidget; | |||||
| TModuleLightWidget* createLight(math::Vec pos, engine::Module* module, int firstLightId) { | |||||
| TModuleLightWidget* o = new TModuleLightWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| o->module = module; | o->module = module; | ||||
| o->firstLightId = firstLightId; | o->firstLightId = firstLightId; | ||||
| @@ -118,33 +118,33 @@ TModuleLightWidget *createLight(math::Vec pos, engine::Module *module, int first | |||||
| } | } | ||||
| template <class TModuleLightWidget> | template <class TModuleLightWidget> | ||||
| TModuleLightWidget *createLightCentered(math::Vec pos, engine::Module *module, int firstLightId) { | |||||
| TModuleLightWidget *o = createLight<TModuleLightWidget>(pos, module, firstLightId); | |||||
| TModuleLightWidget* createLightCentered(math::Vec pos, engine::Module* module, int firstLightId) { | |||||
| TModuleLightWidget* o = createLight<TModuleLightWidget>(pos, module, firstLightId); | |||||
| o->box.pos = o->box.pos.minus(o->box.size.div(2)); | o->box.pos = o->box.pos.minus(o->box.size.div(2)); | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TMenuLabel = ui::MenuLabel> | template <class TMenuLabel = ui::MenuLabel> | ||||
| TMenuLabel *createMenuLabel(std::string text) { | |||||
| TMenuLabel *o = new TMenuLabel; | |||||
| TMenuLabel * createMenuLabel(std::string text) { | |||||
| TMenuLabel* o = new TMenuLabel; | |||||
| o->text = text; | o->text = text; | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TMenuItem = ui::MenuItem> | template <class TMenuItem = ui::MenuItem> | ||||
| TMenuItem *createMenuItem(std::string text, std::string rightText = "") { | |||||
| TMenuItem *o = new TMenuItem; | |||||
| TMenuItem * createMenuItem(std::string text, std::string rightText = "") { | |||||
| TMenuItem* o = new TMenuItem; | |||||
| o->text = text; | o->text = text; | ||||
| o->rightText = rightText; | o->rightText = rightText; | ||||
| return o; | return o; | ||||
| } | } | ||||
| template <class TMenu = ui::Menu> | template <class TMenu = ui::Menu> | ||||
| TMenu *createMenu() { | |||||
| TMenu *o = new TMenu; | |||||
| TMenu * createMenu() { | |||||
| TMenu* o = new TMenu; | |||||
| o->box.pos = APP->window->mousePos; | o->box.pos = APP->window->mousePos; | ||||
| ui::MenuOverlay *menuOverlay = new ui::MenuOverlay; | |||||
| ui::MenuOverlay* menuOverlay = new ui::MenuOverlay; | |||||
| menuOverlay->addChild(o); | menuOverlay->addChild(o); | ||||
| APP->scene->addChild(menuOverlay); | APP->scene->addChild(menuOverlay); | ||||
| @@ -11,8 +11,8 @@ namespace rack { | |||||
| namespace app { | namespace app { | ||||
| struct ModuleWidget; | |||||
| struct CableWidget; | |||||
| struct ModuleWidget; | |||||
| struct CableWidget; | |||||
| } // namespace app | } // namespace app | ||||
| @@ -52,7 +52,7 @@ struct ComplexAction : Action { | |||||
| ~ComplexAction(); | ~ComplexAction(); | ||||
| void undo() override; | void undo() override; | ||||
| void redo() override; | void redo() override; | ||||
| void push(Action *action); | |||||
| void push(Action* action); | |||||
| bool isEmpty(); | bool isEmpty(); | ||||
| }; | }; | ||||
| @@ -66,14 +66,14 @@ struct ModuleAction : Action { | |||||
| struct ModuleAdd : ModuleAction { | struct ModuleAdd : ModuleAction { | ||||
| plugin::Model *model; | |||||
| plugin::Model* model; | |||||
| math::Vec pos; | math::Vec pos; | ||||
| json_t *moduleJ; | |||||
| json_t* moduleJ; | |||||
| ModuleAdd() { | ModuleAdd() { | ||||
| name = "add module"; | name = "add module"; | ||||
| } | } | ||||
| ~ModuleAdd(); | ~ModuleAdd(); | ||||
| void setModule(app::ModuleWidget *mw); | |||||
| void setModule(app::ModuleWidget* mw); | |||||
| void undo() override; | void undo() override; | ||||
| void redo() override; | void redo() override; | ||||
| }; | }; | ||||
| @@ -108,8 +108,8 @@ struct ModuleBypass : ModuleAction { | |||||
| struct ModuleChange : ModuleAction { | struct ModuleChange : ModuleAction { | ||||
| json_t *oldModuleJ; | |||||
| json_t *newModuleJ; | |||||
| json_t* oldModuleJ; | |||||
| json_t* newModuleJ; | |||||
| ModuleChange() { | ModuleChange() { | ||||
| name = "change module"; | name = "change module"; | ||||
| } | } | ||||
| @@ -138,7 +138,7 @@ struct CableAdd : Action { | |||||
| int inputModuleId; | int inputModuleId; | ||||
| int inputId; | int inputId; | ||||
| NVGcolor color; | NVGcolor color; | ||||
| void setCable(app::CableWidget *cw); | |||||
| void setCable(app::CableWidget* cw); | |||||
| void undo() override; | void undo() override; | ||||
| void redo() override; | void redo() override; | ||||
| CableAdd() { | CableAdd() { | ||||
| @@ -163,7 +163,7 @@ struct State { | |||||
| State(); | State(); | ||||
| ~State(); | ~State(); | ||||
| void clear(); | void clear(); | ||||
| void push(Action *action); | |||||
| void push(Action* action); | |||||
| void undo(); | void undo(); | ||||
| void redo(); | void redo(); | ||||
| bool canUndo(); | bool canUndo(); | ||||
| @@ -35,7 +35,7 @@ void destroy(); | |||||
| /** Do not use this function directly. Use the macros above. | /** Do not use this function directly. Use the macros above. | ||||
| Thread-safe, meaning messages cannot overlap each other in the log. | Thread-safe, meaning messages cannot overlap each other in the log. | ||||
| */ | */ | ||||
| void log(Level level, const char *filename, int line, const char *format, ...); | |||||
| void log(Level level, const char* filename, int line, const char* format, ...); | |||||
| } // namespace logger | } // namespace logger | ||||
| @@ -64,7 +64,7 @@ inline int eucDiv(int a, int b) { | |||||
| return div; | return div; | ||||
| } | } | ||||
| inline void eucDivMod(int a, int b, int *div, int *mod) { | |||||
| inline void eucDivMod(int a, int b, int* div, int* mod) { | |||||
| *div = a / b; | *div = a / b; | ||||
| *mod = a % b; | *mod = a % b; | ||||
| if (*mod < 0) { | if (*mod < 0) { | ||||
| @@ -149,10 +149,10 @@ inline float crossfade(float a, float b, float p) { | |||||
| /** Linearly interpolates an array `p` with index `x`. | /** Linearly interpolates an array `p` with index `x`. | ||||
| Assumes that the array at `p` is of length at least `floor(x) + 1`. | Assumes that the array at `p` is of length at least `floor(x) + 1`. | ||||
| */ | */ | ||||
| inline float interpolateLinear(const float *p, float x) { | |||||
| inline float interpolateLinear(const float* p, float x) { | |||||
| int xi = x; | int xi = x; | ||||
| float xf = x - xi; | float xf = x - xi; | ||||
| return crossfade(p[xi], p[xi+1], xf); | |||||
| return crossfade(p[xi], p[xi + 1], xf); | |||||
| } | } | ||||
| /** Complex multiplication `c = a * b`. | /** Complex multiplication `c = a * b`. | ||||
| @@ -161,7 +161,7 @@ Example: | |||||
| cmultf(ar, ai, br, bi, &ar, &ai); | cmultf(ar, ai, br, bi, &ar, &ai); | ||||
| */ | */ | ||||
| inline void complexMult(float ar, float ai, float br, float bi, float *cr, float *ci) { | |||||
| inline void complexMult(float ar, float ai, float br, float bi, float* cr, float* ci) { | |||||
| *cr = ar * br - ai * bi; | *cr = ar * br - ai * bi; | ||||
| *ci = ar * bi + ai * br; | *ci = ar * bi + ai * br; | ||||
| } | } | ||||
| @@ -280,17 +280,17 @@ struct Rect { | |||||
| /** Returns whether this Rect contains an entire point, inclusive on the top/left, non-inclusive on the bottom/right. */ | /** Returns whether this Rect contains an entire point, inclusive on the top/left, non-inclusive on the bottom/right. */ | ||||
| bool isContaining(Vec v) const { | bool isContaining(Vec v) const { | ||||
| return pos.x <= v.x && v.x < pos.x + size.x | return pos.x <= v.x && v.x < pos.x + size.x | ||||
| && pos.y <= v.y && v.y < pos.y + size.y; | |||||
| && pos.y <= v.y && v.y < pos.y + size.y; | |||||
| } | } | ||||
| /** Returns whether this Rect contains an entire Rect. */ | /** Returns whether this Rect contains an entire Rect. */ | ||||
| bool isContaining(Rect r) const { | bool isContaining(Rect r) const { | ||||
| return pos.x <= r.pos.x && r.pos.x + r.size.x <= pos.x + size.x | return pos.x <= r.pos.x && r.pos.x + r.size.x <= pos.x + size.x | ||||
| && pos.y <= r.pos.y && r.pos.y + r.size.y <= pos.y + size.y; | |||||
| && pos.y <= r.pos.y && r.pos.y + r.size.y <= pos.y + size.y; | |||||
| } | } | ||||
| /** Returns whether this Rect overlaps with another Rect. */ | /** Returns whether this Rect overlaps with another Rect. */ | ||||
| bool isIntersecting(Rect r) const { | bool isIntersecting(Rect r) const { | ||||
| return (pos.x + size.x > r.pos.x && r.pos.x + r.size.x > pos.x) | return (pos.x + size.x > r.pos.x && r.pos.x + r.size.x > pos.x) | ||||
| && (pos.y + size.y > r.pos.y && r.pos.y + r.size.y > pos.y); | |||||
| && (pos.y + size.y > r.pos.y && r.pos.y + r.size.y > pos.y); | |||||
| } | } | ||||
| bool isEqual(Rect r) const { | bool isEqual(Rect r) const { | ||||
| return pos.isEqual(r.pos) && size.isEqual(r.size); | return pos.isEqual(r.pos) && size.isEqual(r.size); | ||||
| @@ -365,22 +365,28 @@ struct Rect { | |||||
| return r; | return r; | ||||
| } | } | ||||
| DEPRECATED bool contains(Vec v) const {return isContaining(v);} | |||||
| DEPRECATED bool contains(Rect r) const {return isContaining(r);} | |||||
| DEPRECATED bool intersects(Rect r) const {return isIntersecting(r);} | |||||
| DEPRECATED bool contains(Vec v) const { | |||||
| return isContaining(v); | |||||
| } | |||||
| DEPRECATED bool contains(Rect r) const { | |||||
| return isContaining(r); | |||||
| } | |||||
| DEPRECATED bool intersects(Rect r) const { | |||||
| return isIntersecting(r); | |||||
| } | |||||
| }; | }; | ||||
| inline Vec Vec::clamp(Rect bound) const { | inline Vec Vec::clamp(Rect bound) const { | ||||
| return Vec( | return Vec( | ||||
| math::clamp(x, bound.pos.x, bound.pos.x + bound.size.x), | |||||
| math::clamp(y, bound.pos.y, bound.pos.y + bound.size.y)); | |||||
| math::clamp(x, bound.pos.x, bound.pos.x + bound.size.x), | |||||
| math::clamp(y, bound.pos.y, bound.pos.y + bound.size.y)); | |||||
| } | } | ||||
| inline Vec Vec::clampSafe(Rect bound) const { | inline Vec Vec::clampSafe(Rect bound) const { | ||||
| return Vec( | return Vec( | ||||
| math::clampSafe(x, bound.pos.x, bound.pos.x + bound.size.x), | |||||
| math::clampSafe(y, bound.pos.y, bound.pos.y + bound.size.y)); | |||||
| math::clampSafe(x, bound.pos.x, bound.pos.x + bound.size.x), | |||||
| math::clampSafe(y, bound.pos.y, bound.pos.y + bound.size.y)); | |||||
| } | } | ||||
| @@ -59,17 +59,31 @@ struct Output; | |||||
| struct Driver { | struct Driver { | ||||
| virtual ~Driver() {} | virtual ~Driver() {} | ||||
| virtual std::string getName() {return "";} | |||||
| virtual std::string getName() { | |||||
| return ""; | |||||
| } | |||||
| virtual std::vector<int> getInputDeviceIds() {return {};} | |||||
| virtual std::string getInputDeviceName(int deviceId) {return "";} | |||||
| virtual InputDevice *subscribeInput(int deviceId, Input *input) {return NULL;} | |||||
| virtual void unsubscribeInput(int deviceId, Input *input) {} | |||||
| virtual std::vector<int> getInputDeviceIds() { | |||||
| return {}; | |||||
| } | |||||
| virtual std::string getInputDeviceName(int deviceId) { | |||||
| return ""; | |||||
| } | |||||
| virtual InputDevice* subscribeInput(int deviceId, Input* input) { | |||||
| return NULL; | |||||
| } | |||||
| virtual void unsubscribeInput(int deviceId, Input* input) {} | |||||
| virtual std::vector<int> getOutputDeviceIds() {return {};} | |||||
| virtual std::string getOutputDeviceName(int deviceId) {return "";} | |||||
| virtual OutputDevice *subscribeOutput(int deviceId, Output *output) {return NULL;} | |||||
| virtual void unsubscribeOutput(int deviceId, Output *output) {} | |||||
| virtual std::vector<int> getOutputDeviceIds() { | |||||
| return {}; | |||||
| } | |||||
| virtual std::string getOutputDeviceName(int deviceId) { | |||||
| return ""; | |||||
| } | |||||
| virtual OutputDevice* subscribeOutput(int deviceId, Output* output) { | |||||
| return NULL; | |||||
| } | |||||
| virtual void unsubscribeOutput(int deviceId, Output* output) {} | |||||
| }; | }; | ||||
| //////////////////// | //////////////////// | ||||
| @@ -82,15 +96,15 @@ struct Device { | |||||
| struct InputDevice : Device { | struct InputDevice : Device { | ||||
| std::set<Input*> subscribed; | std::set<Input*> subscribed; | ||||
| void subscribe(Input *input); | |||||
| void unsubscribe(Input *input); | |||||
| void subscribe(Input* input); | |||||
| void unsubscribe(Input* input); | |||||
| void onMessage(Message message); | void onMessage(Message message); | ||||
| }; | }; | ||||
| struct OutputDevice : Device { | struct OutputDevice : Device { | ||||
| std::set<Output*> subscribed; | std::set<Output*> subscribed; | ||||
| void subscribe(Output *input); | |||||
| void unsubscribe(Output *input); | |||||
| void subscribe(Output* input); | |||||
| void unsubscribe(Output* input); | |||||
| virtual void sendMessage(Message message) {} | virtual void sendMessage(Message message) {} | ||||
| }; | }; | ||||
| @@ -108,7 +122,7 @@ struct Port { | |||||
| */ | */ | ||||
| int channel = -1; | int channel = -1; | ||||
| /** Not owned */ | /** Not owned */ | ||||
| Driver *driver = NULL; | |||||
| Driver* driver = NULL; | |||||
| /** Remember to call setDriverId(-1) in subclass destructors. */ | /** Remember to call setDriverId(-1) in subclass destructors. */ | ||||
| virtual ~Port() {} | virtual ~Port() {} | ||||
| @@ -125,14 +139,14 @@ struct Port { | |||||
| std::string getChannelName(int channel); | std::string getChannelName(int channel); | ||||
| void setChannel(int channel); | void setChannel(int channel); | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| }; | }; | ||||
| struct Input : Port { | struct Input : Port { | ||||
| /** Not owned */ | /** Not owned */ | ||||
| InputDevice *inputDevice = NULL; | |||||
| InputDevice* inputDevice = NULL; | |||||
| Input(); | Input(); | ||||
| ~Input(); | ~Input(); | ||||
| @@ -152,13 +166,13 @@ struct InputQueue : Input { | |||||
| std::queue<Message> queue; | std::queue<Message> queue; | ||||
| void onMessage(Message message) override; | void onMessage(Message message) override; | ||||
| /** If a Message is available, writes `message` and return true */ | /** If a Message is available, writes `message` and return true */ | ||||
| bool shift(Message *message); | |||||
| bool shift(Message* message); | |||||
| }; | }; | ||||
| struct Output : Port { | struct Output : Port { | ||||
| /** Not owned */ | /** Not owned */ | ||||
| OutputDevice *outputDevice = NULL; | |||||
| OutputDevice* outputDevice = NULL; | |||||
| Output(); | Output(); | ||||
| ~Output(); | ~Output(); | ||||
| @@ -176,7 +190,7 @@ struct Output : Port { | |||||
| void init(); | void init(); | ||||
| void destroy(); | void destroy(); | ||||
| /** Registers a new MIDI driver. Takes pointer ownership. */ | /** Registers a new MIDI driver. Takes pointer ownership. */ | ||||
| void addDriver(int driverId, Driver *driver); | |||||
| void addDriver(int driverId, Driver* driver); | |||||
| } // namespace midi | } // namespace midi | ||||
| @@ -21,13 +21,13 @@ enum Method { | |||||
| /** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) | /** Requests a JSON API URL over HTTP(S), using the data as the query (GET) or the body (POST, etc) | ||||
| Caller must json_decref(). | Caller must json_decref(). | ||||
| */ | */ | ||||
| json_t *requestJson(Method method, std::string url, json_t *dataJ); | |||||
| json_t* requestJson(Method method, std::string url, json_t* dataJ); | |||||
| /** Returns true if downloaded successfully */ | /** Returns true if downloaded successfully */ | ||||
| bool requestDownload(std::string url, const std::string &filename, float *progress); | |||||
| bool requestDownload(std::string url, const std::string& filename, float* progress); | |||||
| /** URL-encodes `s` */ | /** URL-encodes `s` */ | ||||
| std::string encodeUrl(const std::string &s); | |||||
| std::string encodeUrl(const std::string& s); | |||||
| /** Gets the path portion of the URL. */ | /** Gets the path portion of the URL. */ | ||||
| std::string urlPath(const std::string &url); | |||||
| std::string urlPath(const std::string& url); | |||||
| } // namespace network | } // namespace network | ||||
| @@ -30,8 +30,8 @@ struct PatchManager { | |||||
| /** Disconnects all cables */ | /** Disconnects all cables */ | ||||
| void disconnectDialog(); | void disconnectDialog(); | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| bool isLegacy(int level); | bool isLegacy(int level); | ||||
| }; | }; | ||||
| @@ -25,21 +25,21 @@ struct Update { | |||||
| void init(); | void init(); | ||||
| void destroy(); | void destroy(); | ||||
| void logIn(const std::string &email, const std::string &password); | |||||
| void logIn(const std::string& email, const std::string& password); | |||||
| void logOut(); | void logOut(); | ||||
| bool isLoggedIn(); | bool isLoggedIn(); | ||||
| void queryUpdates(); | void queryUpdates(); | ||||
| bool hasUpdates(); | bool hasUpdates(); | ||||
| void syncUpdate(Update *update); | |||||
| void syncUpdate(Update* update); | |||||
| void syncUpdates(); | void syncUpdates(); | ||||
| bool isSyncing(); | bool isSyncing(); | ||||
| Plugin *getPlugin(const std::string &pluginSlug); | |||||
| Model *getModel(const std::string &pluginSlug, const std::string &modelSlug); | |||||
| std::string normalizeTag(const std::string &tag); | |||||
| Plugin* getPlugin(const std::string& pluginSlug); | |||||
| Model* getModel(const std::string& pluginSlug, const std::string& modelSlug); | |||||
| std::string normalizeTag(const std::string& tag); | |||||
| /** Checks that the slug contains only alphanumeric characters, "-", and "_" */ | /** Checks that the slug contains only alphanumeric characters, "-", and "_" */ | ||||
| bool isSlugValid(const std::string &slug); | |||||
| bool isSlugValid(const std::string& slug); | |||||
| /** Returns a string containing only the valid slug characters. */ | /** Returns a string containing only the valid slug characters. */ | ||||
| std::string normalizeSlug(const std::string &slug); | |||||
| std::string normalizeSlug(const std::string& slug); | |||||
| extern const std::set<std::string> allowedTags; | extern const std::set<std::string> allowedTags; | ||||
| @@ -9,12 +9,12 @@ namespace rack { | |||||
| namespace app { | namespace app { | ||||
| struct ModuleWidget; | |||||
| struct ModuleWidget; | |||||
| } // namespace app | } // namespace app | ||||
| namespace engine { | namespace engine { | ||||
| struct Module; | |||||
| struct Module; | |||||
| } // namespace engine | } // namespace engine | ||||
| @@ -22,7 +22,7 @@ namespace plugin { | |||||
| struct Model { | 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 after releasing your module. | /** Must be unique. Used for saving patches. Never change this after releasing your module. | ||||
| @@ -38,13 +38,19 @@ struct Model { | |||||
| virtual ~Model() {} | virtual ~Model() {} | ||||
| /** Creates a headless Module */ | /** Creates a headless Module */ | ||||
| virtual engine::Module *createModule() { return NULL; } | |||||
| virtual engine::Module* createModule() { | |||||
| return NULL; | |||||
| } | |||||
| /** Creates a ModuleWidget with a Module attached */ | /** Creates a ModuleWidget with a Module attached */ | ||||
| virtual app::ModuleWidget *createModuleWidget() { return NULL; } | |||||
| virtual app::ModuleWidget* createModuleWidget() { | |||||
| return NULL; | |||||
| } | |||||
| /** Creates a ModuleWidget with no Module, useful for previews */ | /** Creates a ModuleWidget with no Module, useful for previews */ | ||||
| virtual app::ModuleWidget *createModuleWidgetNull() { return NULL; } | |||||
| virtual app::ModuleWidget* createModuleWidgetNull() { | |||||
| return NULL; | |||||
| } | |||||
| void fromJson(json_t *rootJ); | |||||
| void fromJson(json_t* rootJ); | |||||
| }; | }; | ||||
| @@ -18,7 +18,7 @@ struct Plugin { | |||||
| /** The file path to 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 after releasing your plugin. | /** 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" | ||||
| @@ -63,9 +63,9 @@ struct Plugin { | |||||
| double modifiedTimestamp = -INFINITY; | double modifiedTimestamp = -INFINITY; | ||||
| ~Plugin(); | ~Plugin(); | ||||
| void addModel(Model *model); | |||||
| Model *getModel(std::string slug); | |||||
| void fromJson(json_t *rootJ); | |||||
| void addModel(Model* model); | |||||
| Model* getModel(std::string slug); | |||||
| void fromJson(json_t* rootJ); | |||||
| }; | }; | ||||
| @@ -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 *plugin); | |||||
| void init(rack::plugin::Plugin* plugin); | |||||
| @@ -101,16 +101,16 @@ namespace rack { | |||||
| /** Define this macro before including this header to prevent common namespaces from being included in the main `rack::` namespace. */ | /** Define this macro before including this header to prevent common namespaces from being included in the main `rack::` namespace. */ | ||||
| #ifndef RACK_FLATTEN_NAMESPACES | #ifndef RACK_FLATTEN_NAMESPACES | ||||
| // Import some namespaces for convenience | |||||
| using namespace logger; | |||||
| using namespace math; | |||||
| using namespace widget; | |||||
| using namespace ui; | |||||
| using namespace app; | |||||
| using plugin::Plugin; | |||||
| using plugin::Model; | |||||
| using namespace engine; | |||||
| using namespace componentlibrary; | |||||
| // Import some namespaces for convenience | |||||
| using namespace logger; | |||||
| using namespace math; | |||||
| using namespace widget; | |||||
| using namespace ui; | |||||
| using namespace app; | |||||
| using plugin::Plugin; | |||||
| using plugin::Model; | |||||
| using namespace engine; | |||||
| using namespace componentlibrary; | |||||
| #endif | #endif | ||||
| @@ -17,35 +17,91 @@ namespace rack { | |||||
| using namespace math; | using namespace math; | ||||
| DEPRECATED inline int min(int a, int b) {return std::min(a, b);} | |||||
| DEPRECATED inline int max(int a, int b) {return std::max(a, b);} | |||||
| DEPRECATED inline int eucmod(int a, int base) {return eucMod(a, base);} | |||||
| DEPRECATED inline bool ispow2(int n) {return isPow2(n);} | |||||
| DEPRECATED inline int clamp2(int x, int a, int b) {return clampSafe(x, a, b);} | |||||
| DEPRECATED inline float min(float a, float b) {return std::min(a, b);} | |||||
| DEPRECATED inline float max(float a, float b) {return std::max(a, b);} | |||||
| DEPRECATED inline float eucmod(float a, float base) {return eucMod(a, base);} | |||||
| DEPRECATED inline float clamp2(float x, float a, float b) {return clampSafe(x, a, b);} | |||||
| DEPRECATED inline int mini(int a, int b) {return std::min(a, b);} | |||||
| DEPRECATED inline int maxi(int a, int b) {return std::max(a, b);} | |||||
| DEPRECATED inline int clampi(int x, int min, int max) {return math::clamp(x, min, max);} | |||||
| DEPRECATED inline int absi(int a) {return std::fabs(a);} | |||||
| DEPRECATED inline int eucmodi(int a, int base) {return eucMod(a, base);} | |||||
| DEPRECATED inline int log2i(int n) {return math::log2(n);} | |||||
| DEPRECATED inline bool ispow2i(int n) {return isPow2(n);} | |||||
| DEPRECATED inline float absf(float x) {return std::fabs(x);} | |||||
| DEPRECATED inline float sgnf(float x) {return sgn(x);} | |||||
| DEPRECATED inline float eucmodf(float a, float base) {return eucMod(a, base);} | |||||
| DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) {return math::isNear(a, b, epsilon);} | |||||
| DEPRECATED inline float clampf(float x, float min, float max) {return math::clamp(x, min, max);} | |||||
| DEPRECATED inline float clamp2f(float x, float min, float max) {return clampSafe(x, min, max);} | |||||
| 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 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);} | |||||
| DEPRECATED inline int min(int a, int b) { | |||||
| return std::min(a, b); | |||||
| } | |||||
| DEPRECATED inline int max(int a, int b) { | |||||
| return std::max(a, b); | |||||
| } | |||||
| DEPRECATED inline int eucmod(int a, int base) { | |||||
| return eucMod(a, base); | |||||
| } | |||||
| DEPRECATED inline bool ispow2(int n) { | |||||
| return isPow2(n); | |||||
| } | |||||
| DEPRECATED inline int clamp2(int x, int a, int b) { | |||||
| return clampSafe(x, a, b); | |||||
| } | |||||
| DEPRECATED inline float min(float a, float b) { | |||||
| return std::min(a, b); | |||||
| } | |||||
| DEPRECATED inline float max(float a, float b) { | |||||
| return std::max(a, b); | |||||
| } | |||||
| DEPRECATED inline float eucmod(float a, float base) { | |||||
| return eucMod(a, base); | |||||
| } | |||||
| DEPRECATED inline float clamp2(float x, float a, float b) { | |||||
| return clampSafe(x, a, b); | |||||
| } | |||||
| DEPRECATED inline int mini(int a, int b) { | |||||
| return std::min(a, b); | |||||
| } | |||||
| DEPRECATED inline int maxi(int a, int b) { | |||||
| return std::max(a, b); | |||||
| } | |||||
| DEPRECATED inline int clampi(int x, int min, int max) { | |||||
| return math::clamp(x, min, max); | |||||
| } | |||||
| DEPRECATED inline int absi(int a) { | |||||
| return std::fabs(a); | |||||
| } | |||||
| DEPRECATED inline int eucmodi(int a, int base) { | |||||
| return eucMod(a, base); | |||||
| } | |||||
| DEPRECATED inline int log2i(int n) { | |||||
| return math::log2(n); | |||||
| } | |||||
| DEPRECATED inline bool ispow2i(int n) { | |||||
| return isPow2(n); | |||||
| } | |||||
| DEPRECATED inline float absf(float x) { | |||||
| return std::fabs(x); | |||||
| } | |||||
| DEPRECATED inline float sgnf(float x) { | |||||
| return sgn(x); | |||||
| } | |||||
| DEPRECATED inline float eucmodf(float a, float base) { | |||||
| return eucMod(a, base); | |||||
| } | |||||
| DEPRECATED inline bool nearf(float a, float b, float epsilon = 1.0e-6f) { | |||||
| return math::isNear(a, b, epsilon); | |||||
| } | |||||
| DEPRECATED inline float clampf(float x, float min, float max) { | |||||
| return math::clamp(x, min, max); | |||||
| } | |||||
| DEPRECATED inline float clamp2f(float x, float min, float max) { | |||||
| return clampSafe(x, min, max); | |||||
| } | |||||
| 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 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); | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // string | // string | ||||
| @@ -57,11 +113,21 @@ DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br | |||||
| // random | // random | ||||
| //////////////////// | //////////////////// | ||||
| DEPRECATED inline uint32_t randomu32() {return random::u32();} | |||||
| DEPRECATED inline uint64_t randomu64() {return random::u64();} | |||||
| DEPRECATED inline float randomUniform() {return random::uniform();} | |||||
| DEPRECATED inline float randomNormal() {return random::normal();} | |||||
| DEPRECATED inline float randomf() {return random::uniform();} | |||||
| DEPRECATED inline uint32_t randomu32() { | |||||
| return random::u32(); | |||||
| } | |||||
| DEPRECATED inline uint64_t randomu64() { | |||||
| return random::u64(); | |||||
| } | |||||
| DEPRECATED inline float randomUniform() { | |||||
| return random::uniform(); | |||||
| } | |||||
| DEPRECATED inline float randomNormal() { | |||||
| return random::normal(); | |||||
| } | |||||
| DEPRECATED inline float randomf() { | |||||
| return random::uniform(); | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // logger | // logger | ||||
| @@ -77,23 +143,47 @@ DEPRECATED inline float randomf() {return random::uniform();} | |||||
| // asset | // asset | ||||
| //////////////////// | //////////////////// | ||||
| DEPRECATED inline std::string assetGlobal(std::string filename) {return asset::system(filename);} | |||||
| DEPRECATED inline std::string assetLocal(std::string filename) {return asset::user(filename);} | |||||
| DEPRECATED inline std::string assetPlugin(Plugin *plugin, std::string filename) {return asset::plugin(plugin, filename);} | |||||
| DEPRECATED inline std::string assetGlobal(std::string filename) { | |||||
| return asset::system(filename); | |||||
| } | |||||
| DEPRECATED inline std::string assetLocal(std::string filename) { | |||||
| return asset::user(filename); | |||||
| } | |||||
| DEPRECATED inline std::string assetPlugin(Plugin* plugin, std::string filename) { | |||||
| return asset::plugin(plugin, filename); | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // color | // color | ||||
| //////////////////// | //////////////////// | ||||
| DEPRECATED inline NVGcolor colorClip(NVGcolor a) {return color::clamp(a);} | |||||
| DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) {return color::minus(a, b);} | |||||
| DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) {return color::plus(a, b);} | |||||
| DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) {return color::mult(a, b);} | |||||
| DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) {return color::mult(a, x);} | |||||
| DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) {return color::screen(a, b);} | |||||
| DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) {return color::alpha(a, alpha);} | |||||
| DEPRECATED inline NVGcolor colorFromHexString(std::string s) {return color::fromHexString(s);} | |||||
| DEPRECATED inline std::string colorToHexString(NVGcolor c) {return color::toHexString(c);} | |||||
| DEPRECATED inline NVGcolor colorClip(NVGcolor a) { | |||||
| return color::clamp(a); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorMinus(NVGcolor a, NVGcolor b) { | |||||
| return color::minus(a, b); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorPlus(NVGcolor a, NVGcolor b) { | |||||
| return color::plus(a, b); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorMult(NVGcolor a, NVGcolor b) { | |||||
| return color::mult(a, b); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorMult(NVGcolor a, float x) { | |||||
| return color::mult(a, x); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorScreen(NVGcolor a, NVGcolor b) { | |||||
| return color::screen(a, b); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorAlpha(NVGcolor a, float alpha) { | |||||
| return color::alpha(a, alpha); | |||||
| } | |||||
| DEPRECATED inline NVGcolor colorFromHexString(std::string s) { | |||||
| return color::fromHexString(s); | |||||
| } | |||||
| DEPRECATED inline std::string colorToHexString(NVGcolor c) { | |||||
| return color::toHexString(c); | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // componentlibrary | // componentlibrary | ||||
| @@ -118,14 +208,14 @@ DEPRECATED static const NVGcolor COLOR_DARK_PANEL = componentlibrary::SCHEME_DAR | |||||
| /** Use createWidget() instead */ | /** Use createWidget() instead */ | ||||
| template <class TScrew> | template <class TScrew> | ||||
| DEPRECATED TScrew *createScrew(math::Vec pos) { | |||||
| DEPRECATED TScrew* createScrew(math::Vec pos) { | |||||
| return createWidget<TScrew>(pos); | return createWidget<TScrew>(pos); | ||||
| } | } | ||||
| /** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */ | /** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */ | ||||
| template <class TParamWidget> | template <class TParamWidget> | ||||
| DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { | |||||
| TParamWidget *o = createParam<TParamWidget>(pos, module, paramId); | |||||
| DEPRECATED TParamWidget* createParam(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) { | |||||
| TParamWidget* o = createParam<TParamWidget>(pos, module, paramId); | |||||
| if (module) { | if (module) { | ||||
| module->configParam(paramId, minValue, maxValue, defaultValue); | module->configParam(paramId, minValue, maxValue, defaultValue); | ||||
| } | } | ||||
| @@ -133,8 +223,8 @@ DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, | |||||
| } | } | ||||
| template <class TParamWidget> | template <class TParamWidget> | ||||
| DEPRECATED TParamWidget *createParamCentered(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { | |||||
| TParamWidget *o = createParamCentered<TParamWidget>(pos, module, paramId); | |||||
| DEPRECATED TParamWidget* createParamCentered(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) { | |||||
| TParamWidget* o = createParamCentered<TParamWidget>(pos, module, paramId); | |||||
| if (module) { | if (module) { | ||||
| module->configParam(paramId, minValue, maxValue, defaultValue); | module->configParam(paramId, minValue, maxValue, defaultValue); | ||||
| } | } | ||||
| @@ -143,8 +233,8 @@ DEPRECATED TParamWidget *createParamCentered(math::Vec pos, Module *module, int | |||||
| /** Use createInput() and createOutput() without the `type` variable */ | /** Use createInput() and createOutput() without the `type` variable */ | ||||
| template <class TPortWidget> | template <class TPortWidget> | ||||
| DEPRECATED TPortWidget *createPort(math::Vec pos, PortWidget::Type type, Module *module, int inputId) { | |||||
| TPortWidget *o = new TPortWidget; | |||||
| DEPRECATED TPortWidget* createPort(math::Vec pos, PortWidget::Type type, Module* module, int inputId) { | |||||
| TPortWidget* o = new TPortWidget; | |||||
| o->box.pos = pos; | o->box.pos = pos; | ||||
| o->type = type; | o->type = type; | ||||
| o->module = module; | o->module = module; | ||||
| @@ -41,10 +41,10 @@ extern bool skipLoadOnLaunch; | |||||
| extern std::string patchPath; | extern std::string patchPath; | ||||
| extern std::vector<NVGcolor> cableColors; | extern std::vector<NVGcolor> cableColors; | ||||
| json_t *toJson(); | |||||
| void fromJson(json_t *rootJ); | |||||
| void save(const std::string &path); | |||||
| void load(const std::string &path); | |||||
| json_t* toJson(); | |||||
| void fromJson(json_t* rootJ); | |||||
| void save(const std::string& path); | |||||
| void load(const std::string& path); | |||||
| } // namespace settings | } // namespace settings | ||||
| @@ -374,7 +374,7 @@ inline __m128 sse_mathfun_cos_ps(__m128 x) { // any x | |||||
| /* since sin_ps and cos_ps are almost identical, sincos_ps could replace both of them.. | /* since sin_ps and cos_ps are almost identical, sincos_ps could replace both of them.. | ||||
| it is almost as fast, and gives you a free cosine with your sine */ | it is almost as fast, and gives you a free cosine with your sine */ | ||||
| inline void sse_mathfun_sincos_ps(__m128 x, __m128 *s, __m128 *c) { | |||||
| inline void sse_mathfun_sincos_ps(__m128 x, __m128* s, __m128* c) { | |||||
| __m128 xmm1, xmm2, xmm3 = _mm_setzero_ps(), sign_bit_sin, y; | __m128 xmm1, xmm2, xmm3 = _mm_setzero_ps(), sign_bit_sin, y; | ||||
| __m128i emm0, emm2, emm4; | __m128i emm0, emm2, emm4; | ||||
| sign_bit_sin = x; | sign_bit_sin = x; | ||||
| @@ -63,13 +63,13 @@ struct Vector<float, 4> { | |||||
| /** Returns a vector with all 1 bits. */ | /** Returns a vector with all 1 bits. */ | ||||
| static Vector mask() { | static Vector mask() { | ||||
| return _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); | |||||
| return _mm_castsi128_ps(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); | |||||
| } | } | ||||
| /** Reads an array of 4 values. | /** Reads an array of 4 values. | ||||
| On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`. | On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`. | ||||
| */ | */ | ||||
| static Vector load(const float *x) { | |||||
| static Vector load(const float* x) { | |||||
| /* | /* | ||||
| My benchmarks show that _mm_loadu_ps() performs equally as fast as _mm_load_ps() when data is actually aligned. | My benchmarks show that _mm_loadu_ps() performs equally as fast as _mm_load_ps() when data is actually aligned. | ||||
| This post seems to agree. https://stackoverflow.com/a/20265193/272642 | This post seems to agree. https://stackoverflow.com/a/20265193/272642 | ||||
| @@ -81,12 +81,16 @@ struct Vector<float, 4> { | |||||
| /** Writes an array of 4 values. | /** Writes an array of 4 values. | ||||
| On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`. | On little-endian machines (e.g. x86), the order is reversed, so `x[0]` corresponds to `vector.s[3]`. | ||||
| */ | */ | ||||
| void store(float *x) { | |||||
| void store(float* x) { | |||||
| _mm_storeu_ps(x, v); | _mm_storeu_ps(x, v); | ||||
| } | } | ||||
| float &operator[](int i) {return s[i];} | |||||
| const float &operator[](int i) const {return s[i];} | |||||
| float& operator[](int i) { | |||||
| return s[i]; | |||||
| } | |||||
| const float& operator[](int i) const { | |||||
| return s[i]; | |||||
| } | |||||
| // Conversions | // Conversions | ||||
| Vector(Vector<int32_t, 4> a); | Vector(Vector<int32_t, 4> a); | ||||
| @@ -119,18 +123,22 @@ struct Vector<int32_t, 4> { | |||||
| static Vector mask() { | static Vector mask() { | ||||
| return Vector(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); | return Vector(_mm_cmpeq_epi32(_mm_setzero_si128(), _mm_setzero_si128())); | ||||
| } | } | ||||
| static Vector load(const int32_t *x) { | |||||
| static Vector load(const int32_t* x) { | |||||
| // HACK | // HACK | ||||
| // Use _mm_loadu_si128() because GCC doesn't support _mm_loadu_si32() | // Use _mm_loadu_si128() because GCC doesn't support _mm_loadu_si32() | ||||
| return Vector(_mm_loadu_si128((__m128i*) x)); | return Vector(_mm_loadu_si128((__m128i*) x)); | ||||
| } | } | ||||
| void store(int32_t *x) { | |||||
| void store(int32_t* x) { | |||||
| // HACK | // HACK | ||||
| // Use _mm_storeu_si128() because GCC doesn't support _mm_storeu_si32() | // Use _mm_storeu_si128() because GCC doesn't support _mm_storeu_si32() | ||||
| _mm_storeu_si128((__m128i*) x, v); | _mm_storeu_si128((__m128i*) x, v); | ||||
| } | } | ||||
| int32_t &operator[](int i) {return s[i];} | |||||
| const int32_t &operator[](int i) const {return s[i];} | |||||
| int32_t& operator[](int i) { | |||||
| return s[i]; | |||||
| } | |||||
| const int32_t& operator[](int i) const { | |||||
| return s[i]; | |||||
| } | |||||
| Vector(Vector<float, 4> a); | Vector(Vector<float, 4> a); | ||||
| static Vector cast(Vector<float, 4> a); | static Vector cast(Vector<float, 4> a); | ||||
| }; | }; | ||||
| @@ -160,21 +168,21 @@ inline Vector<int32_t, 4> Vector<int32_t, 4>::cast(Vector<float, 4> a) { | |||||
| /** `~a & b` */ | /** `~a & b` */ | ||||
| inline Vector<float, 4> andnot(const Vector<float, 4> &a, const Vector<float, 4> &b) { | |||||
| inline Vector<float, 4> andnot(const Vector<float, 4>& a, const Vector<float, 4>& b) { | |||||
| return Vector<float, 4>(_mm_andnot_ps(a.v, b.v)); | return Vector<float, 4>(_mm_andnot_ps(a.v, b.v)); | ||||
| } | } | ||||
| /** Returns an integer with each bit corresponding to the most significant bit of each element. | /** Returns an integer with each bit corresponding to the most significant bit of each element. | ||||
| For example, `movemask(float_4::mask())` returns 0xf. | For example, `movemask(float_4::mask())` returns 0xf. | ||||
| */ | */ | ||||
| inline int movemask(const Vector<float, 4> &a) { | |||||
| inline int movemask(const Vector<float, 4>& a) { | |||||
| return _mm_movemask_ps(a.v); | return _mm_movemask_ps(a.v); | ||||
| } | } | ||||
| /** Returns an integer with each bit corresponding to the most significant bit of each byte. | /** Returns an integer with each bit corresponding to the most significant bit of each byte. | ||||
| For example, `movemask(int32_4::mask())` returns 0xffff. | For example, `movemask(int32_4::mask())` returns 0xffff. | ||||
| */ | */ | ||||
| inline int movemask(const Vector<int32_t, 4> &a) { | |||||
| inline int movemask(const Vector<int32_t, 4>& a) { | |||||
| return _mm_movemask_epi8(a.v); | return _mm_movemask_epi8(a.v); | ||||
| } | } | ||||
| @@ -250,7 +258,7 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator==, _mm_cmpeq_ps) | |||||
| DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator==, _mm_cmpeq_epi32) | DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator==, _mm_cmpeq_epi32) | ||||
| DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator>=, _mm_cmpge_ps) | DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator>=, _mm_cmpge_ps) | ||||
| inline Vector<int32_t, 4> operator>=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) { | |||||
| inline Vector<int32_t, 4> operator>=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) { | |||||
| return Vector<int32_t, 4>(_mm_cmpgt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | return Vector<int32_t, 4>(_mm_cmpgt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | ||||
| } | } | ||||
| @@ -258,7 +266,7 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator>, _mm_cmpgt_ps) | |||||
| DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator>, _mm_cmpgt_epi32) | DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator>, _mm_cmpgt_epi32) | ||||
| DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator<=, _mm_cmple_ps) | DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator<=, _mm_cmple_ps) | ||||
| inline Vector<int32_t, 4> operator<=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) { | |||||
| inline Vector<int32_t, 4> operator<=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) { | |||||
| return Vector<int32_t, 4>(_mm_cmplt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | return Vector<int32_t, 4>(_mm_cmplt_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | ||||
| } | } | ||||
| @@ -266,75 +274,75 @@ DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator<, _mm_cmplt_ps) | |||||
| DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator<, _mm_cmplt_epi32) | DECLARE_VECTOR_OPERATOR_INFIX(int32_t, 4, operator<, _mm_cmplt_epi32) | ||||
| DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator!=, _mm_cmpneq_ps) | DECLARE_VECTOR_OPERATOR_INFIX(float, 4, operator!=, _mm_cmpneq_ps) | ||||
| inline Vector<int32_t, 4> operator!=(const Vector<int32_t, 4> &a, const Vector<int32_t, 4> &b) { | |||||
| inline Vector<int32_t, 4> operator!=(const Vector<int32_t, 4>& a, const Vector<int32_t, 4>& b) { | |||||
| return Vector<int32_t, 4>(_mm_cmpeq_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | return Vector<int32_t, 4>(_mm_cmpeq_epi32(a.v, b.v)) ^ Vector<int32_t, 4>::mask(); | ||||
| } | } | ||||
| /** `+a` */ | /** `+a` */ | ||||
| inline Vector<float, 4> operator+(const Vector<float, 4> &a) { | |||||
| inline Vector<float, 4> operator+(const Vector<float, 4>& a) { | |||||
| return a; | return a; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> operator+(const Vector<int32_t, 4> &a) { | |||||
| inline Vector<int32_t, 4> operator+(const Vector<int32_t, 4>& a) { | |||||
| return a; | return a; | ||||
| } | } | ||||
| /** `-a` */ | /** `-a` */ | ||||
| inline Vector<float, 4> operator-(const Vector<float, 4> &a) { | |||||
| inline Vector<float, 4> operator-(const Vector<float, 4>& a) { | |||||
| return 0.f - a; | return 0.f - a; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> operator-(const Vector<int32_t, 4> &a) { | |||||
| inline Vector<int32_t, 4> operator-(const Vector<int32_t, 4>& a) { | |||||
| return 0 - a; | return 0 - a; | ||||
| } | } | ||||
| /** `++a` */ | /** `++a` */ | ||||
| inline Vector<float, 4> &operator++(Vector<float, 4> &a) { | |||||
| inline Vector<float, 4>& operator++(Vector<float, 4>& a) { | |||||
| a += 1.f; | a += 1.f; | ||||
| return a; | return a; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> &operator++(Vector<int32_t, 4> &a) { | |||||
| inline Vector<int32_t, 4>& operator++(Vector<int32_t, 4>& a) { | |||||
| a += 1; | a += 1; | ||||
| return a; | return a; | ||||
| } | } | ||||
| /** `--a` */ | /** `--a` */ | ||||
| inline Vector<float, 4> &operator--(Vector<float, 4> &a) { | |||||
| inline Vector<float, 4>& operator--(Vector<float, 4>& a) { | |||||
| a -= 1.f; | a -= 1.f; | ||||
| return a; | return a; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> &operator--(Vector<int32_t, 4> &a) { | |||||
| inline Vector<int32_t, 4>& operator--(Vector<int32_t, 4>& a) { | |||||
| a -= 1; | a -= 1; | ||||
| return a; | return a; | ||||
| } | } | ||||
| /** `a++` */ | /** `a++` */ | ||||
| inline Vector<float, 4> operator++(Vector<float, 4> &a, int) { | |||||
| inline Vector<float, 4> operator++(Vector<float, 4>& a, int) { | |||||
| Vector<float, 4> b = a; | Vector<float, 4> b = a; | ||||
| ++a; | ++a; | ||||
| return b; | return b; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> operator++(Vector<int32_t, 4> &a, int) { | |||||
| inline Vector<int32_t, 4> operator++(Vector<int32_t, 4>& a, int) { | |||||
| Vector<int32_t, 4> b = a; | Vector<int32_t, 4> b = a; | ||||
| ++a; | ++a; | ||||
| return b; | return b; | ||||
| } | } | ||||
| /** `a--` */ | /** `a--` */ | ||||
| inline Vector<float, 4> operator--(Vector<float, 4> &a, int) { | |||||
| inline Vector<float, 4> operator--(Vector<float, 4>& a, int) { | |||||
| Vector<float, 4> b = a; | Vector<float, 4> b = a; | ||||
| --a; | --a; | ||||
| return b; | return b; | ||||
| } | } | ||||
| inline Vector<int32_t, 4> operator--(Vector<int32_t, 4> &a, int) { | |||||
| inline Vector<int32_t, 4> operator--(Vector<int32_t, 4>& a, int) { | |||||
| Vector<int32_t, 4> b = a; | Vector<int32_t, 4> b = a; | ||||
| --a; | --a; | ||||
| return b; | return b; | ||||
| } | } | ||||
| /** `~a` */ | /** `~a` */ | ||||
| inline Vector<float, 4> operator~(const Vector<float, 4> &a) { | |||||
| inline Vector<float, 4> operator~(const Vector<float, 4>& a) { | |||||
| return a ^ Vector<float, 4>::mask(); | return a ^ Vector<float, 4>::mask(); | ||||
| } | } | ||||
| inline Vector<int32_t, 4> operator~(const Vector<int32_t, 4> &a) { | |||||
| inline Vector<int32_t, 4> operator~(const Vector<int32_t, 4>& a) { | |||||
| return a ^ Vector<int32_t, 4>::mask(); | return a ^ Vector<int32_t, 4>::mask(); | ||||
| } | } | ||||
| @@ -11,55 +11,55 @@ namespace string { | |||||
| /** Converts a UTF-16/32 string (depending on the size of wchar_t) to a UTF-8 string. */ | /** Converts a UTF-16/32 string (depending on the size of wchar_t) to a UTF-8 string. */ | ||||
| std::string fromWstring(const std::wstring &s); | |||||
| std::wstring toWstring(const std::string &s); | |||||
| std::string fromWstring(const std::wstring& s); | |||||
| std::wstring toWstring(const std::string& s); | |||||
| /** Converts a `printf()` format string and optional arguments into a std::string. | /** Converts a `printf()` format string and optional arguments into a std::string. | ||||
| Remember that "%s" must reference a `char *`, so use `.c_str()` for `std::string`s, otherwise you might get binary garbage. | Remember that "%s" must reference a `char *`, so use `.c_str()` for `std::string`s, otherwise you might get binary garbage. | ||||
| */ | */ | ||||
| std::string f(const char *format, ...); | |||||
| std::string f(const char* format, ...); | |||||
| /** Replaces all characters to lowercase letters */ | /** Replaces all characters to lowercase letters */ | ||||
| std::string lowercase(const std::string &s); | |||||
| std::string lowercase(const std::string& s); | |||||
| /** Replaces all characters to uppercase letters */ | /** Replaces all characters to uppercase letters */ | ||||
| std::string uppercase(const std::string &s); | |||||
| std::string uppercase(const std::string& s); | |||||
| /** Removes whitespace from beginning and end of string. */ | /** Removes whitespace from beginning and end of string. */ | ||||
| std::string trim(const std::string &s); | |||||
| std::string trim(const std::string& s); | |||||
| /** Truncates and adds "..." to a string, not exceeding `len` characters */ | /** Truncates and adds "..." to a string, not exceeding `len` characters */ | ||||
| std::string ellipsize(const std::string &s, size_t len); | |||||
| std::string ellipsizePrefix(const std::string &s, size_t len); | |||||
| bool startsWith(const std::string &str, const std::string &prefix); | |||||
| bool endsWith(const std::string &str, const std::string &suffix); | |||||
| std::string ellipsize(const std::string& s, size_t len); | |||||
| std::string ellipsizePrefix(const std::string& s, size_t len); | |||||
| bool startsWith(const std::string& str, const std::string& prefix); | |||||
| bool endsWith(const std::string& str, const std::string& suffix); | |||||
| /** Extracts the directory of the path. | /** Extracts the directory of the path. | ||||
| Example: directory("dir/file.txt") // "dir" | Example: directory("dir/file.txt") // "dir" | ||||
| Calls POSIX dirname(). | Calls POSIX dirname(). | ||||
| */ | */ | ||||
| std::string directory(const std::string &path); | |||||
| std::string directory(const std::string& path); | |||||
| /** Extracts the filename of the path. | /** Extracts the filename of the path. | ||||
| Example: directory("dir/file.txt") // "file.txt" | Example: directory("dir/file.txt") // "file.txt" | ||||
| Calls POSIX basename(). | Calls POSIX basename(). | ||||
| */ | */ | ||||
| std::string filename(const std::string &path); | |||||
| std::string filename(const std::string& path); | |||||
| /** Extracts the portion of a filename without the extension. | /** Extracts the portion of a filename without the extension. | ||||
| Example: filenameBase("file.txt") // "file" | Example: filenameBase("file.txt") // "file" | ||||
| Note: Only works on filenames. Call filename(path) to get the filename of the path. | Note: Only works on filenames. Call filename(path) to get the filename of the path. | ||||
| */ | */ | ||||
| std::string filenameBase(const std::string &filename); | |||||
| std::string filenameBase(const std::string& filename); | |||||
| /** Extracts the extension of a filename. | /** Extracts the extension of a filename. | ||||
| Example: filenameExtension("file.txt") // "txt" | Example: filenameExtension("file.txt") // "txt" | ||||
| Note: Only works on filenames. Call filename(path) to get the filename of the path. | Note: Only works on filenames. Call filename(path) to get the filename of the path. | ||||
| */ | */ | ||||
| std::string filenameExtension(const std::string &filename); | |||||
| std::string filenameExtension(const std::string& filename); | |||||
| /** Returns the canonicalized absolute path pointed to by `path`, following symlinks. | /** Returns the canonicalized absolute path pointed to by `path`, following symlinks. | ||||
| Returns "" if the symbol is not found. | Returns "" if the symbol is not found. | ||||
| */ | */ | ||||
| std::string absolutePath(const std::string &path); | |||||
| std::string absolutePath(const std::string& path); | |||||
| /** Scores how well a query matches a string. | /** Scores how well a query matches a string. | ||||
| A score of 0 means no match. | A score of 0 means no match. | ||||
| The score is arbitrary and is only meaningful for sorting. | The score is arbitrary and is only meaningful for sorting. | ||||
| */ | */ | ||||
| float fuzzyScore(const std::string &s, const std::string &query); | |||||
| float fuzzyScore(const std::string& s, const std::string& query); | |||||
| struct CaseInsensitiveCompare { | struct CaseInsensitiveCompare { | ||||
| bool operator()(const std::string &a, const std::string &b) const { | |||||
| bool operator()(const std::string& a, const std::string& b) const { | |||||
| return lowercase(a) < lowercase(b); | return lowercase(a) < lowercase(b); | ||||
| } | } | ||||
| }; | }; | ||||
| @@ -7,7 +7,7 @@ | |||||
| namespace rack { | namespace rack { | ||||
| void svgDraw(NVGcontext *vg, NSVGimage *svg); | |||||
| void svgDraw(NVGcontext* vg, NSVGimage* svg); | |||||
| } // namespace rack | } // namespace rack | ||||
| @@ -12,23 +12,23 @@ namespace system { | |||||
| /** Returns a list of all entries (directories, files, symbols) in a directory. */ | /** Returns a list of all entries (directories, files, symbols) in a directory. */ | ||||
| std::list<std::string> getEntries(const std::string &path); | |||||
| std::list<std::string> getEntries(const std::string& path); | |||||
| /** Returns whether the given path is a file. */ | /** Returns whether the given path is a file. */ | ||||
| bool isFile(const std::string &path); | |||||
| bool isFile(const std::string& path); | |||||
| /** Returns whether the given path is a directory. */ | /** Returns whether the given path is a directory. */ | ||||
| bool isDirectory(const std::string &path); | |||||
| bool isDirectory(const std::string& path); | |||||
| /** Moves a file. */ | /** Moves a file. */ | ||||
| void moveFile(const std::string &srcPath, const std::string &destPath); | |||||
| void moveFile(const std::string& srcPath, const std::string& destPath); | |||||
| /** Copies a file. */ | /** Copies a file. */ | ||||
| void copyFile(const std::string &srcPath, const std::string &destPath); | |||||
| void copyFile(const std::string& srcPath, const std::string& destPath); | |||||
| /** Creates a directory. | /** Creates a directory. | ||||
| The parent directory must exist. | The parent directory must exist. | ||||
| */ | */ | ||||
| void createDirectory(const std::string &path); | |||||
| void createDirectory(const std::string& path); | |||||
| /** Returns the number of logical simultaneous multithreading (SMT) (e.g. Intel Hyperthreaded) threads on the CPU. */ | /** Returns the number of logical simultaneous multithreading (SMT) (e.g. Intel Hyperthreaded) threads on the CPU. */ | ||||
| int getLogicalCoreCount(); | int getLogicalCoreCount(); | ||||
| /** Sets a name of the current thread for debuggers and OS-specific process viewers. */ | /** Sets a name of the current thread for debuggers and OS-specific process viewers. */ | ||||
| void setThreadName(const std::string &name); | |||||
| void setThreadName(const std::string& name); | |||||
| /** Sets the current thread to be high-priority. */ | /** Sets the current thread to be high-priority. */ | ||||
| void setThreadRealTime(bool realTime); | void setThreadRealTime(bool realTime); | ||||
| /** Returns the caller's human-readable stack trace with "\n"-separated lines. */ | /** Returns the caller's human-readable stack trace with "\n"-separated lines. */ | ||||
| @@ -37,13 +37,13 @@ std::string getStackTrace(); | |||||
| Shell injection is possible, so make sure the URL is trusted or hard coded. | Shell injection is possible, so make sure the URL is trusted or hard coded. | ||||
| May block, so open in a new thread. | May block, so open in a new thread. | ||||
| */ | */ | ||||
| void openBrowser(const std::string &url); | |||||
| void openBrowser(const std::string& url); | |||||
| /** Opens Windows Explorer, Finder, etc at the folder location. */ | /** Opens Windows Explorer, Finder, etc at the folder location. */ | ||||
| void openFolder(const std::string &path); | |||||
| void openFolder(const std::string& path); | |||||
| /** Runs an executable without blocking. | /** Runs an executable without blocking. | ||||
| The launched process will continue running if the current process is closed. | The launched process will continue running if the current process is closed. | ||||
| */ | */ | ||||
| void runProcessDetached(const std::string &path); | |||||
| void runProcessDetached(const std::string& path); | |||||
| std::string getOperatingSystemInfo(); | std::string getOperatingSystemInfo(); | ||||
| @@ -11,13 +11,13 @@ namespace ui { | |||||
| struct Button : widget::OpaqueWidget { | struct Button : widget::OpaqueWidget { | ||||
| std::string text; | std::string text; | ||||
| /** Not owned. Tracks the pressed state of the button.*/ | /** Not owned. Tracks the pressed state of the button.*/ | ||||
| Quantity *quantity = NULL; | |||||
| Quantity* quantity = NULL; | |||||
| Button(); | Button(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDragDrop(const event::DragDrop &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDragDrop(const event::DragDrop& e) override; | |||||
| }; | }; | ||||
| @@ -8,7 +8,7 @@ namespace ui { | |||||
| struct ChoiceButton : Button { | struct ChoiceButton : Button { | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -10,12 +10,14 @@ namespace ui { | |||||
| struct IconButton : Button { | struct IconButton : Button { | ||||
| widget::FramebufferWidget *fw; | |||||
| widget::SvgWidget *sw; | |||||
| widget::FramebufferWidget* fw; | |||||
| widget::SvgWidget* sw; | |||||
| IconButton(); | IconButton(); | ||||
| void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) { | |||||
| setSvg(svg); | |||||
| } | |||||
| }; | }; | ||||
| @@ -20,7 +20,7 @@ struct Label : widget::Widget { | |||||
| Alignment alignment = LEFT_ALIGNMENT; | Alignment alignment = LEFT_ALIGNMENT; | ||||
| Label(); | Label(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -9,17 +9,17 @@ namespace ui { | |||||
| struct Menu : widget::OpaqueWidget { | struct Menu : widget::OpaqueWidget { | ||||
| Menu *parentMenu = NULL; | |||||
| Menu *childMenu = NULL; | |||||
| Menu* parentMenu = NULL; | |||||
| Menu* childMenu = NULL; | |||||
| /** The entry which created the child menu */ | /** The entry which created the child menu */ | ||||
| MenuEntry *activeEntry = NULL; | |||||
| MenuEntry* activeEntry = NULL; | |||||
| Menu(); | Menu(); | ||||
| ~Menu(); | ~Menu(); | ||||
| void setChildMenu(Menu *menu); | |||||
| void setChildMenu(Menu* menu); | |||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onHoverScroll(const event::HoverScroll &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onHoverScroll(const event::HoverScroll& e) override; | |||||
| }; | }; | ||||
| @@ -15,12 +15,14 @@ struct MenuItem : MenuEntry { | |||||
| bool disabled = false; | bool disabled = false; | ||||
| bool active = false; | bool active = false; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void step() override; | void step() override; | ||||
| void onEnter(const event::Enter &e) override; | |||||
| void onDragDrop(const event::DragDrop &e) override; | |||||
| void onEnter(const event::Enter& e) override; | |||||
| void onDragDrop(const event::DragDrop& e) override; | |||||
| void doAction(); | void doAction(); | ||||
| virtual Menu *createChildMenu() {return NULL;} | |||||
| virtual Menu* createChildMenu() { | |||||
| return NULL; | |||||
| } | |||||
| }; | }; | ||||
| @@ -10,7 +10,7 @@ namespace ui { | |||||
| struct MenuLabel : MenuEntry { | struct MenuLabel : MenuEntry { | ||||
| std::string text; | std::string text; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void step() override; | void step() override; | ||||
| }; | }; | ||||
| @@ -10,8 +10,8 @@ namespace ui { | |||||
| /** Deletes itself from parent when clicked */ | /** Deletes itself from parent when clicked */ | ||||
| struct MenuOverlay : widget::OpaqueWidget { | struct MenuOverlay : widget::OpaqueWidget { | ||||
| void step() override; | void step() override; | ||||
| void onButton(const event::Button &e) override; | |||||
| void onHoverKey(const event::HoverKey &e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onHoverKey(const event::HoverKey& e) override; | |||||
| }; | }; | ||||
| @@ -9,7 +9,7 @@ namespace ui { | |||||
| struct MenuSeparator : MenuEntry { | struct MenuSeparator : MenuEntry { | ||||
| MenuSeparator(); | MenuSeparator(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -8,7 +8,7 @@ namespace ui { | |||||
| struct PasswordField : TextField { | struct PasswordField : TextField { | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -10,10 +10,10 @@ namespace ui { | |||||
| struct ProgressBar : widget::Widget { | struct ProgressBar : widget::Widget { | ||||
| /** Not owned. Stores the progress value and label. */ | /** Not owned. Stores the progress value and label. */ | ||||
| Quantity *quantity = NULL; | |||||
| Quantity* quantity = NULL; | |||||
| ProgressBar(); | ProgressBar(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -12,11 +12,11 @@ namespace ui { | |||||
| struct RadioButton : widget::OpaqueWidget { | struct RadioButton : widget::OpaqueWidget { | ||||
| /** Not owned. */ | /** Not owned. */ | ||||
| Quantity *quantity = NULL; | |||||
| Quantity* quantity = NULL; | |||||
| RadioButton(); | RadioButton(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onDragDrop(const event::DragDrop &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onDragDrop(const event::DragDrop& e) override; | |||||
| }; | }; | ||||
| @@ -18,10 +18,10 @@ struct ScrollBar : widget::OpaqueWidget { | |||||
| float size = 0.0; | float size = 0.0; | ||||
| ScrollBar(); | ScrollBar(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragMove(const event::DragMove &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragMove(const event::DragMove& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| }; | }; | ||||
| @@ -10,19 +10,19 @@ namespace ui { | |||||
| /** Handles a container with ScrollBar */ | /** Handles a container with ScrollBar */ | ||||
| struct ScrollWidget : widget::OpaqueWidget { | struct ScrollWidget : widget::OpaqueWidget { | ||||
| widget::Widget *container; | |||||
| ScrollBar *horizontalScrollBar; | |||||
| ScrollBar *verticalScrollBar; | |||||
| widget::Widget* container; | |||||
| ScrollBar* horizontalScrollBar; | |||||
| ScrollBar* verticalScrollBar; | |||||
| math::Vec offset; | math::Vec offset; | ||||
| ScrollWidget(); | ScrollWidget(); | ||||
| void scrollTo(math::Rect r); | void scrollTo(math::Rect r); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void step() override; | void step() override; | ||||
| void onButton(const event::Button &e) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragMove(const event::DragMove &e) override; | |||||
| void onHoverScroll(const event::HoverScroll &e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragMove(const event::DragMove& e) override; | |||||
| void onHoverScroll(const event::HoverScroll& e) override; | |||||
| }; | }; | ||||
| @@ -11,14 +11,14 @@ namespace ui { | |||||
| struct Slider : widget::OpaqueWidget { | struct Slider : widget::OpaqueWidget { | ||||
| /** Not owned. */ | /** Not owned. */ | ||||
| Quantity *quantity = NULL; | |||||
| Quantity* quantity = NULL; | |||||
| Slider(); | Slider(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onDragStart(const event::DragStart &e) override; | |||||
| void onDragMove(const event::DragMove &e) override; | |||||
| void onDragEnd(const event::DragEnd &e) override; | |||||
| void onDoubleClick(const event::DoubleClick &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onDragStart(const event::DragStart& e) override; | |||||
| void onDragMove(const event::DragMove& e) override; | |||||
| void onDragEnd(const event::DragEnd& e) override; | |||||
| void onDoubleClick(const event::DoubleClick& e) override; | |||||
| }; | }; | ||||
| @@ -20,11 +20,11 @@ struct TextField : widget::OpaqueWidget { | |||||
| int selection = 0; | int selection = 0; | ||||
| TextField(); | TextField(); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void onDragHover(const event::DragHover &e) override; | |||||
| void onButton(const event::Button &e) override; | |||||
| void onSelectText(const event::SelectText &e) override; | |||||
| void onSelectKey(const event::SelectKey &e) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onDragHover(const event::DragHover& e) override; | |||||
| void onButton(const event::Button& e) override; | |||||
| void onSelectText(const event::SelectText& e) override; | |||||
| void onSelectKey(const event::SelectKey& e) override; | |||||
| /** Inserts text at the cursor, replacing the selection if necessary */ | /** Inserts text at the cursor, replacing the selection if necessary */ | ||||
| void insertText(std::string text); | void insertText(std::string text); | ||||
| @@ -11,7 +11,7 @@ struct Tooltip : widget::Widget { | |||||
| std::string text; | std::string text; | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -15,7 +15,7 @@ struct FramebufferWidget : Widget { | |||||
| bool dirty = true; | bool dirty = true; | ||||
| bool bypass = false; | bool bypass = false; | ||||
| float oversample = 1.0; | float oversample = 1.0; | ||||
| NVGLUframebuffer *fb = NULL; | |||||
| NVGLUframebuffer* fb = NULL; | |||||
| /** Scale relative to the world */ | /** Scale relative to the world */ | ||||
| math::Vec scale; | math::Vec scale; | ||||
| /** Offset in world coordinates */ | /** Offset in world coordinates */ | ||||
| @@ -34,7 +34,7 @@ struct FramebufferWidget : Widget { | |||||
| FramebufferWidget(); | FramebufferWidget(); | ||||
| ~FramebufferWidget(); | ~FramebufferWidget(); | ||||
| void step() override; | void step() override; | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| virtual void drawFramebuffer(); | virtual void drawFramebuffer(); | ||||
| int getImageHandle(); | int getImageHandle(); | ||||
| }; | }; | ||||
| @@ -10,14 +10,14 @@ namespace widget { | |||||
| Also consumes Hover and Button for left-clicks. | Also consumes Hover and Button for left-clicks. | ||||
| */ | */ | ||||
| struct OpaqueWidget : Widget { | struct OpaqueWidget : Widget { | ||||
| void onHover(const event::Hover &e) override { | |||||
| void onHover(const event::Hover& e) override { | |||||
| Widget::onHover(e); | Widget::onHover(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| // Consume if not consumed by child | // Consume if not consumed by child | ||||
| if (!e.isConsumed()) | if (!e.isConsumed()) | ||||
| e.consume(this); | e.consume(this); | ||||
| } | } | ||||
| void onButton(const event::Button &e) override { | |||||
| void onButton(const event::Button& e) override { | |||||
| Widget::onButton(e); | Widget::onButton(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | if (e.button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
| @@ -26,26 +26,26 @@ struct OpaqueWidget : Widget { | |||||
| e.consume(this); | e.consume(this); | ||||
| } | } | ||||
| } | } | ||||
| void onHoverKey(const event::HoverKey &e) override { | |||||
| void onHoverKey(const event::HoverKey& e) override { | |||||
| Widget::onHoverKey(e); | Widget::onHoverKey(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| } | } | ||||
| void onHoverText(const event::HoverText &e) override { | |||||
| void onHoverText(const event::HoverText& e) override { | |||||
| Widget::onHoverText(e); | Widget::onHoverText(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| } | } | ||||
| void onHoverScroll(const event::HoverScroll &e) override { | |||||
| void onHoverScroll(const event::HoverScroll& e) override { | |||||
| Widget::onHoverScroll(e); | Widget::onHoverScroll(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| } | } | ||||
| void onDragHover(const event::DragHover &e) override { | |||||
| void onDragHover(const event::DragHover& e) override { | |||||
| Widget::onDragHover(e); | Widget::onDragHover(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| // Consume if not consumed by child | // Consume if not consumed by child | ||||
| if (!e.isConsumed()) | if (!e.isConsumed()) | ||||
| e.consume(this); | e.consume(this); | ||||
| } | } | ||||
| void onPathDrop(const event::PathDrop &e) override { | |||||
| void onPathDrop(const event::PathDrop& e) override { | |||||
| Widget::onPathDrop(e); | Widget::onPathDrop(e); | ||||
| e.stopPropagating(); | e.stopPropagating(); | ||||
| } | } | ||||
| @@ -16,9 +16,11 @@ struct SvgWidget : Widget { | |||||
| /** Sets and wraps the SVG */ | /** Sets and wraps the SVG */ | ||||
| void setSvg(std::shared_ptr<Svg> svg); | void setSvg(std::shared_ptr<Svg> svg); | ||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) {setSvg(svg);} | |||||
| DEPRECATED void setSVG(std::shared_ptr<Svg> svg) { | |||||
| setSvg(svg); | |||||
| } | |||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| }; | }; | ||||
| @@ -37,7 +37,7 @@ struct TransformWidget : Widget { | |||||
| nvgTransformPremultiply(transform, t); | nvgTransformPremultiply(transform, t); | ||||
| } | } | ||||
| void draw(const DrawArgs &args) override { | |||||
| void draw(const DrawArgs& args) override { | |||||
| // No need to save the state because that is done in the parent | // No need to save the state because that is done in the parent | ||||
| nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]); | nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]); | ||||
| Widget::draw(args); | Widget::draw(args); | ||||
| @@ -9,13 +9,13 @@ namespace widget { | |||||
| /** A Widget that does not respond to events and does not pass events to children */ | /** A Widget that does not respond to events and does not pass events to children */ | ||||
| struct TransparentWidget : Widget { | struct TransparentWidget : Widget { | ||||
| /** Override behavior to do nothing instead. */ | /** Override behavior to do nothing instead. */ | ||||
| void onHover(const event::Hover &e) override {} | |||||
| void onButton(const event::Button &e) override {} | |||||
| void onHoverKey(const event::HoverKey &e) override {} | |||||
| void onHoverText(const event::HoverText &e) override {} | |||||
| void onHoverScroll(const event::HoverScroll &e) override {} | |||||
| void onDragHover(const event::DragHover &e) override {} | |||||
| void onPathDrop(const event::PathDrop &e) override {} | |||||
| void onHover(const event::Hover& e) override {} | |||||
| void onButton(const event::Button& e) override {} | |||||
| void onHoverKey(const event::HoverKey& e) override {} | |||||
| void onHoverText(const event::HoverText& e) override {} | |||||
| void onHoverScroll(const event::HoverScroll& e) override {} | |||||
| void onDragHover(const event::DragHover& e) override {} | |||||
| void onPathDrop(const event::PathDrop& e) override {} | |||||
| }; | }; | ||||
| @@ -23,7 +23,7 @@ struct Widget { | |||||
| /** Stores position and size */ | /** Stores position and size */ | ||||
| math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)); | math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)); | ||||
| /** Automatically set when Widget is added as a child to another Widget */ | /** Automatically set when Widget is added as a child to another Widget */ | ||||
| Widget *parent = NULL; | |||||
| Widget* parent = NULL; | |||||
| std::list<Widget*> children; | std::list<Widget*> children; | ||||
| /** Disables rendering but allow stepping */ | /** Disables rendering but allow stepping */ | ||||
| bool visible = true; | bool visible = true; | ||||
| @@ -40,7 +40,7 @@ struct Widget { | |||||
| virtual math::Rect getChildrenBoundingBox(); | virtual math::Rect getChildrenBoundingBox(); | ||||
| /** Returns `v` transformed into the coordinate system of `relative` */ | /** Returns `v` transformed into the coordinate system of `relative` */ | ||||
| virtual math::Vec getRelativeOffset(math::Vec v, Widget *relative); | |||||
| virtual math::Vec getRelativeOffset(math::Vec v, Widget* relative); | |||||
| /** Returns `v` transformed into world coordinates */ | /** Returns `v` transformed into world coordinates */ | ||||
| math::Vec getAbsoluteOffset(math::Vec v) { | math::Vec getAbsoluteOffset(math::Vec v) { | ||||
| return getRelativeOffset(v, NULL); | return getRelativeOffset(v, NULL); | ||||
| @@ -49,20 +49,24 @@ struct Widget { | |||||
| virtual math::Rect getViewport(math::Rect r); | virtual math::Rect getViewport(math::Rect r); | ||||
| template <class T> | template <class T> | ||||
| T *getAncestorOfType() { | |||||
| if (!parent) return NULL; | |||||
| T *p = dynamic_cast<T*>(parent); | |||||
| if (p) return p; | |||||
| T* getAncestorOfType() { | |||||
| if (!parent) | |||||
| return NULL; | |||||
| T* p = dynamic_cast<T*>(parent); | |||||
| if (p) | |||||
| return p; | |||||
| return parent->getAncestorOfType<T>(); | return parent->getAncestorOfType<T>(); | ||||
| } | } | ||||
| template <class T> | template <class T> | ||||
| T *getFirstDescendantOfType() { | |||||
| for (Widget *child : children) { | |||||
| T *c = dynamic_cast<T*>(child); | |||||
| if (c) return c; | |||||
| T* getFirstDescendantOfType() { | |||||
| for (Widget* child : children) { | |||||
| T* c = dynamic_cast<T*>(child); | |||||
| if (c) | |||||
| return c; | |||||
| c = child->getFirstDescendantOfType<T>(); | c = child->getFirstDescendantOfType<T>(); | ||||
| if (c) return c; | |||||
| if (c) | |||||
| return c; | |||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| @@ -70,12 +74,12 @@ struct Widget { | |||||
| /** Adds widget to list of children. | /** Adds widget to list of children. | ||||
| Gives ownership of widget to this widget instance. | Gives ownership of widget to this widget instance. | ||||
| */ | */ | ||||
| void addChild(Widget *child); | |||||
| void addChildBottom(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 | ||||
| */ | */ | ||||
| void removeChild(Widget *child); | |||||
| void removeChild(Widget* child); | |||||
| /** Removes and deletes all children */ | /** Removes and deletes all children */ | ||||
| void clearChildren(); | void clearChildren(); | ||||
| @@ -83,26 +87,26 @@ struct Widget { | |||||
| virtual void step(); | virtual void step(); | ||||
| struct DrawArgs { | struct DrawArgs { | ||||
| NVGcontext *vg; | |||||
| NVGcontext* vg; | |||||
| math::Rect clipBox; | math::Rect clipBox; | ||||
| NVGLUframebuffer *fb = NULL; | |||||
| NVGLUframebuffer* fb = NULL; | |||||
| }; | }; | ||||
| /** Draws the widget to the NanoVG context */ | /** Draws the widget to the NanoVG context */ | ||||
| virtual void draw(const DrawArgs &args); | |||||
| virtual void draw(const DrawArgs& args); | |||||
| /** Override draw(const DrawArgs &args) instead */ | /** Override draw(const DrawArgs &args) instead */ | ||||
| DEPRECATED virtual void draw(NVGcontext *vg) {} | |||||
| DEPRECATED virtual void draw(NVGcontext* vg) {} | |||||
| // Events | // Events | ||||
| /** Recurses an event to all visible Widgets */ | /** Recurses an event to all visible Widgets */ | ||||
| template <typename TMethod, class TEvent> | template <typename TMethod, class TEvent> | ||||
| void recurseEvent(TMethod f, const TEvent &e) { | |||||
| void recurseEvent(TMethod f, const TEvent& e) { | |||||
| for (auto it = children.rbegin(); it != children.rend(); it++) { | for (auto it = children.rbegin(); it != children.rend(); it++) { | ||||
| // Stop propagation if requested | // Stop propagation if requested | ||||
| if (!e.isPropagating()) | if (!e.isPropagating()) | ||||
| break; | break; | ||||
| Widget *child = *it; | |||||
| Widget* child = *it; | |||||
| // Filter child by visibility | // Filter child by visibility | ||||
| if (!child->visible) | if (!child->visible) | ||||
| continue; | continue; | ||||
| @@ -116,12 +120,12 @@ struct Widget { | |||||
| /** Recurses an event to all visible Widgets until it is consumed. */ | /** Recurses an event to all visible Widgets until it is consumed. */ | ||||
| template <typename TMethod, class TEvent> | template <typename TMethod, class TEvent> | ||||
| void recursePositionEvent(TMethod f, const TEvent &e) { | |||||
| void recursePositionEvent(TMethod f, const TEvent& e) { | |||||
| for (auto it = children.rbegin(); it != children.rend(); it++) { | for (auto it = children.rbegin(); it != children.rend(); it++) { | ||||
| // Stop propagation if requested | // Stop propagation if requested | ||||
| if (!e.isPropagating()) | if (!e.isPropagating()) | ||||
| break; | break; | ||||
| Widget *child = *it; | |||||
| Widget* child = *it; | |||||
| // Filter child by visibility and position | // Filter child by visibility and position | ||||
| if (!child->visible) | if (!child->visible) | ||||
| continue; | continue; | ||||
| @@ -139,35 +143,55 @@ struct Widget { | |||||
| /** Override these event callbacks to respond to events. | /** Override these event callbacks to respond to events. | ||||
| See event.hpp for a description of each event. | See event.hpp for a description of each event. | ||||
| */ | */ | ||||
| virtual void onHover(const event::Hover &e) {recursePositionEvent(&Widget::onHover, e);} | |||||
| virtual void onButton(const event::Button &e) {recursePositionEvent(&Widget::onButton, e);} | |||||
| virtual void onDoubleClick(const event::DoubleClick &e) {} | |||||
| virtual void onHoverKey(const event::HoverKey &e) {recursePositionEvent(&Widget::onHoverKey, e);} | |||||
| virtual void onHoverText(const event::HoverText &e) {recursePositionEvent(&Widget::onHoverText, e);} | |||||
| virtual void onHoverScroll(const event::HoverScroll &e) {recursePositionEvent(&Widget::onHoverScroll, e);} | |||||
| virtual void onEnter(const event::Enter &e) {} | |||||
| virtual void onLeave(const event::Leave &e) {} | |||||
| virtual void onSelect(const event::Select &e) {} | |||||
| virtual void onDeselect(const event::Deselect &e) {} | |||||
| virtual void onSelectKey(const event::SelectKey &e) {} | |||||
| virtual void onSelectText(const event::SelectText &e) {} | |||||
| virtual void onDragStart(const event::DragStart &e) {} | |||||
| virtual void onDragEnd(const event::DragEnd &e) {} | |||||
| virtual void onDragMove(const event::DragMove &e) {} | |||||
| virtual void onDragHover(const event::DragHover &e) {recursePositionEvent(&Widget::onDragHover, e);} | |||||
| virtual void onDragEnter(const event::DragEnter &e) {} | |||||
| virtual void onDragLeave(const event::DragLeave &e) {} | |||||
| virtual void onDragDrop(const event::DragDrop &e) {} | |||||
| virtual void onPathDrop(const event::PathDrop &e) {recursePositionEvent(&Widget::onPathDrop, e);} | |||||
| virtual void onAction(const event::Action &e) {} | |||||
| virtual void onChange(const event::Change &e) {} | |||||
| virtual void onZoom(const event::Zoom &e) {recurseEvent(&Widget::onZoom, e);} | |||||
| virtual void onReposition(const event::Reposition &e) {} | |||||
| virtual void onResize(const event::Resize &e) {} | |||||
| virtual void onAdd(const event::Add &e) {} | |||||
| virtual void onRemove(const event::Remove &e) {} | |||||
| virtual void onShow(const event::Show &e) {recurseEvent(&Widget::onShow, e);} | |||||
| virtual void onHide(const event::Hide &e) {recurseEvent(&Widget::onHide, e);} | |||||
| virtual void onHover(const event::Hover& e) { | |||||
| recursePositionEvent(&Widget::onHover, e); | |||||
| } | |||||
| virtual void onButton(const event::Button& e) { | |||||
| recursePositionEvent(&Widget::onButton, e); | |||||
| } | |||||
| virtual void onDoubleClick(const event::DoubleClick& e) {} | |||||
| virtual void onHoverKey(const event::HoverKey& e) { | |||||
| recursePositionEvent(&Widget::onHoverKey, e); | |||||
| } | |||||
| virtual void onHoverText(const event::HoverText& e) { | |||||
| recursePositionEvent(&Widget::onHoverText, e); | |||||
| } | |||||
| virtual void onHoverScroll(const event::HoverScroll& e) { | |||||
| recursePositionEvent(&Widget::onHoverScroll, e); | |||||
| } | |||||
| virtual void onEnter(const event::Enter& e) {} | |||||
| virtual void onLeave(const event::Leave& e) {} | |||||
| virtual void onSelect(const event::Select& e) {} | |||||
| virtual void onDeselect(const event::Deselect& e) {} | |||||
| virtual void onSelectKey(const event::SelectKey& e) {} | |||||
| virtual void onSelectText(const event::SelectText& e) {} | |||||
| virtual void onDragStart(const event::DragStart& e) {} | |||||
| virtual void onDragEnd(const event::DragEnd& e) {} | |||||
| virtual void onDragMove(const event::DragMove& e) {} | |||||
| virtual void onDragHover(const event::DragHover& e) { | |||||
| recursePositionEvent(&Widget::onDragHover, e); | |||||
| } | |||||
| virtual void onDragEnter(const event::DragEnter& e) {} | |||||
| virtual void onDragLeave(const event::DragLeave& e) {} | |||||
| virtual void onDragDrop(const event::DragDrop& e) {} | |||||
| virtual void onPathDrop(const event::PathDrop& e) { | |||||
| recursePositionEvent(&Widget::onPathDrop, e); | |||||
| } | |||||
| virtual void onAction(const event::Action& e) {} | |||||
| virtual void onChange(const event::Change& e) {} | |||||
| virtual void onZoom(const event::Zoom& e) { | |||||
| recurseEvent(&Widget::onZoom, e); | |||||
| } | |||||
| virtual void onReposition(const event::Reposition& e) {} | |||||
| virtual void onResize(const event::Resize& e) {} | |||||
| virtual void onAdd(const event::Add& e) {} | |||||
| virtual void onRemove(const event::Remove& e) {} | |||||
| virtual void onShow(const event::Show& e) { | |||||
| recurseEvent(&Widget::onShow, e); | |||||
| } | |||||
| virtual void onHide(const event::Hide& e) { | |||||
| recurseEvent(&Widget::onHide, e); | |||||
| } | |||||
| }; | }; | ||||
| @@ -10,42 +10,42 @@ namespace widget { | |||||
| struct ZoomWidget : Widget { | struct ZoomWidget : Widget { | ||||
| float zoom = 1.f; | float zoom = 1.f; | ||||
| math::Vec getRelativeOffset(math::Vec v, Widget *relative) override; | |||||
| math::Vec getRelativeOffset(math::Vec v, Widget* relative) override; | |||||
| math::Rect getViewport(math::Rect r) override; | math::Rect getViewport(math::Rect r) override; | ||||
| void setZoom(float zoom); | void setZoom(float zoom); | ||||
| void draw(const DrawArgs &args) override; | |||||
| void draw(const DrawArgs& args) override; | |||||
| void onHover(const event::Hover &e) override { | |||||
| void onHover(const event::Hover& e) override { | |||||
| event::Hover e2 = e; | event::Hover e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onHover(e2); | Widget::onHover(e2); | ||||
| } | } | ||||
| void onButton(const event::Button &e) override { | |||||
| void onButton(const event::Button& e) override { | |||||
| event::Button e2 = e; | event::Button e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onButton(e2); | Widget::onButton(e2); | ||||
| } | } | ||||
| void onHoverKey(const event::HoverKey &e) override { | |||||
| void onHoverKey(const event::HoverKey& e) override { | |||||
| event::HoverKey e2 = e; | event::HoverKey e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onHoverKey(e2); | Widget::onHoverKey(e2); | ||||
| } | } | ||||
| void onHoverText(const event::HoverText &e) override { | |||||
| void onHoverText(const event::HoverText& e) override { | |||||
| event::HoverText e2 = e; | event::HoverText e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onHoverText(e2); | Widget::onHoverText(e2); | ||||
| } | } | ||||
| void onHoverScroll(const event::HoverScroll &e) override { | |||||
| void onHoverScroll(const event::HoverScroll& e) override { | |||||
| event::HoverScroll e2 = e; | event::HoverScroll e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onHoverScroll(e2); | Widget::onHoverScroll(e2); | ||||
| } | } | ||||
| void onDragHover(const event::DragHover &e) override { | |||||
| void onDragHover(const event::DragHover& e) override { | |||||
| event::DragHover e2 = e; | event::DragHover e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onDragHover(e2); | Widget::onDragHover(e2); | ||||
| } | } | ||||
| void onPathDrop(const event::PathDrop &e) override { | |||||
| void onPathDrop(const event::PathDrop& e) override { | |||||
| event::PathDrop e2 = e; | event::PathDrop e2 = e; | ||||
| e2.pos = e.pos.div(zoom); | e2.pos = e.pos.div(zoom); | ||||
| Widget::onPathDrop(e2); | Widget::onPathDrop(e2); | ||||
| @@ -20,40 +20,40 @@ namespace rack { | |||||
| // Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. | // Constructing these directly will load from the disk each time. Use the load() functions to load from disk and cache them as long as the shared_ptr is held. | ||||
| struct Font { | struct Font { | ||||
| NVGcontext *vg; | |||||
| NVGcontext* vg; | |||||
| int handle = -1; | int handle = -1; | ||||
| /** Don't call this directly but instead use `APP->window->loadFont()` */ | /** Don't call this directly but instead use `APP->window->loadFont()` */ | ||||
| void loadFile(const std::string &filename, NVGcontext *vg); | |||||
| void loadFile(const std::string& filename, NVGcontext* vg); | |||||
| ~Font(); | ~Font(); | ||||
| /** Use `APP->window->loadFont()` instead. */ | /** Use `APP->window->loadFont()` instead. */ | ||||
| DEPRECATED static std::shared_ptr<Font> load(const std::string &filename); | |||||
| DEPRECATED static std::shared_ptr<Font> load(const std::string& filename); | |||||
| }; | }; | ||||
| struct Image { | struct Image { | ||||
| NVGcontext *vg; | |||||
| NVGcontext* vg; | |||||
| int handle = -1; | int handle = -1; | ||||
| /** Don't call this directly but instead use `APP->window->loadImage()` */ | /** Don't call this directly but instead use `APP->window->loadImage()` */ | ||||
| void loadFile(const std::string &filename, NVGcontext *vg); | |||||
| void loadFile(const std::string& filename, NVGcontext* vg); | |||||
| ~Image(); | ~Image(); | ||||
| /** Use `APP->window->loadImage()` instead. */ | /** Use `APP->window->loadImage()` instead. */ | ||||
| DEPRECATED static std::shared_ptr<Image> load(const std::string &filename); | |||||
| DEPRECATED static std::shared_ptr<Image> load(const std::string& filename); | |||||
| }; | }; | ||||
| struct Svg { | struct Svg { | ||||
| NSVGimage *handle = NULL; | |||||
| NSVGimage* handle = NULL; | |||||
| /** Don't call this directly but instead use `APP->window->loadSvg()` */ | /** Don't call this directly but instead use `APP->window->loadSvg()` */ | ||||
| void loadFile(const std::string &filename); | |||||
| void loadFile(const std::string& filename); | |||||
| ~Svg(); | ~Svg(); | ||||
| /** Use `APP->window->loadSvg()` instead. */ | /** Use `APP->window->loadSvg()` instead. */ | ||||
| DEPRECATED static std::shared_ptr<Svg> load(const std::string &filename); | |||||
| DEPRECATED static std::shared_ptr<Svg> load(const std::string& filename); | |||||
| }; | }; | ||||
| DEPRECATED typedef Svg SVG; | DEPRECATED typedef Svg SVG; | ||||
| struct Window { | struct Window { | ||||
| GLFWwindow *win = NULL; | |||||
| NVGcontext *vg = NULL; | |||||
| GLFWwindow* win = NULL; | |||||
| NVGcontext* vg = NULL; | |||||
| /** The scaling ratio */ | /** The scaling ratio */ | ||||
| float pixelRatio = 1.f; | float pixelRatio = 1.f; | ||||
| /* The ratio between the framebuffer size and the window size reported by the OS. | /* The ratio between the framebuffer size and the window size reported by the OS. | ||||
| @@ -72,7 +72,7 @@ struct Window { | |||||
| std::map<std::string, std::weak_ptr<Svg>> svgCache; | std::map<std::string, std::weak_ptr<Svg>> svgCache; | ||||
| struct Internal; | struct Internal; | ||||
| Internal *internal; | |||||
| Internal* internal; | |||||
| Window(); | Window(); | ||||
| ~Window(); | ~Window(); | ||||
| @@ -90,9 +90,9 @@ struct Window { | |||||
| bool isFullScreen(); | bool isFullScreen(); | ||||
| bool isFrameOverdue(); | bool isFrameOverdue(); | ||||
| std::shared_ptr<Font> loadFont(const std::string &filename); | |||||
| std::shared_ptr<Image> loadImage(const std::string &filename); | |||||
| std::shared_ptr<Svg> loadSvg(const std::string &filename); | |||||
| std::shared_ptr<Font> loadFont(const std::string& filename); | |||||
| std::shared_ptr<Image> loadImage(const std::string& filename); | |||||
| std::shared_ptr<Svg> loadSvg(const std::string& filename); | |||||
| }; | }; | ||||
| @@ -24,22 +24,28 @@ void App::init() { | |||||
| App::~App() { | App::~App() { | ||||
| // Set pointers to NULL so other objects will segfault when attempting to access them | // Set pointers to NULL so other objects will segfault when attempting to access them | ||||
| if (scene) delete scene; | |||||
| if (scene) | |||||
| delete scene; | |||||
| scene = NULL; | scene = NULL; | ||||
| if (patch) delete patch; | |||||
| if (patch) | |||||
| delete patch; | |||||
| patch = NULL; | patch = NULL; | ||||
| if (event) delete event; | |||||
| if (event) | |||||
| delete event; | |||||
| event = NULL; | event = NULL; | ||||
| if (history) delete history; | |||||
| if (history) | |||||
| delete history; | |||||
| history = NULL; | history = NULL; | ||||
| if (window) delete window; | |||||
| if (window) | |||||
| delete window; | |||||
| window = NULL; | window = NULL; | ||||
| if (engine) delete engine; | |||||
| if (engine) | |||||
| delete engine; | |||||
| engine = NULL; | engine = NULL; | ||||
| } | } | ||||
| static App *appInstance = NULL; | |||||
| static App* appInstance = NULL; | |||||
| void appInit() { | void appInit() { | ||||
| assert(!appInstance); | assert(!appInstance); | ||||
| @@ -53,7 +59,7 @@ void appDestroy() { | |||||
| appInstance = NULL; | appInstance = NULL; | ||||
| } | } | ||||
| App *appGet() { | |||||
| App* appGet() { | |||||
| return appInstance; | return appInstance; | ||||
| } | } | ||||
| @@ -7,23 +7,23 @@ namespace app { | |||||
| struct AudioDriverItem : ui::MenuItem { | struct AudioDriverItem : ui::MenuItem { | ||||
| audio::Port *port; | |||||
| audio::Port* port; | |||||
| int driverId; | int driverId; | ||||
| void onAction(const event::Action &e) override { | |||||
| void onAction(const event::Action& e) override { | |||||
| port->setDriverId(driverId); | port->setDriverId(driverId); | ||||
| } | } | ||||
| }; | }; | ||||
| struct AudioDriverChoice : LedDisplayChoice { | struct AudioDriverChoice : LedDisplayChoice { | ||||
| audio::Port *port; | |||||
| void onAction(const event::Action &e) override { | |||||
| audio::Port* port; | |||||
| void onAction(const event::Action& e) override { | |||||
| if (!port) | if (!port) | ||||
| return; | return; | ||||
| ui::Menu *menu = createMenu(); | |||||
| ui::Menu* menu = createMenu(); | |||||
| menu->addChild(createMenuLabel("Audio driver")); | menu->addChild(createMenuLabel("Audio driver")); | ||||
| for (int driverId : port->getDriverIds()) { | for (int driverId : port->getDriverIds()) { | ||||
| AudioDriverItem *item = new AudioDriverItem; | |||||
| AudioDriverItem* item = new AudioDriverItem; | |||||
| item->port = port; | item->port = port; | ||||
| item->driverId = driverId; | item->driverId = driverId; | ||||
| item->text = port->getDriverName(driverId); | item->text = port->getDriverName(driverId); | ||||
| @@ -47,28 +47,28 @@ struct AudioDriverChoice : LedDisplayChoice { | |||||
| struct AudioDeviceItem : ui::MenuItem { | struct AudioDeviceItem : ui::MenuItem { | ||||
| audio::Port *port; | |||||
| audio::Port* port; | |||||
| int deviceId; | int deviceId; | ||||
| int offset; | int offset; | ||||
| void onAction(const event::Action &e) override { | |||||
| void onAction(const event::Action& e) override { | |||||
| port->setDeviceId(deviceId, offset); | port->setDeviceId(deviceId, offset); | ||||
| } | } | ||||
| }; | }; | ||||
| struct AudioDeviceChoice : LedDisplayChoice { | struct AudioDeviceChoice : LedDisplayChoice { | ||||
| audio::Port *port; | |||||
| audio::Port* port; | |||||
| /** Prevents devices with a ridiculous number of channels from being displayed */ | /** Prevents devices with a ridiculous number of channels from being displayed */ | ||||
| int maxTotalChannels = 128; | int maxTotalChannels = 128; | ||||
| void onAction(const event::Action &e) override { | |||||
| void onAction(const event::Action& e) override { | |||||
| if (!port) | if (!port) | ||||
| return; | return; | ||||
| ui::Menu *menu = createMenu(); | |||||
| ui::Menu* menu = createMenu(); | |||||
| menu->addChild(createMenuLabel("Audio device")); | menu->addChild(createMenuLabel("Audio device")); | ||||
| int deviceCount = port->getDeviceCount(); | int deviceCount = port->getDeviceCount(); | ||||
| { | { | ||||
| AudioDeviceItem *item = new AudioDeviceItem; | |||||
| AudioDeviceItem* item = new AudioDeviceItem; | |||||
| item->port = port; | item->port = port; | ||||
| item->deviceId = -1; | item->deviceId = -1; | ||||
| item->text = "(No device)"; | item->text = "(No device)"; | ||||
| @@ -78,7 +78,7 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
| for (int deviceId = 0; deviceId < deviceCount; deviceId++) { | for (int deviceId = 0; deviceId < deviceCount; deviceId++) { | ||||
| int channels = std::min(maxTotalChannels, port->getDeviceChannels(deviceId)); | int channels = std::min(maxTotalChannels, port->getDeviceChannels(deviceId)); | ||||
| for (int offset = 0; offset < channels; offset += port->maxChannels) { | for (int offset = 0; offset < channels; offset += port->maxChannels) { | ||||
| AudioDeviceItem *item = new AudioDeviceItem; | |||||
| AudioDeviceItem* item = new AudioDeviceItem; | |||||
| item->port = port; | item->port = port; | ||||
| item->deviceId = deviceId; | item->deviceId = deviceId; | ||||
| item->offset = offset; | item->offset = offset; | ||||
| @@ -104,27 +104,27 @@ struct AudioDeviceChoice : LedDisplayChoice { | |||||
| struct AudioSampleRateItem : ui::MenuItem { | struct AudioSampleRateItem : ui::MenuItem { | ||||
| audio::Port *port; | |||||
| audio::Port* port; | |||||
| int sampleRate; | int sampleRate; | ||||
| void onAction(const event::Action &e) override { | |||||
| void onAction(const event::Action& e) override { | |||||
| port->setSampleRate(sampleRate); | port->setSampleRate(sampleRate); | ||||
| } | } | ||||
| }; | }; | ||||
| struct AudioSampleRateChoice : LedDisplayChoice { | struct AudioSampleRateChoice : LedDisplayChoice { | ||||
| audio::Port *port; | |||||
| void onAction(const event::Action &e) override { | |||||
| audio::Port* port; | |||||
| void onAction(const event::Action& e) override { | |||||
| if (!port) | if (!port) | ||||
| return; | return; | ||||
| ui::Menu *menu = createMenu(); | |||||
| ui::Menu* menu = createMenu(); | |||||
| menu->addChild(createMenuLabel("Sample rate")); | menu->addChild(createMenuLabel("Sample rate")); | ||||
| std::vector<int> sampleRates = port->getSampleRates(); | std::vector<int> sampleRates = port->getSampleRates(); | ||||
| if (sampleRates.empty()) { | if (sampleRates.empty()) { | ||||
| menu->addChild(createMenuLabel("(Locked by device)")); | menu->addChild(createMenuLabel("(Locked by device)")); | ||||
| } | } | ||||
| for (int sampleRate : sampleRates) { | for (int sampleRate : sampleRates) { | ||||
| AudioSampleRateItem *item = new AudioSampleRateItem; | |||||
| AudioSampleRateItem* item = new AudioSampleRateItem; | |||||
| item->port = port; | item->port = port; | ||||
| item->sampleRate = sampleRate; | item->sampleRate = sampleRate; | ||||
| item->text = string::f("%g kHz", sampleRate / 1000.0); | item->text = string::f("%g kHz", sampleRate / 1000.0); | ||||
| @@ -145,27 +145,27 @@ struct AudioSampleRateChoice : LedDisplayChoice { | |||||
| struct AudioBlockSizeItem : ui::MenuItem { | struct AudioBlockSizeItem : ui::MenuItem { | ||||
| audio::Port *port; | |||||
| audio::Port* port; | |||||
| int blockSize; | int blockSize; | ||||
| void onAction(const event::Action &e) override { | |||||
| void onAction(const event::Action& e) override { | |||||
| port->setBlockSize(blockSize); | port->setBlockSize(blockSize); | ||||
| } | } | ||||
| }; | }; | ||||
| struct AudioBlockSizeChoice : LedDisplayChoice { | struct AudioBlockSizeChoice : LedDisplayChoice { | ||||
| audio::Port *port; | |||||
| void onAction(const event::Action &e) override { | |||||
| audio::Port* port; | |||||
| void onAction(const event::Action& e) override { | |||||
| if (!port) | if (!port) | ||||
| return; | return; | ||||
| ui::Menu *menu = createMenu(); | |||||
| ui::Menu* menu = createMenu(); | |||||
| menu->addChild(createMenuLabel("Block size")); | menu->addChild(createMenuLabel("Block size")); | ||||
| std::vector<int> blockSizes = port->getBlockSizes(); | std::vector<int> blockSizes = port->getBlockSizes(); | ||||
| if (blockSizes.empty()) { | if (blockSizes.empty()) { | ||||
| menu->addChild(createMenuLabel("(Locked by device)")); | menu->addChild(createMenuLabel("(Locked by device)")); | ||||
| } | } | ||||
| for (int blockSize : blockSizes) { | for (int blockSize : blockSizes) { | ||||
| AudioBlockSizeItem *item = new AudioBlockSizeItem; | |||||
| AudioBlockSizeItem* item = new AudioBlockSizeItem; | |||||
| item->port = port; | item->port = port; | ||||
| item->blockSize = blockSize; | item->blockSize = blockSize; | ||||
| float latency = (float) blockSize / port->sampleRate * 1000.0; | float latency = (float) blockSize / port->sampleRate * 1000.0; | ||||
| @@ -186,12 +186,12 @@ struct AudioBlockSizeChoice : LedDisplayChoice { | |||||
| }; | }; | ||||
| void AudioWidget::setAudioPort(audio::Port *port) { | |||||
| void AudioWidget::setAudioPort(audio::Port* port) { | |||||
| clearChildren(); | clearChildren(); | ||||
| math::Vec pos; | math::Vec pos; | ||||
| AudioDriverChoice *driverChoice = createWidget<AudioDriverChoice>(pos); | |||||
| AudioDriverChoice* driverChoice = createWidget<AudioDriverChoice>(pos); | |||||
| driverChoice->box.size.x = box.size.x; | driverChoice->box.size.x = box.size.x; | ||||
| driverChoice->port = port; | driverChoice->port = port; | ||||
| addChild(driverChoice); | addChild(driverChoice); | ||||
| @@ -202,7 +202,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { | |||||
| this->driverSeparator->box.size.x = box.size.x; | this->driverSeparator->box.size.x = box.size.x; | ||||
| addChild(this->driverSeparator); | addChild(this->driverSeparator); | ||||
| AudioDeviceChoice *deviceChoice = createWidget<AudioDeviceChoice>(pos); | |||||
| AudioDeviceChoice* deviceChoice = createWidget<AudioDeviceChoice>(pos); | |||||
| deviceChoice->box.size.x = box.size.x; | deviceChoice->box.size.x = box.size.x; | ||||
| deviceChoice->port = port; | deviceChoice->port = port; | ||||
| addChild(deviceChoice); | addChild(deviceChoice); | ||||
| @@ -213,7 +213,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { | |||||
| this->deviceSeparator->box.size.x = box.size.x; | this->deviceSeparator->box.size.x = box.size.x; | ||||
| addChild(this->deviceSeparator); | addChild(this->deviceSeparator); | ||||
| AudioSampleRateChoice *sampleRateChoice = createWidget<AudioSampleRateChoice>(pos); | |||||
| AudioSampleRateChoice* sampleRateChoice = createWidget<AudioSampleRateChoice>(pos); | |||||
| sampleRateChoice->box.size.x = box.size.x / 2; | sampleRateChoice->box.size.x = box.size.x / 2; | ||||
| sampleRateChoice->port = port; | sampleRateChoice->port = port; | ||||
| addChild(sampleRateChoice); | addChild(sampleRateChoice); | ||||
| @@ -224,7 +224,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { | |||||
| this->sampleRateSeparator->box.size.y = this->sampleRateChoice->box.size.y; | this->sampleRateSeparator->box.size.y = this->sampleRateChoice->box.size.y; | ||||
| addChild(this->sampleRateSeparator); | addChild(this->sampleRateSeparator); | ||||
| AudioBlockSizeChoice *bufferSizeChoice = createWidget<AudioBlockSizeChoice>(pos); | |||||
| AudioBlockSizeChoice* bufferSizeChoice = createWidget<AudioBlockSizeChoice>(pos); | |||||
| bufferSizeChoice->box.pos.x = box.size.x / 2; | bufferSizeChoice->box.pos.x = box.size.x / 2; | ||||
| bufferSizeChoice->box.size.x = box.size.x / 2; | bufferSizeChoice->box.size.x = box.size.x / 2; | ||||
| bufferSizeChoice->port = port; | bufferSizeChoice->port = port; | ||||
| @@ -11,7 +11,7 @@ | |||||
| namespace rack { | namespace rack { | ||||
| namespace app { | namespace app { | ||||
| static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) { | |||||
| static void drawPlug(NVGcontext* vg, math::Vec pos, NVGcolor color) { | |||||
| NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | ||||
| // Plug solid | // Plug solid | ||||
| @@ -32,7 +32,7 @@ static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) { | |||||
| nvgFill(vg); | nvgFill(vg); | ||||
| } | } | ||||
| static void drawCable(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) { | |||||
| static void drawCable(NVGcontext* vg, math::Vec pos1, math::Vec pos2, NVGcolor color, float thickness, float tension, float opacity) { | |||||
| NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10); | NVGcolor colorShadow = nvgRGBAf(0, 0, 0, 0.10); | ||||
| NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); | ||||
| @@ -44,7 +44,7 @@ static void drawCable(NVGcontext *vg, math::Vec pos1, math::Vec pos2, NVGcolor c | |||||
| float dist = pos1.minus(pos2).norm(); | float dist = pos1.minus(pos2).norm(); | ||||
| math::Vec slump; | math::Vec slump; | ||||
| slump.y = (1.0 - tension) * (150.0 + 1.0*dist); | |||||
| slump.y = (1.0 - tension) * (150.0 + 1.0 * dist); | |||||
| math::Vec pos3 = pos1.plus(pos2).div(2).plus(slump); | math::Vec pos3 = pos1.plus(pos2).div(2).plus(slump); | ||||
| // Adjust pos1 and pos2 to not draw over the plug | // Adjust pos1 and pos2 to not draw over the plug | ||||
| @@ -99,7 +99,7 @@ bool CableWidget::isComplete() { | |||||
| return outputPort && inputPort; | return outputPort && inputPort; | ||||
| } | } | ||||
| void CableWidget::setOutput(PortWidget *outputPort) { | |||||
| void CableWidget::setOutput(PortWidget* outputPort) { | |||||
| this->outputPort = outputPort; | this->outputPort = outputPort; | ||||
| if (outputPort) { | if (outputPort) { | ||||
| assert(outputPort->type == PortWidget::OUTPUT); | assert(outputPort->type == PortWidget::OUTPUT); | ||||
| @@ -108,7 +108,7 @@ void CableWidget::setOutput(PortWidget *outputPort) { | |||||
| } | } | ||||
| } | } | ||||
| void CableWidget::setInput(PortWidget *inputPort) { | |||||
| void CableWidget::setInput(PortWidget* inputPort) { | |||||
| this->inputPort = inputPort; | this->inputPort = inputPort; | ||||
| if (inputPort) { | if (inputPort) { | ||||
| assert(inputPort->type == PortWidget::INPUT); | assert(inputPort->type == PortWidget::INPUT); | ||||
| @@ -141,9 +141,9 @@ math::Vec CableWidget::getInputPos() { | |||||
| } | } | ||||
| } | } | ||||
| json_t *CableWidget::toJson() { | |||||
| json_t* CableWidget::toJson() { | |||||
| assert(isComplete()); | assert(isComplete()); | ||||
| json_t *rootJ = json_object(); | |||||
| json_t* rootJ = json_object(); | |||||
| json_object_set_new(rootJ, "id", json_integer(cable->id)); | json_object_set_new(rootJ, "id", json_integer(cable->id)); | ||||
| json_object_set_new(rootJ, "outputModuleId", json_integer(cable->outputModule->id)); | json_object_set_new(rootJ, "outputModuleId", json_integer(cable->outputModule->id)); | ||||
| @@ -157,35 +157,41 @@ json_t *CableWidget::toJson() { | |||||
| return rootJ; | return rootJ; | ||||
| } | } | ||||
| void CableWidget::fromJson(json_t *rootJ) { | |||||
| void CableWidget::fromJson(json_t* rootJ) { | |||||
| // outputModuleId | // outputModuleId | ||||
| json_t *outputModuleIdJ = json_object_get(rootJ, "outputModuleId"); | |||||
| if (!outputModuleIdJ) return; | |||||
| json_t* outputModuleIdJ = json_object_get(rootJ, "outputModuleId"); | |||||
| if (!outputModuleIdJ) | |||||
| return; | |||||
| int outputModuleId = json_integer_value(outputModuleIdJ); | int outputModuleId = json_integer_value(outputModuleIdJ); | ||||
| ModuleWidget *outputModule = APP->scene->rack->getModule(outputModuleId); | |||||
| if (!outputModule) return; | |||||
| ModuleWidget* outputModule = APP->scene->rack->getModule(outputModuleId); | |||||
| if (!outputModule) | |||||
| return; | |||||
| // inputModuleId | // inputModuleId | ||||
| json_t *inputModuleIdJ = json_object_get(rootJ, "inputModuleId"); | |||||
| if (!inputModuleIdJ) return; | |||||
| json_t* inputModuleIdJ = json_object_get(rootJ, "inputModuleId"); | |||||
| if (!inputModuleIdJ) | |||||
| return; | |||||
| int inputModuleId = json_integer_value(inputModuleIdJ); | int inputModuleId = json_integer_value(inputModuleIdJ); | ||||
| ModuleWidget *inputModule = APP->scene->rack->getModule(inputModuleId); | |||||
| if (!inputModule) return; | |||||
| ModuleWidget* inputModule = APP->scene->rack->getModule(inputModuleId); | |||||
| if (!inputModule) | |||||
| return; | |||||
| // outputId | // outputId | ||||
| json_t *outputIdJ = json_object_get(rootJ, "outputId"); | |||||
| if (!outputIdJ) return; | |||||
| json_t* outputIdJ = json_object_get(rootJ, "outputId"); | |||||
| if (!outputIdJ) | |||||
| return; | |||||
| int outputId = json_integer_value(outputIdJ); | int outputId = json_integer_value(outputIdJ); | ||||
| // inputId | // inputId | ||||
| json_t *inputIdJ = json_object_get(rootJ, "inputId"); | |||||
| if (!inputIdJ) return; | |||||
| json_t* inputIdJ = json_object_get(rootJ, "inputId"); | |||||
| if (!inputIdJ) | |||||
| return; | |||||
| int inputId = json_integer_value(inputIdJ); | int inputId = json_integer_value(inputIdJ); | ||||
| // Only set ID if unset | // Only set ID if unset | ||||
| if (cable->id < 0) { | if (cable->id < 0) { | ||||
| // id | // id | ||||
| json_t *idJ = json_object_get(rootJ, "id"); | |||||
| json_t* idJ = json_object_get(rootJ, "id"); | |||||
| // Before 1.0, cables IDs were not used, so just leave it as default and Engine will assign one automatically. | // Before 1.0, cables IDs were not used, so just leave it as default and Engine will assign one automatically. | ||||
| if (idJ) { | if (idJ) { | ||||
| cable->id = json_integer_value(idJ); | cable->id = json_integer_value(idJ); | ||||
| @@ -199,13 +205,13 @@ void CableWidget::fromJson(json_t *rootJ) { | |||||
| setInput(inputModule->inputs[inputId]); | setInput(inputModule->inputs[inputId]); | ||||
| } | } | ||||
| else { | else { | ||||
| for (PortWidget *port : outputModule->outputs) { | |||||
| for (PortWidget* port : outputModule->outputs) { | |||||
| if (port->portId == outputId) { | if (port->portId == outputId) { | ||||
| setOutput(port); | setOutput(port); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| for (PortWidget *port : inputModule->inputs) { | |||||
| for (PortWidget* port : inputModule->inputs) { | |||||
| if (port->portId == inputId) { | if (port->portId == inputId) { | ||||
| setInput(port); | setInput(port); | ||||
| break; | break; | ||||
| @@ -215,7 +221,7 @@ void CableWidget::fromJson(json_t *rootJ) { | |||||
| if (!isComplete()) | if (!isComplete()) | ||||
| return; | return; | ||||
| json_t *colorJ = json_object_get(rootJ, "color"); | |||||
| json_t* colorJ = json_object_get(rootJ, "color"); | |||||
| if (colorJ) { | if (colorJ) { | ||||
| // v0.6.0 and earlier patches use JSON objects. Just ignore them if so and use the existing cable color. | // v0.6.0 and earlier patches use JSON objects. Just ignore them if so and use the existing cable color. | ||||
| if (json_is_string(colorJ)) | if (json_is_string(colorJ)) | ||||
| @@ -223,13 +229,13 @@ void CableWidget::fromJson(json_t *rootJ) { | |||||
| } | } | ||||
| } | } | ||||
| void CableWidget::draw(const DrawArgs &args) { | |||||
| void CableWidget::draw(const DrawArgs& args) { | |||||
| float opacity = settings::cableOpacity; | float opacity = settings::cableOpacity; | ||||
| float tension = settings::cableTension; | float tension = settings::cableTension; | ||||
| float thickness = 5; | float thickness = 5; | ||||
| if (isComplete()) { | if (isComplete()) { | ||||
| engine::Output *output = &cable->outputModule->outputs[cable->outputId]; | |||||
| engine::Output* output = &cable->outputModule->outputs[cable->outputId]; | |||||
| // Draw opaque if mouse is hovering over a connected port | // Draw opaque if mouse is hovering over a connected port | ||||
| if (output->channels > 1) { | if (output->channels > 1) { | ||||
| // Increase thickness if output port is polyphonic | // Increase thickness if output port is polyphonic | ||||
| @@ -254,7 +260,7 @@ void CableWidget::draw(const DrawArgs &args) { | |||||
| drawCable(args.vg, outputPos, inputPos, color, thickness, tension, opacity); | drawCable(args.vg, outputPos, inputPos, color, thickness, tension, opacity); | ||||
| } | } | ||||
| void CableWidget::drawPlugs(const DrawArgs &args) { | |||||
| void CableWidget::drawPlugs(const DrawArgs& args) { | |||||
| math::Vec outputPos = getOutputPos(); | math::Vec outputPos = getOutputPos(); | ||||
| math::Vec inputPos = getInputPos(); | math::Vec inputPos = getInputPos(); | ||||
| @@ -10,12 +10,12 @@ CircularShadow::CircularShadow() { | |||||
| opacity = 0.15; | opacity = 0.15; | ||||
| } | } | ||||
| void CircularShadow::draw(const DrawArgs &args) { | |||||
| void CircularShadow::draw(const DrawArgs& args) { | |||||
| if (opacity <= 0.0) | if (opacity <= 0.0) | ||||
| return; | return; | ||||
| nvgBeginPath(args.vg); | nvgBeginPath(args.vg); | ||||
| nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2*blurRadius, box.size.y + 2*blurRadius); | |||||
| nvgRect(args.vg, -blurRadius, -blurRadius, box.size.x + 2 * blurRadius, box.size.y + 2 * blurRadius); | |||||
| math::Vec center = box.size.div(2.0); | math::Vec center = box.size.div(2.0); | ||||
| float radius = center.x; | float radius = center.x; | ||||
| NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity); | NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity); | ||||
| @@ -12,7 +12,7 @@ namespace app { | |||||
| static const float KNOB_SENSITIVITY = 0.0015f; | static const float KNOB_SENSITIVITY = 0.0015f; | ||||
| void Knob::onHover(const event::Hover &e) { | |||||
| void Knob::onHover(const event::Hover& e) { | |||||
| math::Vec c = box.size.div(2); | math::Vec c = box.size.div(2); | ||||
| float dist = e.pos.minus(c).norm(); | float dist = e.pos.minus(c).norm(); | ||||
| if (dist <= c.x) { | if (dist <= c.x) { | ||||
| @@ -20,7 +20,7 @@ void Knob::onHover(const event::Hover &e) { | |||||
| } | } | ||||
| } | } | ||||
| void Knob::onButton(const event::Button &e) { | |||||
| void Knob::onButton(const event::Button& e) { | |||||
| math::Vec c = box.size.div(2); | math::Vec c = box.size.div(2); | ||||
| float dist = e.pos.minus(c).norm(); | float dist = e.pos.minus(c).norm(); | ||||
| if (dist <= c.x) { | if (dist <= c.x) { | ||||
| @@ -28,7 +28,7 @@ void Knob::onButton(const event::Button &e) { | |||||
| } | } | ||||
| } | } | ||||
| void Knob::onDragStart(const event::DragStart &e) { | |||||
| void Knob::onDragStart(const event::DragStart& e) { | |||||
| if (e.button != GLFW_MOUSE_BUTTON_LEFT) | if (e.button != GLFW_MOUSE_BUTTON_LEFT) | ||||
| return; | return; | ||||
| @@ -42,7 +42,7 @@ void Knob::onDragStart(const event::DragStart &e) { | |||||
| APP->window->cursorLock(); | APP->window->cursorLock(); | ||||
| } | } | ||||
| void Knob::onDragEnd(const event::DragEnd &e) { | |||||
| void Knob::onDragEnd(const event::DragEnd& e) { | |||||
| if (e.button != GLFW_MOUSE_BUTTON_LEFT) | if (e.button != GLFW_MOUSE_BUTTON_LEFT) | ||||
| return; | return; | ||||
| @@ -52,7 +52,7 @@ void Knob::onDragEnd(const event::DragEnd &e) { | |||||
| float newValue = paramQuantity->getSmoothValue(); | float newValue = paramQuantity->getSmoothValue(); | ||||
| if (oldValue != newValue) { | if (oldValue != newValue) { | ||||
| // Push ParamChange history action | // Push ParamChange history action | ||||
| history::ParamChange *h = new history::ParamChange; | |||||
| history::ParamChange* h = new history::ParamChange; | |||||
| h->name = "move knob"; | h->name = "move knob"; | ||||
| h->moduleId = paramQuantity->module->id; | h->moduleId = paramQuantity->module->id; | ||||
| h->paramId = paramQuantity->paramId; | h->paramId = paramQuantity->paramId; | ||||
| @@ -63,7 +63,7 @@ void Knob::onDragEnd(const event::DragEnd &e) { | |||||
| } | } | ||||
| } | } | ||||
| void Knob::onDragMove(const event::DragMove &e) { | |||||
| void Knob::onDragMove(const event::DragMove& e) { | |||||
| if (e.button != GLFW_MOUSE_BUTTON_LEFT) | if (e.button != GLFW_MOUSE_BUTTON_LEFT) | ||||
| return; | return; | ||||
| @@ -8,7 +8,7 @@ namespace rack { | |||||
| namespace app { | namespace app { | ||||
| void LedDisplay::draw(const DrawArgs &args) { | |||||
| void LedDisplay::draw(const DrawArgs& args) { | |||||
| nvgBeginPath(args.vg); | nvgBeginPath(args.vg); | ||||
| nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5.0); | nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5.0); | ||||
| nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00)); | nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00)); | ||||
| @@ -24,7 +24,7 @@ LedDisplaySeparator::LedDisplaySeparator() { | |||||
| box.size = math::Vec(); | box.size = math::Vec(); | ||||
| } | } | ||||
| void LedDisplaySeparator::draw(const DrawArgs &args) { | |||||
| void LedDisplaySeparator::draw(const DrawArgs& args) { | |||||
| nvgBeginPath(args.vg); | nvgBeginPath(args.vg); | ||||
| nvgMoveTo(args.vg, 0, 0); | nvgMoveTo(args.vg, 0, 0); | ||||
| nvgLineTo(args.vg, box.size.x, box.size.y); | nvgLineTo(args.vg, box.size.x, box.size.y); | ||||
| @@ -42,7 +42,7 @@ LedDisplayChoice::LedDisplayChoice() { | |||||
| textOffset = math::Vec(10, 18); | textOffset = math::Vec(10, 18); | ||||
| } | } | ||||
| void LedDisplayChoice::draw(const DrawArgs &args) { | |||||
| void LedDisplayChoice::draw(const DrawArgs& args) { | |||||
| nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | ||||
| if (bgColor.a > 0.0) { | if (bgColor.a > 0.0) { | ||||
| nvgBeginPath(args.vg); | nvgBeginPath(args.vg); | ||||
| @@ -62,7 +62,7 @@ void LedDisplayChoice::draw(const DrawArgs &args) { | |||||
| nvgResetScissor(args.vg); | nvgResetScissor(args.vg); | ||||
| } | } | ||||
| void LedDisplayChoice::onButton(const event::Button &e) { | |||||
| void LedDisplayChoice::onButton(const event::Button& e) { | |||||
| OpaqueWidget::onButton(e); | OpaqueWidget::onButton(e); | ||||
| if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) { | if (e.action == GLFW_PRESS && (e.button == GLFW_MOUSE_BUTTON_LEFT || e.button == GLFW_MOUSE_BUTTON_RIGHT)) { | ||||
| @@ -80,7 +80,7 @@ LedDisplayTextField::LedDisplayTextField() { | |||||
| } | } | ||||
| void LedDisplayTextField::draw(const DrawArgs &args) { | |||||
| void LedDisplayTextField::draw(const DrawArgs& args) { | |||||
| nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | nvgScissor(args.vg, RECT_ARGS(args.clipBox)); | ||||
| // Background | // Background | ||||
| @@ -98,8 +98,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) { | |||||
| int begin = std::min(cursor, selection); | int begin = std::min(cursor, selection); | ||||
| int end = (this == APP->event->selectedWidget) ? std::max(cursor, selection) : -1; | int end = (this == APP->event->selectedWidget) ? std::max(cursor, selection) : -1; | ||||
| bndIconLabelCaret(args.vg, textOffset.x, textOffset.y, | bndIconLabelCaret(args.vg, textOffset.x, textOffset.y, | ||||
| box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y, | |||||
| -1, color, 12, text.c_str(), highlightColor, begin, end); | |||||
| box.size.x - 2 * textOffset.x, box.size.y - 2 * textOffset.y, | |||||
| -1, color, 12, text.c_str(), highlightColor, begin, end); | |||||
| bndSetFont(APP->window->uiFont->handle); | bndSetFont(APP->window->uiFont->handle); | ||||
| } | } | ||||
| @@ -110,8 +110,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) { | |||||
| int LedDisplayTextField::getTextPosition(math::Vec mousePos) { | int LedDisplayTextField::getTextPosition(math::Vec mousePos) { | ||||
| bndSetFont(font->handle); | bndSetFont(font->handle); | ||||
| int textPos = bndIconLabelTextPosition(APP->window->vg, textOffset.x, textOffset.y, | int textPos = bndIconLabelTextPosition(APP->window->vg, textOffset.x, textOffset.y, | ||||
| box.size.x - 2*textOffset.x, box.size.y - 2*textOffset.y, | |||||
| -1, 12, text.c_str(), mousePos.x, mousePos.y); | |||||
| box.size.x - 2 * textOffset.x, box.size.y - 2 * textOffset.y, | |||||
| -1, 12, text.c_str(), mousePos.x, mousePos.y); | |||||
| bndSetFont(APP->window->uiFont->handle); | bndSetFont(APP->window->uiFont->handle); | ||||
| return textPos; | return textPos; | ||||
| } | } | ||||