diff --git a/include/Quantity.hpp b/include/Quantity.hpp index b1f7ff77..5a33e636 100644 --- a/include/Quantity.hpp +++ b/include/Quantity.hpp @@ -19,24 +19,36 @@ struct Quantity { /** Returns the value 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 */ - virtual float getMinValue() {return 0.f;} + virtual float getMinValue() { + return 0.f; + } /** Returns the maximum allowed value */ - virtual float getMaxValue() {return 1.f;} + virtual float getMaxValue() { + return 1.f; + } /** 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 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 */ - 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 */ @@ -48,12 +60,16 @@ struct Quantity { virtual void setDisplayValueString(std::string s); /** The name of the quantity */ - virtual std::string getLabel() {return "";} + virtual std::string getLabel() { + return ""; + } /** 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%". */ - virtual std::string getUnit() {return "";} + virtual std::string getUnit() { + return ""; + } /** Returns a string representation of the quantity */ virtual std::string getString(); diff --git a/include/app.hpp b/include/app.hpp index 0d916fe8..3304b3db 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -6,12 +6,12 @@ namespace rack { namespace history { - struct State; +struct State; } // namespace history namespace engine { - struct Engine; +struct Engine; } // namespace engine @@ -20,23 +20,23 @@ struct PatchManager; namespace event { - struct State; +struct State; } // namespace event namespace app { - struct Scene; +struct Scene; } // namespace app /** Contains the application state */ 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(); ~App(); @@ -46,7 +46,7 @@ struct App { void appInit(); void appDestroy(); /** Returns the global App pointer */ -App *appGet(); +App* appGet(); /** Accesses the global App pointer */ #define APP appGet() diff --git a/include/app/AudioWidget.hpp b/include/app/AudioWidget.hpp index cc09acfe..f70c4d09 100644 --- a/include/app/AudioWidget.hpp +++ b/include/app/AudioWidget.hpp @@ -9,14 +9,14 @@ namespace app { 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); }; diff --git a/include/app/CableWidget.hpp b/include/app/CableWidget.hpp index 5ebc1e68..266f9f13 100644 --- a/include/app/CableWidget.hpp +++ b/include/app/CableWidget.hpp @@ -12,25 +12,25 @@ namespace app { 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. */ - engine::Cable *cable; + engine::Cable* cable; NVGcolor color; CableWidget(); ~CableWidget(); bool isComplete(); - void setOutput(PortWidget *outputPort); - void setInput(PortWidget *inputPort); + void setOutput(PortWidget* outputPort); + void setInput(PortWidget* inputPort); math::Vec getOutputPos(); 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); }; diff --git a/include/app/CircularShadow.hpp b/include/app/CircularShadow.hpp index f16602ba..53d31724 100644 --- a/include/app/CircularShadow.hpp +++ b/include/app/CircularShadow.hpp @@ -12,7 +12,7 @@ struct CircularShadow : widget::TransparentWidget { float opacity; CircularShadow(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/app/Knob.hpp b/include/app/Knob.hpp index 9cc3075d..4ea96179 100644 --- a/include/app/Knob.hpp +++ b/include/app/Knob.hpp @@ -20,11 +20,11 @@ struct Knob : ParamWidget { /** Drag horizontally instead of vertically */ 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 randomize() override; }; diff --git a/include/app/LedDisplay.hpp b/include/app/LedDisplay.hpp index 366b4c5a..065c3ea7 100644 --- a/include/app/LedDisplay.hpp +++ b/include/app/LedDisplay.hpp @@ -10,12 +10,12 @@ namespace app { struct LedDisplay : widget::OpaqueWidget { - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; struct LedDisplaySeparator : widget::Widget { LedDisplaySeparator(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; struct LedDisplayChoice : widget::OpaqueWidget { @@ -25,8 +25,8 @@ struct LedDisplayChoice : widget::OpaqueWidget { NVGcolor color; NVGcolor bgColor; 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 { @@ -34,7 +34,7 @@ struct LedDisplayTextField : ui::TextField { math::Vec textOffset; NVGcolor color; LedDisplayTextField(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; int getTextPosition(math::Vec mousePos) override; }; diff --git a/include/app/LightWidget.hpp b/include/app/LightWidget.hpp index 1849fda5..deb29a05 100644 --- a/include/app/LightWidget.hpp +++ b/include/app/LightWidget.hpp @@ -12,9 +12,9 @@ struct LightWidget : widget::TransparentWidget { NVGcolor color = 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); }; diff --git a/include/app/MenuBar.hpp b/include/app/MenuBar.hpp index 2d7a1fba..c81f42cf 100644 --- a/include/app/MenuBar.hpp +++ b/include/app/MenuBar.hpp @@ -8,11 +8,11 @@ namespace app { struct MenuBar : widget::OpaqueWidget { - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; -MenuBar *createMenuBar(); +MenuBar* createMenuBar(); } // namespace app diff --git a/include/app/MidiWidget.hpp b/include/app/MidiWidget.hpp index de302827..7281d056 100644 --- a/include/app/MidiWidget.hpp +++ b/include/app/MidiWidget.hpp @@ -9,12 +9,12 @@ namespace app { 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); }; diff --git a/include/app/ModuleBrowser.hpp b/include/app/ModuleBrowser.hpp index 7eaa38b6..b36e6658 100644 --- a/include/app/ModuleBrowser.hpp +++ b/include/app/ModuleBrowser.hpp @@ -7,7 +7,7 @@ namespace rack { namespace app { -widget::Widget *moduleBrowserCreate(); +widget::Widget* moduleBrowserCreate(); } // namespace app diff --git a/include/app/ModuleLightWidget.hpp b/include/app/ModuleLightWidget.hpp index 679b2aa5..2e2ab13d 100644 --- a/include/app/ModuleLightWidget.hpp +++ b/include/app/ModuleLightWidget.hpp @@ -12,7 +12,7 @@ namespace app { Will access firstLightId, firstLightId + 1, etc. for each added color */ struct ModuleLightWidget : MultiLightWidget { - engine::Module *module = NULL; + engine::Module* module = NULL; int firstLightId; void step() override; diff --git a/include/app/ModuleWidget.hpp b/include/app/ModuleWidget.hpp index 0ee314df..48d8b2f1 100644 --- a/include/app/ModuleWidget.hpp +++ b/include/app/ModuleWidget.hpp @@ -14,11 +14,11 @@ namespace app { /** Manages an engine::Module in the rack. */ struct ModuleWidget : widget::OpaqueWidget { - plugin::Model *model = NULL; + plugin::Model* model = NULL; /** 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. */ std::vector params; @@ -29,39 +29,39 @@ struct ModuleWidget : widget::OpaqueWidget { math::Vec oldPos; ModuleWidget(); - DEPRECATED ModuleWidget(engine::Module *module) : ModuleWidget() { + DEPRECATED ModuleWidget(engine::Module* module) : ModuleWidget() { setModule(module); } ~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 Transfers ownership */ - void setModule(engine::Module *module); + void setModule(engine::Module* module); void setPanel(std::shared_ptr svg); /** 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. 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 */ void copyClipboard(); @@ -93,7 +93,7 @@ struct ModuleWidget : widget::OpaqueWidget { /** Override to add context menu entries to your subclass. It is recommended to add a blank ui::MenuEntry first for spacing. */ - virtual void appendContextMenu(ui::Menu *menu) {} + virtual void appendContextMenu(ui::Menu* menu) {} }; diff --git a/include/app/MultiLightWidget.hpp b/include/app/MultiLightWidget.hpp index 64acc2af..9fb2dc58 100644 --- a/include/app/MultiLightWidget.hpp +++ b/include/app/MultiLightWidget.hpp @@ -14,7 +14,7 @@ struct MultiLightWidget : LightWidget { void addBaseColor(NVGcolor baseColor); /** Sets the color to a linear combination of the baseColors with the given weights */ - void setBrightnesses(const std::vector &brightnesses); + void setBrightnesses(const std::vector& brightnesses); }; diff --git a/include/app/ParamWidget.hpp b/include/app/ParamWidget.hpp index 9bc55063..11906f1d 100644 --- a/include/app/ParamWidget.hpp +++ b/include/app/ParamWidget.hpp @@ -12,20 +12,20 @@ namespace app { /** Manages an engine::Param on a ModuleWidget. */ struct ParamWidget : widget::OpaqueWidget { - engine::ParamQuantity *paramQuantity = NULL; + engine::ParamQuantity* paramQuantity = NULL; float dirtyValue = NAN; - ui::Tooltip *tooltip = NULL; + ui::Tooltip* tooltip = NULL; 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 */ - void fromJson(json_t *rootJ); + void fromJson(json_t* rootJ); void createContextMenu(); void resetAction(); virtual void reset() {} diff --git a/include/app/PortWidget.hpp b/include/app/PortWidget.hpp index b0c421eb..6a5c90a0 100644 --- a/include/app/PortWidget.hpp +++ b/include/app/PortWidget.hpp @@ -11,7 +11,7 @@ namespace app { /** Manages an engine::Port on a ModuleWidget. */ struct PortWidget : widget::OpaqueWidget { - engine::Module *module = NULL; + engine::Module* module = NULL; int portId; bool hovered = false; @@ -20,22 +20,22 @@ struct PortWidget : widget::OpaqueWidget { INPUT }; Type type; - MultiLightWidget *plugLight; + MultiLightWidget* plugLight; PortWidget(); ~PortWidget(); 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; }; diff --git a/include/app/RackRail.hpp b/include/app/RackRail.hpp index e7ca67e7..6c62e75e 100644 --- a/include/app/RackRail.hpp +++ b/include/app/RackRail.hpp @@ -11,7 +11,7 @@ struct RackRail : widget::TransparentWidget { std::shared_ptr busBoardSvg; RackRail(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/app/RackScrollWidget.hpp b/include/app/RackScrollWidget.hpp index 12554303..1759179c 100644 --- a/include/app/RackScrollWidget.hpp +++ b/include/app/RackScrollWidget.hpp @@ -10,17 +10,17 @@ namespace app { struct RackScrollWidget : ui::ScrollWidget { - widget::ZoomWidget *zoomWidget; - RackWidget *rackWidget; + widget::ZoomWidget* zoomWidget; + RackWidget* rackWidget; /** The pivot point for zooming */ math::Vec zoomPos; math::Vec oldOffset; RackScrollWidget(); 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(); }; diff --git a/include/app/RackWidget.hpp b/include/app/RackWidget.hpp index 468fd62c..149c1d40 100644 --- a/include/app/RackWidget.hpp +++ b/include/app/RackWidget.hpp @@ -16,13 +16,13 @@ namespace app { /** Container for ModuleWidget and CableWidget. */ 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 */ math::Vec mousePos; - ParamWidget *touchedParam = NULL; + ParamWidget* touchedParam = NULL; std::map moduleDragPositions; int nextCableColorId = 0; @@ -30,17 +30,17 @@ struct RackWidget : widget::OpaqueWidget { ~RackWidget(); 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 */ void clear(); - json_t *toJson(); - void fromJson(json_t *rootJ); + json_t* toJson(); + void fromJson(json_t* rootJ); void pastePresetClipboardAction(); // Module methods @@ -48,39 +48,39 @@ struct RackWidget : widget::OpaqueWidget { /** Adds a module and adds it to the Engine 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 */ - void removeModule(ModuleWidget *mw); + void removeModule(ModuleWidget* mw); /** 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 */ - 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(); void updateModuleDragPositions(); - history::ComplexAction *getModuleDragAction(); + history::ComplexAction* getModuleDragAction(); // Cable methods void clearCables(); void clearCablesAction(); /** 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. 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 */ - 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 */ - 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 */ - std::list getCablesOnPort(PortWidget *port); + std::list getCablesOnPort(PortWidget* port); }; diff --git a/include/app/Scene.hpp b/include/app/Scene.hpp index 92d32acd..d909df80 100644 --- a/include/app/Scene.hpp +++ b/include/app/Scene.hpp @@ -12,10 +12,10 @@ namespace app { struct Scene : widget::OpaqueWidget { // 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; @@ -27,9 +27,9 @@ struct Scene : widget::OpaqueWidget { Scene(); ~Scene(); 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(); }; diff --git a/include/app/SliderKnob.hpp b/include/app/SliderKnob.hpp index 95d5cd68..4d2219f3 100644 --- a/include/app/SliderKnob.hpp +++ b/include/app/SliderKnob.hpp @@ -9,10 +9,10 @@ namespace app { struct SliderKnob : Knob { // Bypass Knob's circular hitbox detection - void onHover(const event::Hover &e) override { + void onHover(const event::Hover& e) override { ParamWidget::onHover(e); } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { ParamWidget::onButton(e); } }; diff --git a/include/app/SvgButton.hpp b/include/app/SvgButton.hpp index 973a83e9..d0d810dc 100644 --- a/include/app/SvgButton.hpp +++ b/include/app/SvgButton.hpp @@ -11,16 +11,16 @@ namespace app { struct SvgButton : widget::OpaqueWidget { - widget::FramebufferWidget *fb; - CircularShadow *shadow; - widget::SvgWidget *sw; + widget::FramebufferWidget* fb; + CircularShadow* shadow; + widget::SvgWidget* sw; std::vector> frames; SvgButton(); void addFrame(std::shared_ptr 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; }; diff --git a/include/app/SvgKnob.hpp b/include/app/SvgKnob.hpp index c45349bf..997b3dc3 100644 --- a/include/app/SvgKnob.hpp +++ b/include/app/SvgKnob.hpp @@ -13,18 +13,20 @@ namespace app { /** A knob which rotates an SVG and caches it in a framebuffer */ 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 */ float minAngle = 0.f; float maxAngle = M_PI; SvgKnob(); void setSvg(std::shared_ptr svg); - DEPRECATED void setSVG(std::shared_ptr svg) {setSvg(svg);} - void onChange(const event::Change &e) override; + DEPRECATED void setSVG(std::shared_ptr svg) { + setSvg(svg); + } + void onChange(const event::Change& e) override; }; diff --git a/include/app/SvgPanel.hpp b/include/app/SvgPanel.hpp index c4be6627..9044f008 100644 --- a/include/app/SvgPanel.hpp +++ b/include/app/SvgPanel.hpp @@ -11,7 +11,7 @@ namespace app { struct PanelBorder : widget::TransparentWidget { - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/app/SvgPort.hpp b/include/app/SvgPort.hpp index 142f29b6..c52ee485 100644 --- a/include/app/SvgPort.hpp +++ b/include/app/SvgPort.hpp @@ -11,13 +11,15 @@ namespace app { struct SvgPort : PortWidget { - widget::FramebufferWidget *fb; - CircularShadow *shadow; - widget::SvgWidget *sw; + widget::FramebufferWidget* fb; + CircularShadow* shadow; + widget::SvgWidget* sw; SvgPort(); void setSvg(std::shared_ptr svg); - DEPRECATED void setSVG(std::shared_ptr svg) {setSvg(svg);} + DEPRECATED void setSVG(std::shared_ptr svg) { + setSvg(svg); + } }; diff --git a/include/app/SvgScrew.hpp b/include/app/SvgScrew.hpp index 71441ce2..7e8d886b 100644 --- a/include/app/SvgScrew.hpp +++ b/include/app/SvgScrew.hpp @@ -11,8 +11,8 @@ namespace app { /** If you don't add these to your ModuleWidget, they will fall out of the rack... */ struct SvgScrew : widget::Widget { - widget::FramebufferWidget *fb; - widget::SvgWidget *sw; + widget::FramebufferWidget* fb; + widget::SvgWidget* sw; SvgScrew(); void setSvg(std::shared_ptr svg); diff --git a/include/app/SvgSlider.hpp b/include/app/SvgSlider.hpp index b6a40212..c61d4ccd 100644 --- a/include/app/SvgSlider.hpp +++ b/include/app/SvgSlider.hpp @@ -13,19 +13,23 @@ namespace app { Can be used for horizontal or vertical linear faders. */ 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 */ math::Vec minHandlePos, maxHandlePos; SvgSlider(); void setBackgroundSvg(std::shared_ptr svg); void setHandleSvg(std::shared_ptr svg); - void onChange(const event::Change &e) override; + void onChange(const event::Change& e) override; - DEPRECATED void setBackgroundSVG(std::shared_ptr svg) {setBackgroundSvg(svg);} - DEPRECATED void setHandleSVG(std::shared_ptr svg) {setBackgroundSvg(svg);} + DEPRECATED void setBackgroundSVG(std::shared_ptr svg) { + setBackgroundSvg(svg); + } + DEPRECATED void setHandleSVG(std::shared_ptr svg) { + setBackgroundSvg(svg); + } DEPRECATED void setSVGs(std::shared_ptr backgroundSvg, std::shared_ptr handleSvg) { setBackgroundSvg(backgroundSvg); setHandleSvg(handleSvg); diff --git a/include/app/SvgSwitch.hpp b/include/app/SvgSwitch.hpp index 4b12605a..b8ca995e 100644 --- a/include/app/SvgSwitch.hpp +++ b/include/app/SvgSwitch.hpp @@ -12,15 +12,15 @@ namespace app { /** A ParamWidget with multiple frames corresponding to its value */ struct SvgSwitch : Switch { - widget::FramebufferWidget *fb; - CircularShadow *shadow; - widget::SvgWidget *sw; + widget::FramebufferWidget* fb; + CircularShadow* shadow; + widget::SvgWidget* sw; std::vector> frames; SvgSwitch(); /** Adds an SVG file to represent the next switch position */ void addFrame(std::shared_ptr svg); - void onChange(const event::Change &e) override; + void onChange(const event::Change& e) override; }; diff --git a/include/app/Switch.hpp b/include/app/Switch.hpp index ecf74791..4465dcc4 100644 --- a/include/app/Switch.hpp +++ b/include/app/Switch.hpp @@ -20,9 +20,9 @@ struct Switch : ParamWidget { bool momentaryReleased = false; 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 randomize() override; }; diff --git a/include/asset.hpp b/include/asset.hpp index 4ee7722f..b1ba8760 100644 --- a/include/asset.hpp +++ b/include/asset.hpp @@ -6,7 +6,7 @@ namespace rack { namespace plugin { - struct Plugin; +struct 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. */ std::string user(std::string filename); /** 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 diff --git a/include/audio.hpp b/include/audio.hpp index a4bf5b59..65150dc9 100644 --- a/include/audio.hpp +++ b/include/audio.hpp @@ -4,7 +4,7 @@ #pragma GCC diagnostic push #ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif #include #pragma GCC diagnostic pop @@ -28,7 +28,7 @@ struct Port { int blockSize = 256; int numOutputs = 0; int numInputs = 0; - RtAudio *rtAudio = NULL; + RtAudio* rtAudio = NULL; /** Cached */ RtAudio::DeviceInfo deviceInfo; @@ -40,7 +40,7 @@ struct Port { void setDriverId(int driverId); 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 */ int getDeviceChannels(int deviceId); std::string getDeviceName(int deviceId); @@ -58,12 +58,12 @@ struct Port { void openStream(); 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 onOpenStream() {} virtual void onChannelsChange() {} - json_t *toJson(); - void fromJson(json_t *rootJ); + json_t* toJson(); + void fromJson(json_t* rootJ); }; diff --git a/include/bridge.hpp b/include/bridge.hpp index 98819526..f9784452 100644 --- a/include/bridge.hpp +++ b/include/bridge.hpp @@ -8,8 +8,8 @@ namespace rack { void bridgeInit(); 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 diff --git a/include/common.hpp b/include/common.hpp index 2dd0de3a..97e99453 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -120,13 +120,13 @@ Example: Foo *foo = construct(&Foo::greeting, "Hello world", &Foo::legs, 2); */ template -T *construct() { +T* construct() { return new T; } template -T *construct(F f, V v, Args... args) { - T *o = construct(args...); +T* construct(F f, V v, Args... args) { + T* o = construct(args...); o->*f = v; return o; } @@ -144,7 +144,9 @@ template struct DeferWrapper { F f; DeferWrapper(F f) : f(f) {} - ~DeferWrapper() { f(); } + ~DeferWrapper() { + f(); + } }; template @@ -157,7 +159,7 @@ DeferWrapper deferWrapper(F f) { /** An exception meant to be shown to the user */ struct UserException : std::runtime_error { - UserException(const std::string &msg) : std::runtime_error(msg) {} + UserException(const std::string& msg) : std::runtime_error(msg) {} }; diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 684bf6c4..6cb66dd3 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -45,8 +45,8 @@ static const NVGcolor SCHEME_DARK_GRAY = nvgRGB(0x17, 0x17, 0x17); struct RoundKnob : app::SvgKnob { 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 { 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 { 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 { 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"))); // 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"))); capFb->addChild(cap); addChild(capFb); @@ -311,16 +311,16 @@ struct SynthTechAlco : app::SvgKnob { struct Trimpot : app::SvgKnob { 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"))); } }; struct BefacoBigKnob : app::SvgKnob { 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"))); } }; @@ -333,8 +333,8 @@ struct BefacoBigSnapKnob : BefacoBigKnob { struct BefacoTinyKnob : app::SvgKnob { 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"))); } }; diff --git a/include/dsp/common.hpp b/include/dsp/common.hpp index 58c4b32f..03183c16 100644 --- a/include/dsp/common.hpp +++ b/include/dsp/common.hpp @@ -53,23 +53,23 @@ T dbToAmplitude(T db) { template T quadraticBipolar(T x) { - return simd::sgn(x) * (x*x); + return simd::sgn(x) * (x * x); } template T cubic(T x) { - return x*x*x; + return x * x * x; } template T quarticBipolar(T x) { - return simd::sgn(x) * (x*x*x*x); + return simd::sgn(x) * (x * x * x * x); } template T quintic(T x) { // optimal with -fassociative-math - return x*x*x*x*x; + return x * x * x * x * x; } template diff --git a/include/dsp/fft.hpp b/include/dsp/fft.hpp index b48af38a..603f4c12 100644 --- a/include/dsp/fft.hpp +++ b/include/dsp/fft.hpp @@ -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. */ struct RealFFT { - PFFFT_Setup *setup; + PFFFT_Setup* setup; int length; RealFFT(size_t length) { @@ -31,7 +31,7 @@ struct RealFFT { 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. */ - void rfftUnordered(const float *input, float *output) { + void rfftUnordered(const float* input, float* output) { pffft_transform(setup, input, output, NULL, PFFFT_FORWARD); } @@ -39,7 +39,7 @@ struct RealFFT { Input is `2*length` elements. Output is `length` elements. 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); } @@ -54,17 +54,17 @@ struct RealFFT { output[length - 2] = real(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); } - void irfft(const float *input, float *output) { + void irfft(const float* input, float* output) { pffft_transform_ordered(setup, input, output, NULL, PFFFT_BACKWARD); } /** Scales the RFFT so that `scale(IFFT(FFT(x))) = x`. */ - void scale(float *x) { + void scale(float* x) { float a = 1.f / length; for (int i = 0; i < length; i++) { x[i] *= a; @@ -77,7 +77,7 @@ struct RealFFT { `length` must be a multiple of 16. */ struct ComplexFFT { - PFFFT_Setup *setup; + PFFFT_Setup* setup; int length; ComplexFFT(size_t length) { @@ -93,7 +93,7 @@ struct ComplexFFT { Input and output must be aligned using the above align*() functions. 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); } @@ -101,23 +101,23 @@ struct ComplexFFT { Input is `2*length` elements. Output is `2*length` elements. 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); } - void fft(const float *input, float *output) { + void fft(const float* input, float* output) { 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); } - void scale(float *x) { + void scale(float* x) { float a = 1.f / length; 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; } } }; diff --git a/include/dsp/filter.hpp b/include/dsp/filter.hpp index a628c0c3..b1360652 100644 --- a/include/dsp/filter.hpp +++ b/include/dsp/filter.hpp @@ -214,7 +214,7 @@ struct TBiquadFilter { T process(T in) { // Advance IIR 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 x[1] = x[0]; x[0] = in; @@ -348,7 +348,7 @@ struct TBiquadFilter { } } - void copyParameters(const TBiquadFilter &from) { + void copyParameters(const TBiquadFilter& from) { b[0] = from.b[0]; b[1] = from.b[1]; b[2] = from.b[2]; diff --git a/include/dsp/fir.hpp b/include/dsp/fir.hpp index a3633c80..f99b65de 100644 --- a/include/dsp/fir.hpp +++ b/include/dsp/fir.hpp @@ -8,7 +8,7 @@ namespace dsp { /** 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; for (int i = 0; i < len; 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 */ -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++) { float t = i - (len - 1) / 2.f; 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 { // `kernelBlocks` number of contiguous FFT blocks of size `blockSize` // 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 kernelBlocks = 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. */ RealTimeConvolver(size_t blockSize) { this->blockSize = blockSize; - pffft = pffft_new_setup(blockSize*2, PFFFT_REAL); + pffft = pffft_new_setup(blockSize * 2, PFFFT_REAL); outputTail = new float[blockSize]; 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() { @@ -54,7 +54,7 @@ struct RealTimeConvolver { pffft_destroy_setup(pffft); } - void setKernel(const float *kernel, size_t length) { + void setKernel(const float* kernel, size_t length) { // Clear existing kernel if (kernelFfts) { pffft_aligned_free(kernelFfts); @@ -72,17 +72,17 @@ struct RealTimeConvolver { kernelBlocks = (length - 1) / blockSize + 1; // 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++) { // 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 - 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 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) { std::memset(output, 0, sizeof(float) * blockSize); return; @@ -99,17 +99,17 @@ struct RealTimeConvolver { // Step input position inputPos = (inputPos + 1) % kernelBlocks; // 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); // 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 - std::memset(tmpBlock, 0, sizeof(float) * blockSize*2); + std::memset(tmpBlock, 0, sizeof(float) * blockSize * 2); // convolve input fft by kernel fft // Note: This is the CPU bottleneck loop for (size_t i = 0; i < kernelBlocks; i++) { 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 pffft_transform(pffft, tmpBlock, tmpBlock, NULL, PFFFT_BACKWARD); @@ -118,7 +118,7 @@ struct RealTimeConvolver { tmpBlock[i] += outputTail[i]; } // 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++) { // Scale based on FFT output[i] = tmpBlock[i] * scale; diff --git a/include/dsp/minblep.hpp b/include/dsp/minblep.hpp index bd64cacc..05bf48d3 100644 --- a/include/dsp/minblep.hpp +++ b/include/dsp/minblep.hpp @@ -12,7 +12,7 @@ o: oversample factor output: must be length `2 * z * o`. 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 diff --git a/include/dsp/resampler.hpp b/include/dsp/resampler.hpp index 82d5ab5c..27c244d7 100644 --- a/include/dsp/resampler.hpp +++ b/include/dsp/resampler.hpp @@ -15,7 +15,7 @@ namespace dsp { /** Resamples by a fixed rational factor. */ template struct SampleRateConverter { - SpeexResamplerState *st = NULL; + SpeexResamplerState* st = NULL; int channels = MAX_CHANNELS; int quality = SPEEX_RESAMPLER_QUALITY_DEFAULT; int inRate = 44100; @@ -73,7 +73,7 @@ struct SampleRateConverter { } /** `in` and `out` are interlaced with the number of channels */ - void process(const Frame *in, int *inFrames, Frame *out, int *outFrames) { + void process(const Frame* in, int* inFrames, Frame* out, int* outFrames) { assert(in); assert(inFrames); assert(out); @@ -105,13 +105,13 @@ struct SampleRateConverter { /** Downsamples by an integer factor. */ template struct Decimator { - T inBuffer[OVERSAMPLE*QUALITY]; - float kernel[OVERSAMPLE*QUALITY]; + T inBuffer[OVERSAMPLE * QUALITY]; + float kernel[OVERSAMPLE * QUALITY]; int inIndex; 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(); } void reset() { @@ -119,17 +119,17 @@ struct Decimator { std::memset(inBuffer, 0, sizeof(inBuffer)); } /** `in` must be length OVERSAMPLE */ - T process(T *in) { + T process(T* in) { // Copy input to buffer - std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE*sizeof(T)); + std::memcpy(&inBuffer[inIndex], in, OVERSAMPLE * sizeof(T)); // Advance index inIndex += OVERSAMPLE; - inIndex %= OVERSAMPLE*QUALITY; + inIndex %= OVERSAMPLE * QUALITY; // Perform naive convolution 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; - index = (index + OVERSAMPLE*QUALITY) % (OVERSAMPLE*QUALITY); + index = (index + OVERSAMPLE * QUALITY) % (OVERSAMPLE * QUALITY); out += kernel[i] * inBuffer[index]; } return out; @@ -141,12 +141,12 @@ struct Decimator { template struct Upsampler { float inBuffer[QUALITY]; - float kernel[OVERSAMPLE*QUALITY]; + float kernel[OVERSAMPLE * QUALITY]; int inIndex; 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(); } void reset() { @@ -154,7 +154,7 @@ struct Upsampler { std::memset(inBuffer, 0, sizeof(inBuffer)); } /** `out` must be length OVERSAMPLE */ - void process(float in, float *out) { + void process(float in, float* out) { // Zero-stuff input buffer inBuffer[inIndex] = OVERSAMPLE * in; // Advance index diff --git a/include/dsp/ringbuffer.hpp b/include/dsp/ringbuffer.hpp index 278d7d01..ea545937 100644 --- a/include/dsp/ringbuffer.hpp +++ b/include/dsp/ringbuffer.hpp @@ -18,13 +18,13 @@ struct RingBuffer { size_t end = 0; size_t mask(size_t i) const { - return i & (S - 1); + return i & (S - 1); } void push(T t) { size_t i = mask(end++); data[i] = t; } - void pushBuffer(const T *t, int n) { + void pushBuffer(const T* t, int n) { size_t i = mask(end); size_t e1 = i + n; size_t e2 = (e1 < S) ? e1 : S; @@ -37,7 +37,7 @@ struct RingBuffer { T shift() { 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 s1 = i + n; size_t s2 = (s1 < S) ? s1 : S; @@ -70,7 +70,7 @@ Thread-safe for single producers and consumers? */ template struct DoubleRingBuffer { - T data[S*2]; + T data[S * 2]; size_t start = 0; size_t end = 0; @@ -104,7 +104,7 @@ struct DoubleRingBuffer { If any data is appended, you must call endIncr afterwards. Pointer is invalidated when any other method is called. */ - T *endData() { + T* endData() { return &data[mask(end)]; } void endIncr(size_t n) { @@ -123,7 +123,7 @@ struct DoubleRingBuffer { /** Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards. */ - const T *startData() const { + const T* startData() const { return &data[mask(start)]; } 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. */ - T *endData(size_t n) { + T* endData(size_t n) { if (end + n > N) { returnBuffer(); } @@ -189,7 +189,7 @@ struct AppleRingBuffer { /** Returns a pointer to S consecutive elements for consumption If any data is consumed, call startIncr afterwards. */ - const T *startData() const { + const T* startData() const { return &data[start]; } void startIncr(size_t n) { diff --git a/include/dsp/window.hpp b/include/dsp/window.hpp index 089aabf0..6e50413f 100644 --- a/include/dsp/window.hpp +++ b/include/dsp/window.hpp @@ -16,7 +16,7 @@ inline T hann(T p) { } /** 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++) { x[i] *= hann(float(i) / (len - 1)); } @@ -29,12 +29,12 @@ A typical alpha value is 0.16. template inline T blackman(T alpha, T p) { 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++) { 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 inline T blackmanNuttall(T p) { 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++) { x[i] *= blackmanNuttall(float(i) / (len - 1)); } @@ -65,13 +65,13 @@ https://en.wikipedia.org/wiki/Window_function#Blackman%E2%80%93Harris_window template inline T blackmanHarris(T p) { 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++) { x[i] *= blackmanHarris(float(i) / (len - 1)); } diff --git a/include/engine/Cable.hpp b/include/engine/Cable.hpp index 55f2b391..d6ca22de 100644 --- a/include/engine/Cable.hpp +++ b/include/engine/Cable.hpp @@ -9,9 +9,9 @@ namespace engine { struct Cable { int id = -1; - Module *outputModule = NULL; + Module* outputModule = NULL; int outputId; - Module *inputModule = NULL; + Module* inputModule = NULL; int inputId; }; diff --git a/include/engine/Engine.hpp b/include/engine/Engine.hpp index a9db9f6c..2778b7ac 100644 --- a/include/engine/Engine.hpp +++ b/include/engine/Engine.hpp @@ -12,7 +12,7 @@ namespace engine { struct Engine { struct Internal; - Internal *internal; + Internal* internal; Engine(); ~Engine(); @@ -37,12 +37,12 @@ struct Engine { If the module ID is -1, an ID is automatically assigned. 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 /** Adds a cable to the rack engine. @@ -50,26 +50,26 @@ struct Engine { If the cable ID is -1, an ID is automatically assigned. Does not transfer pointer ownership. */ - void addCable(Cable *cable); - void removeCable(Cable *cable); + void addCable(Cable* cable); + void removeCable(Cable* cable); // 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 - void addParamHandle(ParamHandle *paramHandle); - void removeParamHandle(ParamHandle *paramHandle); + void addParamHandle(ParamHandle* paramHandle); + void removeParamHandle(ParamHandle* paramHandle); /** 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. */ - DEPRECATED ParamHandle *getParamHandle(Module *module, int paramId); + DEPRECATED ParamHandle* getParamHandle(Module* module, int paramId); /** 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. */ - void updateParamHandle(ParamHandle *paramHandle, int moduleId, int paramId, bool overwrite = true); + void updateParamHandle(ParamHandle* paramHandle, int moduleId, int paramId, bool overwrite = true); }; diff --git a/include/engine/Module.hpp b/include/engine/Module.hpp index 3eef9225..25144374 100644 --- a/include/engine/Module.hpp +++ b/include/engine/Module.hpp @@ -14,7 +14,7 @@ namespace rack { namespace plugin { - struct Model; +struct Model; } @@ -23,7 +23,7 @@ namespace engine { /** DSP processor instance for your 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. */ int id = -1; @@ -42,7 +42,7 @@ struct Module { /** ID of the expander module, or -1 if nonexistent. */ int moduleId = -1; /** Pointer to the expander Module, or NULL if nonexistent. */ - Module *module = NULL; + Module* module = NULL; /** 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). 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". 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; }; @@ -97,10 +97,10 @@ struct Module { if (paramQuantities[paramId]) delete paramQuantities[paramId]; - Param *p = ¶ms[paramId]; + Param* p = ¶ms[paramId]; p->value = defaultValue; - ParamQuantity *q = new TParamQuantity; + ParamQuantity* q = new TParamQuantity; q->module = this; q->paramId = paramId; q->minValue = minValue; @@ -125,7 +125,7 @@ struct Module { /** Advances the module by one audio sample. 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 ignored "-Wdeprecated-declarations" step(); @@ -145,12 +145,14 @@ struct Module { /** Called when the Module is removed from the Engine */ 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. */ - virtual json_t *dataToJson() { return NULL; } - virtual void dataFromJson(json_t *root) {} + virtual json_t* dataToJson() { + return NULL; + } + virtual void dataFromJson(json_t* root) {} }; diff --git a/include/engine/ParamHandle.hpp b/include/engine/ParamHandle.hpp index ed4dfb95..cae77e18 100644 --- a/include/engine/ParamHandle.hpp +++ b/include/engine/ParamHandle.hpp @@ -16,7 +16,7 @@ struct ParamHandle { */ int moduleId = -1; int paramId = 0; - Module *module = NULL; + Module* module = NULL; std::string text; NVGcolor color; diff --git a/include/engine/ParamQuantity.hpp b/include/engine/ParamQuantity.hpp index 7f117645..26dfb9fc 100644 --- a/include/engine/ParamQuantity.hpp +++ b/include/engine/ParamQuantity.hpp @@ -12,7 +12,7 @@ struct Module; /** A Quantity that wraps an engine::Param. */ struct ParamQuantity : Quantity { - Module *module = NULL; + Module* module = NULL; int paramId = 0; /** The minimum allowed value. */ @@ -38,7 +38,7 @@ struct ParamQuantity : Quantity { /** An optional one-sentence description of the parameter. */ std::string description; - Param *getParam(); + Param* getParam(); /** Request to the engine to smoothly set the value */ void setSmoothValue(float smoothValue); float getSmoothValue(); diff --git a/include/engine/Port.hpp b/include/engine/Port.hpp index 012a3eca..fde04547 100644 --- a/include/engine/Port.hpp +++ b/include/engine/Port.hpp @@ -62,12 +62,12 @@ struct alignas(32) Port { /** Returns a pointer to the array of voltages beginning with firstChannel. The pointer can be used for reading and writing. */ - float *getVoltages(int firstChannel = 0) { + float* getVoltages(int firstChannel = 0) { return &voltages[firstChannel]; } /** 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++) { 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. 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++) { voltages[c] = v[c]; } @@ -105,7 +105,7 @@ struct alignas(32) Port { template T getPolyVoltageSimd(int firstChannel) { - return isMonophonic() ? getVoltage(0) : getVoltageSimd(firstChannel); + return isMonophonic() ? getVoltage(0) : getVoltageSimd(firstChannel); } template diff --git a/include/event.hpp b/include/event.hpp index fcf78e03..d40e5969 100644 --- a/include/event.hpp +++ b/include/event.hpp @@ -31,7 +31,7 @@ namespace rack { 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. */ bool consumed = false; /** The widget that responded to the event. */ - widget::Widget *target = NULL; + widget::Widget* target = NULL; }; /** Base class for all events. */ struct Base { - Context *context = NULL; + Context* context = NULL; /** Prevents the event from being handled by more Widgets. */ void stopPropagating() const { - if (!context) return; + if (!context) + return; context->propagating = false; } bool isPropagating() const { - if (!context) return true; + if (!context) + return true; return context->propagating; } /** Tells the event handler that a particular Widget consumed the event. 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; } - widget::Widget *getTarget() const { - if (!context) return NULL; + widget::Widget* getTarget() const { + if (!context) + return NULL; return context->target; } /** Sets the target Widget and stops propagating. 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->consumed = true; context->target = w; } bool isConsumed() const { - if (!context) return false; + if (!context) + return false; return context->consumed; } }; @@ -256,7 +262,7 @@ Consume this event to allow DragEnter and DragLeave to occur. */ struct DragHover : DragBase, PositionBase { /** The dragged widget */ - widget::Widget *origin = NULL; + widget::Widget* origin = NULL; /** Change in mouse position since the last frame. Can be zero. */ math::Vec mouseDelta; }; @@ -268,7 +274,7 @@ The target sets `draggedWidget`, which allows DragLeave to occur. */ struct DragEnter : DragBase { /** 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 { /** 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 { /** The dragged widget */ - widget::Widget *origin = NULL; + widget::Widget* origin = NULL; }; @@ -294,10 +300,10 @@ struct DragDrop : DragBase { Recurses. */ struct PathDrop : Base, PositionBase { - PathDrop(const std::vector &paths) : paths(paths) {} + PathDrop(const std::vector& paths) : paths(paths) {} /** List of file paths in the dropped selection */ - const std::vector &paths; + const std::vector& paths; }; @@ -361,32 +367,42 @@ struct Hide : Base { struct State { - widget::Widget *rootWidget = NULL; + widget::Widget* rootWidget = NULL; /** State widgets 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; - widget::Widget *dragHoveredWidget = NULL; - widget::Widget *selectedWidget = NULL; + widget::Widget* dragHoveredWidget = NULL; + widget::Widget* selectedWidget = NULL; /** For double-clicking */ double lastClickTime = -INFINITY; - widget::Widget *lastClickedWidget = NULL; + widget::Widget* lastClickedWidget = NULL; std::set 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 */ - void finalizeWidget(widget::Widget *w); + void finalizeWidget(widget::Widget* w); bool handleButton(math::Vec pos, int button, int action, int mods); bool handleHover(math::Vec pos, math::Vec mouseDelta); @@ -394,7 +410,7 @@ struct State { bool handleScroll(math::Vec pos, math::Vec scrollDelta); bool handleText(math::Vec pos, int codepoint); bool handleKey(math::Vec pos, int key, int scancode, int action, int mods); - bool handleDrop(math::Vec pos, const std::vector &paths); + bool handleDrop(math::Vec pos, const std::vector& paths); bool handleZoom(); }; diff --git a/include/force_link_glibc_2.23.h b/include/force_link_glibc_2.23.h index 87b1c120..1cf6567d 100644 --- a/include/force_link_glibc_2.23.h +++ b/include/force_link_glibc_2.23.h @@ -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_getspecific,__pthread_getspecific@GLIBC_2.2.5"); #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 __asm__(".symver __pthread_mutex_destroy,__pthread_mutex_destroy@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 __recvfrom_chk,__recvfrom_chk@GLIBC_2.4"); #ifdef _REENTRANT -__asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2"); + __asm__(".symver __register_atfork,__register_atfork@GLIBC_2.3.2"); #endif __asm__(".symver __remainder_finite,__remainder_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 psignal,psignal@GLIBC_2.2.5"); #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 __asm__(".symver pthread_attr_getaffinity_np,pthread_attr_getaffinity_np@GLIBC_2.3.4"); #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 __asm__(".symver pthread_attr_getguardsize,pthread_attr_getguardsize@GLIBC_2.2.5"); #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 #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 #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 #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 __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_getstacksize,pthread_attr_getstacksize@GLIBC_2.2.5"); #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 __asm__(".symver pthread_attr_setaffinity_np,pthread_attr_setaffinity_np@GLIBC_2.3.4"); #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 __asm__(".symver pthread_attr_setguardsize,pthread_attr_setguardsize@GLIBC_2.2.5"); #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 #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 #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 #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 __asm__(".symver pthread_attr_setstack,pthread_attr_setstack@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_cancel,pthread_cancel@GLIBC_2.2.5"); #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 #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 #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 __asm__(".symver pthread_cond_signal,pthread_cond_signal@GLIBC_2.3.2"); #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 __asm__(".symver pthread_cond_wait,pthread_cond_wait@GLIBC_2.3.2"); #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 __asm__(".symver pthread_condattr_getclock,pthread_condattr_getclock@GLIBC_2.3.3"); __asm__(".symver pthread_condattr_getpshared,pthread_condattr_getpshared@GLIBC_2.2.5"); #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 __asm__(".symver pthread_condattr_setclock,pthread_condattr_setclock@GLIBC_2.3.3"); __asm__(".symver pthread_condattr_setpshared,pthread_condattr_setpshared@GLIBC_2.2.5"); #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 #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 #ifdef _REENTRANT -__asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5"); + __asm__(".symver pthread_equal,pthread_equal@GLIBC_2.2.5"); #endif #ifdef _REENTRANT -__asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5"); + __asm__(".symver pthread_exit,pthread_exit@GLIBC_2.2.5"); #endif __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"); @@ -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_getname_np,pthread_getname_np@GLIBC_2.12"); #ifdef _REENTRANT -__asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5"); + __asm__(".symver pthread_getschedparam,pthread_getschedparam@GLIBC_2.2.5"); #endif #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 #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 #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 #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 __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_np,pthread_mutex_consistent_np@GLIBC_2.4"); #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 __asm__(".symver pthread_mutex_getprioceiling,pthread_mutex_getprioceiling@GLIBC_2.4"); #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 #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 __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_trylock,pthread_mutex_trylock@GLIBC_2.2.5"); #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 __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"); @@ -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_settype,pthread_mutexattr_settype@GLIBC_2.2.5"); #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 __asm__(".symver pthread_rwlock_destroy,pthread_rwlock_destroy@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_setpshared,pthread_rwlockattr_setpshared@GLIBC_2.2.5"); #ifdef _REENTRANT -__asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5"); + __asm__(".symver pthread_self,pthread_self@GLIBC_2.2.5"); #endif __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"); #ifdef _REENTRANT -__asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5"); + __asm__(".symver pthread_setcancelstate,pthread_setcancelstate@GLIBC_2.2.5"); #endif #ifdef _REENTRANT -__asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5"); + __asm__(".symver pthread_setcanceltype,pthread_setcanceltype@GLIBC_2.2.5"); #endif __asm__(".symver pthread_setconcurrency,pthread_setconcurrency@GLIBC_2.2.5"); __asm__(".symver pthread_setname_np,pthread_setname_np@GLIBC_2.12"); #ifdef _REENTRANT -__asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5"); + __asm__(".symver pthread_setschedparam,pthread_setschedparam@GLIBC_2.2.5"); #endif __asm__(".symver pthread_setschedprio,pthread_setschedprio@GLIBC_2.3.4"); #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 __asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2.5"); __asm__(".symver pthread_sigqueue,pthread_sigqueue@GLIBC_2.11"); diff --git a/include/helpers.hpp b/include/helpers.hpp index 1187d7c8..a1f9b5b3 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -17,49 +17,49 @@ namespace rack { template -plugin::Model *createModel(const std::string &slug) { +plugin::Model* createModel(const std::string& slug) { 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; return m; } - app::ModuleWidget *createModuleWidget() override { - TModule *m = new TModule; + app::ModuleWidget* createModuleWidget() override { + TModule* m = new TModule; m->engine::Module::model = this; - app::ModuleWidget *mw = new TModuleWidget(m); + app::ModuleWidget* mw = new TModuleWidget(m); mw->model = this; 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; return mw; } }; - plugin::Model *o = new TModel; + plugin::Model* o = new TModel; o->slug = slug; return o; } template -TWidget *createWidget(math::Vec pos) { - TWidget *o = new TWidget; +TWidget* createWidget(math::Vec pos) { + TWidget* o = new TWidget; o->box.pos = pos; return o; } template -TWidget *createWidgetCentered(math::Vec pos) { - TWidget *o = createWidget(pos); +TWidget* createWidgetCentered(math::Vec pos) { + TWidget* o = createWidget(pos); o->box.pos = o->box.pos.minus(o->box.size.div(2)); return o; } template -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; if (module) { o->paramQuantity = module->paramQuantities[paramId]; @@ -68,15 +68,15 @@ TParamWidget *createParam(math::Vec pos, engine::Module *module, int paramId) { } template -TParamWidget *createParamCentered(math::Vec pos, engine::Module *module, int paramId) { - TParamWidget *o = createParam(pos, module, paramId); +TParamWidget* createParamCentered(math::Vec pos, engine::Module* module, int paramId) { + TParamWidget* o = createParam(pos, module, paramId); o->box.pos = o->box.pos.minus(o->box.size.div(2)); return o; } template -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->module = module; o->type = app::PortWidget::INPUT; @@ -85,15 +85,15 @@ TPortWidget *createInput(math::Vec pos, engine::Module *module, int inputId) { } template -TPortWidget *createInputCentered(math::Vec pos, engine::Module *module, int inputId) { - TPortWidget *o = createInput(pos, module, inputId); +TPortWidget* createInputCentered(math::Vec pos, engine::Module* module, int inputId) { + TPortWidget* o = createInput(pos, module, inputId); o->box.pos = o->box.pos.minus(o->box.size.div(2)); return o; } template -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->module = module; o->type = app::PortWidget::OUTPUT; @@ -102,15 +102,15 @@ TPortWidget *createOutput(math::Vec pos, engine::Module *module, int outputId) { } template -TPortWidget *createOutputCentered(math::Vec pos, engine::Module *module, int outputId) { - TPortWidget *o = createOutput(pos, module, outputId); +TPortWidget* createOutputCentered(math::Vec pos, engine::Module* module, int outputId) { + TPortWidget* o = createOutput(pos, module, outputId); o->box.pos = o->box.pos.minus(o->box.size.div(2)); return o; } template -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->module = module; o->firstLightId = firstLightId; @@ -118,33 +118,33 @@ TModuleLightWidget *createLight(math::Vec pos, engine::Module *module, int first } template -TModuleLightWidget *createLightCentered(math::Vec pos, engine::Module *module, int firstLightId) { - TModuleLightWidget *o = createLight(pos, module, firstLightId); +TModuleLightWidget* createLightCentered(math::Vec pos, engine::Module* module, int firstLightId) { + TModuleLightWidget* o = createLight(pos, module, firstLightId); o->box.pos = o->box.pos.minus(o->box.size.div(2)); return o; } template -TMenuLabel *createMenuLabel(std::string text) { - TMenuLabel *o = new TMenuLabel; +TMenuLabel * createMenuLabel(std::string text) { + TMenuLabel* o = new TMenuLabel; o->text = text; return o; } template -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->rightText = rightText; return o; } template -TMenu *createMenu() { - TMenu *o = new TMenu; +TMenu * createMenu() { + TMenu* o = new TMenu; o->box.pos = APP->window->mousePos; - ui::MenuOverlay *menuOverlay = new ui::MenuOverlay; + ui::MenuOverlay* menuOverlay = new ui::MenuOverlay; menuOverlay->addChild(o); APP->scene->addChild(menuOverlay); diff --git a/include/history.hpp b/include/history.hpp index 6127ee9c..013f2f5b 100644 --- a/include/history.hpp +++ b/include/history.hpp @@ -11,8 +11,8 @@ namespace rack { namespace app { - struct ModuleWidget; - struct CableWidget; +struct ModuleWidget; +struct CableWidget; } // namespace app @@ -52,7 +52,7 @@ struct ComplexAction : Action { ~ComplexAction(); void undo() override; void redo() override; - void push(Action *action); + void push(Action* action); bool isEmpty(); }; @@ -66,14 +66,14 @@ struct ModuleAction : Action { struct ModuleAdd : ModuleAction { - plugin::Model *model; + plugin::Model* model; math::Vec pos; - json_t *moduleJ; + json_t* moduleJ; ModuleAdd() { name = "add module"; } ~ModuleAdd(); - void setModule(app::ModuleWidget *mw); + void setModule(app::ModuleWidget* mw); void undo() override; void redo() override; }; @@ -108,8 +108,8 @@ struct ModuleBypass : ModuleAction { struct ModuleChange : ModuleAction { - json_t *oldModuleJ; - json_t *newModuleJ; + json_t* oldModuleJ; + json_t* newModuleJ; ModuleChange() { name = "change module"; } @@ -138,7 +138,7 @@ struct CableAdd : Action { int inputModuleId; int inputId; NVGcolor color; - void setCable(app::CableWidget *cw); + void setCable(app::CableWidget* cw); void undo() override; void redo() override; CableAdd() { @@ -163,7 +163,7 @@ struct State { State(); ~State(); void clear(); - void push(Action *action); + void push(Action* action); void undo(); void redo(); bool canUndo(); diff --git a/include/logger.hpp b/include/logger.hpp index e35cc12f..9e94bfea 100644 --- a/include/logger.hpp +++ b/include/logger.hpp @@ -35,7 +35,7 @@ void destroy(); /** Do not use this function directly. Use the macros above. 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 diff --git a/include/math.hpp b/include/math.hpp index 95b2632b..8011ac05 100644 --- a/include/math.hpp +++ b/include/math.hpp @@ -64,7 +64,7 @@ inline int eucDiv(int a, int b) { 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; *mod = a % b; if (*mod < 0) { @@ -149,10 +149,10 @@ inline float crossfade(float a, float b, float p) { /** Linearly interpolates an array `p` with index `x`. 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; 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`. @@ -161,7 +161,7 @@ Example: 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; *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. */ bool isContaining(Vec v) const { 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. */ bool isContaining(Rect r) const { 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. */ bool isIntersecting(Rect r) const { 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 { return pos.isEqual(r.pos) && size.isEqual(r.size); @@ -365,22 +365,28 @@ struct Rect { 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 { 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 { 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)); } diff --git a/include/midi.hpp b/include/midi.hpp index fc1387b7..f1bd35d4 100644 --- a/include/midi.hpp +++ b/include/midi.hpp @@ -59,17 +59,31 @@ struct Output; struct Driver { virtual ~Driver() {} - virtual std::string getName() {return "";} + virtual std::string getName() { + return ""; + } - virtual std::vector 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 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 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 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 { std::set subscribed; - void subscribe(Input *input); - void unsubscribe(Input *input); + void subscribe(Input* input); + void unsubscribe(Input* input); void onMessage(Message message); }; struct OutputDevice : Device { std::set subscribed; - void subscribe(Output *input); - void unsubscribe(Output *input); + void subscribe(Output* input); + void unsubscribe(Output* input); virtual void sendMessage(Message message) {} }; @@ -108,7 +122,7 @@ struct Port { */ int channel = -1; /** Not owned */ - Driver *driver = NULL; + Driver* driver = NULL; /** Remember to call setDriverId(-1) in subclass destructors. */ virtual ~Port() {} @@ -125,14 +139,14 @@ struct Port { std::string getChannelName(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 { /** Not owned */ - InputDevice *inputDevice = NULL; + InputDevice* inputDevice = NULL; Input(); ~Input(); @@ -152,13 +166,13 @@ struct InputQueue : Input { std::queue queue; void onMessage(Message message) override; /** If a Message is available, writes `message` and return true */ - bool shift(Message *message); + bool shift(Message* message); }; struct Output : Port { /** Not owned */ - OutputDevice *outputDevice = NULL; + OutputDevice* outputDevice = NULL; Output(); ~Output(); @@ -176,7 +190,7 @@ struct Output : Port { void init(); void destroy(); /** Registers a new MIDI driver. Takes pointer ownership. */ -void addDriver(int driverId, Driver *driver); +void addDriver(int driverId, Driver* driver); } // namespace midi diff --git a/include/network.hpp b/include/network.hpp index 6e8484be..1843bb8d 100644 --- a/include/network.hpp +++ b/include/network.hpp @@ -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) 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 */ -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` */ -std::string encodeUrl(const std::string &s); +std::string encodeUrl(const std::string& s); /** Gets the path portion of the URL. */ -std::string urlPath(const std::string &url); +std::string urlPath(const std::string& url); } // namespace network diff --git a/include/patch.hpp b/include/patch.hpp index f6ff9712..48f8b1b6 100644 --- a/include/patch.hpp +++ b/include/patch.hpp @@ -30,8 +30,8 @@ struct PatchManager { /** Disconnects all cables */ void disconnectDialog(); - json_t *toJson(); - void fromJson(json_t *rootJ); + json_t* toJson(); + void fromJson(json_t* rootJ); bool isLegacy(int level); }; diff --git a/include/plugin.hpp b/include/plugin.hpp index cbe04424..3cd7f682 100644 --- a/include/plugin.hpp +++ b/include/plugin.hpp @@ -25,21 +25,21 @@ struct Update { void init(); void destroy(); -void logIn(const std::string &email, const std::string &password); +void logIn(const std::string& email, const std::string& password); void logOut(); bool isLoggedIn(); void queryUpdates(); bool hasUpdates(); -void syncUpdate(Update *update); +void syncUpdate(Update* update); void syncUpdates(); 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 "_" */ -bool isSlugValid(const std::string &slug); +bool isSlugValid(const std::string& slug); /** 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 allowedTags; diff --git a/include/plugin/Model.hpp b/include/plugin/Model.hpp index 5320a5ea..0e1f4b3f 100644 --- a/include/plugin/Model.hpp +++ b/include/plugin/Model.hpp @@ -9,12 +9,12 @@ namespace rack { namespace app { - struct ModuleWidget; +struct ModuleWidget; } // namespace app namespace engine { - struct Module; +struct Module; } // namespace engine @@ -22,7 +22,7 @@ namespace plugin { struct Model { - Plugin *plugin = NULL; + Plugin* plugin = NULL; std::vector presetPaths; /** Must be unique. Used for saving patches. Never change this after releasing your module. @@ -38,13 +38,19 @@ struct Model { virtual ~Model() {} /** Creates a headless Module */ - virtual engine::Module *createModule() { return NULL; } + virtual engine::Module* createModule() { + return NULL; + } /** 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 */ - virtual app::ModuleWidget *createModuleWidgetNull() { return NULL; } + virtual app::ModuleWidget* createModuleWidgetNull() { + return NULL; + } - void fromJson(json_t *rootJ); + void fromJson(json_t* rootJ); }; diff --git a/include/plugin/Plugin.hpp b/include/plugin/Plugin.hpp index 2d3d98ef..c7fd2b7b 100644 --- a/include/plugin/Plugin.hpp +++ b/include/plugin/Plugin.hpp @@ -18,7 +18,7 @@ struct Plugin { /** The file path to the plugin's directory */ std::string path; /** OS-dependent library handle */ - void *handle = NULL; + void* handle = NULL; /** 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" @@ -63,9 +63,9 @@ struct Plugin { double modifiedTimestamp = -INFINITY; ~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); }; diff --git a/include/plugin/callbacks.hpp b/include/plugin/callbacks.hpp index 904e0f7f..7a72faa0 100644 --- a/include/plugin/callbacks.hpp +++ b/include/plugin/callbacks.hpp @@ -6,4 +6,4 @@ You must implement this in your plugin */ extern "C" -void init(rack::plugin::Plugin *plugin); +void init(rack::plugin::Plugin* plugin); diff --git a/include/rack.hpp b/include/rack.hpp index b15bb23e..98b10c24 100644 --- a/include/rack.hpp +++ b/include/rack.hpp @@ -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. */ #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 diff --git a/include/rack0.hpp b/include/rack0.hpp index 110538a7..17f7557e 100644 --- a/include/rack0.hpp +++ b/include/rack0.hpp @@ -17,35 +17,91 @@ namespace rack { 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 @@ -57,11 +113,21 @@ DEPRECATED inline void cmultf(float *cr, float *ci, float ar, float ai, float br // 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 @@ -77,23 +143,47 @@ DEPRECATED inline float randomf() {return random::uniform();} // 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 //////////////////// -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 @@ -118,14 +208,14 @@ DEPRECATED static const NVGcolor COLOR_DARK_PANEL = componentlibrary::SCHEME_DAR /** Use createWidget() instead */ template -DEPRECATED TScrew *createScrew(math::Vec pos) { +DEPRECATED TScrew* createScrew(math::Vec pos) { return createWidget(pos); } /** Use createParam(pos, module, paramId) and set the Param properties in your Module constructor */ template -DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { - TParamWidget *o = createParam(pos, module, paramId); +DEPRECATED TParamWidget* createParam(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) { + TParamWidget* o = createParam(pos, module, paramId); if (module) { module->configParam(paramId, minValue, maxValue, defaultValue); } @@ -133,8 +223,8 @@ DEPRECATED TParamWidget *createParam(math::Vec pos, Module *module, int paramId, } template -DEPRECATED TParamWidget *createParamCentered(math::Vec pos, Module *module, int paramId, float minValue, float maxValue, float defaultValue) { - TParamWidget *o = createParamCentered(pos, module, paramId); +DEPRECATED TParamWidget* createParamCentered(math::Vec pos, Module* module, int paramId, float minValue, float maxValue, float defaultValue) { + TParamWidget* o = createParamCentered(pos, module, paramId); if (module) { 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 */ template -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->type = type; o->module = module; diff --git a/include/settings.hpp b/include/settings.hpp index 36059752..767e0cd8 100644 --- a/include/settings.hpp +++ b/include/settings.hpp @@ -41,10 +41,10 @@ extern bool skipLoadOnLaunch; extern std::string patchPath; extern std::vector 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 diff --git a/include/simd/sse_mathfun.h b/include/simd/sse_mathfun.h index 6276d489..5d12bd1f 100644 --- a/include/simd/sse_mathfun.h +++ b/include/simd/sse_mathfun.h @@ -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.. 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; __m128i emm0, emm2, emm4; sign_bit_sin = x; diff --git a/include/simd/vector.hpp b/include/simd/vector.hpp index 5a92a3c1..8508e7dc 100644 --- a/include/simd/vector.hpp +++ b/include/simd/vector.hpp @@ -63,13 +63,13 @@ struct Vector { /** Returns a vector with all 1 bits. */ 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. 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. This post seems to agree. https://stackoverflow.com/a/20265193/272642 @@ -81,12 +81,16 @@ struct Vector { /** 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]`. */ - void store(float *x) { + void store(float* x) { _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 Vector(Vector a); @@ -119,18 +123,22 @@ struct Vector { static Vector mask() { 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 // Use _mm_loadu_si128() because GCC doesn't support _mm_loadu_si32() return Vector(_mm_loadu_si128((__m128i*) x)); } - void store(int32_t *x) { + void store(int32_t* x) { // HACK // Use _mm_storeu_si128() because GCC doesn't support _mm_storeu_si32() _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 a); static Vector cast(Vector a); }; @@ -160,21 +168,21 @@ inline Vector Vector::cast(Vector a) { /** `~a & b` */ -inline Vector andnot(const Vector &a, const Vector &b) { +inline Vector andnot(const Vector& a, const Vector& b) { return Vector(_mm_andnot_ps(a.v, b.v)); } /** Returns an integer with each bit corresponding to the most significant bit of each element. For example, `movemask(float_4::mask())` returns 0xf. */ -inline int movemask(const Vector &a) { +inline int movemask(const Vector& a) { return _mm_movemask_ps(a.v); } /** Returns an integer with each bit corresponding to the most significant bit of each byte. For example, `movemask(int32_4::mask())` returns 0xffff. */ -inline int movemask(const Vector &a) { +inline int movemask(const Vector& a) { 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(float, 4, operator>=, _mm_cmpge_ps) -inline Vector operator>=(const Vector &a, const Vector &b) { +inline Vector operator>=(const Vector& a, const Vector& b) { return Vector(_mm_cmpgt_epi32(a.v, b.v)) ^ Vector::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(float, 4, operator<=, _mm_cmple_ps) -inline Vector operator<=(const Vector &a, const Vector &b) { +inline Vector operator<=(const Vector& a, const Vector& b) { return Vector(_mm_cmplt_epi32(a.v, b.v)) ^ Vector::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(float, 4, operator!=, _mm_cmpneq_ps) -inline Vector operator!=(const Vector &a, const Vector &b) { +inline Vector operator!=(const Vector& a, const Vector& b) { return Vector(_mm_cmpeq_epi32(a.v, b.v)) ^ Vector::mask(); } /** `+a` */ -inline Vector operator+(const Vector &a) { +inline Vector operator+(const Vector& a) { return a; } -inline Vector operator+(const Vector &a) { +inline Vector operator+(const Vector& a) { return a; } /** `-a` */ -inline Vector operator-(const Vector &a) { +inline Vector operator-(const Vector& a) { return 0.f - a; } -inline Vector operator-(const Vector &a) { +inline Vector operator-(const Vector& a) { return 0 - a; } /** `++a` */ -inline Vector &operator++(Vector &a) { +inline Vector& operator++(Vector& a) { a += 1.f; return a; } -inline Vector &operator++(Vector &a) { +inline Vector& operator++(Vector& a) { a += 1; return a; } /** `--a` */ -inline Vector &operator--(Vector &a) { +inline Vector& operator--(Vector& a) { a -= 1.f; return a; } -inline Vector &operator--(Vector &a) { +inline Vector& operator--(Vector& a) { a -= 1; return a; } /** `a++` */ -inline Vector operator++(Vector &a, int) { +inline Vector operator++(Vector& a, int) { Vector b = a; ++a; return b; } -inline Vector operator++(Vector &a, int) { +inline Vector operator++(Vector& a, int) { Vector b = a; ++a; return b; } /** `a--` */ -inline Vector operator--(Vector &a, int) { +inline Vector operator--(Vector& a, int) { Vector b = a; --a; return b; } -inline Vector operator--(Vector &a, int) { +inline Vector operator--(Vector& a, int) { Vector b = a; --a; return b; } /** `~a` */ -inline Vector operator~(const Vector &a) { +inline Vector operator~(const Vector& a) { return a ^ Vector::mask(); } -inline Vector operator~(const Vector &a) { +inline Vector operator~(const Vector& a) { return a ^ Vector::mask(); } diff --git a/include/string.hpp b/include/string.hpp index 1cd6d8a9..86708d5b 100644 --- a/include/string.hpp +++ b/include/string.hpp @@ -11,55 +11,55 @@ namespace 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. 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 */ -std::string lowercase(const std::string &s); +std::string lowercase(const std::string& s); /** 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. */ -std::string trim(const std::string &s); +std::string trim(const std::string& s); /** 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. Example: directory("dir/file.txt") // "dir" Calls POSIX dirname(). */ -std::string directory(const std::string &path); +std::string directory(const std::string& path); /** Extracts the filename of the path. Example: directory("dir/file.txt") // "file.txt" 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. Example: filenameBase("file.txt") // "file" 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. Example: filenameExtension("file.txt") // "txt" 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 "" 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. A score of 0 means no match. 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 { - 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); } }; diff --git a/include/svg.hpp b/include/svg.hpp index b8e3110b..a035f3b4 100644 --- a/include/svg.hpp +++ b/include/svg.hpp @@ -7,7 +7,7 @@ namespace rack { -void svgDraw(NVGcontext *vg, NSVGimage *svg); +void svgDraw(NVGcontext* vg, NSVGimage* svg); } // namespace rack diff --git a/include/system.hpp b/include/system.hpp index 81df2fd0..2f7ab920 100644 --- a/include/system.hpp +++ b/include/system.hpp @@ -12,23 +12,23 @@ namespace system { /** Returns a list of all entries (directories, files, symbols) in a directory. */ -std::list getEntries(const std::string &path); +std::list getEntries(const std::string& path); /** 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. */ -bool isDirectory(const std::string &path); +bool isDirectory(const std::string& path); /** 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. */ -void copyFile(const std::string &srcPath, const std::string &destPath); +void copyFile(const std::string& srcPath, const std::string& destPath); /** Creates a directory. 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. */ int getLogicalCoreCount(); /** 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. */ void setThreadRealTime(bool realTime); /** 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. 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. */ -void openFolder(const std::string &path); +void openFolder(const std::string& path); /** Runs an executable without blocking. 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(); diff --git a/include/ui/Button.hpp b/include/ui/Button.hpp index d3a6b479..ecf9cdb2 100644 --- a/include/ui/Button.hpp +++ b/include/ui/Button.hpp @@ -11,13 +11,13 @@ namespace ui { struct Button : widget::OpaqueWidget { std::string text; /** Not owned. Tracks the pressed state of the button.*/ - Quantity *quantity = NULL; + Quantity* quantity = NULL; 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; }; diff --git a/include/ui/ChoiceButton.hpp b/include/ui/ChoiceButton.hpp index c068b407..e64123c1 100644 --- a/include/ui/ChoiceButton.hpp +++ b/include/ui/ChoiceButton.hpp @@ -8,7 +8,7 @@ namespace ui { struct ChoiceButton : Button { - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/ui/IconButton.hpp b/include/ui/IconButton.hpp index f6bd47de..01d540d4 100644 --- a/include/ui/IconButton.hpp +++ b/include/ui/IconButton.hpp @@ -10,12 +10,14 @@ namespace ui { struct IconButton : Button { - widget::FramebufferWidget *fw; - widget::SvgWidget *sw; + widget::FramebufferWidget* fw; + widget::SvgWidget* sw; IconButton(); void setSvg(std::shared_ptr svg); - DEPRECATED void setSVG(std::shared_ptr svg) {setSvg(svg);} + DEPRECATED void setSVG(std::shared_ptr svg) { + setSvg(svg); + } }; diff --git a/include/ui/Label.hpp b/include/ui/Label.hpp index 72de8428..6218e458 100644 --- a/include/ui/Label.hpp +++ b/include/ui/Label.hpp @@ -20,7 +20,7 @@ struct Label : widget::Widget { Alignment alignment = LEFT_ALIGNMENT; Label(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/ui/Menu.hpp b/include/ui/Menu.hpp index fb503ea5..01e4a3af 100644 --- a/include/ui/Menu.hpp +++ b/include/ui/Menu.hpp @@ -9,17 +9,17 @@ namespace ui { struct Menu : widget::OpaqueWidget { - Menu *parentMenu = NULL; - Menu *childMenu = NULL; + Menu* parentMenu = NULL; + Menu* childMenu = NULL; /** The entry which created the child menu */ - MenuEntry *activeEntry = NULL; + MenuEntry* activeEntry = NULL; Menu(); ~Menu(); - void setChildMenu(Menu *menu); + void setChildMenu(Menu* menu); 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; }; diff --git a/include/ui/MenuItem.hpp b/include/ui/MenuItem.hpp index 0ad5e4ac..574f98db 100644 --- a/include/ui/MenuItem.hpp +++ b/include/ui/MenuItem.hpp @@ -15,12 +15,14 @@ struct MenuItem : MenuEntry { bool disabled = false; bool active = false; - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) 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(); - virtual Menu *createChildMenu() {return NULL;} + virtual Menu* createChildMenu() { + return NULL; + } }; diff --git a/include/ui/MenuLabel.hpp b/include/ui/MenuLabel.hpp index 789a455c..1e653e63 100644 --- a/include/ui/MenuLabel.hpp +++ b/include/ui/MenuLabel.hpp @@ -10,7 +10,7 @@ namespace ui { struct MenuLabel : MenuEntry { std::string text; - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; void step() override; }; diff --git a/include/ui/MenuOverlay.hpp b/include/ui/MenuOverlay.hpp index 98590426..53b5ec45 100644 --- a/include/ui/MenuOverlay.hpp +++ b/include/ui/MenuOverlay.hpp @@ -10,8 +10,8 @@ namespace ui { /** Deletes itself from parent when clicked */ struct MenuOverlay : widget::OpaqueWidget { 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; }; diff --git a/include/ui/MenuSeparator.hpp b/include/ui/MenuSeparator.hpp index a51bae47..888136ad 100644 --- a/include/ui/MenuSeparator.hpp +++ b/include/ui/MenuSeparator.hpp @@ -9,7 +9,7 @@ namespace ui { struct MenuSeparator : MenuEntry { MenuSeparator(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/ui/PasswordField.hpp b/include/ui/PasswordField.hpp index df6e91d6..e3d81000 100644 --- a/include/ui/PasswordField.hpp +++ b/include/ui/PasswordField.hpp @@ -8,7 +8,7 @@ namespace ui { struct PasswordField : TextField { - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/ui/ProgressBar.hpp b/include/ui/ProgressBar.hpp index 015292b2..f300629f 100644 --- a/include/ui/ProgressBar.hpp +++ b/include/ui/ProgressBar.hpp @@ -10,10 +10,10 @@ namespace ui { struct ProgressBar : widget::Widget { /** Not owned. Stores the progress value and label. */ - Quantity *quantity = NULL; + Quantity* quantity = NULL; ProgressBar(); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/ui/RadioButton.hpp b/include/ui/RadioButton.hpp index 6c6bdbf6..01bd26f5 100644 --- a/include/ui/RadioButton.hpp +++ b/include/ui/RadioButton.hpp @@ -12,11 +12,11 @@ namespace ui { struct RadioButton : widget::OpaqueWidget { /** Not owned. */ - Quantity *quantity = NULL; + Quantity* quantity = NULL; 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; }; diff --git a/include/ui/ScrollBar.hpp b/include/ui/ScrollBar.hpp index d928c6c4..daa3d1b4 100644 --- a/include/ui/ScrollBar.hpp +++ b/include/ui/ScrollBar.hpp @@ -18,10 +18,10 @@ struct ScrollBar : widget::OpaqueWidget { float size = 0.0; 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; }; diff --git a/include/ui/ScrollWidget.hpp b/include/ui/ScrollWidget.hpp index e50356f2..1a40bf8a 100644 --- a/include/ui/ScrollWidget.hpp +++ b/include/ui/ScrollWidget.hpp @@ -10,19 +10,19 @@ namespace ui { /** Handles a container with ScrollBar */ struct ScrollWidget : widget::OpaqueWidget { - widget::Widget *container; - ScrollBar *horizontalScrollBar; - ScrollBar *verticalScrollBar; + widget::Widget* container; + ScrollBar* horizontalScrollBar; + ScrollBar* verticalScrollBar; math::Vec offset; ScrollWidget(); void scrollTo(math::Rect r); - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) 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; }; diff --git a/include/ui/Slider.hpp b/include/ui/Slider.hpp index 1a66ca6d..a781eef6 100644 --- a/include/ui/Slider.hpp +++ b/include/ui/Slider.hpp @@ -11,14 +11,14 @@ namespace ui { struct Slider : widget::OpaqueWidget { /** Not owned. */ - Quantity *quantity = NULL; + Quantity* quantity = NULL; 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; }; diff --git a/include/ui/TextField.hpp b/include/ui/TextField.hpp index 1bfcca22..6bf63d94 100644 --- a/include/ui/TextField.hpp +++ b/include/ui/TextField.hpp @@ -20,11 +20,11 @@ struct TextField : widget::OpaqueWidget { int selection = 0; 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 */ void insertText(std::string text); diff --git a/include/ui/Tooltip.hpp b/include/ui/Tooltip.hpp index e4a0bd0d..22e66e68 100644 --- a/include/ui/Tooltip.hpp +++ b/include/ui/Tooltip.hpp @@ -11,7 +11,7 @@ struct Tooltip : widget::Widget { std::string text; void step() override; - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/widget/FramebufferWidget.hpp b/include/widget/FramebufferWidget.hpp index 33032c26..e83ec25b 100644 --- a/include/widget/FramebufferWidget.hpp +++ b/include/widget/FramebufferWidget.hpp @@ -15,7 +15,7 @@ struct FramebufferWidget : Widget { bool dirty = true; bool bypass = false; float oversample = 1.0; - NVGLUframebuffer *fb = NULL; + NVGLUframebuffer* fb = NULL; /** Scale relative to the world */ math::Vec scale; /** Offset in world coordinates */ @@ -34,7 +34,7 @@ struct FramebufferWidget : Widget { FramebufferWidget(); ~FramebufferWidget(); void step() override; - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; virtual void drawFramebuffer(); int getImageHandle(); }; diff --git a/include/widget/OpaqueWidget.hpp b/include/widget/OpaqueWidget.hpp index 8fbab334..32f4becd 100644 --- a/include/widget/OpaqueWidget.hpp +++ b/include/widget/OpaqueWidget.hpp @@ -10,14 +10,14 @@ namespace widget { Also consumes Hover and Button for left-clicks. */ struct OpaqueWidget : Widget { - void onHover(const event::Hover &e) override { + void onHover(const event::Hover& e) override { Widget::onHover(e); e.stopPropagating(); // Consume if not consumed by child if (!e.isConsumed()) e.consume(this); } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { Widget::onButton(e); e.stopPropagating(); if (e.button == GLFW_MOUSE_BUTTON_LEFT) { @@ -26,26 +26,26 @@ struct OpaqueWidget : Widget { e.consume(this); } } - void onHoverKey(const event::HoverKey &e) override { + void onHoverKey(const event::HoverKey& e) override { Widget::onHoverKey(e); e.stopPropagating(); } - void onHoverText(const event::HoverText &e) override { + void onHoverText(const event::HoverText& e) override { Widget::onHoverText(e); e.stopPropagating(); } - void onHoverScroll(const event::HoverScroll &e) override { + void onHoverScroll(const event::HoverScroll& e) override { Widget::onHoverScroll(e); e.stopPropagating(); } - void onDragHover(const event::DragHover &e) override { + void onDragHover(const event::DragHover& e) override { Widget::onDragHover(e); e.stopPropagating(); // Consume if not consumed by child if (!e.isConsumed()) e.consume(this); } - void onPathDrop(const event::PathDrop &e) override { + void onPathDrop(const event::PathDrop& e) override { Widget::onPathDrop(e); e.stopPropagating(); } diff --git a/include/widget/SvgWidget.hpp b/include/widget/SvgWidget.hpp index d9aef3b0..799b64cd 100644 --- a/include/widget/SvgWidget.hpp +++ b/include/widget/SvgWidget.hpp @@ -16,9 +16,11 @@ struct SvgWidget : Widget { /** Sets and wraps the SVG */ void setSvg(std::shared_ptr svg); - DEPRECATED void setSVG(std::shared_ptr svg) {setSvg(svg);} + DEPRECATED void setSVG(std::shared_ptr svg) { + setSvg(svg); + } - void draw(const DrawArgs &args) override; + void draw(const DrawArgs& args) override; }; diff --git a/include/widget/TransformWidget.hpp b/include/widget/TransformWidget.hpp index e6b0cdad..a9f2e099 100644 --- a/include/widget/TransformWidget.hpp +++ b/include/widget/TransformWidget.hpp @@ -37,7 +37,7 @@ struct TransformWidget : Widget { 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 nvgTransform(args.vg, transform[0], transform[1], transform[2], transform[3], transform[4], transform[5]); Widget::draw(args); diff --git a/include/widget/TransparentWidget.hpp b/include/widget/TransparentWidget.hpp index ad82c8f4..c30913f6 100644 --- a/include/widget/TransparentWidget.hpp +++ b/include/widget/TransparentWidget.hpp @@ -9,13 +9,13 @@ namespace widget { /** A Widget that does not respond to events and does not pass events to children */ struct TransparentWidget : Widget { /** 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 {} }; diff --git a/include/widget/Widget.hpp b/include/widget/Widget.hpp index 665fd79e..3ada076c 100644 --- a/include/widget/Widget.hpp +++ b/include/widget/Widget.hpp @@ -23,7 +23,7 @@ struct Widget { /** Stores position and size */ math::Rect box = math::Rect(math::Vec(), math::Vec(INFINITY, INFINITY)); /** Automatically set when Widget is added as a child to another Widget */ - Widget *parent = NULL; + Widget* parent = NULL; std::list children; /** Disables rendering but allow stepping */ bool visible = true; @@ -40,7 +40,7 @@ struct Widget { virtual math::Rect getChildrenBoundingBox(); /** 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 */ math::Vec getAbsoluteOffset(math::Vec v) { return getRelativeOffset(v, NULL); @@ -49,20 +49,24 @@ struct Widget { virtual math::Rect getViewport(math::Rect r); template - T *getAncestorOfType() { - if (!parent) return NULL; - T *p = dynamic_cast(parent); - if (p) return p; + T* getAncestorOfType() { + if (!parent) + return NULL; + T* p = dynamic_cast(parent); + if (p) + return p; return parent->getAncestorOfType(); } template - T *getFirstDescendantOfType() { - for (Widget *child : children) { - T *c = dynamic_cast(child); - if (c) return c; + T* getFirstDescendantOfType() { + for (Widget* child : children) { + T* c = dynamic_cast(child); + if (c) + return c; c = child->getFirstDescendantOfType(); - if (c) return c; + if (c) + return c; } return NULL; } @@ -70,12 +74,12 @@ struct Widget { /** Adds widget to list of children. 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. Does not delete widget but transfers ownership to caller */ - void removeChild(Widget *child); + void removeChild(Widget* child); /** Removes and deletes all children */ void clearChildren(); @@ -83,26 +87,26 @@ struct Widget { virtual void step(); struct DrawArgs { - NVGcontext *vg; + NVGcontext* vg; math::Rect clipBox; - NVGLUframebuffer *fb = NULL; + NVGLUframebuffer* fb = NULL; }; /** 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 */ - DEPRECATED virtual void draw(NVGcontext *vg) {} + DEPRECATED virtual void draw(NVGcontext* vg) {} // Events /** Recurses an event to all visible Widgets */ template - void recurseEvent(TMethod f, const TEvent &e) { + void recurseEvent(TMethod f, const TEvent& e) { for (auto it = children.rbegin(); it != children.rend(); it++) { // Stop propagation if requested if (!e.isPropagating()) break; - Widget *child = *it; + Widget* child = *it; // Filter child by visibility if (!child->visible) continue; @@ -116,12 +120,12 @@ struct Widget { /** Recurses an event to all visible Widgets until it is consumed. */ template - void recursePositionEvent(TMethod f, const TEvent &e) { + void recursePositionEvent(TMethod f, const TEvent& e) { for (auto it = children.rbegin(); it != children.rend(); it++) { // Stop propagation if requested if (!e.isPropagating()) break; - Widget *child = *it; + Widget* child = *it; // Filter child by visibility and position if (!child->visible) continue; @@ -139,35 +143,55 @@ struct Widget { /** Override these event callbacks to respond to events. 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); + } }; diff --git a/include/widget/ZoomWidget.hpp b/include/widget/ZoomWidget.hpp index 89fc2a48..10003720 100644 --- a/include/widget/ZoomWidget.hpp +++ b/include/widget/ZoomWidget.hpp @@ -10,42 +10,42 @@ namespace widget { struct ZoomWidget : Widget { 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; 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; e2.pos = e.pos.div(zoom); Widget::onHover(e2); } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { event::Button e2 = e; e2.pos = e.pos.div(zoom); Widget::onButton(e2); } - void onHoverKey(const event::HoverKey &e) override { + void onHoverKey(const event::HoverKey& e) override { event::HoverKey e2 = e; e2.pos = e.pos.div(zoom); Widget::onHoverKey(e2); } - void onHoverText(const event::HoverText &e) override { + void onHoverText(const event::HoverText& e) override { event::HoverText e2 = e; e2.pos = e.pos.div(zoom); Widget::onHoverText(e2); } - void onHoverScroll(const event::HoverScroll &e) override { + void onHoverScroll(const event::HoverScroll& e) override { event::HoverScroll e2 = e; e2.pos = e.pos.div(zoom); Widget::onHoverScroll(e2); } - void onDragHover(const event::DragHover &e) override { + void onDragHover(const event::DragHover& e) override { event::DragHover e2 = e; e2.pos = e.pos.div(zoom); Widget::onDragHover(e2); } - void onPathDrop(const event::PathDrop &e) override { + void onPathDrop(const event::PathDrop& e) override { event::PathDrop e2 = e; e2.pos = e.pos.div(zoom); Widget::onPathDrop(e2); diff --git a/include/window.hpp b/include/window.hpp index 150e2254..c9fa36d6 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -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. struct Font { - NVGcontext *vg; + NVGcontext* vg; int handle = -1; /** 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(); /** Use `APP->window->loadFont()` instead. */ - DEPRECATED static std::shared_ptr load(const std::string &filename); + DEPRECATED static std::shared_ptr load(const std::string& filename); }; struct Image { - NVGcontext *vg; + NVGcontext* vg; int handle = -1; /** 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(); /** Use `APP->window->loadImage()` instead. */ - DEPRECATED static std::shared_ptr load(const std::string &filename); + DEPRECATED static std::shared_ptr load(const std::string& filename); }; struct Svg { - NSVGimage *handle = NULL; + NSVGimage* handle = NULL; /** Don't call this directly but instead use `APP->window->loadSvg()` */ - void loadFile(const std::string &filename); + void loadFile(const std::string& filename); ~Svg(); /** Use `APP->window->loadSvg()` instead. */ - DEPRECATED static std::shared_ptr load(const std::string &filename); + DEPRECATED static std::shared_ptr load(const std::string& filename); }; DEPRECATED typedef Svg SVG; struct Window { - GLFWwindow *win = NULL; - NVGcontext *vg = NULL; + GLFWwindow* win = NULL; + NVGcontext* vg = NULL; /** The scaling ratio */ float pixelRatio = 1.f; /* The ratio between the framebuffer size and the window size reported by the OS. @@ -72,7 +72,7 @@ struct Window { std::map> svgCache; struct Internal; - Internal *internal; + Internal* internal; Window(); ~Window(); @@ -90,9 +90,9 @@ struct Window { bool isFullScreen(); bool isFrameOverdue(); - std::shared_ptr loadFont(const std::string &filename); - std::shared_ptr loadImage(const std::string &filename); - std::shared_ptr loadSvg(const std::string &filename); + std::shared_ptr loadFont(const std::string& filename); + std::shared_ptr loadImage(const std::string& filename); + std::shared_ptr loadSvg(const std::string& filename); }; diff --git a/src/app.cpp b/src/app.cpp index 063d0c78..52a6e912 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -24,22 +24,28 @@ void App::init() { App::~App() { // Set pointers to NULL so other objects will segfault when attempting to access them - if (scene) delete scene; + if (scene) + delete scene; scene = NULL; - if (patch) delete patch; + if (patch) + delete patch; patch = NULL; - if (event) delete event; + if (event) + delete event; event = NULL; - if (history) delete history; + if (history) + delete history; history = NULL; - if (window) delete window; + if (window) + delete window; window = NULL; - if (engine) delete engine; + if (engine) + delete engine; engine = NULL; } -static App *appInstance = NULL; +static App* appInstance = NULL; void appInit() { assert(!appInstance); @@ -53,7 +59,7 @@ void appDestroy() { appInstance = NULL; } -App *appGet() { +App* appGet() { return appInstance; } diff --git a/src/app/AudioWidget.cpp b/src/app/AudioWidget.cpp index aebc8b85..65667471 100644 --- a/src/app/AudioWidget.cpp +++ b/src/app/AudioWidget.cpp @@ -7,23 +7,23 @@ namespace app { struct AudioDriverItem : ui::MenuItem { - audio::Port *port; + audio::Port* port; int driverId; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setDriverId(driverId); } }; 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) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("Audio driver")); for (int driverId : port->getDriverIds()) { - AudioDriverItem *item = new AudioDriverItem; + AudioDriverItem* item = new AudioDriverItem; item->port = port; item->driverId = driverId; item->text = port->getDriverName(driverId); @@ -47,28 +47,28 @@ struct AudioDriverChoice : LedDisplayChoice { struct AudioDeviceItem : ui::MenuItem { - audio::Port *port; + audio::Port* port; int deviceId; int offset; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setDeviceId(deviceId, offset); } }; struct AudioDeviceChoice : LedDisplayChoice { - audio::Port *port; + audio::Port* port; /** Prevents devices with a ridiculous number of channels from being displayed */ int maxTotalChannels = 128; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { if (!port) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("Audio device")); int deviceCount = port->getDeviceCount(); { - AudioDeviceItem *item = new AudioDeviceItem; + AudioDeviceItem* item = new AudioDeviceItem; item->port = port; item->deviceId = -1; item->text = "(No device)"; @@ -78,7 +78,7 @@ struct AudioDeviceChoice : LedDisplayChoice { for (int deviceId = 0; deviceId < deviceCount; deviceId++) { int channels = std::min(maxTotalChannels, port->getDeviceChannels(deviceId)); for (int offset = 0; offset < channels; offset += port->maxChannels) { - AudioDeviceItem *item = new AudioDeviceItem; + AudioDeviceItem* item = new AudioDeviceItem; item->port = port; item->deviceId = deviceId; item->offset = offset; @@ -104,27 +104,27 @@ struct AudioDeviceChoice : LedDisplayChoice { struct AudioSampleRateItem : ui::MenuItem { - audio::Port *port; + audio::Port* port; int sampleRate; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setSampleRate(sampleRate); } }; 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) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("Sample rate")); std::vector sampleRates = port->getSampleRates(); if (sampleRates.empty()) { menu->addChild(createMenuLabel("(Locked by device)")); } for (int sampleRate : sampleRates) { - AudioSampleRateItem *item = new AudioSampleRateItem; + AudioSampleRateItem* item = new AudioSampleRateItem; item->port = port; item->sampleRate = sampleRate; item->text = string::f("%g kHz", sampleRate / 1000.0); @@ -145,27 +145,27 @@ struct AudioSampleRateChoice : LedDisplayChoice { struct AudioBlockSizeItem : ui::MenuItem { - audio::Port *port; + audio::Port* port; int blockSize; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setBlockSize(blockSize); } }; 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) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("Block size")); std::vector blockSizes = port->getBlockSizes(); if (blockSizes.empty()) { menu->addChild(createMenuLabel("(Locked by device)")); } for (int blockSize : blockSizes) { - AudioBlockSizeItem *item = new AudioBlockSizeItem; + AudioBlockSizeItem* item = new AudioBlockSizeItem; item->port = port; item->blockSize = blockSize; 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(); math::Vec pos; - AudioDriverChoice *driverChoice = createWidget(pos); + AudioDriverChoice* driverChoice = createWidget(pos); driverChoice->box.size.x = box.size.x; driverChoice->port = port; addChild(driverChoice); @@ -202,7 +202,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { this->driverSeparator->box.size.x = box.size.x; addChild(this->driverSeparator); - AudioDeviceChoice *deviceChoice = createWidget(pos); + AudioDeviceChoice* deviceChoice = createWidget(pos); deviceChoice->box.size.x = box.size.x; deviceChoice->port = port; addChild(deviceChoice); @@ -213,7 +213,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { this->deviceSeparator->box.size.x = box.size.x; addChild(this->deviceSeparator); - AudioSampleRateChoice *sampleRateChoice = createWidget(pos); + AudioSampleRateChoice* sampleRateChoice = createWidget(pos); sampleRateChoice->box.size.x = box.size.x / 2; sampleRateChoice->port = port; addChild(sampleRateChoice); @@ -224,7 +224,7 @@ void AudioWidget::setAudioPort(audio::Port *port) { this->sampleRateSeparator->box.size.y = this->sampleRateChoice->box.size.y; addChild(this->sampleRateSeparator); - AudioBlockSizeChoice *bufferSizeChoice = createWidget(pos); + AudioBlockSizeChoice* bufferSizeChoice = createWidget(pos); bufferSizeChoice->box.pos.x = box.size.x / 2; bufferSizeChoice->box.size.x = box.size.x / 2; bufferSizeChoice->port = port; diff --git a/src/app/CableWidget.cpp b/src/app/CableWidget.cpp index 59976420..95186522 100644 --- a/src/app/CableWidget.cpp +++ b/src/app/CableWidget.cpp @@ -11,7 +11,7 @@ namespace rack { 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); // Plug solid @@ -32,7 +32,7 @@ static void drawPlug(NVGcontext *vg, math::Vec pos, NVGcolor color) { 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 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(); 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); // Adjust pos1 and pos2 to not draw over the plug @@ -99,7 +99,7 @@ bool CableWidget::isComplete() { return outputPort && inputPort; } -void CableWidget::setOutput(PortWidget *outputPort) { +void CableWidget::setOutput(PortWidget* outputPort) { this->outputPort = outputPort; if (outputPort) { 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; if (inputPort) { assert(inputPort->type == PortWidget::INPUT); @@ -141,9 +141,9 @@ math::Vec CableWidget::getInputPos() { } } -json_t *CableWidget::toJson() { +json_t* CableWidget::toJson() { 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, "outputModuleId", json_integer(cable->outputModule->id)); @@ -157,35 +157,41 @@ json_t *CableWidget::toJson() { return rootJ; } -void CableWidget::fromJson(json_t *rootJ) { +void CableWidget::fromJson(json_t* rootJ) { // 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); - ModuleWidget *outputModule = APP->scene->rack->getModule(outputModuleId); - if (!outputModule) return; + ModuleWidget* outputModule = APP->scene->rack->getModule(outputModuleId); + if (!outputModule) + return; // 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); - ModuleWidget *inputModule = APP->scene->rack->getModule(inputModuleId); - if (!inputModule) return; + ModuleWidget* inputModule = APP->scene->rack->getModule(inputModuleId); + if (!inputModule) + return; // 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); // 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); // Only set ID if unset if (cable->id < 0) { // 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. if (idJ) { cable->id = json_integer_value(idJ); @@ -199,13 +205,13 @@ void CableWidget::fromJson(json_t *rootJ) { setInput(inputModule->inputs[inputId]); } else { - for (PortWidget *port : outputModule->outputs) { + for (PortWidget* port : outputModule->outputs) { if (port->portId == outputId) { setOutput(port); break; } } - for (PortWidget *port : inputModule->inputs) { + for (PortWidget* port : inputModule->inputs) { if (port->portId == inputId) { setInput(port); break; @@ -215,7 +221,7 @@ void CableWidget::fromJson(json_t *rootJ) { if (!isComplete()) return; - json_t *colorJ = json_object_get(rootJ, "color"); + json_t* colorJ = json_object_get(rootJ, "color"); if (colorJ) { // 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)) @@ -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 tension = settings::cableTension; float thickness = 5; 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 if (output->channels > 1) { // 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); } -void CableWidget::drawPlugs(const DrawArgs &args) { +void CableWidget::drawPlugs(const DrawArgs& args) { math::Vec outputPos = getOutputPos(); math::Vec inputPos = getInputPos(); diff --git a/src/app/CircularShadow.cpp b/src/app/CircularShadow.cpp index f77e4506..56846777 100644 --- a/src/app/CircularShadow.cpp +++ b/src/app/CircularShadow.cpp @@ -10,12 +10,12 @@ CircularShadow::CircularShadow() { opacity = 0.15; } -void CircularShadow::draw(const DrawArgs &args) { +void CircularShadow::draw(const DrawArgs& args) { if (opacity <= 0.0) return; 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); float radius = center.x; NVGcolor icol = nvgRGBAf(0.0, 0.0, 0.0, opacity); diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index b0f2a63d..6b8c349e 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -12,7 +12,7 @@ namespace app { 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); float dist = e.pos.minus(c).norm(); 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); float dist = e.pos.minus(c).norm(); 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) return; @@ -42,7 +42,7 @@ void Knob::onDragStart(const event::DragStart &e) { APP->window->cursorLock(); } -void Knob::onDragEnd(const event::DragEnd &e) { +void Knob::onDragEnd(const event::DragEnd& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -52,7 +52,7 @@ void Knob::onDragEnd(const event::DragEnd &e) { float newValue = paramQuantity->getSmoothValue(); if (oldValue != newValue) { // Push ParamChange history action - history::ParamChange *h = new history::ParamChange; + history::ParamChange* h = new history::ParamChange; h->name = "move knob"; h->moduleId = paramQuantity->module->id; 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) return; diff --git a/src/app/LedDisplay.cpp b/src/app/LedDisplay.cpp index 2c8957ab..252c694d 100644 --- a/src/app/LedDisplay.cpp +++ b/src/app/LedDisplay.cpp @@ -8,7 +8,7 @@ namespace rack { namespace app { -void LedDisplay::draw(const DrawArgs &args) { +void LedDisplay::draw(const DrawArgs& args) { nvgBeginPath(args.vg); nvgRoundedRect(args.vg, 0, 0, box.size.x, box.size.y, 5.0); nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00)); @@ -24,7 +24,7 @@ LedDisplaySeparator::LedDisplaySeparator() { box.size = math::Vec(); } -void LedDisplaySeparator::draw(const DrawArgs &args) { +void LedDisplaySeparator::draw(const DrawArgs& args) { nvgBeginPath(args.vg); nvgMoveTo(args.vg, 0, 0); nvgLineTo(args.vg, box.size.x, box.size.y); @@ -42,7 +42,7 @@ LedDisplayChoice::LedDisplayChoice() { textOffset = math::Vec(10, 18); } -void LedDisplayChoice::draw(const DrawArgs &args) { +void LedDisplayChoice::draw(const DrawArgs& args) { nvgScissor(args.vg, RECT_ARGS(args.clipBox)); if (bgColor.a > 0.0) { nvgBeginPath(args.vg); @@ -62,7 +62,7 @@ void LedDisplayChoice::draw(const DrawArgs &args) { nvgResetScissor(args.vg); } -void LedDisplayChoice::onButton(const event::Button &e) { +void LedDisplayChoice::onButton(const event::Button& e) { OpaqueWidget::onButton(e); 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)); // Background @@ -98,8 +98,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) { int begin = std::min(cursor, selection); int end = (this == APP->event->selectedWidget) ? std::max(cursor, selection) : -1; 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); } @@ -110,8 +110,8 @@ void LedDisplayTextField::draw(const DrawArgs &args) { int LedDisplayTextField::getTextPosition(math::Vec mousePos) { bndSetFont(font->handle); 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); return textPos; } diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index 6a1ce934..2cf46933 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -6,12 +6,12 @@ namespace rack { namespace app { -void LightWidget::draw(const DrawArgs &args) { +void LightWidget::draw(const DrawArgs& args) { drawLight(args); drawHalo(args); } -void LightWidget::drawLight(const DrawArgs &args) { +void LightWidget::drawLight(const DrawArgs& args) { float radius = box.size.x / 2.0; nvgBeginPath(args.vg); @@ -37,12 +37,12 @@ void LightWidget::drawLight(const DrawArgs &args) { } } -void LightWidget::drawHalo(const DrawArgs &args) { +void LightWidget::drawHalo(const DrawArgs& args) { float radius = box.size.x / 2.0; float oradius = 4.0 * radius; nvgBeginPath(args.vg); - nvgRect(args.vg, radius - oradius, radius - oradius, 2*oradius, 2*oradius); + nvgRect(args.vg, radius - oradius, radius - oradius, 2 * oradius, 2 * oradius); NVGpaint paint; NVGcolor icol = color::mult(color, 0.07); diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 9b7681ad..9f5fcc53 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -29,7 +29,7 @@ struct MenuButton : ui::Button { box.size.x = bndLabelWidth(APP->window->vg, -1, text.c_str()) + 1.0; Widget::step(); } - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; @@ -41,7 +41,7 @@ struct MenuButton : ui::Button { }; struct NotificationIcon : widget::Widget { - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { nvgBeginPath(args.vg); float radius = 4; nvgCircle(args.vg, radius, radius, radius); @@ -54,8 +54,8 @@ struct NotificationIcon : widget::Widget { struct UrlItem : ui::MenuItem { std::string url; - void onAction(const event::Action &e) override { - std::thread t([=] { + void onAction(const event::Action& e) override { + std::thread t([ = ] { system::openBrowser(url); }); t.detach(); @@ -64,8 +64,8 @@ struct UrlItem : ui::MenuItem { struct FolderItem : ui::MenuItem { std::string path; - void onAction(const event::Action &e) override { - std::thread t([=] { + void onAction(const event::Action& e) override { + std::thread t([ = ] { system::openFolder(path); }); t.detach(); @@ -77,83 +77,83 @@ struct FolderItem : ui::MenuItem { //////////////////// struct NewItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->resetDialog(); } }; struct OpenItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->loadDialog(); } }; struct SaveItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->saveDialog(); } }; struct SaveAsItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->saveAsDialog(); } }; struct SaveTemplateItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->saveTemplateDialog(); } }; struct RevertItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->revertDialog(); } }; struct QuitItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->window->close(); } }; struct FileButton : MenuButton { - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; - NewItem *newItem = new NewItem; + NewItem* newItem = new NewItem; newItem->text = "New"; newItem->rightText = RACK_MOD_CTRL_NAME "+N"; menu->addChild(newItem); - OpenItem *openItem = new OpenItem; + OpenItem* openItem = new OpenItem; openItem->text = "Open"; openItem->rightText = RACK_MOD_CTRL_NAME "+O"; menu->addChild(openItem); - SaveItem *saveItem = new SaveItem; + SaveItem* saveItem = new SaveItem; saveItem->text = "Save"; saveItem->rightText = RACK_MOD_CTRL_NAME "+S"; menu->addChild(saveItem); - SaveAsItem *saveAsItem = new SaveAsItem; + SaveAsItem* saveAsItem = new SaveAsItem; saveAsItem->text = "Save as"; saveAsItem->rightText = RACK_MOD_CTRL_NAME "+Shift+S"; menu->addChild(saveAsItem); - SaveTemplateItem *saveTemplateItem = new SaveTemplateItem; + SaveTemplateItem* saveTemplateItem = new SaveTemplateItem; saveTemplateItem->text = "Save template"; menu->addChild(saveTemplateItem); - RevertItem *revertItem = new RevertItem; + RevertItem* revertItem = new RevertItem; revertItem->text = "Revert"; revertItem->rightText = RACK_MOD_CTRL_NAME "+" RACK_MOD_SHIFT_NAME "+O"; menu->addChild(revertItem); - QuitItem *quitItem = new QuitItem; + QuitItem* quitItem = new QuitItem; quitItem->text = "Quit"; quitItem->rightText = RACK_MOD_CTRL_NAME "+Q"; menu->addChild(quitItem); @@ -165,42 +165,42 @@ struct FileButton : MenuButton { //////////////////// struct UndoItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->history->undo(); } }; struct RedoItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->history->redo(); } }; struct DisconnectCablesItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->patch->disconnectDialog(); } }; struct EditButton : MenuButton { - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; - UndoItem *undoItem = new UndoItem; + UndoItem* undoItem = new UndoItem; undoItem->text = "Undo " + APP->history->getUndoName(); undoItem->rightText = RACK_MOD_CTRL_NAME "+Z"; undoItem->disabled = !APP->history->canUndo(); menu->addChild(undoItem); - RedoItem *redoItem = new RedoItem; + RedoItem* redoItem = new RedoItem; redoItem->text = "Redo " + APP->history->getRedoName(); redoItem->rightText = RACK_MOD_CTRL_NAME "+" RACK_MOD_SHIFT_NAME "+Z"; redoItem->disabled = !APP->history->canRedo(); menu->addChild(redoItem); - DisconnectCablesItem *disconnectCablesItem = new DisconnectCablesItem; + DisconnectCablesItem* disconnectCablesItem = new DisconnectCablesItem; disconnectCablesItem->text = "Clear cables"; menu->addChild(disconnectCablesItem); } @@ -217,13 +217,27 @@ struct ZoomQuantity : Quantity { float getValue() override { return settings::zoom; } - float getMinValue() override {return -2.0;} - float getMaxValue() override {return 2.0;} - float getDefaultValue() override {return 0.0;} - float getDisplayValue() override {return std::round(std::pow(2.f, getValue()) * 100);} - void setDisplayValue(float displayValue) override {setValue(std::log2(displayValue / 100));} - std::string getLabel() override {return "Zoom";} - std::string getUnit() override {return "%";} + float getMinValue() override { + return -2.0; + } + float getMaxValue() override { + return 2.0; + } + float getDefaultValue() override { + return 0.0; + } + float getDisplayValue() override { + return std::round(std::pow(2.f, getValue()) * 100); + } + void setDisplayValue(float displayValue) override { + setValue(std::log2(displayValue / 100)); + } + std::string getLabel() override { + return "Zoom"; + } + std::string getUnit() override { + return "%"; + } }; struct ZoomSlider : ui::Slider { @@ -242,11 +256,21 @@ struct CableOpacityQuantity : Quantity { float getValue() override { return settings::cableOpacity; } - float getDefaultValue() override {return 0.5;} - float getDisplayValue() override {return getValue() * 100;} - void setDisplayValue(float displayValue) override {setValue(displayValue / 100);} - std::string getLabel() override {return "Cable opacity";} - std::string getUnit() override {return "%";} + float getDefaultValue() override { + return 0.5; + } + float getDisplayValue() override { + return getValue() * 100; + } + void setDisplayValue(float displayValue) override { + setValue(displayValue / 100); + } + std::string getLabel() override { + return "Cable opacity"; + } + std::string getUnit() override { + return "%"; + } }; struct CableOpacitySlider : ui::Slider { @@ -265,9 +289,15 @@ struct CableTensionQuantity : Quantity { float getValue() override { return settings::cableTension; } - float getDefaultValue() override {return 0.5;} - std::string getLabel() override {return "Cable tension";} - int getDisplayPrecision() override {return 2;} + float getDefaultValue() override { + return 0.5; + } + std::string getLabel() override { + return "Cable tension"; + } + int getDisplayPrecision() override { + return 2; + } }; struct CableTensionSlider : ui::Slider { @@ -280,63 +310,63 @@ struct CableTensionSlider : ui::Slider { }; struct ParamTooltipItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::paramTooltip ^= true; } }; struct LockModulesItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::lockModules ^= true; } }; struct CursorLockItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::allowCursorLock ^= true; } }; struct FullscreenItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->window->setFullScreen(!APP->window->isFullScreen()); } }; struct ViewButton : MenuButton { - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; - ParamTooltipItem *paramTooltipItem = new ParamTooltipItem; + ParamTooltipItem* paramTooltipItem = new ParamTooltipItem; paramTooltipItem->text = "Parameter tooltips"; paramTooltipItem->rightText = CHECKMARK(settings::paramTooltip); menu->addChild(paramTooltipItem); - LockModulesItem *lockModulesItem = new LockModulesItem; + LockModulesItem* lockModulesItem = new LockModulesItem; lockModulesItem->text = "Lock modules"; lockModulesItem->rightText = CHECKMARK(settings::lockModules); menu->addChild(lockModulesItem); - CursorLockItem *cursorLockItem = new CursorLockItem; + CursorLockItem* cursorLockItem = new CursorLockItem; cursorLockItem->text = "Lock cursor while dragging"; cursorLockItem->rightText = CHECKMARK(settings::allowCursorLock); menu->addChild(cursorLockItem); - ZoomSlider *zoomSlider = new ZoomSlider; + ZoomSlider* zoomSlider = new ZoomSlider; zoomSlider->box.size.x = 200.0; menu->addChild(zoomSlider); - CableOpacitySlider *cableOpacitySlider = new CableOpacitySlider; + CableOpacitySlider* cableOpacitySlider = new CableOpacitySlider; cableOpacitySlider->box.size.x = 200.0; menu->addChild(cableOpacitySlider); - CableTensionSlider *cableTensionSlider = new CableTensionSlider; + CableTensionSlider* cableTensionSlider = new CableTensionSlider; cableTensionSlider->box.size.x = 200.0; menu->addChild(cableTensionSlider); - FullscreenItem *fullscreenItem = new FullscreenItem; + FullscreenItem* fullscreenItem = new FullscreenItem; fullscreenItem->text = "Fullscreen"; fullscreenItem->rightText = "F11"; if (APP->window->isFullScreen()) @@ -350,30 +380,30 @@ struct ViewButton : MenuButton { //////////////////// struct CpuMeterItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::cpuMeter ^= true; } }; struct EnginePauseItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { APP->engine->setPaused(!APP->engine->isPaused()); } }; struct SampleRateValueItem : ui::MenuItem { float sampleRate; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::sampleRate = sampleRate; APP->engine->setPaused(false); } }; struct SampleRateItem : ui::MenuItem { - ui::Menu *createChildMenu() override { - ui::Menu *menu = new ui::Menu; + ui::Menu* createChildMenu() override { + ui::Menu* menu = new ui::Menu; - EnginePauseItem *enginePauseItem = new EnginePauseItem; + EnginePauseItem* enginePauseItem = new EnginePauseItem; enginePauseItem->text = "Pause"; enginePauseItem->rightText = CHECKMARK(APP->engine->isPaused()); menu->addChild(enginePauseItem); @@ -384,7 +414,7 @@ struct SampleRateItem : ui::MenuItem { float sampleRate = (j == 0) ? 44100.f : 48000.f; sampleRate *= oversample; - SampleRateValueItem *item = new SampleRateValueItem; + SampleRateValueItem* item = new SampleRateValueItem; item->sampleRate = sampleRate; item->text = string::f("%g kHz", sampleRate / 1000.0); if (oversample > 1) @@ -399,7 +429,7 @@ struct SampleRateItem : ui::MenuItem { }; struct RealTimeItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::realTime ^= true; } }; @@ -415,23 +445,23 @@ struct ThreadCountValueItem : ui::MenuItem { text += " (lowest CPU usage)"; rightText = CHECKMARK(settings::threadCount == threadCount); } - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { settings::threadCount = threadCount; } }; struct ThreadCountItem : ui::MenuItem { - ui::Menu *createChildMenu() override { - ui::Menu *menu = new ui::Menu; + ui::Menu* createChildMenu() override { + ui::Menu* menu = new ui::Menu; - RealTimeItem *realTimeItem = new RealTimeItem; + RealTimeItem* realTimeItem = new RealTimeItem; realTimeItem->text = "Real-time priority"; realTimeItem->rightText = CHECKMARK(settings::realTime); menu->addChild(realTimeItem); int coreCount = system::getLogicalCoreCount(); for (int i = 1; i <= coreCount; i++) { - ThreadCountValueItem *item = new ThreadCountValueItem; + ThreadCountValueItem* item = new ThreadCountValueItem; item->setThreadCount(i); menu->addChild(item); } @@ -440,22 +470,22 @@ struct ThreadCountItem : ui::MenuItem { }; struct EngineButton : MenuButton { - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; - CpuMeterItem *cpuMeterItem = new CpuMeterItem; + CpuMeterItem* cpuMeterItem = new CpuMeterItem; cpuMeterItem->text = "Module timer"; cpuMeterItem->rightText = CHECKMARK(settings::cpuMeter); menu->addChild(cpuMeterItem); - SampleRateItem *sampleRateItem = new SampleRateItem; + SampleRateItem* sampleRateItem = new SampleRateItem; sampleRateItem->text = "Sample rate"; sampleRateItem->rightText = RIGHT_ARROW; menu->addChild(sampleRateItem); - ThreadCountItem *threadCount = new ThreadCountItem; + ThreadCountItem* threadCount = new ThreadCountItem; threadCount->text = "Threads"; threadCount->rightText = RIGHT_ARROW; menu->addChild(threadCount); @@ -469,8 +499,8 @@ struct EngineButton : MenuButton { static bool isLoggingIn = false; struct AccountEmailField : ui::TextField { - ui::TextField *passwordField; - void onSelectKey(const event::SelectKey &e) override { + ui::TextField* passwordField; + void onSelectKey(const event::SelectKey& e) override { if (e.action == GLFW_PRESS && e.key == GLFW_KEY_TAB) { APP->event->setSelected(passwordField); e.consume(this); @@ -482,9 +512,9 @@ struct AccountEmailField : ui::TextField { }; struct AccountPasswordField : ui::PasswordField { - ui::MenuItem *logInItem; + ui::MenuItem* logInItem; - void onSelectKey(const event::SelectKey &e) override { + void onSelectKey(const event::SelectKey& e) override { if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { logInItem->doAction(); e.consume(this); @@ -496,13 +526,13 @@ struct AccountPasswordField : ui::PasswordField { }; struct LogInItem : ui::MenuItem { - ui::TextField *emailField; - ui::TextField *passwordField; - void onAction(const event::Action &e) override { + ui::TextField* emailField; + ui::TextField* passwordField; + void onAction(const event::Action& e) override { isLoggingIn = true; std::string email = emailField->text; std::string password = passwordField->text; - std::thread t([=] { + std::thread t([ = ] { plugin::logIn(email, password); isLoggingIn = false; }); @@ -537,8 +567,8 @@ struct SyncItem : ui::MenuItem { MenuItem::step(); } - void onAction(const event::Action &e) override { - std::thread t([=] { + void onAction(const event::Action& e) override { + std::thread t([ = ] { plugin::syncUpdates(); }); t.detach(); @@ -547,23 +577,23 @@ struct SyncItem : ui::MenuItem { }; struct PluginSyncItem : ui::MenuItem { - plugin::Update *update; + plugin::Update* update; - void setUpdate(plugin::Update *update) { + void setUpdate(plugin::Update* update) { this->update = update; text = update->pluginName; - plugin::Plugin *p = plugin::getPlugin(update->pluginSlug); + plugin::Plugin* p = plugin::getPlugin(update->pluginSlug); if (p) { rightText += "v" + p->version + " → "; } rightText += "v" + update->version; } - ui::Menu *createChildMenu() override { + ui::Menu* createChildMenu() override { if (update->changelogUrl != "") { - ui::Menu *menu = new ui::Menu; + ui::Menu* menu = new ui::Menu; - UrlItem *changelogUrl = new UrlItem; + UrlItem* changelogUrl = new UrlItem; changelogUrl->text = "Changelog"; changelogUrl->url = update->changelogUrl; menu->addChild(changelogUrl); @@ -585,8 +615,8 @@ struct PluginSyncItem : ui::MenuItem { MenuItem::step(); } - void onAction(const event::Action &e) override { - std::thread t([=] { + void onAction(const event::Action& e) override { + std::thread t([ = ] { plugin::syncUpdate(update); }); t.detach(); @@ -595,7 +625,7 @@ struct PluginSyncItem : ui::MenuItem { }; struct LogOutItem : ui::MenuItem { - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { plugin::logOut(); } }; @@ -622,23 +652,23 @@ struct LibraryMenu : ui::Menu { addChild(createMenuLabel("Disabled in development mode")); } else if (!plugin::isLoggedIn()) { - UrlItem *registerItem = new UrlItem; + UrlItem* registerItem = new UrlItem; registerItem->text = "Register VCV account"; registerItem->url = "https://vcvrack.com/"; addChild(registerItem); - AccountEmailField *emailField = new AccountEmailField; + AccountEmailField* emailField = new AccountEmailField; emailField->placeholder = "Email"; emailField->box.size.x = 240.0; addChild(emailField); - AccountPasswordField *passwordField = new AccountPasswordField; + AccountPasswordField* passwordField = new AccountPasswordField; passwordField->placeholder = "Password"; passwordField->box.size.x = 240.0; emailField->passwordField = passwordField; addChild(passwordField); - LogInItem *logInItem = new LogInItem; + LogInItem* logInItem = new LogInItem; logInItem->emailField = emailField; logInItem->passwordField = passwordField; passwordField->logInItem = logInItem; @@ -647,28 +677,28 @@ struct LibraryMenu : ui::Menu { else { loggedIn = true; - UrlItem *manageItem = new UrlItem; + UrlItem* manageItem = new UrlItem; manageItem->text = "Manage plugins"; manageItem->url = "https://vcvrack.com/plugins.html"; addChild(manageItem); - LogOutItem *logOutItem = new LogOutItem; + LogOutItem* logOutItem = new LogOutItem; logOutItem->text = "Log out"; addChild(logOutItem); - SyncItem *syncItem = new SyncItem; + SyncItem* syncItem = new SyncItem; syncItem->text = "Update all"; addChild(syncItem); if (plugin::hasUpdates()) { addChild(new ui::MenuEntry); - ui::MenuLabel *updatesLabel = new ui::MenuLabel; + ui::MenuLabel* updatesLabel = new ui::MenuLabel; updatesLabel->text = "Updates"; addChild(updatesLabel); - for (plugin::Update &update : plugin::updates) { - PluginSyncItem *updateItem = new PluginSyncItem; + for (plugin::Update& update : plugin::updates) { + PluginSyncItem* updateItem = new PluginSyncItem; updateItem->setUpdate(&update); addChild(updateItem); } @@ -679,15 +709,15 @@ struct LibraryMenu : ui::Menu { struct LibraryButton : MenuButton { - NotificationIcon *notification; + NotificationIcon* notification; LibraryButton() { notification = new NotificationIcon; addChild(notification); } - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; } @@ -713,10 +743,10 @@ struct LibraryButton : MenuButton { //////////////////// struct UpdateItem : ui::MenuItem { - ui::Menu *createChildMenu() override { - ui::Menu *menu = new ui::Menu; + ui::Menu* createChildMenu() override { + ui::Menu* menu = new ui::Menu; - UrlItem *changelogUrl = new UrlItem; + UrlItem* changelogUrl = new UrlItem; changelogUrl->text = "Changelog"; changelogUrl->url = updater::changelogUrl; menu->addChild(changelogUrl); @@ -731,8 +761,8 @@ struct UpdateItem : ui::MenuItem { MenuItem::step(); } - void onAction(const event::Action &e) override { - std::thread t([=] { + void onAction(const event::Action& e) override { + std::thread t([ = ] { updater::update(); }); t.detach(); @@ -742,37 +772,37 @@ struct UpdateItem : ui::MenuItem { struct HelpButton : MenuButton { - NotificationIcon *notification; + NotificationIcon* notification; HelpButton() { notification = new NotificationIcon; addChild(notification); } - void onAction(const event::Action &e) override { - ui::Menu *menu = createMenu(); + void onAction(const event::Action& e) override { + ui::Menu* menu = createMenu(); menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); menu->box.size.x = box.size.x; if (updater::isUpdateAvailable()) { - UpdateItem *updateItem = new UpdateItem; + UpdateItem* updateItem = new UpdateItem; updateItem->text = "Update " + APP_NAME; updateItem->rightText = APP_VERSION + " → " + updater::version; menu->addChild(updateItem); } - UrlItem *manualItem = new UrlItem; + UrlItem* manualItem = new UrlItem; manualItem->text = "Manual"; manualItem->rightText = "F1"; manualItem->url = "https://vcvrack.com/manual/"; menu->addChild(manualItem); - UrlItem *websiteItem = new UrlItem; + UrlItem* websiteItem = new UrlItem; websiteItem->text = "VCVRack.com"; websiteItem->url = "https://vcvrack.com/"; menu->addChild(websiteItem); - FolderItem *folderItem = new FolderItem; + FolderItem* folderItem = new FolderItem; folderItem->text = "Open user folder"; folderItem->path = asset::user(""); menu->addChild(folderItem); @@ -789,7 +819,7 @@ struct HelpButton : MenuButton { // MenuBar //////////////////// -void MenuBar::draw(const DrawArgs &args) { +void MenuBar::draw(const DrawArgs& args) { bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_ALL); bndBevel(args.vg, 0.0, 0.0, box.size.x, box.size.y); @@ -797,38 +827,38 @@ void MenuBar::draw(const DrawArgs &args) { } -MenuBar *createMenuBar() { - MenuBar *menuBar = new MenuBar; +MenuBar* createMenuBar() { + MenuBar* menuBar = new MenuBar; const float margin = 5; - menuBar->box.size.y = BND_WIDGET_HEIGHT + 2*margin; + menuBar->box.size.y = BND_WIDGET_HEIGHT + 2 * margin; - ui::SequentialLayout *layout = new ui::SequentialLayout; + ui::SequentialLayout* layout = new ui::SequentialLayout; layout->box.pos = math::Vec(margin, margin); layout->spacing = math::Vec(0, 0); menuBar->addChild(layout); - FileButton *fileButton = new FileButton; + FileButton* fileButton = new FileButton; fileButton->text = "File"; layout->addChild(fileButton); - EditButton *editButton = new EditButton; + EditButton* editButton = new EditButton; editButton->text = "Edit"; layout->addChild(editButton); - ViewButton *viewButton = new ViewButton; + ViewButton* viewButton = new ViewButton; viewButton->text = "View"; layout->addChild(viewButton); - EngineButton *engineButton = new EngineButton; + EngineButton* engineButton = new EngineButton; engineButton->text = "Engine"; layout->addChild(engineButton); - LibraryButton *libraryButton = new LibraryButton; + LibraryButton* libraryButton = new LibraryButton; libraryButton->text = "Library"; layout->addChild(libraryButton); - HelpButton *helpButton = new HelpButton; + HelpButton* helpButton = new HelpButton; helpButton->text = "Help"; layout->addChild(helpButton); diff --git a/src/app/MidiWidget.cpp b/src/app/MidiWidget.cpp index ea73ecbb..9e346793 100644 --- a/src/app/MidiWidget.cpp +++ b/src/app/MidiWidget.cpp @@ -7,23 +7,23 @@ namespace app { struct MidiDriverItem : ui::MenuItem { - midi::Port *port; + midi::Port* port; int driverId; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setDriverId(driverId); } }; struct MidiDriverChoice : LedDisplayChoice { - midi::Port *port; - void onAction(const event::Action &e) override { + midi::Port* port; + void onAction(const event::Action& e) override { if (!port) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("MIDI driver")); for (int driverId : port->getDriverIds()) { - MidiDriverItem *item = new MidiDriverItem; + MidiDriverItem* item = new MidiDriverItem; item->port = port; item->driverId = driverId; item->text = port->getDriverName(driverId); @@ -44,23 +44,23 @@ struct MidiDriverChoice : LedDisplayChoice { }; struct MidiDeviceItem : ui::MenuItem { - midi::Port *port; + midi::Port* port; int deviceId; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->setDeviceId(deviceId); } }; struct MidiDeviceChoice : LedDisplayChoice { - midi::Port *port; - void onAction(const event::Action &e) override { + midi::Port* port; + void onAction(const event::Action& e) override { if (!port) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("MIDI device")); { - MidiDeviceItem *item = new MidiDeviceItem; + MidiDeviceItem* item = new MidiDeviceItem; item->port = port; item->deviceId = -1; item->text = "(No device)"; @@ -68,7 +68,7 @@ struct MidiDeviceChoice : LedDisplayChoice { menu->addChild(item); } for (int deviceId : port->getDeviceIds()) { - MidiDeviceItem *item = new MidiDeviceItem; + MidiDeviceItem* item = new MidiDeviceItem; item->port = port; item->deviceId = deviceId; item->text = port->getDeviceName(deviceId); @@ -89,23 +89,23 @@ struct MidiDeviceChoice : LedDisplayChoice { }; struct MidiChannelItem : ui::MenuItem { - midi::Port *port; + midi::Port* port; int channel; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { port->channel = channel; } }; struct MidiChannelChoice : LedDisplayChoice { - midi::Port *port; - void onAction(const event::Action &e) override { + midi::Port* port; + void onAction(const event::Action& e) override { if (!port) return; - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); menu->addChild(createMenuLabel("MIDI channel")); for (int channel : port->getChannels()) { - MidiChannelItem *item = new MidiChannelItem; + MidiChannelItem* item = new MidiChannelItem; item->port = port; item->channel = channel; item->text = port->getChannelName(channel); @@ -119,12 +119,12 @@ struct MidiChannelChoice : LedDisplayChoice { }; -void MidiWidget::setMidiPort(midi::Port *port) { +void MidiWidget::setMidiPort(midi::Port* port) { clearChildren(); math::Vec pos; - MidiDriverChoice *driverChoice = createWidget(pos); + MidiDriverChoice* driverChoice = createWidget(pos); driverChoice->box.size.x = box.size.x; driverChoice->port = port; addChild(driverChoice); @@ -135,7 +135,7 @@ void MidiWidget::setMidiPort(midi::Port *port) { this->driverSeparator->box.size.x = box.size.x; addChild(this->driverSeparator); - MidiDeviceChoice *deviceChoice = createWidget(pos); + MidiDeviceChoice* deviceChoice = createWidget(pos); deviceChoice->box.size.x = box.size.x; deviceChoice->port = port; addChild(deviceChoice); @@ -146,7 +146,7 @@ void MidiWidget::setMidiPort(midi::Port *port) { this->deviceSeparator->box.size.x = box.size.x; addChild(this->deviceSeparator); - MidiChannelChoice *channelChoice = createWidget(pos); + MidiChannelChoice* channelChoice = createWidget(pos); channelChoice->box.size.x = box.size.x; channelChoice->port = port; addChild(channelChoice); diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 0ff9a058..a68f2b72 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -34,7 +34,7 @@ namespace app { // Static functions -static float modelScore(plugin::Model *model, const std::string &search) { +static float modelScore(plugin::Model* model, const std::string& search) { if (search.empty()) return 1.f; std::string s; @@ -45,7 +45,7 @@ static float modelScore(plugin::Model *model, const std::string &search) { s += model->name; s += " "; s += model->slug; - for (const std::string &tag : model->tags) { + for (const std::string& tag : model->tags) { s += " "; s += tag; } @@ -53,7 +53,7 @@ static float modelScore(plugin::Model *model, const std::string &search) { return score; } -static bool isModelVisible(plugin::Model *model, const std::string &search, const std::string &brand, const std::string &tag) { +static bool isModelVisible(plugin::Model* model, const std::string& search, const std::string& brand, const std::string& tag) { // Filter search query if (search != "") { float score = modelScore(model, search); @@ -70,7 +70,7 @@ static bool isModelVisible(plugin::Model *model, const std::string &search, cons // Filter tag if (tag != "") { bool found = false; - for (const std::string &modelTag : model->tags) { + for (const std::string& modelTag : model->tags) { if (modelTag == tag) { found = true; break; @@ -83,14 +83,14 @@ static bool isModelVisible(plugin::Model *model, const std::string &search, cons return true; } -static ModuleWidget *chooseModel(plugin::Model *model) { +static ModuleWidget* chooseModel(plugin::Model* model) { // Create module - ModuleWidget *moduleWidget = model->createModuleWidget(); + ModuleWidget* moduleWidget = model->createModuleWidget(); assert(moduleWidget); APP->scene->rack->addModuleAtMouse(moduleWidget); // Push ModuleAdd history action - history::ModuleAdd *h = new history::ModuleAdd; + history::ModuleAdd* h = new history::ModuleAdd; h->name = "create module"; h->setModule(moduleWidget); APP->history->push(h); @@ -102,7 +102,7 @@ static ModuleWidget *chooseModel(plugin::Model *model) { } template -V get_default(const std::map &m, const K &key, const V &def) { +V get_default(const std::map& m, const K& key, const V& def) { auto it = m.find(key); if (it == m.end()) return def; @@ -121,7 +121,7 @@ struct BrowserOverlay : widget::OpaqueWidget { OpaqueWidget::step(); } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { OpaqueWidget::onButton(e); if (e.getTarget() != this) return; @@ -138,11 +138,11 @@ static const float MODEL_BOX_ZOOM = 0.5f; struct ModelBox : widget::OpaqueWidget { - plugin::Model *model; - widget::Widget *previewWidget; - ui::Tooltip *tooltip = NULL; + plugin::Model* model; + widget::Widget* previewWidget; + ui::Tooltip* tooltip = NULL; /** Lazily created */ - widget::FramebufferWidget *previewFb = NULL; + widget::FramebufferWidget* previewFb = NULL; /** Number of frames since draw() has been called */ int visibleFrames = 0; @@ -154,7 +154,7 @@ struct ModelBox : widget::OpaqueWidget { box.size = box.size.ceil(); } - void setModel(plugin::Model *model) { + void setModel(plugin::Model* model) { this->model = model; previewWidget = new widget::TransparentWidget; @@ -170,11 +170,11 @@ struct ModelBox : widget::OpaqueWidget { } previewWidget->addChild(previewFb); - widget::ZoomWidget *zoomWidget = new widget::ZoomWidget; + widget::ZoomWidget* zoomWidget = new widget::ZoomWidget; zoomWidget->setZoom(MODEL_BOX_ZOOM); previewFb->addChild(zoomWidget); - ModuleWidget *moduleWidget = model->createModuleWidgetNull(); + ModuleWidget* moduleWidget = model->createModuleWidgetNull(); zoomWidget->addChild(moduleWidget); zoomWidget->box.size.x = moduleWidget->box.size.x * MODEL_BOX_ZOOM; @@ -198,7 +198,7 @@ struct ModelBox : widget::OpaqueWidget { OpaqueWidget::step(); } - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { visibleFrames = 0; // Lazily create preview when drawn @@ -210,7 +210,7 @@ struct ModelBox : widget::OpaqueWidget { nvgBeginPath(args.vg); float r = 10; // Blur radius float c = 10; // Corner radius - nvgRect(args.vg, -r, -r, box.size.x + 2*r, box.size.y + 2*r); + nvgRect(args.vg, -r, -r, box.size.x + 2 * r, box.size.y + 2 * r); NVGcolor shadowColor = nvgRGBAf(0, 0, 0, 0.5); NVGcolor transparentColor = nvgRGBAf(0, 0, 0, 0); nvgFillPaint(args.vg, nvgBoxGradient(args.vg, 0, 0, box.size.x, box.size.y, c, r, shadowColor, transparentColor)); @@ -219,7 +219,7 @@ struct ModelBox : widget::OpaqueWidget { OpaqueWidget::draw(args); } - void setTooltip(ui::Tooltip *tooltip) { + void setTooltip(ui::Tooltip* tooltip) { if (this->tooltip) { this->tooltip->parent->removeChild(this->tooltip); delete this->tooltip; @@ -232,20 +232,20 @@ struct ModelBox : widget::OpaqueWidget { } } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { OpaqueWidget::onButton(e); if (e.getTarget() != this) return; if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { - ModuleWidget *mw = chooseModel(model); + ModuleWidget* mw = chooseModel(model); // Pretend the moduleWidget was clicked so it can be dragged in the RackWidget e.consume(mw); } } - void onEnter(const event::Enter &e) override { + void onEnter(const event::Enter& e) override { std::string text; text = model->plugin->brand; text += " " + model->name; @@ -260,16 +260,16 @@ struct ModelBox : widget::OpaqueWidget { if (model->description != "") { text += "\n" + model->description; } - ui::Tooltip *tooltip = new ui::Tooltip; + ui::Tooltip* tooltip = new ui::Tooltip; tooltip->text = text; setTooltip(tooltip); } - void onLeave(const event::Leave &e) override { + void onLeave(const event::Leave& e) override { setTooltip(NULL); } - void onHide(const event::Hide &e) override { + void onHide(const event::Hide& e) override { // Hide tooltip setTooltip(NULL); OpaqueWidget::onHide(e); @@ -278,13 +278,13 @@ struct ModelBox : widget::OpaqueWidget { struct BrandItem : ui::MenuItem { - void onAction(const event::Action &e) override; + void onAction(const event::Action& e) override; void step() override; }; struct TagItem : ui::MenuItem { - void onAction(const event::Action &e) override; + void onAction(const event::Action& e) override; void step() override; }; @@ -296,16 +296,16 @@ struct BrowserSearchField : ui::TextField { TextField::step(); } - void onSelectKey(const event::SelectKey &e) override; - void onChange(const event::Change &e) override; - void onAction(const event::Action &e) override; + void onSelectKey(const event::SelectKey& e) override; + void onChange(const event::Change& e) override; + void onAction(const event::Action& e) override; - void onHide(const event::Hide &e) override { + void onHide(const event::Hide& e) override { APP->event->setSelected(NULL); ui::TextField::onHide(e); } - void onShow(const event::Show &e) override { + void onShow(const event::Show& e) override { selectAll(); TextField::onShow(e); } @@ -313,19 +313,19 @@ struct BrowserSearchField : ui::TextField { struct ClearButton : ui::Button { - void onAction(const event::Action &e) override; + void onAction(const event::Action& e) override; }; struct BrowserSidebar : widget::Widget { - BrowserSearchField *searchField; - ClearButton *clearButton; - ui::Label *brandLabel; - ui::List *brandList; - ui::ScrollWidget *brandScroll; - ui::Label *tagLabel; - ui::List *tagList; - ui::ScrollWidget *tagScroll; + BrowserSearchField* searchField; + ClearButton* clearButton; + ui::Label* brandLabel; + ui::List* brandList; + ui::ScrollWidget* brandScroll; + ui::Label* tagLabel; + ui::List* tagList; + ui::ScrollWidget* tagScroll; BrowserSidebar() { // Search @@ -353,12 +353,12 @@ struct BrowserSidebar : widget::Widget { // Collect brands from all plugins std::set brands; - for (plugin::Plugin *plugin : plugin::plugins) { + for (plugin::Plugin* plugin : plugin::plugins) { brands.insert(plugin->brand); } - for (const std::string &brand : brands) { - BrandItem *item = new BrandItem; + for (const std::string& brand : brands) { + BrandItem* item = new BrandItem; item->text = brand; brandList->addChild(item); } @@ -377,8 +377,8 @@ struct BrowserSidebar : widget::Widget { tagList = new ui::List; tagScroll->container->addChild(tagList); - for (const std::string &tag : plugin::allowedTags) { - TagItem *item = new TagItem; + for (const std::string& tag : plugin::allowedTags) { + TagItem* item = new TagItem; item->text = tag; tagList->addChild(item); } @@ -412,11 +412,11 @@ struct BrowserSidebar : widget::Widget { struct ModuleBrowser : widget::OpaqueWidget { - BrowserSidebar *sidebar; - ui::ScrollWidget *modelScroll; - ui::Label *modelLabel; - ui::MarginLayout *modelMargin; - ui::SequentialLayout *modelContainer; + BrowserSidebar* sidebar; + ui::ScrollWidget* modelScroll; + ui::Label* modelLabel; + ui::MarginLayout* modelMargin; + ui::SequentialLayout* modelContainer; std::string search; std::string brand; @@ -444,9 +444,9 @@ struct ModuleBrowser : widget::OpaqueWidget { modelMargin->addChild(modelContainer); // Add ModelBoxes for each Model - for (plugin::Plugin *plugin : plugin::plugins) { - for (plugin::Model *model : plugin->models) { - ModelBox *moduleBox = new ModelBox; + for (plugin::Plugin* plugin : plugin::plugins) { + for (plugin::Model* model : plugin->models) { + ModelBox* moduleBox = new ModelBox; moduleBox->setModel(model); modelContainer->addChild(moduleBox); } @@ -470,7 +470,7 @@ struct ModuleBrowser : widget::OpaqueWidget { OpaqueWidget::step(); } - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, 0); Widget::draw(args); } @@ -480,16 +480,16 @@ struct ModuleBrowser : widget::OpaqueWidget { modelScroll->offset = math::Vec(); // Filter ModelBoxes - for (Widget *w : modelContainer->children) { - ModelBox *m = dynamic_cast(w); + for (Widget* w : modelContainer->children) { + ModelBox* m = dynamic_cast(w); assert(m); m->visible = isModelVisible(m->model, search, brand, tag); } // Sort ModelBoxes - modelContainer->children.sort([&](Widget *w1, Widget *w2) { - ModelBox *m1 = dynamic_cast(w1); - ModelBox *m2 = dynamic_cast(w2); + modelContainer->children.sort([&](Widget * w1, Widget * w2) { + ModelBox* m1 = dynamic_cast(w1); + ModelBox* m2 = dynamic_cast(w2); // Sort by (modifiedTimestamp descending, plugin brand) auto t1 = std::make_tuple(-m1->model->plugin->modifiedTimestamp, m1->model->plugin->brand); auto t2 = std::make_tuple(-m2->model->plugin->modifiedTimestamp, m2->model->plugin->brand); @@ -502,8 +502,8 @@ struct ModuleBrowser : widget::OpaqueWidget { else { std::map scores; // Compute scores - for (Widget *w : modelContainer->children) { - ModelBox *m = dynamic_cast(w); + for (Widget* w : modelContainer->children) { + ModelBox* m = dynamic_cast(w); assert(m); if (!m->visible) continue; @@ -520,15 +520,15 @@ struct ModuleBrowser : widget::OpaqueWidget { // Get modules that would be filtered by just the search query std::vector filteredModels; - for (Widget *w : modelContainer->children) { - ModelBox *m = dynamic_cast(w); + for (Widget* w : modelContainer->children) { + ModelBox* m = dynamic_cast(w); assert(m); if (isModelVisible(m->model, search, "", "")) filteredModels.push_back(m->model); } - auto hasModel = [&](const std::string &brand, const std::string &tag) -> bool { - for (plugin::Model *model : filteredModels) { + auto hasModel = [&](const std::string & brand, const std::string & tag) -> bool { + for (plugin::Model* model : filteredModels) { if (isModelVisible(model, "", brand, tag)) return true; } @@ -537,8 +537,8 @@ struct ModuleBrowser : widget::OpaqueWidget { // Enable brand and tag items that are available in visible ModelBoxes int brandsLen = 0; - for (Widget *w : sidebar->brandList->children) { - BrandItem *item = dynamic_cast(w); + for (Widget* w : sidebar->brandList->children) { + BrandItem* item = dynamic_cast(w); assert(item); item->disabled = !hasModel(item->text, tag); if (!item->disabled) @@ -547,8 +547,8 @@ struct ModuleBrowser : widget::OpaqueWidget { sidebar->brandLabel->text = string::f("Brands (%d)", brandsLen); int tagsLen = 0; - for (Widget *w : sidebar->tagList->children) { - TagItem *item = dynamic_cast(w); + for (Widget* w : sidebar->tagList->children) { + TagItem* item = dynamic_cast(w); assert(item); item->disabled = !hasModel(brand, item->text); if (!item->disabled) @@ -558,7 +558,7 @@ struct ModuleBrowser : widget::OpaqueWidget { // Count models int modelsLen = 0; - for (Widget *w : modelContainer->children) { + for (Widget* w : modelContainer->children) { if (w->visible) modelsLen++; } @@ -573,7 +573,7 @@ struct ModuleBrowser : widget::OpaqueWidget { refresh(); } - void onShow(const event::Show &e) override { + void onShow(const event::Show& e) override { refresh(); OpaqueWidget::onShow(e); } @@ -583,8 +583,8 @@ struct ModuleBrowser : widget::OpaqueWidget { // Implementations to resolve dependencies -inline void BrandItem::onAction(const event::Action &e) { - ModuleBrowser *browser = getAncestorOfType(); +inline void BrandItem::onAction(const event::Action& e) { + ModuleBrowser* browser = getAncestorOfType(); if (browser->brand == text) browser->brand = ""; else @@ -594,12 +594,12 @@ inline void BrandItem::onAction(const event::Action &e) { inline void BrandItem::step() { MenuItem::step(); - ModuleBrowser *browser = getAncestorOfType(); + ModuleBrowser* browser = getAncestorOfType(); active = (browser->brand == text); } -inline void TagItem::onAction(const event::Action &e) { - ModuleBrowser *browser = getAncestorOfType(); +inline void TagItem::onAction(const event::Action& e) { + ModuleBrowser* browser = getAncestorOfType(); if (browser->tag == text) browser->tag = ""; else @@ -609,21 +609,21 @@ inline void TagItem::onAction(const event::Action &e) { inline void TagItem::step() { MenuItem::step(); - ModuleBrowser *browser = getAncestorOfType(); + ModuleBrowser* browser = getAncestorOfType(); active = (browser->tag == text); } -inline void BrowserSearchField::onSelectKey(const event::SelectKey &e) { +inline void BrowserSearchField::onSelectKey(const event::SelectKey& e) { if (e.action == GLFW_PRESS) { switch (e.key) { case GLFW_KEY_ESCAPE: { - BrowserOverlay *overlay = getAncestorOfType(); + BrowserOverlay* overlay = getAncestorOfType(); overlay->hide(); e.consume(this); } break; case GLFW_KEY_BACKSPACE: { if (text == "") { - ModuleBrowser *browser = getAncestorOfType(); + ModuleBrowser* browser = getAncestorOfType(); browser->clear(); e.consume(this); } @@ -635,17 +635,17 @@ inline void BrowserSearchField::onSelectKey(const event::SelectKey &e) { ui::TextField::onSelectKey(e); } -inline void BrowserSearchField::onChange(const event::Change &e) { - ModuleBrowser *browser = getAncestorOfType(); +inline void BrowserSearchField::onChange(const event::Change& e) { + ModuleBrowser* browser = getAncestorOfType(); browser->search = string::trim(text); browser->refresh(); } -inline void BrowserSearchField::onAction(const event::Action &e) { +inline void BrowserSearchField::onAction(const event::Action& e) { // Get first ModelBox - ModelBox *mb = NULL; - ModuleBrowser *browser = getAncestorOfType(); - for (Widget *w : browser->modelContainer->children) { + ModelBox* mb = NULL; + ModuleBrowser* browser = getAncestorOfType(); + for (Widget* w : browser->modelContainer->children) { if (w->visible) { mb = dynamic_cast(w); break; @@ -657,8 +657,8 @@ inline void BrowserSearchField::onAction(const event::Action &e) { } } -inline void ClearButton::onAction(const event::Action &e) { - ModuleBrowser *browser = getAncestorOfType(); +inline void ClearButton::onAction(const event::Action& e) { + ModuleBrowser* browser = getAncestorOfType(); browser->clear(); } @@ -666,10 +666,10 @@ inline void ClearButton::onAction(const event::Action &e) { // Global functions -widget::Widget *moduleBrowserCreate() { - BrowserOverlay *overlay = new BrowserOverlay; +widget::Widget* moduleBrowserCreate() { + BrowserOverlay* overlay = new BrowserOverlay; - ModuleBrowser *browser = new ModuleBrowser; + ModuleBrowser* browser = new ModuleBrowser; overlay->addChild(browser); return overlay; diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 874a40cd..b88aaec9 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -23,7 +23,7 @@ static const char PRESET_FILTERS[] = "VCV Rack module preset (.vcvm):vcvm"; struct ModuleUrlItem : ui::MenuItem { std::string url; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { std::thread t(system::openBrowser, url); t.detach(); } @@ -32,7 +32,7 @@ struct ModuleUrlItem : ui::MenuItem { struct ModuleFolderItem : ui::MenuItem { std::string path; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { std::thread t(system::openFolder, path); t.detach(); } @@ -40,62 +40,62 @@ struct ModuleFolderItem : ui::MenuItem { struct ModulePluginItem : ui::MenuItem { - plugin::Plugin *plugin; - ui::Menu *createChildMenu() override { - ui::Menu *menu = new ui::Menu; + plugin::Plugin* plugin; + ui::Menu* createChildMenu() override { + ui::Menu* menu = new ui::Menu; - ui::MenuLabel *pluginLabel = new ui::MenuLabel; + ui::MenuLabel* pluginLabel = new ui::MenuLabel; pluginLabel->text = plugin->name; menu->addChild(pluginLabel); - ui::MenuLabel *versionLabel = new ui::MenuLabel; + ui::MenuLabel* versionLabel = new ui::MenuLabel; versionLabel->text = "v" + plugin->version; menu->addChild(versionLabel); if (!plugin->author.empty()) { if (!plugin->authorUrl.empty()) { - ModuleUrlItem *authorItem = new ModuleUrlItem; + ModuleUrlItem* authorItem = new ModuleUrlItem; authorItem->text = plugin->author; authorItem->url = plugin->authorUrl; menu->addChild(authorItem); } else { - ui::MenuLabel *authorLabel = new ui::MenuLabel; + ui::MenuLabel* authorLabel = new ui::MenuLabel; authorLabel->text = plugin->author; menu->addChild(authorLabel); } } if (!plugin->pluginUrl.empty()) { - ModuleUrlItem *websiteItem = new ModuleUrlItem; + ModuleUrlItem* websiteItem = new ModuleUrlItem; websiteItem->text = "Website"; websiteItem->url = plugin->pluginUrl; menu->addChild(websiteItem); } if (!plugin->manualUrl.empty()) { - ModuleUrlItem *manualItem = new ModuleUrlItem; + ModuleUrlItem* manualItem = new ModuleUrlItem; manualItem->text = "Manual"; manualItem->url = plugin->manualUrl; menu->addChild(manualItem); } if (!plugin->sourceUrl.empty()) { - ModuleUrlItem *sourceItem = new ModuleUrlItem; + ModuleUrlItem* sourceItem = new ModuleUrlItem; sourceItem->text = "Source code"; sourceItem->url = plugin->sourceUrl; menu->addChild(sourceItem); } if (!plugin->donateUrl.empty()) { - ModuleUrlItem *donateItem = new ModuleUrlItem; + ModuleUrlItem* donateItem = new ModuleUrlItem; donateItem->text = "Donate"; donateItem->url = plugin->donateUrl; menu->addChild(donateItem); } if (!plugin->path.empty()) { - ModuleFolderItem *pathItem = new ModuleFolderItem; + ModuleFolderItem* pathItem = new ModuleFolderItem; pathItem->text = "Open plugin folder"; pathItem->path = plugin->path; menu->addChild(pathItem); @@ -107,93 +107,93 @@ struct ModulePluginItem : ui::MenuItem { struct ModuleDisconnectItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->disconnectAction(); } }; struct ModuleResetItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->resetAction(); } }; struct ModuleRandomizeItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->randomizeAction(); } }; struct ModuleCopyItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->copyClipboard(); } }; struct ModulePasteItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->pasteClipboardAction(); } }; struct ModuleSaveItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->saveDialog(); } }; struct ModuleLoadItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->loadDialog(); } }; struct ModulePresetPathItem : ui::MenuItem { - ModuleWidget *moduleWidget; + ModuleWidget* moduleWidget; std::string presetPath; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { moduleWidget->loadAction(presetPath); } }; struct ModulePresetItem : ui::MenuItem { - ModuleWidget *moduleWidget; - ui::Menu *createChildMenu() override { - ui::Menu *menu = new ui::Menu; + ModuleWidget* moduleWidget; + ui::Menu* createChildMenu() override { + ui::Menu* menu = new ui::Menu; - ModuleCopyItem *copyItem = new ModuleCopyItem; + ModuleCopyItem* copyItem = new ModuleCopyItem; copyItem->text = "Copy"; copyItem->rightText = RACK_MOD_CTRL_NAME "+C"; copyItem->moduleWidget = moduleWidget; menu->addChild(copyItem); - ModulePasteItem *pasteItem = new ModulePasteItem; + ModulePasteItem* pasteItem = new ModulePasteItem; pasteItem->text = "Paste"; pasteItem->rightText = RACK_MOD_CTRL_NAME "+V"; pasteItem->moduleWidget = moduleWidget; menu->addChild(pasteItem); - ModuleLoadItem *loadItem = new ModuleLoadItem; + ModuleLoadItem* loadItem = new ModuleLoadItem; loadItem->text = "Open"; loadItem->moduleWidget = moduleWidget; menu->addChild(loadItem); - ModuleSaveItem *saveItem = new ModuleSaveItem; + ModuleSaveItem* saveItem = new ModuleSaveItem; saveItem->text = "Save as"; saveItem->moduleWidget = moduleWidget; menu->addChild(saveItem); @@ -202,8 +202,8 @@ struct ModulePresetItem : ui::MenuItem { menu->addChild(new MenuEntry); menu->addChild(createMenuLabel("Factory presets")); - for (const std::string &presetPath : moduleWidget->model->presetPaths) { - ModulePresetPathItem *presetItem = new ModulePresetPathItem; + for (const std::string& presetPath : moduleWidget->model->presetPaths) { + ModulePresetPathItem* presetItem = new ModulePresetPathItem; std::string presetName = string::filenameBase(string::filename(presetPath)); presetItem->text = presetName; presetItem->presetPath = presetPath; @@ -218,24 +218,24 @@ struct ModulePresetItem : ui::MenuItem { struct ModuleCloneItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->cloneAction(); } }; struct ModuleBypassItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->bypassAction(); } }; struct ModuleDeleteItem : ui::MenuItem { - ModuleWidget *moduleWidget; - void onAction(const event::Action &e) override { + ModuleWidget* moduleWidget; + void onAction(const event::Action& e) override { moduleWidget->removeAction(); } }; @@ -249,7 +249,7 @@ ModuleWidget::~ModuleWidget() { setModule(NULL); } -void ModuleWidget::draw(const DrawArgs &args) { +void ModuleWidget::draw(const DrawArgs& args) { nvgScissor(args.vg, RECT_ARGS(args.clipBox)); if (module && module->bypass) { @@ -262,8 +262,8 @@ void ModuleWidget::draw(const DrawArgs &args) { if (module && settings::cpuMeter && !module->bypass) { nvgBeginPath(args.vg); nvgRect(args.vg, - 0, box.size.y - 35, - 65, 35); + 0, box.size.y - 35, + 65, 35); nvgFillColor(args.vg, nvgRGBAf(0, 0, 0, 0.75)); nvgFill(args.vg); @@ -275,8 +275,8 @@ void ModuleWidget::draw(const DrawArgs &args) { float p = math::clamp(module->cpuTime / APP->engine->getSampleTime(), 0.f, 1.f); nvgBeginPath(args.vg); nvgRect(args.vg, - 0, (1.f - p) * box.size.y, - 5, p * box.size.y); + 0, (1.f - p) * box.size.y, + 5, p * box.size.y); nvgFillColor(args.vg, nvgRGBAf(1, 0, 0, 1.0)); nvgFill(args.vg); } @@ -294,19 +294,19 @@ void ModuleWidget::draw(const DrawArgs &args) { nvgResetScissor(args.vg); } -void ModuleWidget::drawShadow(const DrawArgs &args) { +void ModuleWidget::drawShadow(const DrawArgs& args) { nvgBeginPath(args.vg); float r = 20; // Blur radius float c = 20; // Corner radius math::Vec b = math::Vec(-10, 30); // Offset from each corner - nvgRect(args.vg, b.x - r, b.y - r, box.size.x - 2*b.x + 2*r, box.size.y - 2*b.y + 2*r); + nvgRect(args.vg, b.x - r, b.y - r, box.size.x - 2 * b.x + 2 * r, box.size.y - 2 * b.y + 2 * r); NVGcolor shadowColor = nvgRGBAf(0, 0, 0, 0.2); NVGcolor transparentColor = nvgRGBAf(0, 0, 0, 0); - nvgFillPaint(args.vg, nvgBoxGradient(args.vg, b.x, b.y, box.size.x - 2*b.x, box.size.y - 2*b.y, c, r, shadowColor, transparentColor)); + nvgFillPaint(args.vg, nvgBoxGradient(args.vg, b.x, b.y, box.size.x - 2 * b.x, box.size.y - 2 * b.y, c, r, shadowColor, transparentColor)); nvgFill(args.vg); } -void ModuleWidget::onButton(const event::Button &e) { +void ModuleWidget::onButton(const event::Button& e) { OpaqueWidget::onButton(e); if (e.isConsumed()) return; @@ -317,7 +317,7 @@ void ModuleWidget::onButton(const event::Button &e) { } } -void ModuleWidget::onHoverKey(const event::HoverKey &e) { +void ModuleWidget::onHoverKey(const event::HoverKey& e) { OpaqueWidget::onHoverKey(e); if (e.isConsumed()) return; @@ -382,7 +382,7 @@ void ModuleWidget::onHoverKey(const event::HoverKey &e) { } } -void ModuleWidget::onDragStart(const event::DragStart &e) { +void ModuleWidget::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -391,11 +391,11 @@ void ModuleWidget::onDragStart(const event::DragStart &e) { APP->scene->rack->updateModuleDragPositions(); } -void ModuleWidget::onDragEnd(const event::DragEnd &e) { +void ModuleWidget::onDragEnd(const event::DragEnd& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - history::ComplexAction *h = APP->scene->rack->getModuleDragAction(); + history::ComplexAction* h = APP->scene->rack->getModuleDragAction(); if (!h) { delete h; return; @@ -403,7 +403,7 @@ void ModuleWidget::onDragEnd(const event::DragEnd &e) { APP->history->push(h); } -void ModuleWidget::onDragMove(const event::DragMove &e) { +void ModuleWidget::onDragMove(const event::DragMove& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -416,7 +416,7 @@ void ModuleWidget::onDragMove(const event::DragMove &e) { } } -void ModuleWidget::setModule(engine::Module *module) { +void ModuleWidget::setModule(engine::Module* module) { if (this->module) { delete this->module; } @@ -432,7 +432,7 @@ void ModuleWidget::setPanel(std::shared_ptr svg) { } // Create SvgPanel - SvgPanel *svgPanel = new SvgPanel; + SvgPanel* svgPanel = new SvgPanel; svgPanel->setBackground(svg); panel = svgPanel; addChildBottom(panel); @@ -441,16 +441,16 @@ void ModuleWidget::setPanel(std::shared_ptr svg) { box.size.x = std::round(panel->box.size.x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; } -void ModuleWidget::addParam(ParamWidget *param) { +void ModuleWidget::addParam(ParamWidget* param) { params.push_back(param); addChild(param); } -void ModuleWidget::addOutput(PortWidget *output) { +void ModuleWidget::addOutput(PortWidget* output) { // Check that the port is an output assert(output->type == PortWidget::OUTPUT); // Check that the port doesn't have a duplicate ID - for (PortWidget *output2 : outputs) { + for (PortWidget* output2 : outputs) { assert(output->portId != output2->portId); } // Add port @@ -458,11 +458,11 @@ void ModuleWidget::addOutput(PortWidget *output) { addChild(output); } -void ModuleWidget::addInput(PortWidget *input) { +void ModuleWidget::addInput(PortWidget* input) { // Check that the port is an input assert(input->type == PortWidget::INPUT); // Check that the port doesn't have a duplicate ID - for (PortWidget *input2 : inputs) { + for (PortWidget* input2 : inputs) { assert(input->portId != input2->portId); } // Add port @@ -470,50 +470,50 @@ void ModuleWidget::addInput(PortWidget *input) { addChild(input); } -ParamWidget *ModuleWidget::getParam(int paramId) { - for (ParamWidget *param : params) { +ParamWidget* ModuleWidget::getParam(int paramId) { + for (ParamWidget* param : params) { if (param->paramQuantity && param->paramQuantity->paramId == paramId) return param; } return NULL; } -PortWidget *ModuleWidget::getOutput(int outputId) { - for (PortWidget *port : outputs) { +PortWidget* ModuleWidget::getOutput(int outputId) { + for (PortWidget* port : outputs) { if (port->portId == outputId) return port; } return NULL; } -PortWidget *ModuleWidget::getInput(int inputId) { - for (PortWidget *port : inputs) { +PortWidget* ModuleWidget::getInput(int inputId) { + for (PortWidget* port : inputs) { if (port->portId == inputId) return port; } return NULL; } -json_t *ModuleWidget::toJson() { +json_t* ModuleWidget::toJson() { if (!module) return NULL; - json_t *rootJ = module->toJson(); + json_t* rootJ = module->toJson(); return rootJ; } -void ModuleWidget::fromJson(json_t *rootJ) { +void ModuleWidget::fromJson(json_t* rootJ) { if (!module) return; module->fromJson(rootJ); } void ModuleWidget::copyClipboard() { - json_t *moduleJ = toJson(); + json_t* moduleJ = toJson(); DEFER({ json_decref(moduleJ); }); - char *moduleJson = json_dumps(moduleJ, JSON_INDENT(2) | JSON_REAL_PRECISION(9)); + char* moduleJson = json_dumps(moduleJ, JSON_INDENT(2) | JSON_REAL_PRECISION(9)); DEFER({ free(moduleJson); }); @@ -521,14 +521,14 @@ void ModuleWidget::copyClipboard() { } void ModuleWidget::pasteClipboardAction() { - const char *moduleJson = glfwGetClipboardString(APP->window->win); + const char* moduleJson = glfwGetClipboardString(APP->window->win); if (!moduleJson) { WARN("Could not get text from clipboard."); return; } json_error_t error; - json_t *moduleJ = json_loads(moduleJson, 0, &error); + json_t* moduleJ = json_loads(moduleJson, 0, &error); if (!moduleJ) { WARN("JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text); return; @@ -538,7 +538,7 @@ void ModuleWidget::pasteClipboardAction() { }); // history::ModuleChange - history::ModuleChange *h = new history::ModuleChange; + history::ModuleChange* h = new history::ModuleChange; h->name = "paste module preset"; h->moduleId = module->id; h->oldModuleJ = toJson(); @@ -552,7 +552,7 @@ void ModuleWidget::pasteClipboardAction() { void ModuleWidget::loadAction(std::string filename) { INFO("Loading preset %s", filename.c_str()); - FILE *file = fopen(filename.c_str(), "r"); + FILE* file = fopen(filename.c_str(), "r"); if (!file) { WARN("Could not load patch file %s", filename.c_str()); return; @@ -562,7 +562,7 @@ void ModuleWidget::loadAction(std::string filename) { }); json_error_t error; - json_t *moduleJ = json_loadf(file, 0, &error); + json_t* moduleJ = json_loadf(file, 0, &error); if (!moduleJ) { std::string message = string::f("File is not a valid patch file. JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text); osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, message.c_str()); @@ -573,7 +573,7 @@ void ModuleWidget::loadAction(std::string filename) { }); // history::ModuleChange - history::ModuleChange *h = new history::ModuleChange; + history::ModuleChange* h = new history::ModuleChange; h->name = "load module preset"; h->moduleId = module->id; h->oldModuleJ = toJson(); @@ -587,13 +587,13 @@ void ModuleWidget::loadAction(std::string filename) { void ModuleWidget::save(std::string filename) { INFO("Saving preset %s", filename.c_str()); - json_t *moduleJ = toJson(); + json_t* moduleJ = toJson(); assert(moduleJ); DEFER({ json_decref(moduleJ); }); - FILE *file = fopen(filename.c_str(), "w"); + FILE* file = fopen(filename.c_str(), "w"); if (!file) { WARN("Could not write to patch file %s", filename.c_str()); } @@ -608,12 +608,12 @@ void ModuleWidget::loadDialog() { std::string dir = asset::user("presets"); system::createDirectory(dir); - osdialog_filters *filters = osdialog_filters_parse(PRESET_FILTERS); + osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS); DEFER({ osdialog_filters_free(filters); }); - char *path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters); + char* path = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters); if (!path) { // No path selected return; @@ -629,12 +629,12 @@ void ModuleWidget::saveDialog() { std::string dir = asset::user("presets"); system::createDirectory(dir); - osdialog_filters *filters = osdialog_filters_parse(PRESET_FILTERS); + osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS); DEFER({ osdialog_filters_free(filters); }); - char *path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), "Untitled.vcvm", filters); + char* path = osdialog_file(OSDIALOG_SAVE, dir.c_str(), "Untitled.vcvm", filters); if (!path) { // No path selected return; @@ -653,10 +653,10 @@ void ModuleWidget::saveDialog() { } void ModuleWidget::disconnect() { - for (PortWidget *input : inputs) { + for (PortWidget* input : inputs) { APP->scene->rack->clearCablesOnPort(input); } - for (PortWidget *output : outputs) { + for (PortWidget* output : outputs) { APP->scene->rack->clearCablesOnPort(output); } } @@ -665,12 +665,12 @@ void ModuleWidget::resetAction() { assert(module); // history::ModuleChange - history::ModuleChange *h = new history::ModuleChange; + history::ModuleChange* h = new history::ModuleChange; h->name = "reset module"; h->moduleId = module->id; h->oldModuleJ = toJson(); - for (ParamWidget *param : params) { + for (ParamWidget* param : params) { param->reset(); } APP->engine->resetModule(module); @@ -683,12 +683,12 @@ void ModuleWidget::randomizeAction() { assert(module); // history::ModuleChange - history::ModuleChange *h = new history::ModuleChange; + history::ModuleChange* h = new history::ModuleChange; h->name = "randomize module"; h->moduleId = module->id; h->oldModuleJ = toJson(); - for (ParamWidget *param : params) { + for (ParamWidget* param : params) { param->randomize(); } APP->engine->randomizeModule(module); @@ -697,28 +697,28 @@ void ModuleWidget::randomizeAction() { APP->history->push(h); } -static void disconnectActions(ModuleWidget *mw, history::ComplexAction *complexAction) { +static void disconnectActions(ModuleWidget* mw, history::ComplexAction* complexAction) { // Add CableRemove action for all cables attached to outputs for (PortWidget* output : mw->outputs) { - for (CableWidget *cw : APP->scene->rack->getCablesOnPort(output)) { + for (CableWidget* cw : APP->scene->rack->getCablesOnPort(output)) { if (!cw->isComplete()) continue; // history::CableRemove - history::CableRemove *h = new history::CableRemove; + history::CableRemove* h = new history::CableRemove; h->setCable(cw); complexAction->push(h); } } // Add CableRemove action for all cables attached to inputs for (PortWidget* input : mw->inputs) { - for (CableWidget *cw : APP->scene->rack->getCablesOnPort(input)) { + for (CableWidget* cw : APP->scene->rack->getCablesOnPort(input)) { if (!cw->isComplete()) continue; // Avoid creating duplicate actions for self-patched cables if (cw->outputPort->module == mw->module) continue; // history::CableRemove - history::CableRemove *h = new history::CableRemove; + history::CableRemove* h = new history::CableRemove; h->setCable(cw); complexAction->push(h); } @@ -726,7 +726,7 @@ static void disconnectActions(ModuleWidget *mw, history::ComplexAction *complexA } void ModuleWidget::disconnectAction() { - history::ComplexAction *complexAction = new history::ComplexAction; + history::ComplexAction* complexAction = new history::ComplexAction; complexAction->name = "disconnect cables"; disconnectActions(this, complexAction); APP->history->push(complexAction); @@ -735,10 +735,10 @@ void ModuleWidget::disconnectAction() { } void ModuleWidget::cloneAction() { - ModuleWidget *clonedModuleWidget = model->createModuleWidget(); + ModuleWidget* clonedModuleWidget = model->createModuleWidget(); assert(clonedModuleWidget); // JSON serialization is the obvious way to do this - json_t *moduleJ = toJson(); + json_t* moduleJ = toJson(); clonedModuleWidget->fromJson(moduleJ); json_decref(moduleJ); @@ -748,7 +748,7 @@ void ModuleWidget::cloneAction() { APP->scene->rack->addModuleAtMouse(clonedModuleWidget); // history::ModuleAdd - history::ModuleAdd *h = new history::ModuleAdd; + history::ModuleAdd* h = new history::ModuleAdd; h->name = "clone modules"; h->setModule(clonedModuleWidget); APP->history->push(h); @@ -757,7 +757,7 @@ void ModuleWidget::cloneAction() { void ModuleWidget::bypassAction() { assert(module); // history::ModuleBypass - history::ModuleBypass *h = new history::ModuleBypass; + history::ModuleBypass* h = new history::ModuleBypass; h->moduleId = module->id; h->bypass = !module->bypass; APP->history->push(h); @@ -765,12 +765,12 @@ void ModuleWidget::bypassAction() { } void ModuleWidget::removeAction() { - history::ComplexAction *complexAction = new history::ComplexAction; + history::ComplexAction* complexAction = new history::ComplexAction; complexAction->name = "remove module"; disconnectActions(this, complexAction); // history::ModuleRemove - history::ModuleRemove *moduleRemove = new history::ModuleRemove; + history::ModuleRemove* moduleRemove = new history::ModuleRemove; moduleRemove->setModule(this); complexAction->push(moduleRemove); @@ -782,50 +782,50 @@ void ModuleWidget::removeAction() { } void ModuleWidget::createContextMenu() { - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); assert(model); - ui::MenuLabel *modelLabel = new ui::MenuLabel; + ui::MenuLabel* modelLabel = new ui::MenuLabel; modelLabel->text = model->plugin->brand + " " + model->name; menu->addChild(modelLabel); - ModulePluginItem *pluginItem = new ModulePluginItem; + ModulePluginItem* pluginItem = new ModulePluginItem; pluginItem->text = "Plugin"; pluginItem->rightText = RIGHT_ARROW; pluginItem->plugin = model->plugin; menu->addChild(pluginItem); - ModulePresetItem *presetsItem = new ModulePresetItem; + ModulePresetItem* presetsItem = new ModulePresetItem; presetsItem->text = "Preset"; presetsItem->rightText = RIGHT_ARROW; presetsItem->moduleWidget = this; menu->addChild(presetsItem); - ModuleResetItem *resetItem = new ModuleResetItem; + ModuleResetItem* resetItem = new ModuleResetItem; resetItem->text = "Initialize"; resetItem->rightText = RACK_MOD_CTRL_NAME "+I"; resetItem->moduleWidget = this; menu->addChild(resetItem); - ModuleRandomizeItem *randomizeItem = new ModuleRandomizeItem; + ModuleRandomizeItem* randomizeItem = new ModuleRandomizeItem; randomizeItem->text = "Randomize"; randomizeItem->rightText = RACK_MOD_CTRL_NAME "+R"; randomizeItem->moduleWidget = this; menu->addChild(randomizeItem); - ModuleDisconnectItem *disconnectItem = new ModuleDisconnectItem; + ModuleDisconnectItem* disconnectItem = new ModuleDisconnectItem; disconnectItem->text = "Disconnect cables"; disconnectItem->rightText = RACK_MOD_CTRL_NAME "+U"; disconnectItem->moduleWidget = this; menu->addChild(disconnectItem); - ModuleCloneItem *cloneItem = new ModuleCloneItem; + ModuleCloneItem* cloneItem = new ModuleCloneItem; cloneItem->text = "Duplicate"; cloneItem->rightText = RACK_MOD_CTRL_NAME "+D"; cloneItem->moduleWidget = this; menu->addChild(cloneItem); - ModuleBypassItem *bypassItem = new ModuleBypassItem; + ModuleBypassItem* bypassItem = new ModuleBypassItem; bypassItem->text = "Disable"; bypassItem->rightText = RACK_MOD_CTRL_NAME "+E"; if (module && module->bypass) @@ -833,7 +833,7 @@ void ModuleWidget::createContextMenu() { bypassItem->moduleWidget = this; menu->addChild(bypassItem); - ModuleDeleteItem *deleteItem = new ModuleDeleteItem; + ModuleDeleteItem* deleteItem = new ModuleDeleteItem; deleteItem->text = "Delete"; deleteItem->rightText = "Backspace/Delete"; deleteItem->moduleWidget = this; diff --git a/src/app/MultiLightWidget.cpp b/src/app/MultiLightWidget.cpp index 6621a776..1efca431 100644 --- a/src/app/MultiLightWidget.cpp +++ b/src/app/MultiLightWidget.cpp @@ -10,7 +10,7 @@ void MultiLightWidget::addBaseColor(NVGcolor baseColor) { baseColors.push_back(baseColor); } -void MultiLightWidget::setBrightnesses(const std::vector &brightnesses) { +void MultiLightWidget::setBrightnesses(const std::vector& brightnesses) { assert(brightnesses.size() == baseColors.size()); color = nvgRGBAf(0, 0, 0, 0); for (size_t i = 0; i < baseColors.size(); i++) { diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index 8752ae19..1127f192 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -14,7 +14,7 @@ namespace app { struct ParamField : ui::TextField { - ParamWidget *paramWidget; + ParamWidget* paramWidget; void step() override { // Keep selected @@ -22,14 +22,14 @@ struct ParamField : ui::TextField { TextField::step(); } - void setParamWidget(ParamWidget *paramWidget) { + void setParamWidget(ParamWidget* paramWidget) { this->paramWidget = paramWidget; if (paramWidget->paramQuantity) text = paramWidget->paramQuantity->getDisplayValueString(); selectAll(); } - void onSelectKey(const event::SelectKey &e) override { + void onSelectKey(const event::SelectKey& e) override { if (e.action == GLFW_PRESS && (e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER)) { float oldValue = paramWidget->paramQuantity->getValue(); if (paramWidget->paramQuantity) @@ -38,7 +38,7 @@ struct ParamField : ui::TextField { if (oldValue != newValue) { // Push ParamChange history action - history::ParamChange *h = new history::ParamChange; + history::ParamChange* h = new history::ParamChange; h->moduleId = paramWidget->paramQuantity->module->id; h->paramId = paramWidget->paramQuantity->paramId; h->oldValue = oldValue; @@ -46,7 +46,7 @@ struct ParamField : ui::TextField { APP->history->push(h); } - ui::MenuOverlay *overlay = getAncestorOfType(); + ui::MenuOverlay* overlay = getAncestorOfType(); overlay->requestDelete(); e.consume(this); } @@ -58,7 +58,7 @@ struct ParamField : ui::TextField { struct ParamTooltip : ui::Tooltip { - ParamWidget *paramWidget; + ParamWidget* paramWidget; void step() override { if (paramWidget->paramQuantity) { @@ -77,7 +77,7 @@ struct ParamTooltip : ui::Tooltip { struct ParamLabel : ui::MenuLabel { - ParamWidget *paramWidget; + ParamWidget* paramWidget; void step() override { text = paramWidget->paramQuantity->getString(); MenuLabel::step(); @@ -86,8 +86,8 @@ struct ParamLabel : ui::MenuLabel { struct ParamResetItem : ui::MenuItem { - ParamWidget *paramWidget; - void onAction(const event::Action &e) override { + ParamWidget* paramWidget; + void onAction(const event::Action& e) override { paramWidget->resetAction(); } }; @@ -98,9 +98,9 @@ struct ParamFineItem : ui::MenuItem { struct ParamUnmapItem : ui::MenuItem { - ParamWidget *paramWidget; - void onAction(const event::Action &e) override { - engine::ParamHandle *paramHandle = APP->engine->getParamHandle(paramWidget->paramQuantity->module->id, paramWidget->paramQuantity->paramId); + ParamWidget* paramWidget; + void onAction(const event::Action& e) override { + engine::ParamHandle* paramHandle = APP->engine->getParamHandle(paramWidget->paramQuantity->module->id, paramWidget->paramQuantity->paramId); if (paramHandle) { APP->engine->updateParamHandle(paramHandle, -1, 0); } @@ -122,26 +122,26 @@ void ParamWidget::step() { Widget::step(); } -void ParamWidget::draw(const DrawArgs &args) { +void ParamWidget::draw(const DrawArgs& args) { Widget::draw(args); // Param map indicator - engine::ParamHandle *paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module->id, paramQuantity->paramId) : NULL; + engine::ParamHandle* paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module->id, paramQuantity->paramId) : NULL; if (paramHandle) { - NVGcolor color = paramHandle->color; - nvgBeginPath(args.vg); - const float radius = 6; - // nvgCircle(args.vg, box.size.x / 2, box.size.y / 2, radius); - nvgRect(args.vg, box.size.x - radius, box.size.y - radius, radius, radius); - nvgFillColor(args.vg, color); - nvgFill(args.vg); - nvgStrokeColor(args.vg, color::mult(color, 0.5)); - nvgStrokeWidth(args.vg, 1.0); - nvgStroke(args.vg); + NVGcolor color = paramHandle->color; + nvgBeginPath(args.vg); + const float radius = 6; + // nvgCircle(args.vg, box.size.x / 2, box.size.y / 2, radius); + nvgRect(args.vg, box.size.x - radius, box.size.y - radius, radius, radius); + nvgFillColor(args.vg, color); + nvgFill(args.vg); + nvgStrokeColor(args.vg, color::mult(color, 0.5)); + nvgStrokeWidth(args.vg, 1.0); + nvgStroke(args.vg); } } -void ParamWidget::onButton(const event::Button &e) { +void ParamWidget::onButton(const event::Button& e) { OpaqueWidget::onButton(e); // Touch parameter @@ -159,20 +159,20 @@ void ParamWidget::onButton(const event::Button &e) { } } -void ParamWidget::onDoubleClick(const event::DoubleClick &e) { +void ParamWidget::onDoubleClick(const event::DoubleClick& e) { resetAction(); } -void ParamWidget::onEnter(const event::Enter &e) { +void ParamWidget::onEnter(const event::Enter& e) { if (settings::paramTooltip && !tooltip && paramQuantity) { - ParamTooltip *paramTooltip = new ParamTooltip; + ParamTooltip* paramTooltip = new ParamTooltip; paramTooltip->paramWidget = this; APP->scene->addChild(paramTooltip); tooltip = paramTooltip; } } -void ParamWidget::onLeave(const event::Leave &e) { +void ParamWidget::onLeave(const event::Leave& e) { if (tooltip) { APP->scene->removeChild(tooltip); delete tooltip; @@ -180,8 +180,8 @@ void ParamWidget::onLeave(const event::Leave &e) { } } -void ParamWidget::fromJson(json_t *rootJ) { - json_t *valueJ = json_object_get(rootJ, "value"); +void ParamWidget::fromJson(json_t* rootJ) { + json_t* valueJ = json_object_get(rootJ, "value"); if (valueJ) { if (paramQuantity) paramQuantity->setValue(json_number_value(valueJ)); @@ -189,18 +189,18 @@ void ParamWidget::fromJson(json_t *rootJ) { } void ParamWidget::createContextMenu() { - ui::Menu *menu = createMenu(); + ui::Menu* menu = createMenu(); - ParamLabel *paramLabel = new ParamLabel; + ParamLabel* paramLabel = new ParamLabel; paramLabel->paramWidget = this; menu->addChild(paramLabel); - ParamField *paramField = new ParamField; + ParamField* paramField = new ParamField; paramField->box.size.x = 100; paramField->setParamWidget(this); menu->addChild(paramField); - ParamResetItem *resetItem = new ParamResetItem; + ParamResetItem* resetItem = new ParamResetItem; resetItem->text = "Initialize"; resetItem->rightText = "Double-click"; resetItem->paramWidget = this; @@ -212,9 +212,9 @@ void ParamWidget::createContextMenu() { // fineItem->disabled = true; // menu->addChild(fineItem); - engine::ParamHandle *paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module->id, paramQuantity->paramId) : NULL; + engine::ParamHandle* paramHandle = paramQuantity ? APP->engine->getParamHandle(paramQuantity->module->id, paramQuantity->paramId) : NULL; if (paramHandle) { - ParamUnmapItem *unmapItem = new ParamUnmapItem; + ParamUnmapItem* unmapItem = new ParamUnmapItem; unmapItem->text = "Unmap"; unmapItem->rightText = paramHandle->text; unmapItem->paramWidget = this; @@ -232,7 +232,7 @@ void ParamWidget::resetAction() { if (oldValue != newValue) { // Push ParamChange history action - history::ParamChange *h = new history::ParamChange; + history::ParamChange* h = new history::ParamChange; h->name = "reset parameter"; h->moduleId = paramQuantity->module->id; h->paramId = paramQuantity->paramId; diff --git a/src/app/PortWidget.cpp b/src/app/PortWidget.cpp index 2f3463cb..6cfe0440 100644 --- a/src/app/PortWidget.cpp +++ b/src/app/PortWidget.cpp @@ -49,8 +49,8 @@ void PortWidget::step() { Widget::step(); } -void PortWidget::draw(const DrawArgs &args) { - CableWidget *cw = APP->scene->rack->incompleteCable; +void PortWidget::draw(const DrawArgs& args) { + CableWidget* cw = APP->scene->rack->incompleteCable; if (cw) { // Dim the PortWidget if the active cable cannot plug into this PortWidget if (type == OUTPUT ? cw->outputPort : cw->inputPort) @@ -59,14 +59,14 @@ void PortWidget::draw(const DrawArgs &args) { Widget::draw(args); } -void PortWidget::onButton(const event::Button &e) { +void PortWidget::onButton(const event::Button& e) { OpaqueWidget::onButton(e); if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) { - CableWidget *cw = APP->scene->rack->getTopCable(this); + CableWidget* cw = APP->scene->rack->getTopCable(this); if (cw) { // history::CableRemove - history::CableRemove *h = new history::CableRemove; + history::CableRemove* h = new history::CableRemove; h->setCable(cw); APP->history->push(h); @@ -78,25 +78,25 @@ void PortWidget::onButton(const event::Button &e) { } } -void PortWidget::onEnter(const event::Enter &e) { +void PortWidget::onEnter(const event::Enter& e) { hovered = true; } -void PortWidget::onLeave(const event::Leave &e) { +void PortWidget::onLeave(const event::Leave& e) { hovered = false; } -void PortWidget::onDragStart(const event::DragStart &e) { +void PortWidget::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - CableWidget *cw = NULL; + CableWidget* cw = NULL; if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) { if (type == OUTPUT) { // Keep cable NULL. Will be created below } else { - CableWidget *topCw = APP->scene->rack->getTopCable(this); + CableWidget* topCw = APP->scene->rack->getTopCable(this); if (topCw) { cw = new CableWidget; cw->setOutput(topCw->outputPort); @@ -109,7 +109,7 @@ void PortWidget::onDragStart(const event::DragStart &e) { if (cw) { // history::CableRemove - history::CableRemove *h = new history::CableRemove; + history::CableRemove* h = new history::CableRemove; h->setCable(cw); APP->history->push(h); @@ -134,16 +134,16 @@ void PortWidget::onDragStart(const event::DragStart &e) { APP->scene->rack->setIncompleteCable(cw); } -void PortWidget::onDragEnd(const event::DragEnd &e) { +void PortWidget::onDragEnd(const event::DragEnd& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - CableWidget *cw = APP->scene->rack->releaseIncompleteCable(); + CableWidget* cw = APP->scene->rack->releaseIncompleteCable(); if (cw->isComplete()) { APP->scene->rack->addCable(cw); // history::CableAdd - history::CableAdd *h = new history::CableAdd; + history::CableAdd* h = new history::CableAdd; h->setCable(cw); APP->history->push(h); } @@ -152,7 +152,7 @@ void PortWidget::onDragEnd(const event::DragEnd &e) { } } -void PortWidget::onDragDrop(const event::DragDrop &e) { +void PortWidget::onDragDrop(const event::DragDrop& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -162,7 +162,7 @@ void PortWidget::onDragDrop(const event::DragDrop &e) { return; } - CableWidget *cw = APP->scene->rack->incompleteCable; + CableWidget* cw = APP->scene->rack->incompleteCable; if (cw) { cw->hoveredOutputPort = cw->hoveredInputPort = NULL; if (type == OUTPUT) @@ -172,7 +172,7 @@ void PortWidget::onDragDrop(const event::DragDrop &e) { } } -void PortWidget::onDragEnter(const event::DragEnter &e) { +void PortWidget::onDragEnter(const event::DragEnter& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -182,7 +182,7 @@ void PortWidget::onDragEnter(const event::DragEnter &e) { return; } - CableWidget *cw = APP->scene->rack->incompleteCable; + CableWidget* cw = APP->scene->rack->incompleteCable; if (cw) { if (type == OUTPUT) cw->hoveredOutputPort = this; @@ -191,15 +191,15 @@ void PortWidget::onDragEnter(const event::DragEnter &e) { } } -void PortWidget::onDragLeave(const event::DragLeave &e) { +void PortWidget::onDragLeave(const event::DragLeave& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; - PortWidget *originPort = dynamic_cast(e.origin); + PortWidget* originPort = dynamic_cast(e.origin); if (!originPort) return; - CableWidget *cw = APP->scene->rack->incompleteCable; + CableWidget* cw = APP->scene->rack->incompleteCable; if (cw) { if (type == OUTPUT) cw->hoveredOutputPort = NULL; diff --git a/src/app/RackRail.cpp b/src/app/RackRail.cpp index 9f135de2..0d5ad62b 100644 --- a/src/app/RackRail.cpp +++ b/src/app/RackRail.cpp @@ -13,7 +13,7 @@ RackRail::RackRail() { } -void RackRail::draw(const DrawArgs &args) { +void RackRail::draw(const DrawArgs& args) { const float railHeight = 15; // Background color diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 18d5c410..0bd00cf0 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -76,19 +76,19 @@ void RackScrollWidget::step() { } -void RackScrollWidget::draw(const DrawArgs &args) { +void RackScrollWidget::draw(const DrawArgs& args) { // DEBUG("%f %f %f %f", RECT_ARGS(args.clipBox)); ScrollWidget::draw(args); } -void RackScrollWidget::onHoverKey(const event::HoverKey &e) { +void RackScrollWidget::onHoverKey(const event::HoverKey& e) { ScrollWidget::onHoverKey(e); if (e.isConsumed()) return; // Scroll with arrow keys float arrowSpeed = 30.0; - if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL |GLFW_MOD_SHIFT)) + if ((e.mods & RACK_MOD_MASK) == (RACK_MOD_CTRL | GLFW_MOD_SHIFT)) arrowSpeed /= 16.0; else if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) arrowSpeed *= 4.0; @@ -117,7 +117,7 @@ void RackScrollWidget::onHoverKey(const event::HoverKey &e) { } } -void RackScrollWidget::onHoverScroll(const event::HoverScroll &e) { +void RackScrollWidget::onHoverScroll(const event::HoverScroll& e) { if ((APP->window->getMods() & RACK_MOD_MASK) == RACK_MOD_CTRL) { // Increase zoom float zoomDelta = e.scrollDelta.y / 50 / 4; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 035d8fd2..d0b3a652 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -19,24 +19,24 @@ namespace rack { namespace app { -static ModuleWidget *moduleFromJson(json_t *moduleJ) { +static ModuleWidget* moduleFromJson(json_t* moduleJ) { // Get slugs - json_t *pluginSlugJ = json_object_get(moduleJ, "plugin"); + json_t* pluginSlugJ = json_object_get(moduleJ, "plugin"); if (!pluginSlugJ) return NULL; - json_t *modelSlugJ = json_object_get(moduleJ, "model"); + json_t* modelSlugJ = json_object_get(moduleJ, "model"); if (!modelSlugJ) return NULL; std::string pluginSlug = json_string_value(pluginSlugJ); std::string modelSlug = json_string_value(modelSlugJ); // Get Model - plugin::Model *model = plugin::getModel(pluginSlug, modelSlug); + plugin::Model* model = plugin::getModel(pluginSlug, modelSlug); if (!model) return NULL; // Create ModuleWidget - ModuleWidget *moduleWidget = model->createModuleWidget(); + ModuleWidget* moduleWidget = model->createModuleWidget(); assert(moduleWidget); moduleWidget->fromJson(moduleJ); return moduleWidget; @@ -44,10 +44,10 @@ static ModuleWidget *moduleFromJson(json_t *moduleJ) { struct ModuleContainer : widget::Widget { - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { // Draw shadows behind each ModuleWidget first, so the shadow doesn't overlap the front of other ModuleWidgets. - for (widget::Widget *child : children) { - ModuleWidget *w = dynamic_cast(child); + for (widget::Widget* child : children) { + ModuleWidget* w = dynamic_cast(child); assert(w); nvgSave(args.vg); @@ -62,10 +62,10 @@ struct ModuleContainer : widget::Widget { struct CableContainer : widget::TransparentWidget { - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { // Draw cable plugs - for (widget::Widget *w : children) { - CableWidget *cw = dynamic_cast(w); + for (widget::Widget* w : children) { + CableWidget* cw = dynamic_cast(w); assert(cw); cw->drawPlugs(args); } @@ -80,7 +80,7 @@ RackWidget::RackWidget() { railFb->box.size = math::Vec(); railFb->oversample = 1.0; { - RackRail *rail = new RackRail; + RackRail* rail = new RackRail; rail->box.size = math::Vec(); railFb->addChild(rail); } @@ -101,7 +101,7 @@ void RackWidget::step() { Widget::step(); } -void RackWidget::draw(const DrawArgs &args) { +void RackWidget::draw(const DrawArgs& args) { // Resize and reposition the RackRail to align on the grid. math::Rect railBox; railBox.pos = args.clipBox.pos.div(BUS_BOARD_GRID_SIZE).floor().mult(BUS_BOARD_GRID_SIZE); @@ -111,19 +111,19 @@ void RackWidget::draw(const DrawArgs &args) { } railFb->box = railBox; - RackRail *rail = railFb->getFirstDescendantOfType(); + RackRail* rail = railFb->getFirstDescendantOfType(); rail->box.size = railFb->box.size; Widget::draw(args); } -void RackWidget::onHover(const event::Hover &e) { +void RackWidget::onHover(const event::Hover& e) { // Set before calling children's onHover() mousePos = e.pos; OpaqueWidget::onHover(e); } -void RackWidget::onHoverKey(const event::HoverKey &e) { +void RackWidget::onHoverKey(const event::HoverKey& e) { OpaqueWidget::onHoverKey(e); if (e.isConsumed()) return; @@ -140,13 +140,13 @@ void RackWidget::onHoverKey(const event::HoverKey &e) { } } -void RackWidget::onDragHover(const event::DragHover &e) { +void RackWidget::onDragHover(const event::DragHover& e) { // Set before calling children's onDragHover() mousePos = e.pos; OpaqueWidget::onDragHover(e); } -void RackWidget::onButton(const event::Button &e) { +void RackWidget::onButton(const event::Button& e) { Widget::onButton(e); e.stopPropagating(); if (e.isConsumed()) @@ -163,21 +163,21 @@ void RackWidget::clear() { clearCables(); // Remove ModuleWidgets std::list widgets = moduleContainer->children; - for (widget::Widget *w : widgets) { - ModuleWidget *moduleWidget = dynamic_cast(w); + for (widget::Widget* w : widgets) { + ModuleWidget* moduleWidget = dynamic_cast(w); assert(moduleWidget); removeModule(moduleWidget); delete moduleWidget; } } -json_t *RackWidget::toJson() { +json_t* RackWidget::toJson() { // root - json_t *rootJ = json_object(); + json_t* rootJ = json_object(); // Get module offset so modules are aligned to (0, 0) when the patch is loaded. math::Vec moduleOffset = math::Vec(INFINITY, INFINITY); - for (widget::Widget *w : moduleContainer->children) { + for (widget::Widget* w : moduleContainer->children) { moduleOffset = moduleOffset.min(w->box.pos); } if (moduleContainer->children.empty()) { @@ -185,17 +185,17 @@ json_t *RackWidget::toJson() { } // modules - json_t *modulesJ = json_array(); - for (widget::Widget *w : moduleContainer->children) { - ModuleWidget *moduleWidget = dynamic_cast(w); + json_t* modulesJ = json_array(); + for (widget::Widget* w : moduleContainer->children) { + ModuleWidget* moduleWidget = dynamic_cast(w); assert(moduleWidget); // module - json_t *moduleJ = moduleWidget->toJson(); + json_t* moduleJ = moduleWidget->toJson(); { // pos math::Vec pos = moduleWidget->box.pos.minus(moduleOffset); pos = pos.div(RACK_GRID_SIZE).round(); - json_t *posJ = json_pack("[i, i]", (int) pos.x, (int) pos.y); + json_t* posJ = json_pack("[i, i]", (int) pos.x, (int) pos.y); json_object_set_new(moduleJ, "pos", posJ); } json_array_append_new(modulesJ, moduleJ); @@ -203,16 +203,16 @@ json_t *RackWidget::toJson() { json_object_set_new(rootJ, "modules", modulesJ); // cables - json_t *cablesJ = json_array(); - for (widget::Widget *w : cableContainer->children) { - CableWidget *cw = dynamic_cast(w); + json_t* cablesJ = json_array(); + for (widget::Widget* w : cableContainer->children) { + CableWidget* cw = dynamic_cast(w); assert(cw); // Only serialize complete cables if (!cw->isComplete()) continue; - json_t *cableJ = cw->toJson(); + json_t* cableJ = cw->toJson(); json_array_append_new(cablesJ, cableJ); } json_object_set_new(rootJ, "cables", cablesJ); @@ -220,15 +220,15 @@ json_t *RackWidget::toJson() { return rootJ; } -void RackWidget::fromJson(json_t *rootJ) { +void RackWidget::fromJson(json_t* rootJ) { // modules - json_t *modulesJ = json_object_get(rootJ, "modules"); + json_t* modulesJ = json_object_get(rootJ, "modules"); if (!modulesJ) return; size_t moduleIndex; - json_t *moduleJ; + json_t* moduleJ; json_array_foreach(modulesJ, moduleIndex, moduleJ) { - ModuleWidget *moduleWidget = moduleFromJson(moduleJ); + ModuleWidget* moduleWidget = moduleFromJson(moduleJ); if (moduleWidget) { // Before 1.0, the module ID was the index in the "modules" array @@ -237,7 +237,7 @@ void RackWidget::fromJson(json_t *rootJ) { } // pos - json_t *posJ = json_object_get(moduleJ, "pos"); + json_t* posJ = json_object_get(moduleJ, "pos"); double x, y; json_unpack(posJ, "[F, F]", &x, &y); math::Vec pos = math::Vec(x, y); @@ -253,8 +253,8 @@ void RackWidget::fromJson(json_t *rootJ) { addModule(moduleWidget); } else { - json_t *pluginSlugJ = json_object_get(moduleJ, "plugin"); - json_t *modelSlugJ = json_object_get(moduleJ, "model"); + json_t* pluginSlugJ = json_object_get(moduleJ, "plugin"); + json_t* modelSlugJ = json_object_get(moduleJ, "model"); std::string pluginSlug = json_string_value(pluginSlugJ); std::string modelSlug = json_string_value(modelSlugJ); APP->patch->warningLog += string::f("Could not find module \"%s\" of plugin \"%s\"\n", modelSlug.c_str(), pluginSlug.c_str()); @@ -262,16 +262,16 @@ void RackWidget::fromJson(json_t *rootJ) { } // cables - json_t *cablesJ = json_object_get(rootJ, "cables"); + json_t* cablesJ = json_object_get(rootJ, "cables"); // Before 1.0, cables were called wires if (!cablesJ) cablesJ = json_object_get(rootJ, "wires"); assert(cablesJ); size_t cableIndex; - json_t *cableJ; + json_t* cableJ; json_array_foreach(cablesJ, cableIndex, cableJ) { // Create a unserialize cable - CableWidget *cw = new CableWidget; + CableWidget* cw = new CableWidget; cw->fromJson(cableJ); if (!cw->isComplete()) { delete cw; @@ -282,16 +282,16 @@ void RackWidget::fromJson(json_t *rootJ) { } void RackWidget::pastePresetClipboardAction() { - const char *moduleJson = glfwGetClipboardString(APP->window->win); + const char* moduleJson = glfwGetClipboardString(APP->window->win); if (!moduleJson) { WARN("Could not get text from clipboard."); return; } json_error_t error; - json_t *moduleJ = json_loads(moduleJson, 0, &error); + json_t* moduleJ = json_loads(moduleJson, 0, &error); if (moduleJ) { - ModuleWidget *mw = moduleFromJson(moduleJ); + ModuleWidget* mw = moduleFromJson(moduleJ); json_decref(moduleJ); // Reset ID so the Engine automatically assigns a new one @@ -300,7 +300,7 @@ void RackWidget::pastePresetClipboardAction() { addModuleAtMouse(mw); // history::ModuleAdd - history::ModuleAdd *h = new history::ModuleAdd; + history::ModuleAdd* h = new history::ModuleAdd; h->setModule(mw); APP->history->push(h); } @@ -309,15 +309,15 @@ void RackWidget::pastePresetClipboardAction() { } } -static void RackWidget_updateAdjacent(RackWidget *that) { - for (widget::Widget *w : that->moduleContainer->children) { +static void RackWidget_updateAdjacent(RackWidget* that) { + for (widget::Widget* w : that->moduleContainer->children) { math::Vec pLeft = w->box.pos.div(RACK_GRID_SIZE).round(); math::Vec pRight = w->box.getTopRight().div(RACK_GRID_SIZE).round(); - ModuleWidget *mwLeft = NULL; - ModuleWidget *mwRight = NULL; + ModuleWidget* mwLeft = NULL; + ModuleWidget* mwRight = NULL; // Find adjacent modules - for (widget::Widget *w2 : that->moduleContainer->children) { + for (widget::Widget* w2 : that->moduleContainer->children) { if (w2 == w) continue; @@ -335,13 +335,13 @@ static void RackWidget_updateAdjacent(RackWidget *that) { } } - ModuleWidget *mw = dynamic_cast(w); + ModuleWidget* mw = dynamic_cast(w); mw->module->leftExpander.moduleId = mwLeft ? mwLeft->module->id : -1; mw->module->rightExpander.moduleId = mwRight ? mwRight->module->id : -1; } } -void RackWidget::addModule(ModuleWidget *m) { +void RackWidget::addModule(ModuleWidget* m) { // Add module to ModuleContainer assert(m); // Module must be 3U high and at least 1HP wide @@ -356,7 +356,7 @@ void RackWidget::addModule(ModuleWidget *m) { RackWidget_updateAdjacent(this); } -void RackWidget::addModuleAtMouse(ModuleWidget *mw) { +void RackWidget::addModuleAtMouse(ModuleWidget* mw) { assert(mw); // Move module nearest to the mouse position math::Vec pos = mousePos.minus(mw->box.size.div(2)); @@ -364,10 +364,10 @@ void RackWidget::addModuleAtMouse(ModuleWidget *mw) { addModule(mw); } -void RackWidget::removeModule(ModuleWidget *m) { +void RackWidget::removeModule(ModuleWidget* m) { // Unset touchedParamWidget if (touchedParam) { - ModuleWidget *touchedModule = touchedParam->getAncestorOfType(); + ModuleWidget* touchedModule = touchedParam->getAncestorOfType(); if (touchedModule == m) touchedParam = NULL; } @@ -384,10 +384,10 @@ void RackWidget::removeModule(ModuleWidget *m) { moduleContainer->removeChild(m); } -bool RackWidget::requestModulePos(ModuleWidget *mw, math::Vec pos) { +bool RackWidget::requestModulePos(ModuleWidget* mw, math::Vec pos) { // Check intersection with other modules math::Rect mwBox = math::Rect(pos, mw->box.size); - for (widget::Widget *w2 : moduleContainer->children) { + for (widget::Widget* w2 : moduleContainer->children) { // Don't intersect with self if (mw == w2) continue; @@ -406,15 +406,15 @@ bool RackWidget::requestModulePos(ModuleWidget *mw, math::Vec pos) { return true; } -void RackWidget::setModulePosNearest(ModuleWidget *mw, math::Vec pos) { +void RackWidget::setModulePosNearest(ModuleWidget* mw, math::Vec pos) { // Dijkstra's algorithm to generate a sorted list of Vecs closest to `pos`. // Comparison of distance of Vecs to `pos` - auto cmpNearest = [&](const math::Vec &a, const math::Vec &b) { + auto cmpNearest = [&](const math::Vec & a, const math::Vec & b) { return a.minus(pos).square() > b.minus(pos).square(); }; // Comparison of dictionary order of Vecs - auto cmp = [&](const math::Vec &a, const math::Vec &b) { + auto cmp = [&](const math::Vec & a, const math::Vec & b) { if (a.x != b.x) return a.x < b.x; return a.y < b.y; @@ -455,18 +455,18 @@ void RackWidget::setModulePosNearest(ModuleWidget *mw, math::Vec pos) { assert(0); } -void RackWidget::setModulePosForce(ModuleWidget *mw, math::Vec pos) { +void RackWidget::setModulePosForce(ModuleWidget* mw, math::Vec pos) { mw->box.pos = pos.div(RACK_GRID_SIZE).round().mult(RACK_GRID_SIZE); // Comparison of center X coordinates - auto cmp = [&](const widget::Widget *a, const widget::Widget *b) { + auto cmp = [&](const widget::Widget * a, const widget::Widget * b) { return a->box.pos.x + a->box.size.x / 2 < b->box.pos.x + b->box.size.x / 2; }; // Collect modules to the left and right of `mw` std::set leftModules(cmp); std::set rightModules(cmp); - for (widget::Widget *w2 : moduleContainer->children) { + for (widget::Widget* w2 : moduleContainer->children) { if (w2 == mw) continue; // Modules must be on the same row as `mw` @@ -481,7 +481,7 @@ void RackWidget::setModulePosForce(ModuleWidget *mw, math::Vec pos) { // Shove left modules float xLimit = mw->box.pos.x; for (auto it = leftModules.rbegin(); it != leftModules.rend(); it++) { - widget::Widget *w = *it; + widget::Widget* w = *it; float x = xLimit - w->box.size.x; x = std::round(x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; if (w->box.pos.x < x) @@ -493,7 +493,7 @@ void RackWidget::setModulePosForce(ModuleWidget *mw, math::Vec pos) { // Shove right modules xLimit = mw->box.pos.x + mw->box.size.x; for (auto it = rightModules.begin(); it != rightModules.end(); it++) { - widget::Widget *w = *it; + widget::Widget* w = *it; float x = xLimit; x = std::round(x / RACK_GRID_WIDTH) * RACK_GRID_WIDTH; if (w->box.pos.x > x) @@ -505,9 +505,9 @@ void RackWidget::setModulePosForce(ModuleWidget *mw, math::Vec pos) { RackWidget_updateAdjacent(this); } -ModuleWidget *RackWidget::getModule(int moduleId) { - for (widget::Widget *w : moduleContainer->children) { - ModuleWidget *mw = dynamic_cast(w); +ModuleWidget* RackWidget::getModule(int moduleId) { + for (widget::Widget* w : moduleContainer->children) { + ModuleWidget* mw = dynamic_cast(w); assert(mw); if (mw->module->id == moduleId) return mw; @@ -521,22 +521,22 @@ bool RackWidget::isEmpty() { void RackWidget::updateModuleDragPositions() { moduleDragPositions.clear(); - for (widget::Widget *w : moduleContainer->children) { - ModuleWidget *mw = dynamic_cast(w); + for (widget::Widget* w : moduleContainer->children) { + ModuleWidget* mw = dynamic_cast(w); assert(mw); moduleDragPositions[mw->module->id] = mw->box.pos; } } -history::ComplexAction *RackWidget::getModuleDragAction() { - history::ComplexAction *h = new history::ComplexAction; +history::ComplexAction* RackWidget::getModuleDragAction() { + history::ComplexAction* h = new history::ComplexAction; - for (widget::Widget *w : moduleContainer->children) { - ModuleWidget *mw = dynamic_cast(w); + for (widget::Widget* w : moduleContainer->children) { + ModuleWidget* mw = dynamic_cast(w); assert(mw); math::Vec pos = moduleDragPositions.at(mw->module->id); if (!pos.isEqual(mw->box.pos)) { - history::ModuleMove *mmh = new history::ModuleMove; + history::ModuleMove* mmh = new history::ModuleMove; mmh->moduleId = mw->module->id; mmh->oldPos = pos; mmh->newPos = mw->box.pos; @@ -548,8 +548,8 @@ history::ComplexAction *RackWidget::getModuleDragAction() { void RackWidget::clearCables() { - for (widget::Widget *w : cableContainer->children) { - CableWidget *cw = dynamic_cast(w); + for (widget::Widget* w : cableContainer->children) { + CableWidget* cw = dynamic_cast(w); assert(cw); if (!cw->isComplete()) continue; @@ -562,17 +562,17 @@ void RackWidget::clearCables() { void RackWidget::clearCablesAction() { // Add CableRemove for every cable to a ComplexAction - history::ComplexAction *complexAction = new history::ComplexAction; + history::ComplexAction* complexAction = new history::ComplexAction; complexAction->name = "clear cables"; - for (widget::Widget *w : cableContainer->children) { - CableWidget *cw = dynamic_cast(w); + for (widget::Widget* w : cableContainer->children) { + CableWidget* cw = dynamic_cast(w); assert(cw); if (!cw->isComplete()) continue; // history::CableRemove - history::CableRemove *h = new history::CableRemove; + history::CableRemove* h = new history::CableRemove; h->setCable(cw); complexAction->push(h); } @@ -581,8 +581,8 @@ void RackWidget::clearCablesAction() { clearCables(); } -void RackWidget::clearCablesOnPort(PortWidget *port) { - for (CableWidget *cw : getCablesOnPort(port)) { +void RackWidget::clearCablesOnPort(PortWidget* port) { + for (CableWidget* cw : getCablesOnPort(port)) { // Check if cable is connected to port if (cw == incompleteCable) { incompleteCable = NULL; @@ -595,19 +595,19 @@ void RackWidget::clearCablesOnPort(PortWidget *port) { } } -void RackWidget::addCable(CableWidget *w) { +void RackWidget::addCable(CableWidget* w) { assert(w->isComplete()); APP->engine->addCable(w->cable); cableContainer->addChild(w); } -void RackWidget::removeCable(CableWidget *w) { +void RackWidget::removeCable(CableWidget* w) { assert(w->isComplete()); APP->engine->removeCable(w->cable); cableContainer->removeChild(w); } -void RackWidget::setIncompleteCable(CableWidget *w) { +void RackWidget::setIncompleteCable(CableWidget* w) { if (incompleteCable) { cableContainer->removeChild(incompleteCable); delete incompleteCable; @@ -619,16 +619,16 @@ void RackWidget::setIncompleteCable(CableWidget *w) { } } -CableWidget *RackWidget::releaseIncompleteCable() { - CableWidget *cw = incompleteCable; +CableWidget* RackWidget::releaseIncompleteCable() { + CableWidget* cw = incompleteCable; cableContainer->removeChild(incompleteCable); incompleteCable = NULL; return cw; } -CableWidget *RackWidget::getTopCable(PortWidget *port) { +CableWidget* RackWidget::getTopCable(PortWidget* port) { for (auto it = cableContainer->children.rbegin(); it != cableContainer->children.rend(); it++) { - CableWidget *cw = dynamic_cast(*it); + CableWidget* cw = dynamic_cast(*it); assert(cw); // Ignore incomplete cables if (!cw->isComplete()) @@ -639,9 +639,9 @@ CableWidget *RackWidget::getTopCable(PortWidget *port) { return NULL; } -CableWidget *RackWidget::getCable(int cableId) { - for (widget::Widget *w : cableContainer->children) { - CableWidget *cw = dynamic_cast(w); +CableWidget* RackWidget::getCable(int cableId) { + for (widget::Widget* w : cableContainer->children) { + CableWidget* cw = dynamic_cast(w); assert(cw); if (cw->cable->id == cableId) return cw; @@ -649,11 +649,11 @@ CableWidget *RackWidget::getCable(int cableId) { return NULL; } -std::list RackWidget::getCablesOnPort(PortWidget *port) { +std::list RackWidget::getCablesOnPort(PortWidget* port) { assert(port); std::list cables; - for (widget::Widget *w : cableContainer->children) { - CableWidget *cw = dynamic_cast(w); + for (widget::Widget* w : cableContainer->children) { + CableWidget* cw = dynamic_cast(w); assert(cw); if (cw->inputPort == port || cw->outputPort == port) { cables.push_back(cw); diff --git a/src/app/Scene.cpp b/src/app/Scene.cpp index becbf1ba..72c25f3e 100644 --- a/src/app/Scene.cpp +++ b/src/app/Scene.cpp @@ -51,11 +51,11 @@ void Scene::step() { Widget::step(); } -void Scene::draw(const DrawArgs &args) { +void Scene::draw(const DrawArgs& args) { Widget::draw(args); } -void Scene::onHoverKey(const event::HoverKey &e) { +void Scene::onHoverKey(const event::HoverKey& e) { OpaqueWidget::onHoverKey(e); if (e.isConsumed()) return; @@ -155,9 +155,9 @@ void Scene::onHoverKey(const event::HoverKey &e) { } } -void Scene::onPathDrop(const event::PathDrop &e) { +void Scene::onPathDrop(const event::PathDrop& e) { if (e.paths.size() >= 1) { - const std::string &path = e.paths[0]; + const std::string& path = e.paths[0]; if (string::filenameExtension(string::filename(path)) == "vcv") { APP->patch->loadPathDialog(path); e.consume(this); diff --git a/src/app/SvgButton.cpp b/src/app/SvgButton.cpp index 29526327..2919d93b 100644 --- a/src/app/SvgButton.cpp +++ b/src/app/SvgButton.cpp @@ -30,7 +30,7 @@ void SvgButton::addFrame(std::shared_ptr svg) { } } -void SvgButton::onDragStart(const event::DragStart &e) { +void SvgButton::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -40,14 +40,14 @@ void SvgButton::onDragStart(const event::DragStart &e) { } } -void SvgButton::onDragEnd(const event::DragEnd &e) { +void SvgButton::onDragEnd(const event::DragEnd& e) { if (frames.size() >= 1) { sw->setSvg(frames[0]); fb->dirty = true; } } -void SvgButton::onDragDrop(const event::DragDrop &e) { +void SvgButton::onDragDrop(const event::DragDrop& e) { if (e.origin == this) { event::Action eAction; onAction(eAction); diff --git a/src/app/SvgKnob.cpp b/src/app/SvgKnob.cpp index 7a95dcee..9d0c8b2f 100644 --- a/src/app/SvgKnob.cpp +++ b/src/app/SvgKnob.cpp @@ -31,7 +31,7 @@ void SvgKnob::setSvg(std::shared_ptr svg) { // shadow->box = shadow->box.grow(math::Vec(2, 2)); } -void SvgKnob::onChange(const event::Change &e) { +void SvgKnob::onChange(const event::Change& e) { // Re-transform the widget::TransformWidget if (paramQuantity) { float angle; @@ -41,7 +41,7 @@ void SvgKnob::onChange(const event::Change &e) { else { angle = math::rescale(paramQuantity->getValue(), -1.f, 1.f, minAngle, maxAngle); } - angle = std::fmod(angle, 2*M_PI); + angle = std::fmod(angle, 2 * M_PI); tw->identity(); // Rotate SVG math::Vec center = sw->box.getCenter(); diff --git a/src/app/SvgPanel.cpp b/src/app/SvgPanel.cpp index aa9dfe12..7f5459a5 100644 --- a/src/app/SvgPanel.cpp +++ b/src/app/SvgPanel.cpp @@ -5,7 +5,7 @@ namespace rack { namespace app { -void PanelBorder::draw(const DrawArgs &args) { +void PanelBorder::draw(const DrawArgs& args) { NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5); nvgBeginPath(args.vg); nvgRect(args.vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0); @@ -24,14 +24,14 @@ void SvgPanel::step() { } void SvgPanel::setBackground(std::shared_ptr svg) { - widget::SvgWidget *sw = new widget::SvgWidget; + widget::SvgWidget* sw = new widget::SvgWidget; sw->setSvg(svg); addChild(sw); // Set size box.size = sw->box.size.div(RACK_GRID_SIZE).round().mult(RACK_GRID_SIZE); - PanelBorder *pb = new PanelBorder; + PanelBorder* pb = new PanelBorder; pb->box.size = box.size; addChild(pb); } diff --git a/src/app/SvgSlider.cpp b/src/app/SvgSlider.cpp index c459d387..65949ff7 100644 --- a/src/app/SvgSlider.cpp +++ b/src/app/SvgSlider.cpp @@ -30,13 +30,13 @@ void SvgSlider::setHandleSvg(std::shared_ptr svg) { fb->dirty = true; } -void SvgSlider::onChange(const event::Change &e) { +void SvgSlider::onChange(const event::Change& e) { if (paramQuantity) { // Interpolate handle position float v = paramQuantity->getScaledValue(); handle->box.pos = math::Vec( - math::rescale(v, 0.f, 1.f, minHandlePos.x, maxHandlePos.x), - math::rescale(v, 0.f, 1.f, minHandlePos.y, maxHandlePos.y)); + math::rescale(v, 0.f, 1.f, minHandlePos.x, maxHandlePos.x), + math::rescale(v, 0.f, 1.f, minHandlePos.y, maxHandlePos.y)); fb->dirty = true; } ParamWidget::onChange(e); diff --git a/src/app/SvgSwitch.cpp b/src/app/SvgSwitch.cpp index f9172b73..7ed0627e 100644 --- a/src/app/SvgSwitch.cpp +++ b/src/app/SvgSwitch.cpp @@ -30,7 +30,7 @@ void SvgSwitch::addFrame(std::shared_ptr svg) { } } -void SvgSwitch::onChange(const event::Change &e) { +void SvgSwitch::onChange(const event::Change& e) { if (!frames.empty() && paramQuantity) { int index = (int) std::round(paramQuantity->getValue() - paramQuantity->getMinValue()); index = math::clamp(index, 0, (int) frames.size() - 1); diff --git a/src/app/Switch.cpp b/src/app/Switch.cpp index 1d2ae7fe..0ea689d6 100644 --- a/src/app/Switch.cpp +++ b/src/app/Switch.cpp @@ -24,11 +24,11 @@ void Switch::step() { ParamWidget::step(); } -void Switch::onDoubleClick(const event::DoubleClick &e) { +void Switch::onDoubleClick(const event::DoubleClick& e) { // Don't reset parameter on double-click } -void Switch::onDragStart(const event::DragStart &e) { +void Switch::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -54,7 +54,7 @@ void Switch::onDragStart(const event::DragStart &e) { float newValue = paramQuantity->getValue(); if (oldValue != newValue) { // Push ParamChange history action - history::ParamChange *h = new history::ParamChange; + history::ParamChange* h = new history::ParamChange; h->name = "move switch"; h->moduleId = paramQuantity->module->id; h->paramId = paramQuantity->paramId; @@ -66,7 +66,7 @@ void Switch::onDragStart(const event::DragStart &e) { } } -void Switch::onDragEnd(const event::DragEnd &e) { +void Switch::onDragEnd(const event::DragEnd& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; diff --git a/src/asset.cpp b/src/asset.cpp index 9de69a98..522623cc 100644 --- a/src/asset.cpp +++ b/src/asset.cpp @@ -82,16 +82,16 @@ void init() { #endif #if defined ARCH_MAC // Get home directory - struct passwd *pw = getpwuid(getuid()); + struct passwd* pw = getpwuid(getuid()); assert(pw); userDir = pw->pw_dir; userDir += "/Documents/Rack"; #endif #if defined ARCH_LIN // Get home directory - const char *homeBuf = getenv("HOME"); + const char* homeBuf = getenv("HOME"); if (!homeBuf) { - struct passwd *pw = getpwuid(getuid()); + struct passwd* pw = getpwuid(getuid()); assert(pw); homeBuf = pw->pw_dir; } @@ -131,7 +131,7 @@ std::string user(std::string filename) { } -std::string plugin(plugin::Plugin *plugin, std::string filename) { +std::string plugin(plugin::Plugin* plugin, std::string filename) { assert(plugin); return plugin->path + "/" + filename; } diff --git a/src/audio.cpp b/src/audio.cpp index 1d4ec522..b636e492 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -77,7 +77,7 @@ int Port::getDeviceCount() { return 0; } -bool Port::getDeviceInfo(int deviceId, RtAudio::DeviceInfo *deviceInfo) { +bool Port::getDeviceInfo(int deviceId, RtAudio::DeviceInfo* deviceInfo) { if (!deviceInfo) return false; @@ -91,7 +91,7 @@ bool Port::getDeviceInfo(int deviceId, RtAudio::DeviceInfo *deviceInfo) { *deviceInfo = rtAudio->getDeviceInfo(deviceId); return true; } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to query RtAudio device: %s", e.what()); } } @@ -168,7 +168,7 @@ std::vector Port::getSampleRates() { std::vector sampleRates(deviceInfo.sampleRates.begin(), deviceInfo.sampleRates.end()); return sampleRates; } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to query RtAudio device: %s", e.what()); } } @@ -205,15 +205,15 @@ void Port::setChannels(int numOutputs, int numInputs) { } -static int rtCallback(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *userData) { - Port *port = (Port*) userData; +static int rtCallback(void* outputBuffer, void* inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void* userData) { + Port* port = (Port*) userData; assert(port); // Exploit the stream time to run code on startup of the audio thread if (streamTime == 0.0) { system::setThreadName("Audio"); // system::setThreadRealTime(); } - port->processStream((const float *) inputBuffer, (float *) outputBuffer, nFrames); + port->processStream((const float*) inputBuffer, (float*) outputBuffer, nFrames); return 0; } @@ -226,7 +226,7 @@ void Port::openStream() { try { deviceInfo = rtAudio->getDeviceInfo(deviceId); } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to query RtAudio device: %s", e.what()); return; } @@ -265,12 +265,12 @@ void Port::openStream() { try { INFO("Opening audio RtAudio device %d with %d in %d out", deviceId, numInputs, numOutputs); rtAudio->openStream( - numOutputs == 0 ? NULL : &outParameters, - numInputs == 0 ? NULL : &inParameters, - RTAUDIO_FLOAT32, closestSampleRate, (unsigned int*) &blockSize, - &rtCallback, this, &options, NULL); + numOutputs == 0 ? NULL : &outParameters, + numInputs == 0 ? NULL : &inParameters, + RTAUDIO_FLOAT32, closestSampleRate, (unsigned int*) &blockSize, + &rtCallback, this, &options, NULL); } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to open RtAudio stream: %s", e.what()); return; } @@ -279,7 +279,7 @@ void Port::openStream() { INFO("Starting RtAudio stream %d", deviceId); rtAudio->startStream(); } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to start RtAudio stream: %s", e.what()); return; } @@ -303,7 +303,7 @@ void Port::closeStream() { try { rtAudio->stopStream(); } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to stop RtAudio stream %s", e.what()); } } @@ -312,7 +312,7 @@ void Port::closeStream() { try { rtAudio->closeStream(); } - catch (RtAudioError &e) { + catch (RtAudioError& e) { WARN("Failed to close RtAudio stream %s", e.what()); } } @@ -325,8 +325,8 @@ void Port::closeStream() { onCloseStream(); } -json_t *Port::toJson() { - json_t *rootJ = json_object(); +json_t* Port::toJson() { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "driver", json_integer(driverId)); std::string deviceName = getDeviceName(deviceId); if (!deviceName.empty()) @@ -338,14 +338,14 @@ json_t *Port::toJson() { return rootJ; } -void Port::fromJson(json_t *rootJ) { +void Port::fromJson(json_t* rootJ) { closeStream(); - json_t *driverJ = json_object_get(rootJ, "driver"); + json_t* driverJ = json_object_get(rootJ, "driver"); if (driverJ) setDriverId(json_number_value(driverJ)); - json_t *deviceNameJ = json_object_get(rootJ, "deviceName"); + json_t* deviceNameJ = json_object_get(rootJ, "deviceName"); if (deviceNameJ) { std::string deviceName = json_string_value(deviceNameJ); // Search for device ID with equal name @@ -357,19 +357,19 @@ void Port::fromJson(json_t *rootJ) { } } - json_t *offsetJ = json_object_get(rootJ, "offset"); + json_t* offsetJ = json_object_get(rootJ, "offset"); if (offsetJ) offset = json_integer_value(offsetJ); - json_t *maxChannelsJ = json_object_get(rootJ, "maxChannels"); + json_t* maxChannelsJ = json_object_get(rootJ, "maxChannels"); if (maxChannelsJ) maxChannels = json_integer_value(maxChannelsJ); - json_t *sampleRateJ = json_object_get(rootJ, "sampleRate"); + json_t* sampleRateJ = json_object_get(rootJ, "sampleRate"); if (sampleRateJ) sampleRate = json_integer_value(sampleRateJ); - json_t *blockSizeJ = json_object_get(rootJ, "blockSize"); + json_t* blockSizeJ = json_object_get(rootJ, "blockSize"); if (blockSizeJ) blockSize = json_integer_value(blockSizeJ); diff --git a/src/bridge.cpp b/src/bridge.cpp index 015137bd..e637e0a9 100644 --- a/src/bridge.cpp +++ b/src/bridge.cpp @@ -24,11 +24,11 @@ struct BridgeMidiDriver; struct BridgeClientConnection; -static BridgeClientConnection *connections[BRIDGE_NUM_PORTS] = {}; -static audio::Port *audioListeners[BRIDGE_NUM_PORTS] = {}; +static BridgeClientConnection* connections[BRIDGE_NUM_PORTS] = {}; +static audio::Port* audioListeners[BRIDGE_NUM_PORTS] = {}; static std::thread serverThread; static bool serverRunning = false; -static BridgeMidiDriver *driver = NULL; +static BridgeMidiDriver* driver = NULL; struct BridgeMidiInputDevice : midi::InputDevice { @@ -38,7 +38,9 @@ struct BridgeMidiInputDevice : midi::InputDevice { struct BridgeMidiDriver : midi::Driver { BridgeMidiInputDevice devices[16]; - std::string getName() override {return "Bridge";} + std::string getName() override { + return "Bridge"; + } std::vector getInputDeviceIds() override { std::vector deviceIds; @@ -54,7 +56,7 @@ struct BridgeMidiDriver : midi::Driver { return string::f("Port %d", deviceId + 1); } - midi::InputDevice *subscribeInput(int deviceId, midi::Input *input) override { + midi::InputDevice* subscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < 16)) return NULL; @@ -62,7 +64,7 @@ struct BridgeMidiDriver : midi::Driver { return &devices[deviceId]; } - void unsubscribeInput(int deviceId, midi::Input *input) override { + void unsubscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < 16)) return; @@ -83,7 +85,7 @@ struct BridgeClientConnection { } /** Returns true if successful */ - bool send(const void *buffer, int length) { + bool send(const void* buffer, int length) { if (length <= 0) return false; @@ -110,7 +112,7 @@ struct BridgeClientConnection { } /** Returns true if successful */ - bool recv(void *buffer, int length) { + bool recv(void* buffer, int length) { if (length <= 0) return false; @@ -132,7 +134,7 @@ struct BridgeClientConnection { } template - bool recv(T *x) { + bool recv(T* x) { return recv(x, sizeof(*x)); } @@ -206,7 +208,7 @@ struct BridgeClientConnection { case AUDIO_PROCESS_COMMAND: { uint32_t frames = 0; recv(&frames); - if (frames == 0 || frames > (1<<16)) { + if (frames == 0 || frames > (1 << 16)) { ready = false; return; } @@ -259,7 +261,7 @@ struct BridgeClientConnection { refreshAudio(); } - void processStream(const float *input, float *output, int frames) { + void processStream(const float* input, float* output, int frames) { if (!(0 <= port && port < BRIDGE_NUM_PORTS)) return; if (!audioListeners[port]) @@ -429,7 +431,7 @@ void bridgeDestroy() { serverThread.join(); } -void bridgeAudioSubscribe(int port, audio::Port *audio) { +void bridgeAudioSubscribe(int port, audio::Port* audio) { if (!(0 <= port && port < BRIDGE_NUM_PORTS)) return; // Check if an Audio is already subscribed on the port @@ -440,7 +442,7 @@ void bridgeAudioSubscribe(int port, audio::Port *audio) { connections[port]->refreshAudio(); } -void bridgeAudioUnsubscribe(int port, audio::Port *audio) { +void bridgeAudioUnsubscribe(int port, audio::Port* audio) { if (!(0 <= port && port < BRIDGE_NUM_PORTS)) return; if (audioListeners[port] != audio) diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index 75b155fc..e6f584c9 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -19,9 +19,9 @@ struct AudioInterfacePort : audio::Port { std::mutex audioMutex; std::condition_variable audioCv; // Audio thread produces, engine thread consumes - dsp::DoubleRingBuffer, (1<<15)> inputBuffer; + dsp::DoubleRingBuffer < dsp::Frame, (1 << 15) > inputBuffer; // Audio thread consumes, engine thread produces - dsp::DoubleRingBuffer, (1<<15)> outputBuffer; + dsp::DoubleRingBuffer < dsp::Frame, (1 << 15) > outputBuffer; bool active = false; ~AudioInterfacePort() { @@ -29,7 +29,7 @@ struct AudioInterfacePort : audio::Port { setDeviceId(-1, 0); } - void processStream(const float *input, float *output, int frames) override { + void processStream(const float* input, float* output, int frames) override { // Reactivate idle stream if (!active) { active = true; @@ -60,7 +60,7 @@ struct AudioInterfacePort : audio::Port { for (int i = 0; i < frames; i++) { dsp::Frame f = outputBuffer.shift(); for (int j = 0; j < numOutputs; j++) { - output[numOutputs*i + j] = clamp(f.samples[j], -1.f, 1.f); + output[numOutputs * i + j] = clamp(f.samples[j], -1.f, 1.f); } } } @@ -122,7 +122,7 @@ struct AudioInterface : Module { onSampleRateChange(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { // Update SRC states inputSrc.setRates(port.sampleRate, args.sampleRate); outputSrc.setRates(args.sampleRate, port.sampleRate); @@ -212,19 +212,19 @@ struct AudioInterface : Module { // Turn on light if at least one port is enabled in the nearby pair for (int i = 0; i < AUDIO_INPUTS / 2; i++) - lights[INPUT_LIGHT + i].setBrightness(port.active && port.numOutputs >= 2*i+1); + lights[INPUT_LIGHT + i].setBrightness(port.active && port.numOutputs >= 2 * i + 1); for (int i = 0; i < AUDIO_OUTPUTS / 2; i++) - lights[OUTPUT_LIGHT + i].setBrightness(port.active && port.numInputs >= 2*i+1); + lights[OUTPUT_LIGHT + i].setBrightness(port.active && port.numInputs >= 2 * i + 1); } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "audio", port.toJson()); return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *audioJ = json_object_get(rootJ, "audio"); + void dataFromJson(json_t* rootJ) override { + json_t* audioJ = json_object_get(rootJ, "audio"); port.fromJson(audioJ); } @@ -237,7 +237,7 @@ struct AudioInterface : Module { struct AudioInterface8Widget : ModuleWidget { typedef AudioInterface<8, 8> TAudioInterface; - AudioInterface8Widget(TAudioInterface *module) { + AudioInterface8Widget(TAudioInterface* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface.svg"))); @@ -273,7 +273,7 @@ struct AudioInterface8Widget : ModuleWidget { addChild(createLight>(mm2px(Vec(12.524985, 107.17003)), module, TAudioInterface::OUTPUT_LIGHT + 2)); addChild(createLight>(mm2px(Vec(35.725647, 107.17003)), module, TAudioInterface::OUTPUT_LIGHT + 3)); - AudioWidget *audioWidget = createWidget(mm2px(Vec(3.2122073, 14.837339))); + AudioWidget* audioWidget = createWidget(mm2px(Vec(3.2122073, 14.837339))); audioWidget->box.size = mm2px(Vec(44, 28)); audioWidget->setAudioPort(module ? &module->port : NULL); addChild(audioWidget); @@ -284,7 +284,7 @@ struct AudioInterface8Widget : ModuleWidget { struct AudioInterface16Widget : ModuleWidget { typedef AudioInterface<16, 16> TAudioInterface; - AudioInterface16Widget(TAudioInterface *module) { + AudioInterface16Widget(TAudioInterface* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/AudioInterface16.svg"))); @@ -344,7 +344,7 @@ struct AudioInterface16Widget : ModuleWidget { addChild(createLightCentered>(mm2px(Vec(59.861, 108.259)), module, TAudioInterface::OUTPUT_LIGHT + 6)); addChild(createLightCentered>(mm2px(Vec(83.061, 108.259)), module, TAudioInterface::OUTPUT_LIGHT + 7)); - AudioWidget *audioWidget = createWidget(mm2px(Vec(2.57, 14.839))); + AudioWidget* audioWidget = createWidget(mm2px(Vec(2.57, 14.839))); audioWidget->box.size = mm2px(Vec(91.382, 28.0)); audioWidget->setAudioPort(module ? &module->port : NULL); addChild(audioWidget); @@ -352,8 +352,8 @@ struct AudioInterface16Widget : ModuleWidget { }; -Model *modelAudioInterface = createModel, AudioInterface8Widget>("AudioInterface"); -Model *modelAudioInterface16 = createModel, AudioInterface16Widget>("AudioInterface16"); +Model* modelAudioInterface = createModel, AudioInterface8Widget>("AudioInterface"); +Model* modelAudioInterface16 = createModel, AudioInterface16Widget>("AudioInterface16"); } // namespace core diff --git a/src/core/Blank.cpp b/src/core/Blank.cpp index fbd69696..dc6d7f4d 100644 --- a/src/core/Blank.cpp +++ b/src/core/Blank.cpp @@ -7,7 +7,7 @@ namespace core { struct BlankPanel : Widget { - Widget *panelBorder; + Widget* panelBorder; BlankPanel() { panelBorder = new PanelBorder; @@ -19,7 +19,7 @@ struct BlankPanel : Widget { Widget::step(); } - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { nvgBeginPath(args.vg); nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y); nvgFillColor(args.vg, nvgRGB(0xe6, 0xe6, 0xe6)); @@ -38,18 +38,18 @@ struct ModuleResizeHandle : OpaqueWidget { box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT); } - void onDragStart(const event::DragStart &e) override { + void onDragStart(const event::DragStart& e) override { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; dragPos = APP->scene->rack->mousePos; - ModuleWidget *mw = getAncestorOfType(); + ModuleWidget* mw = getAncestorOfType(); assert(mw); originalBox = mw->box; } - void onDragMove(const event::DragMove &e) override { - ModuleWidget *mw = getAncestorOfType(); + void onDragMove(const event::DragMove& e) override { + ModuleWidget* mw = getAncestorOfType(); assert(mw); Vec newDragPos = APP->scene->rack->mousePos; @@ -77,7 +77,7 @@ struct ModuleResizeHandle : OpaqueWidget { } } - void draw(const DrawArgs &args) override { + void draw(const DrawArgs& args) override { for (float x = 5.0; x <= 10.0; x += 5.0) { nvgBeginPath(args.vg); const float margin = 5.0; @@ -92,20 +92,20 @@ struct ModuleResizeHandle : OpaqueWidget { struct BlankWidget : ModuleWidget { - Widget *topRightScrew; - Widget *bottomRightScrew; - Widget *rightHandle; - BlankPanel *blankPanel; + Widget* topRightScrew; + Widget* bottomRightScrew; + Widget* rightHandle; + BlankPanel* blankPanel; - BlankWidget(Module *module) { + BlankWidget(Module* module) { setModule(module); box.size = Vec(RACK_GRID_WIDTH * 10, RACK_GRID_HEIGHT); blankPanel = new BlankPanel; addChild(blankPanel); - ModuleResizeHandle *leftHandle = new ModuleResizeHandle; - ModuleResizeHandle *rightHandle = new ModuleResizeHandle; + ModuleResizeHandle* leftHandle = new ModuleResizeHandle; + ModuleResizeHandle* rightHandle = new ModuleResizeHandle; rightHandle->right = true; this->rightHandle = rightHandle; addChild(leftHandle); @@ -133,8 +133,8 @@ struct BlankWidget : ModuleWidget { ModuleWidget::step(); } - json_t *toJson() override { - json_t *rootJ = ModuleWidget::toJson(); + json_t* toJson() override { + json_t* rootJ = ModuleWidget::toJson(); // width json_object_set_new(rootJ, "width", json_real(box.size.x)); @@ -142,18 +142,18 @@ struct BlankWidget : ModuleWidget { return rootJ; } - void fromJson(json_t *rootJ) override { + void fromJson(json_t* rootJ) override { ModuleWidget::fromJson(rootJ); // width - json_t *widthJ = json_object_get(rootJ, "width"); + json_t* widthJ = json_object_get(rootJ, "width"); if (widthJ) box.size.x = json_number_value(widthJ); } }; -Model *modelBlank = createModel("Blank"); +Model* modelBlank = createModel("Blank"); } // namespace core diff --git a/src/core/CV_CC.cpp b/src/core/CV_CC.cpp index 78a49db4..ff42b296 100644 --- a/src/core/CV_CC.cpp +++ b/src/core/CV_CC.cpp @@ -66,7 +66,7 @@ struct CV_CC : Module { midiOutput.midi::Output::reset(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { const float rateLimiterPeriod = 0.010f; rateLimiterPhase += args.sampleTime / rateLimiterPeriod; if (rateLimiterPhase >= 1.f) { @@ -83,10 +83,10 @@ struct CV_CC : Module { } } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); - json_t *ccsJ = json_array(); + json_t* ccsJ = json_array(); for (int i = 0; i < 16; i++) { json_array_append_new(ccsJ, json_integer(learnedCcs[i])); } @@ -96,17 +96,17 @@ struct CV_CC : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *ccsJ = json_object_get(rootJ, "ccs"); + void dataFromJson(json_t* rootJ) override { + json_t* ccsJ = json_object_get(rootJ, "ccs"); if (ccsJ) { for (int i = 0; i < 16; i++) { - json_t *ccJ = json_array_get(ccsJ, i); + json_t* ccJ = json_array_get(ccsJ, i); if (ccJ) learnedCcs[i] = json_integer_value(ccJ); } } - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiOutput.fromJson(midiJ); } @@ -114,7 +114,7 @@ struct CV_CC : Module { struct CV_CCWidget : ModuleWidget { - CV_CCWidget(CV_CC *module) { + CV_CCWidget(CV_CC* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/CV-CC.svg"))); @@ -141,7 +141,7 @@ struct CV_CCWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(43, 112)), module, CV_CC::CC_INPUTS + 15)); typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget *midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); + TMidiWidget* midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); midiWidget->box.size = mm2px(Vec(44, 54.667)); midiWidget->setMidiPort(module ? &module->midiOutput : NULL); midiWidget->setModule(module); @@ -150,7 +150,7 @@ struct CV_CCWidget : ModuleWidget { }; -Model *modelCV_CC = createModel("CV-CC"); +Model* modelCV_CC = createModel("CV-CC"); } // namespace core diff --git a/src/core/CV_Gate.cpp b/src/core/CV_Gate.cpp index 26dce800..b779c755 100644 --- a/src/core/CV_Gate.cpp +++ b/src/core/CV_Gate.cpp @@ -87,7 +87,7 @@ struct CV_Gate : Module { void onReset() override { for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { - learnedNotes[4 * y + x] = 36 + 4 * (3-y) + x; + learnedNotes[4 * y + x] = 36 + 4 * (3 - y) + x; } } learningId = -1; @@ -95,7 +95,7 @@ struct CV_Gate : Module { midiOutput.midi::Output::reset(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { for (int i = 0; i < 16; i++) { int note = learnedNotes[i]; if (velocityMode) { @@ -112,12 +112,12 @@ struct CV_Gate : Module { } } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); - json_t *notesJ = json_array(); + json_t* notesJ = json_array(); for (int i = 0; i < 16; i++) { - json_t *noteJ = json_integer(learnedNotes[i]); + json_t* noteJ = json_integer(learnedNotes[i]); json_array_append_new(notesJ, noteJ); } json_object_set_new(rootJ, "notes", notesJ); @@ -128,21 +128,21 @@ struct CV_Gate : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *notesJ = json_object_get(rootJ, "notes"); + void dataFromJson(json_t* rootJ) override { + json_t* notesJ = json_object_get(rootJ, "notes"); if (notesJ) { for (int i = 0; i < 16; i++) { - json_t *noteJ = json_array_get(notesJ, i); + json_t* noteJ = json_array_get(notesJ, i); if (noteJ) learnedNotes[i] = json_integer_value(noteJ); } } - json_t *velocityJ = json_object_get(rootJ, "velocity"); + json_t* velocityJ = json_object_get(rootJ, "velocity"); if (velocityJ) velocityMode = json_boolean_value(velocityJ); - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiOutput.fromJson(midiJ); } @@ -150,23 +150,23 @@ struct CV_Gate : Module { struct CV_GateVelocityItem : MenuItem { - CV_Gate *module; - void onAction(const event::Action &e) override { + CV_Gate* module; + void onAction(const event::Action& e) override { module->velocityMode ^= true; } }; struct CV_GatePanicItem : MenuItem { - CV_Gate *module; - void onAction(const event::Action &e) override { + CV_Gate* module; + void onAction(const event::Action& e) override { module->midiOutput.panic(); } }; struct CV_GateWidget : ModuleWidget { - CV_GateWidget(CV_Gate *module) { + CV_GateWidget(CV_Gate* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/CV-Gate.svg"))); @@ -193,22 +193,22 @@ struct CV_GateWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(43, 112)), module, CV_Gate::GATE_INPUTS + 15)); typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget *midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); + TMidiWidget* midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); midiWidget->box.size = mm2px(Vec(44, 54.667)); midiWidget->setMidiPort(module ? &module->midiOutput : NULL); midiWidget->setModule(module); addChild(midiWidget); } - void appendContextMenu(Menu *menu) override { - CV_Gate *module = dynamic_cast(this->module); + void appendContextMenu(Menu* menu) override { + CV_Gate* module = dynamic_cast(this->module); menu->addChild(new MenuEntry); - CV_GateVelocityItem *velocityItem = createMenuItem("Velocity mode", CHECKMARK(module->velocityMode)); + CV_GateVelocityItem* velocityItem = createMenuItem("Velocity mode", CHECKMARK(module->velocityMode)); velocityItem->module = module; menu->addChild(velocityItem); - CV_GatePanicItem *panicItem = new CV_GatePanicItem; + CV_GatePanicItem* panicItem = new CV_GatePanicItem; panicItem->text = "Panic"; panicItem->module = module; menu->addChild(panicItem); @@ -216,7 +216,7 @@ struct CV_GateWidget : ModuleWidget { }; -Model *modelCV_Gate = createModel("CV-Gate"); +Model* modelCV_Gate = createModel("CV-Gate"); } // namespace core diff --git a/src/core/CV_MIDI.cpp b/src/core/CV_MIDI.cpp index 1855a875..ef5245bd 100644 --- a/src/core/CV_MIDI.cpp +++ b/src/core/CV_MIDI.cpp @@ -55,7 +55,7 @@ struct CV_MIDI : Module { midiOutput.reset(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { const float rateLimiterPeriod = 0.005f; rateLimiterPhase += args.sampleTime / rateLimiterPeriod; if (rateLimiterPhase >= 1.f) { @@ -109,14 +109,14 @@ struct CV_MIDI : Module { midiOutput.setContinue(cont); } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "midi", midiOutput.toJson()); return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *midiJ = json_object_get(rootJ, "midi"); + void dataFromJson(json_t* rootJ) override { + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiOutput.fromJson(midiJ); } @@ -124,15 +124,15 @@ struct CV_MIDI : Module { struct CV_MIDIPanicItem : MenuItem { - CV_MIDI *module; - void onAction(const event::Action &e) override { + CV_MIDI* module; + void onAction(const event::Action& e) override { module->midiOutput.panic(); } }; struct CV_MIDIWidget : ModuleWidget { - CV_MIDIWidget(CV_MIDI *module) { + CV_MIDIWidget(CV_MIDI* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/CV-MIDI.svg"))); @@ -154,18 +154,18 @@ struct CV_MIDIWidget : ModuleWidget { addInput(createInputCentered(mm2px(Vec(20, 112)), module, CV_MIDI::STOP_INPUT)); addInput(createInputCentered(mm2px(Vec(32, 112)), module, CV_MIDI::CONTINUE_INPUT)); - MidiWidget *midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); + MidiWidget* midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); midiWidget->box.size = mm2px(Vec(33.840, 28)); midiWidget->setMidiPort(module ? &module->midiOutput : NULL); addChild(midiWidget); } - void appendContextMenu(Menu *menu) override { - CV_MIDI *module = dynamic_cast(this->module); + void appendContextMenu(Menu* menu) override { + CV_MIDI* module = dynamic_cast(this->module); menu->addChild(new MenuEntry); - CV_MIDIPanicItem *panicItem = new CV_MIDIPanicItem; + CV_MIDIPanicItem* panicItem = new CV_MIDIPanicItem; panicItem->text = "Panic"; panicItem->module = module; menu->addChild(panicItem); @@ -173,7 +173,7 @@ struct CV_MIDIWidget : ModuleWidget { }; -Model *modelCV_MIDI = createModel("CV-MIDI"); +Model* modelCV_MIDI = createModel("CV-MIDI"); } // namespace core diff --git a/src/core/MIDI_CC.cpp b/src/core/MIDI_CC.cpp index 5e9866d8..1eb3566d 100644 --- a/src/core/MIDI_CC.cpp +++ b/src/core/MIDI_CC.cpp @@ -46,7 +46,7 @@ struct MIDI_CC : Module { midiInput.reset(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { midi::Message msg; while (midiInput.shift(&msg)) { processMessage(msg); @@ -99,17 +99,17 @@ struct MIDI_CC : Module { values[cc] = value; } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); - json_t *ccsJ = json_array(); + json_t* ccsJ = json_array(); for (int i = 0; i < 16; i++) { json_array_append_new(ccsJ, json_integer(learnedCcs[i])); } json_object_set_new(rootJ, "ccs", ccsJ); // Remember values so users don't have to touch MIDI controller knobs when restarting Rack - json_t *valuesJ = json_array(); + json_t* valuesJ = json_array(); for (int i = 0; i < 128; i++) { json_array_append_new(valuesJ, json_integer(values[i])); } @@ -119,27 +119,27 @@ struct MIDI_CC : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *ccsJ = json_object_get(rootJ, "ccs"); + void dataFromJson(json_t* rootJ) override { + json_t* ccsJ = json_object_get(rootJ, "ccs"); if (ccsJ) { for (int i = 0; i < 16; i++) { - json_t *ccJ = json_array_get(ccsJ, i); + json_t* ccJ = json_array_get(ccsJ, i); if (ccJ) learnedCcs[i] = json_integer_value(ccJ); } } - json_t *valuesJ = json_object_get(rootJ, "values"); + json_t* valuesJ = json_object_get(rootJ, "values"); if (valuesJ) { for (int i = 0; i < 128; i++) { - json_t *valueJ = json_array_get(valuesJ, i); + json_t* valueJ = json_array_get(valuesJ, i); if (valueJ) { values[i] = json_integer_value(valueJ); } } } - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiInput.fromJson(midiJ); } @@ -147,7 +147,7 @@ struct MIDI_CC : Module { struct MIDI_CCWidget : ModuleWidget { - MIDI_CCWidget(MIDI_CC *module) { + MIDI_CCWidget(MIDI_CC* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CC.svg"))); @@ -174,7 +174,7 @@ struct MIDI_CCWidget : ModuleWidget { addOutput(createOutput(mm2px(Vec(38.693932, 108.14429)), module, MIDI_CC::CC_OUTPUT + 15)); typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget *midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); + TMidiWidget* midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); midiWidget->box.size = mm2px(Vec(44, 54.667)); midiWidget->setMidiPort(module ? &module->midiInput : NULL); midiWidget->setModule(module); @@ -184,7 +184,7 @@ struct MIDI_CCWidget : ModuleWidget { // Use legacy slug for compatibility -Model *modelMIDI_CC = createModel("MIDICCToCVInterface"); +Model* modelMIDI_CC = createModel("MIDICCToCVInterface"); } // namespace core diff --git a/src/core/MIDI_CV.cpp b/src/core/MIDI_CV.cpp index 2d6047ae..23c9846e 100644 --- a/src/core/MIDI_CV.cpp +++ b/src/core/MIDI_CV.cpp @@ -106,7 +106,7 @@ struct MIDI_CV : Module { heldNotes.clear(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { midi::Message msg; while (midiInput.shift(&msg)) { processMessage(msg); @@ -129,14 +129,14 @@ struct MIDI_CV : Module { for (int c = 0; c < channels; c++) { outputs[PITCH_OUTPUT].setChannels(channels); outputs[MOD_OUTPUT].setChannels(channels); - outputs[PITCH_OUTPUT].setVoltage(pitchFilters[c].process(args.sampleTime, rescale(pitches[c], 0, 1<<14, -5.f, 5.f)), c); + outputs[PITCH_OUTPUT].setVoltage(pitchFilters[c].process(args.sampleTime, rescale(pitches[c], 0, 1 << 14, -5.f, 5.f)), c); outputs[MOD_OUTPUT].setVoltage(modFilters[c].process(args.sampleTime, rescale(mods[c], 0, 127, 0.f, 10.f)), c); } } else { outputs[PITCH_OUTPUT].setChannels(1); outputs[MOD_OUTPUT].setChannels(1); - outputs[PITCH_OUTPUT].setVoltage(pitchFilters[0].process(args.sampleTime, rescale(pitches[0], 0, 1<<14, -5.f, 5.f))); + outputs[PITCH_OUTPUT].setVoltage(pitchFilters[0].process(args.sampleTime, rescale(pitches[0], 0, 1 << 14, -5.f, 5.f))); outputs[MOD_OUTPUT].setVoltage(modFilters[0].process(args.sampleTime, rescale(mods[0], 0, 127, 0.f, 10.f))); } @@ -377,8 +377,8 @@ struct MIDI_CV : Module { panic(); } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "channels", json_integer(channels)); json_object_set_new(rootJ, "polyMode", json_integer(polyMode)); json_object_set_new(rootJ, "clockDivision", json_integer(clockDivision)); @@ -391,28 +391,28 @@ struct MIDI_CV : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *channelsJ = json_object_get(rootJ, "channels"); + void dataFromJson(json_t* rootJ) override { + json_t* channelsJ = json_object_get(rootJ, "channels"); if (channelsJ) setChannels(json_integer_value(channelsJ)); - json_t *polyModeJ = json_object_get(rootJ, "polyMode"); + json_t* polyModeJ = json_object_get(rootJ, "polyMode"); if (polyModeJ) polyMode = (PolyMode) json_integer_value(polyModeJ); - json_t *clockDivisionJ = json_object_get(rootJ, "clockDivision"); + json_t* clockDivisionJ = json_object_get(rootJ, "clockDivision"); if (clockDivisionJ) clockDivision = json_integer_value(clockDivisionJ); - json_t *lastPitchJ = json_object_get(rootJ, "lastPitch"); + json_t* lastPitchJ = json_object_get(rootJ, "lastPitch"); if (lastPitchJ) pitches[0] = json_integer_value(lastPitchJ); - json_t *lastModJ = json_object_get(rootJ, "lastMod"); + json_t* lastModJ = json_object_get(rootJ, "lastMod"); if (lastModJ) mods[0] = json_integer_value(lastModJ); - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiInput.fromJson(midiJ); } @@ -420,22 +420,22 @@ struct MIDI_CV : Module { struct ClockDivisionValueItem : MenuItem { - MIDI_CV *module; + MIDI_CV* module; int clockDivision; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { module->clockDivision = clockDivision; } }; struct ClockDivisionItem : MenuItem { - MIDI_CV *module; - Menu *createChildMenu() override { - Menu *menu = new Menu; - std::vector divisions = {24*4, 24*2, 24, 24/2, 24/4, 24/8, 2, 1}; + MIDI_CV* module; + Menu* createChildMenu() override { + Menu* menu = new Menu; + std::vector divisions = {24 * 4, 24 * 2, 24, 24 / 2, 24 / 4, 24 / 8, 2, 1}; std::vector divisionNames = {"Whole", "Half", "Quarter", "8th", "16th", "32nd", "12 PPQN", "24 PPQN"}; for (size_t i = 0; i < divisions.size(); i++) { - ClockDivisionValueItem *item = new ClockDivisionValueItem; + ClockDivisionValueItem* item = new ClockDivisionValueItem; item->text = divisionNames[i]; item->rightText = CHECKMARK(module->clockDivision == divisions[i]); item->module = module; @@ -448,20 +448,20 @@ struct ClockDivisionItem : MenuItem { struct ChannelValueItem : MenuItem { - MIDI_CV *module; + MIDI_CV* module; int channels; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { module->setChannels(channels); } }; struct ChannelItem : MenuItem { - MIDI_CV *module; - Menu *createChildMenu() override { - Menu *menu = new Menu; + MIDI_CV* module; + Menu* createChildMenu() override { + Menu* menu = new Menu; for (int channels = 1; channels <= 16; channels++) { - ChannelValueItem *item = new ChannelValueItem; + ChannelValueItem* item = new ChannelValueItem; if (channels == 1) item->text = "Monophonic"; else @@ -477,18 +477,18 @@ struct ChannelItem : MenuItem { struct PolyModeValueItem : MenuItem { - MIDI_CV *module; + MIDI_CV* module; MIDI_CV::PolyMode polyMode; - void onAction(const event::Action &e) override { + void onAction(const event::Action& e) override { module->setPolyMode(polyMode); } }; struct PolyModeItem : MenuItem { - MIDI_CV *module; - Menu *createChildMenu() override { - Menu *menu = new Menu; + MIDI_CV* module; + Menu* createChildMenu() override { + Menu* menu = new Menu; std::vector polyModeNames = { "Rotate", "Reuse", @@ -497,7 +497,7 @@ struct PolyModeItem : MenuItem { }; for (int i = 0; i < MIDI_CV::NUM_POLY_MODES; i++) { MIDI_CV::PolyMode polyMode = (MIDI_CV::PolyMode) i; - PolyModeValueItem *item = new PolyModeValueItem; + PolyModeValueItem* item = new PolyModeValueItem; item->text = polyModeNames[i]; item->rightText = CHECKMARK(module->polyMode == polyMode); item->module = module; @@ -510,15 +510,15 @@ struct PolyModeItem : MenuItem { struct MIDI_CVPanicItem : MenuItem { - MIDI_CV *module; - void onAction(const event::Action &e) override { + MIDI_CV* module; + void onAction(const event::Action& e) override { module->panic(); } }; struct MIDI_CVWidget : ModuleWidget { - MIDI_CVWidget(MIDI_CV *module) { + MIDI_CVWidget(MIDI_CV* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-CV.svg"))); @@ -540,36 +540,36 @@ struct MIDI_CVWidget : ModuleWidget { addOutput(createOutput(mm2px(Vec(16.214, 108.144)), module, MIDI_CV::STOP_OUTPUT)); addOutput(createOutput(mm2px(Vec(27.8143, 108.144)), module, MIDI_CV::CONTINUE_OUTPUT)); - MidiWidget *midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); + MidiWidget* midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); midiWidget->box.size = mm2px(Vec(33.840, 28)); midiWidget->setMidiPort(module ? &module->midiInput : NULL); addChild(midiWidget); } - void appendContextMenu(Menu *menu) override { - MIDI_CV *module = dynamic_cast(this->module); + void appendContextMenu(Menu* menu) override { + MIDI_CV* module = dynamic_cast(this->module); menu->addChild(new MenuEntry); - ClockDivisionItem *clockDivisionItem = new ClockDivisionItem; + ClockDivisionItem* clockDivisionItem = new ClockDivisionItem; clockDivisionItem->text = "CLK/N divider"; clockDivisionItem->rightText = RIGHT_ARROW; clockDivisionItem->module = module; menu->addChild(clockDivisionItem); - ChannelItem *channelItem = new ChannelItem; + ChannelItem* channelItem = new ChannelItem; channelItem->text = "Polyphony channels"; - channelItem->rightText = string::f("%d", module->channels) + " " +RIGHT_ARROW; + channelItem->rightText = string::f("%d", module->channels) + " " + RIGHT_ARROW; channelItem->module = module; menu->addChild(channelItem); - PolyModeItem *polyModeItem = new PolyModeItem; + PolyModeItem* polyModeItem = new PolyModeItem; polyModeItem->text = "Polyphony mode"; polyModeItem->rightText = RIGHT_ARROW; polyModeItem->module = module; menu->addChild(polyModeItem); - MIDI_CVPanicItem *panicItem = new MIDI_CVPanicItem; + MIDI_CVPanicItem* panicItem = new MIDI_CVPanicItem; panicItem->text = "Panic"; panicItem->module = module; menu->addChild(panicItem); @@ -578,7 +578,7 @@ struct MIDI_CVWidget : ModuleWidget { // Use legacy slug for compatibility -Model *modelMIDI_CV = createModel("MIDIToCVInterface"); +Model* modelMIDI_CV = createModel("MIDIToCVInterface"); } // namespace core diff --git a/src/core/MIDI_Gate.cpp b/src/core/MIDI_Gate.cpp index 1ca4dcdd..f2818816 100644 --- a/src/core/MIDI_Gate.cpp +++ b/src/core/MIDI_Gate.cpp @@ -37,7 +37,7 @@ struct MIDI_Gate : Module { void onReset() override { for (int y = 0; y < 4; y++) { for (int x = 0; x < 4; x++) { - learnedNotes[4 * y + x] = 36 + 4 * (3-y) + x; + learnedNotes[4 * y + x] = 36 + 4 * (3 - y) + x; } } learningId = -1; @@ -52,7 +52,7 @@ struct MIDI_Gate : Module { } } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { midi::Message msg; while (midiInput.shift(&msg)) { processMessage(msg); @@ -118,12 +118,12 @@ struct MIDI_Gate : Module { } } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); - json_t *notesJ = json_array(); + json_t* notesJ = json_array(); for (int i = 0; i < 16; i++) { - json_t *noteJ = json_integer(learnedNotes[i]); + json_t* noteJ = json_integer(learnedNotes[i]); json_array_append_new(notesJ, noteJ); } json_object_set_new(rootJ, "notes", notesJ); @@ -134,21 +134,21 @@ struct MIDI_Gate : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { - json_t *notesJ = json_object_get(rootJ, "notes"); + void dataFromJson(json_t* rootJ) override { + json_t* notesJ = json_object_get(rootJ, "notes"); if (notesJ) { for (int i = 0; i < 16; i++) { - json_t *noteJ = json_array_get(notesJ, i); + json_t* noteJ = json_array_get(notesJ, i); if (noteJ) learnedNotes[i] = json_integer_value(noteJ); } } - json_t *velocityJ = json_object_get(rootJ, "velocity"); + json_t* velocityJ = json_object_get(rootJ, "velocity"); if (velocityJ) velocityMode = json_boolean_value(velocityJ); - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiInput.fromJson(midiJ); } @@ -156,23 +156,23 @@ struct MIDI_Gate : Module { struct MIDI_GateVelocityItem : MenuItem { - MIDI_Gate *module; - void onAction(const event::Action &e) override { + MIDI_Gate* module; + void onAction(const event::Action& e) override { module->velocityMode ^= true; } }; struct MIDI_GatePanicItem : MenuItem { - MIDI_Gate *module; - void onAction(const event::Action &e) override { + MIDI_Gate* module; + void onAction(const event::Action& e) override { module->panic(); } }; struct MIDI_GateWidget : ModuleWidget { - MIDI_GateWidget(MIDI_Gate *module) { + MIDI_GateWidget(MIDI_Gate* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Gate.svg"))); @@ -199,22 +199,22 @@ struct MIDI_GateWidget : ModuleWidget { addOutput(createOutput(mm2px(Vec(38.693932, 108.14429)), module, MIDI_Gate::TRIG_OUTPUT + 15)); typedef Grid16MidiWidget> TMidiWidget; - TMidiWidget *midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); + TMidiWidget* midiWidget = createWidget(mm2px(Vec(3.399621, 14.837339))); midiWidget->box.size = mm2px(Vec(44, 54.667)); midiWidget->setMidiPort(module ? &module->midiInput : NULL); midiWidget->setModule(module); addChild(midiWidget); } - void appendContextMenu(Menu *menu) override { - MIDI_Gate *module = dynamic_cast(this->module); + void appendContextMenu(Menu* menu) override { + MIDI_Gate* module = dynamic_cast(this->module); menu->addChild(new MenuEntry); - MIDI_GateVelocityItem *velocityItem = createMenuItem("Velocity mode", CHECKMARK(module->velocityMode)); + MIDI_GateVelocityItem* velocityItem = createMenuItem("Velocity mode", CHECKMARK(module->velocityMode)); velocityItem->module = module; menu->addChild(velocityItem); - MIDI_GatePanicItem *panicItem = new MIDI_GatePanicItem; + MIDI_GatePanicItem* panicItem = new MIDI_GatePanicItem; panicItem->text = "Panic"; panicItem->module = module; menu->addChild(panicItem); @@ -223,7 +223,7 @@ struct MIDI_GateWidget : ModuleWidget { // Use legacy slug for compatibility -Model *modelMIDI_Gate = createModel("MIDITriggerToCVInterface"); +Model* modelMIDI_Gate = createModel("MIDITriggerToCVInterface"); } // namespace core diff --git a/src/core/MIDI_Map.cpp b/src/core/MIDI_Map.cpp index bee12518..38e44d1e 100644 --- a/src/core/MIDI_Map.cpp +++ b/src/core/MIDI_Map.cpp @@ -70,7 +70,7 @@ struct MIDI_Map : Module { midiInput.reset(); } - void process(const ProcessArgs &args) override { + void process(const ProcessArgs& args) override { midi::Message msg; while (midiInput.shift(&msg)) { processMessage(msg); @@ -85,12 +85,12 @@ struct MIDI_Map : Module { if (values[cc] < 0) continue; // Get Module - Module *module = paramHandles[id].module; + Module* module = paramHandles[id].module; if (!module) continue; // Get ParamQuantity int paramId = paramHandles[id].paramId; - ParamQuantity *paramQuantity = module->paramQuantities[paramId]; + ParamQuantity* paramQuantity = module->paramQuantities[paramId]; if (!paramQuantity) continue; if (!paramQuantity->isBounded()) @@ -208,12 +208,12 @@ struct MIDI_Map : Module { paramHandles[id].text = text; } - json_t *dataToJson() override { - json_t *rootJ = json_object(); + json_t* dataToJson() override { + json_t* rootJ = json_object(); - json_t *mapsJ = json_array(); + json_t* mapsJ = json_array(); for (int id = 0; id < mapLen; id++) { - json_t *mapJ = json_object(); + json_t* mapJ = json_object(); json_object_set_new(mapJ, "cc", json_integer(ccs[id])); json_object_set_new(mapJ, "moduleId", json_integer(paramHandles[id].moduleId)); json_object_set_new(mapJ, "paramId", json_integer(paramHandles[id].paramId)); @@ -225,17 +225,17 @@ struct MIDI_Map : Module { return rootJ; } - void dataFromJson(json_t *rootJ) override { + void dataFromJson(json_t* rootJ) override { clearMaps(); - json_t *mapsJ = json_object_get(rootJ, "maps"); + json_t* mapsJ = json_object_get(rootJ, "maps"); if (mapsJ) { - json_t *mapJ; + json_t* mapJ; size_t mapIndex; json_array_foreach(mapsJ, mapIndex, mapJ) { - json_t *ccJ = json_object_get(mapJ, "cc"); - json_t *moduleIdJ = json_object_get(mapJ, "moduleId"); - json_t *paramIdJ = json_object_get(mapJ, "paramId"); + json_t* ccJ = json_object_get(mapJ, "cc"); + json_t* moduleIdJ = json_object_get(mapJ, "moduleId"); + json_t* paramIdJ = json_object_get(mapJ, "paramId"); if (!(ccJ && moduleIdJ && paramIdJ)) continue; if (mapIndex >= MAX_CHANNELS) @@ -248,7 +248,7 @@ struct MIDI_Map : Module { updateMapLen(); - json_t *midiJ = json_object_get(rootJ, "midi"); + json_t* midiJ = json_object_get(rootJ, "midi"); if (midiJ) midiInput.fromJson(midiJ); } @@ -256,15 +256,15 @@ struct MIDI_Map : Module { struct MIDI_MapChoice : LedDisplayChoice { - MIDI_Map *module; + MIDI_Map* module; int id; int disableLearnFrames = -1; - void setModule(MIDI_Map *module) { + void setModule(MIDI_Map* module) { this->module = module; } - void onButton(const event::Button &e) override { + void onButton(const event::Button& e) override { e.stopPropagating(); if (!module) return; @@ -279,11 +279,11 @@ struct MIDI_MapChoice : LedDisplayChoice { } } - void onSelect(const event::Select &e) override { + void onSelect(const event::Select& e) override { if (!module) return; - ScrollWidget *scroll = getAncestorOfType(); + ScrollWidget* scroll = getAncestorOfType(); scroll->scrollTo(box); // Reset touchedParam @@ -291,11 +291,11 @@ struct MIDI_MapChoice : LedDisplayChoice { module->enableLearn(id); } - void onDeselect(const event::Deselect &e) override { + void onDeselect(const event::Deselect& e) override { if (!module) return; // Check if a ParamWidget was touched - ParamWidget *touchedParam = APP->scene->rack->touchedParam; + ParamWidget* touchedParam = APP->scene->rack->touchedParam; if (touchedParam) { APP->scene->rack->touchedParam = NULL; int moduleId = touchedParam->paramQuantity->module->id; @@ -359,21 +359,21 @@ struct MIDI_MapChoice : LedDisplayChoice { return ""; if (id >= module->mapLen) return ""; - ParamHandle *paramHandle = &module->paramHandles[id]; + ParamHandle* paramHandle = &module->paramHandles[id]; if (paramHandle->moduleId < 0) return ""; - ModuleWidget *mw = APP->scene->rack->getModule(paramHandle->moduleId); + ModuleWidget* mw = APP->scene->rack->getModule(paramHandle->moduleId); if (!mw) return ""; // Get the Module from the ModuleWidget instead of the ParamHandle. // I think this is more elegant since this method is called in the app world instead of the engine world. - Module *m = mw->module; + Module* m = mw->module; if (!m) return ""; int paramId = paramHandle->paramId; if (paramId >= (int) m->params.size()) return ""; - ParamQuantity *paramQuantity = m->paramQuantities[paramId]; + ParamQuantity* paramQuantity = m->paramQuantities[paramId]; std::string s; s += mw->model->name; s += " "; @@ -384,12 +384,12 @@ struct MIDI_MapChoice : LedDisplayChoice { struct MIDI_MapDisplay : MidiWidget { - MIDI_Map *module; - ScrollWidget *scroll; - MIDI_MapChoice *choices[MAX_CHANNELS]; - LedDisplaySeparator *separators[MAX_CHANNELS]; + MIDI_Map* module; + ScrollWidget* scroll; + MIDI_MapChoice* choices[MAX_CHANNELS]; + LedDisplaySeparator* separators[MAX_CHANNELS]; - void setModule(MIDI_Map *module) { + void setModule(MIDI_Map* module) { this->module = module; scroll = new ScrollWidget; @@ -398,7 +398,7 @@ struct MIDI_MapDisplay : MidiWidget { scroll->box.size.y = box.size.y - scroll->box.pos.y; addChild(scroll); - LedDisplaySeparator *separator = createWidget(scroll->box.pos); + LedDisplaySeparator* separator = createWidget(scroll->box.pos); separator->box.size.x = box.size.x; addChild(separator); separators[0] = separator; @@ -406,13 +406,13 @@ struct MIDI_MapDisplay : MidiWidget { Vec pos; for (int id = 0; id < MAX_CHANNELS; id++) { if (id > 0) { - LedDisplaySeparator *separator = createWidget(pos); + LedDisplaySeparator* separator = createWidget(pos); separator->box.size.x = box.size.x; scroll->container->addChild(separator); separators[id] = separator; } - MIDI_MapChoice *choice = createWidget(pos); + MIDI_MapChoice* choice = createWidget(pos); choice->box.size.x = box.size.x; choice->id = id; choice->setModule(module); @@ -438,7 +438,7 @@ struct MIDI_MapDisplay : MidiWidget { struct MIDI_MapWidget : ModuleWidget { - MIDI_MapWidget(MIDI_Map *module) { + MIDI_MapWidget(MIDI_Map* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/MIDI-Map.svg"))); @@ -447,7 +447,7 @@ struct MIDI_MapWidget : ModuleWidget { addChild(createWidget(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); addChild(createWidget(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH))); - MIDI_MapDisplay *midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); + MIDI_MapDisplay* midiWidget = createWidget(mm2px(Vec(3.41891, 14.8373))); midiWidget->box.size = mm2px(Vec(43.999, 102.664)); midiWidget->setMidiPort(module ? &module->midiInput : NULL); midiWidget->setModule(module); @@ -456,7 +456,7 @@ struct MIDI_MapWidget : ModuleWidget { }; -Model *modelMIDI_Map = createModel("MIDI-Map"); +Model* modelMIDI_Map = createModel("MIDI-Map"); } // namespace core diff --git a/src/core/Notes.cpp b/src/core/Notes.cpp index 406c889b..b62abeb1 100644 --- a/src/core/Notes.cpp +++ b/src/core/Notes.cpp @@ -6,9 +6,9 @@ namespace core { struct NotesWidget : ModuleWidget { - TextField *textField; + TextField* textField; - NotesWidget(Module *module) { + NotesWidget(Module* module) { setModule(module); setPanel(APP->window->loadSvg(asset::system("res/Core/Notes.svg"))); @@ -23,8 +23,8 @@ struct NotesWidget : ModuleWidget { addChild(textField); } - json_t *toJson() override { - json_t *rootJ = ModuleWidget::toJson(); + json_t* toJson() override { + json_t* rootJ = ModuleWidget::toJson(); // text json_object_set_new(rootJ, "text", json_string(textField->text.c_str())); @@ -32,18 +32,18 @@ struct NotesWidget : ModuleWidget { return rootJ; } - void fromJson(json_t *rootJ) override { + void fromJson(json_t* rootJ) override { ModuleWidget::fromJson(rootJ); // text - json_t *textJ = json_object_get(rootJ, "text"); + json_t* textJ = json_object_get(rootJ, "text"); if (textJ) textField->text = json_string_value(textJ); } }; -Model *modelNotes = createModel("Notes"); +Model* modelNotes = createModel("Notes"); } // namespace core diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp index 0c53e964..349dd3aa 100644 --- a/src/core/plugin.cpp +++ b/src/core/plugin.cpp @@ -5,7 +5,7 @@ namespace rack { namespace core { -void init(rack::Plugin *p) { +void init(rack::Plugin* p) { p->addModel(modelAudioInterface); p->addModel(modelAudioInterface16); p->addModel(modelMIDI_CV); diff --git a/src/core/plugin.hpp b/src/core/plugin.hpp index d761a7ae..ad4f3842 100644 --- a/src/core/plugin.hpp +++ b/src/core/plugin.hpp @@ -5,27 +5,27 @@ namespace rack { namespace core { -extern Model *modelAudioInterface; -extern Model *modelAudioInterface16; -extern Model *modelMIDI_CV; -extern Model *modelMIDI_CC; -extern Model *modelMIDI_Gate; -extern Model *modelMIDI_Map; -extern Model *modelCV_MIDI; -extern Model *modelCV_CC; -extern Model *modelCV_Gate; -extern Model *modelBlank; -extern Model *modelNotes; +extern Model* modelAudioInterface; +extern Model* modelAudioInterface16; +extern Model* modelMIDI_CV; +extern Model* modelMIDI_CC; +extern Model* modelMIDI_Gate; +extern Model* modelMIDI_Map; +extern Model* modelCV_MIDI; +extern Model* modelCV_CC; +extern Model* modelCV_Gate; +extern Model* modelBlank; +extern Model* modelNotes; template struct Grid16MidiWidget : MidiWidget { - LedDisplaySeparator *hSeparators[4]; - LedDisplaySeparator *vSeparators[4]; - TChoice *choices[4][4]; + LedDisplaySeparator* hSeparators[4]; + LedDisplaySeparator* vSeparators[4]; + TChoice* choices[4][4]; template - void setModule(TModule *module) { + void setModule(TModule* module) { Vec pos = channelChoice->box.getBottomLeft(); // Add vSeparators for (int x = 1; x < 4; x++) { @@ -41,7 +41,7 @@ struct Grid16MidiWidget : MidiWidget { for (int x = 0; x < 4; x++) { choices[x][y] = new TChoice; choices[x][y]->box.pos = pos; - choices[x][y]->setId(4*y + x); + choices[x][y]->setId(4 * y + x); choices[x][y]->box.size.x = box.size.x / 4; choices[x][y]->box.pos.x = box.size.x / 4 * x; choices[x][y]->setModule(module); @@ -58,7 +58,7 @@ struct Grid16MidiWidget : MidiWidget { template struct CcChoice : LedDisplayChoice { - TModule *module; + TModule* module; int id; int focusCc; @@ -67,7 +67,7 @@ struct CcChoice : LedDisplayChoice { textOffset.y -= 4; } - void setModule(TModule *module) { + void setModule(TModule* module) { this->module = module; } @@ -97,7 +97,7 @@ struct CcChoice : LedDisplayChoice { } } - void onSelect(const event::Select &e) override { + void onSelect(const event::Select& e) override { if (!module) return; module->learningId = id; @@ -105,7 +105,7 @@ struct CcChoice : LedDisplayChoice { e.consume(this); } - void onDeselect(const event::Deselect &e) override { + void onDeselect(const event::Deselect& e) override { if (!module) return; if (module->learningId == id) { @@ -116,7 +116,7 @@ struct CcChoice : LedDisplayChoice { } } - void onSelectText(const event::SelectText &e) override { + void onSelectText(const event::SelectText& e) override { int c = e.codepoint - '0'; if (0 <= c && c <= 9) { if (focusCc < 0) @@ -128,7 +128,7 @@ struct CcChoice : LedDisplayChoice { e.consume(this); } - void onSelectKey(const event::SelectKey &e) override { + void onSelectKey(const event::SelectKey& e) override { if ((e.key == GLFW_KEY_ENTER || e.key == GLFW_KEY_KP_ENTER) && e.action == GLFW_PRESS && (e.mods & RACK_MOD_MASK) == 0) { event::Deselect eDeselect; onDeselect(eDeselect); @@ -141,7 +141,7 @@ struct CcChoice : LedDisplayChoice { template struct NoteChoice : LedDisplayChoice { - TModule *module; + TModule* module; int id; NoteChoice() { @@ -154,7 +154,7 @@ struct NoteChoice : LedDisplayChoice { this->id = id; } - void setModule(TModule *module) { + void setModule(TModule* module) { this->module = module; } @@ -169,7 +169,7 @@ struct NoteChoice : LedDisplayChoice { } else { uint8_t note = module->learnedNotes[id]; - static const char *noteNames[] = { + static const char* noteNames[] = { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; int oct = note / 12 - 1; @@ -183,14 +183,14 @@ struct NoteChoice : LedDisplayChoice { } } - void onSelect(const event::Select &e) override { + void onSelect(const event::Select& e) override { if (!module) return; module->learningId = id; e.consume(this); } - void onDeselect(const event::Deselect &e) override { + void onDeselect(const event::Deselect& e) override { if (!module) return; if (module->learningId == id) { diff --git a/src/dsp/minblep.cpp b/src/dsp/minblep.cpp index c809e7ed..cba79600 100644 --- a/src/dsp/minblep.cpp +++ b/src/dsp/minblep.cpp @@ -7,12 +7,12 @@ namespace rack { namespace dsp { -void minBlepImpulse(int z, int o, float *output) { +void minBlepImpulse(int z, int o, float* output) { // Symmetric sinc array with `z` zero-crossings on each side int n = 2 * z * o; - float *x = new float[n]; + float* x = new float[n]; for (int i = 0; i < n; i++) { - float p = math::rescale((float) i, 0.f, (float) (n - 1), (float) -z, (float) z); + float p = math::rescale((float) i, 0.f, (float)(n - 1), (float) - z, (float) z); x[i] = sinc(p); } @@ -20,18 +20,18 @@ void minBlepImpulse(int z, int o, float *output) { blackmanHarrisWindow(x, n); // Real cepstrum - float *fx = new float[2*n]; + float* fx = new float[2 * n]; RealFFT rfft(n); rfft.rfft(x, fx); // fx = log(abs(fx)) fx[0] = std::log(std::fabs(fx[0])); for (int i = 1; i < n; i++) { - fx[2*i] = std::log(std::hypot(fx[2*i], fx[2*i+1])); - fx[2*i+1] = 0.f; + fx[2 * i] = std::log(std::hypot(fx[2 * i], fx[2 * i + 1])); + fx[2 * i + 1] = 0.f; } fx[1] = std::log(std::fabs(fx[1])); // Clamp values in case we have -inf - for (int i = 0; i < 2*n; i++) { + for (int i = 0; i < 2 * n; i++) { fx[i] = std::fmax(-30.f, fx[i]); } rfft.irfft(fx, x); @@ -48,10 +48,10 @@ void minBlepImpulse(int z, int o, float *output) { // fx = exp(fx) fx[0] = std::exp(fx[0]); for (int i = 1; i < n; i++) { - float re = std::exp(fx[2*i]); - float im = fx[2*i+1]; - fx[2*i] = re * std::cos(im); - fx[2*i+1] = re * std::sin(im); + float re = std::exp(fx[2 * i]); + float im = fx[2 * i + 1]; + fx[2 * i] = re * std::cos(im); + fx[2 * i + 1] = re * std::sin(im); } fx[1] = std::exp(fx[1]); rfft.irfft(fx, x); diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 4820389c..c1926956 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -43,8 +43,8 @@ struct VIPMutex { struct VIPLock { - VIPMutex &m; - VIPLock(VIPMutex &m) : m(m) { + VIPMutex& m; + VIPLock(VIPMutex& m) : m(m) { std::unique_lock lock(m.countMutex); m.count++; } @@ -135,7 +135,7 @@ struct HybridBarrier { // Wait on mutex { std::unique_lock lock(mutex); - cv.wait(lock, [&]{ + cv.wait(lock, [&] { return count == 0; }); } @@ -144,7 +144,7 @@ struct HybridBarrier { struct EngineWorker { - Engine *engine; + Engine* engine; int id; std::thread thread; bool running = true; @@ -184,7 +184,7 @@ struct Engine::Internal { int nextCableId = 0; // Parameter smoothing - Module *smoothModule = NULL; + Module* smoothModule = NULL; int smoothParamId; float smoothValue; @@ -224,8 +224,8 @@ Engine::~Engine() { delete internal; } -static void Engine_stepModules(Engine *that, int threadId) { - Engine::Internal *internal = that->internal; +static void Engine_stepModules(Engine* that, int threadId) { + Engine::Internal* internal = that->internal; // int threadCount = internal->threadCount; int modulesLen = internal->modules.size(); @@ -243,7 +243,7 @@ static void Engine_stepModules(Engine *that, int threadId) { if (i >= modulesLen) break; - Module *module = internal->modules[i]; + Module* module = internal->modules[i]; if (!module->bypass) { // Step module if (settings::cpuMeter) { @@ -263,18 +263,18 @@ static void Engine_stepModules(Engine *that, int threadId) { } // Iterate ports to step plug lights - for (Input &input : module->inputs) { + for (Input& input : module->inputs) { input.process(sampleTime); } - for (Output &output : module->outputs) { + for (Output& output : module->outputs) { output.process(sampleTime); } } } -static void Cable_step(Cable *that) { - Output *output = &that->outputModule->outputs[that->outputId]; - Input *input = &that->inputModule->inputs[that->inputId]; +static void Cable_step(Cable* that) { + Output* output = &that->outputModule->outputs[that->outputId]; + Input* input = &that->inputModule->inputs[that->inputId]; // Match number of polyphonic channels to output port int channels = output->channels; input->channels = channels; @@ -288,15 +288,15 @@ static void Cable_step(Cable *that) { } } -static void Engine_step(Engine *that) { - Engine::Internal *internal = that->internal; +static void Engine_step(Engine* that) { + Engine::Internal* internal = that->internal; // Param smoothing - Module *smoothModule = internal->smoothModule; + Module* smoothModule = internal->smoothModule; int smoothParamId = internal->smoothParamId; float smoothValue = internal->smoothValue; if (smoothModule) { - Param *param = &smoothModule->params[smoothParamId]; + Param* param = &smoothModule->params[smoothParamId]; float value = param->value; // Decay rate is 1 graphics frame const float smoothLambda = 60.f; @@ -313,12 +313,12 @@ static void Engine_step(Engine *that) { } // Step cables - for (Cable *cable : that->internal->cables) { + for (Cable* cable : that->internal->cables) { Cable_step(cable); } // Flip messages for each module - for (Module *module : that->internal->modules) { + for (Module* module : that->internal->modules) { if (module->leftExpander.messageFlipRequested) { std::swap(module->leftExpander.producerMessage, module->leftExpander.consumerMessage); module->leftExpander.messageFlipRequested = false; @@ -338,7 +338,7 @@ static void Engine_step(Engine *that) { internal->frame++; } -static void Engine_updateExpander(Engine *that, Module::Expander *expander) { +static void Engine_updateExpander(Engine* that, Module::Expander* expander) { if (expander->moduleId >= 0) { if (!expander->module || expander->module->id != expander->moduleId) { expander->module = that->getModule(expander->moduleId); @@ -351,18 +351,18 @@ static void Engine_updateExpander(Engine *that, Module::Expander *expander) { } } -static void Engine_relaunchWorkers(Engine *that) { - Engine::Internal *internal = that->internal; +static void Engine_relaunchWorkers(Engine* that) { + Engine::Internal* internal = that->internal; assert(1 <= internal->threadCount); // Stop all workers - for (EngineWorker &worker : internal->workers) { + for (EngineWorker& worker : internal->workers) { worker.stop(); } internal->engineBarrier.wait(); // Destroy all workers - for (EngineWorker &worker : internal->workers) { + for (EngineWorker& worker : internal->workers) { worker.join(); } internal->workers.resize(0); @@ -377,15 +377,15 @@ static void Engine_relaunchWorkers(Engine *that) { // Create workers internal->workers.resize(internal->threadCount - 1); for (int id = 1; id < internal->threadCount; id++) { - EngineWorker &worker = internal->workers[id - 1]; + EngineWorker& worker = internal->workers[id - 1]; worker.id = id; worker.engine = that; worker.start(); } } -static void Engine_run(Engine *that) { - Engine::Internal *internal = that->internal; +static void Engine_run(Engine* that) { + Engine::Internal* internal = that->internal; // Set up thread system::setThreadName("Engine"); // system::setThreadRealTime(); @@ -405,7 +405,7 @@ static void Engine_run(Engine *that) { if (internal->sampleRate != settings::sampleRate) { internal->sampleRate = settings::sampleRate; internal->sampleTime = 1 / internal->sampleRate; - for (Module *module : internal->modules) { + for (Module* module : internal->modules) { module->onSampleRateChange(); } aheadTime = 0.0; @@ -422,7 +422,7 @@ static void Engine_run(Engine *that) { std::lock_guard lock(internal->mutex); // Update expander pointers - for (Module *module : internal->modules) { + for (Module* module : internal->modules) { Engine_updateExpander(that, &module->leftExpander); Engine_updateExpander(that, &module->rightExpander); } @@ -494,7 +494,7 @@ uint64_t Engine::getFrame() { return internal->frame; } -void Engine::addModule(Module *module) { +void Engine::addModule(Module* module) { assert(module); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -509,7 +509,7 @@ void Engine::addModule(Module *module) { else { // Manual ID // Check that the ID is not already taken - for (Module *m : internal->modules) { + for (Module* m : internal->modules) { assert(module->id != m->id); } if (module->id >= internal->nextModuleId) { @@ -521,13 +521,13 @@ void Engine::addModule(Module *module) { // Trigger Add event module->onAdd(); // Update ParamHandles' module pointers - for (ParamHandle *paramHandle : internal->paramHandles) { + for (ParamHandle* paramHandle : internal->paramHandles) { if (paramHandle->moduleId == module->id) paramHandle->module = module; } } -void Engine::removeModule(Module *module) { +void Engine::removeModule(Module* module) { assert(module); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -539,17 +539,17 @@ void Engine::removeModule(Module *module) { internal->smoothModule = NULL; } // Check that all cables are disconnected - for (Cable *cable : internal->cables) { + for (Cable* cable : internal->cables) { assert(cable->outputModule != module); assert(cable->inputModule != module); } // Update ParamHandles' module pointers - for (ParamHandle *paramHandle : internal->paramHandles) { + for (ParamHandle* paramHandle : internal->paramHandles) { if (paramHandle->moduleId == module->id) paramHandle->module = NULL; } // Update expander pointers - for (Module *m : internal->modules) { + for (Module* m : internal->modules) { if (m->leftExpander.module == module) { m->leftExpander.moduleId = -1; m->leftExpander.module = NULL; @@ -565,18 +565,18 @@ void Engine::removeModule(Module *module) { internal->modules.erase(it); } -Module *Engine::getModule(int moduleId) { +Module* Engine::getModule(int moduleId) { VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); // Find module - for (Module *module : internal->modules) { + for (Module* module : internal->modules) { if (module->id == moduleId) return module; } return NULL; } -void Engine::resetModule(Module *module) { +void Engine::resetModule(Module* module) { assert(module); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -584,7 +584,7 @@ void Engine::resetModule(Module *module) { module->onReset(); } -void Engine::randomizeModule(Module *module) { +void Engine::randomizeModule(Module* module) { assert(module); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -592,65 +592,65 @@ void Engine::randomizeModule(Module *module) { module->onRandomize(); } -void Engine::bypassModule(Module *module, bool bypass) { +void Engine::bypassModule(Module* module, bool bypass) { assert(module); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); if (module->bypass == bypass) return; // Clear outputs and set to 1 channel - for (Output &output : module->outputs) { + for (Output& output : module->outputs) { // This zeros all voltages, but the channel is set to 1 if connected output.setChannels(0); } module->bypass = bypass; } -static void Port_setDisconnected(Port *that) { +static void Port_setDisconnected(Port* that) { that->channels = 0; for (int c = 0; c < PORT_MAX_CHANNELS; c++) { that->voltages[c] = 0.f; } } -static void Port_setConnected(Port *that) { +static void Port_setConnected(Port* that) { if (that->channels > 0) return; that->channels = 1; } -static void Engine_updateConnected(Engine *that) { +static void Engine_updateConnected(Engine* that) { // Find disconnected ports std::set disconnectedPorts; - for (Module *module : that->internal->modules) { - for (Output &output : module->outputs) { + for (Module* module : that->internal->modules) { + for (Output& output : module->outputs) { disconnectedPorts.insert(&output); } - for (Input &input : module->inputs) { + for (Input& input : module->inputs) { disconnectedPorts.insert(&input); } } - for (Cable *cable : that->internal->cables) { + for (Cable* cable : that->internal->cables) { // Connect output - Output &output = cable->outputModule->outputs[cable->outputId]; + Output& output = cable->outputModule->outputs[cable->outputId]; auto outputIt = disconnectedPorts.find(&output); if (outputIt != disconnectedPorts.end()) disconnectedPorts.erase(outputIt); Port_setConnected(&output); // Connect input - Input &input = cable->inputModule->inputs[cable->inputId]; + Input& input = cable->inputModule->inputs[cable->inputId]; auto inputIt = disconnectedPorts.find(&input); if (inputIt != disconnectedPorts.end()) disconnectedPorts.erase(inputIt); Port_setConnected(&input); } // Disconnect ports that have no cable - for (Port *port : disconnectedPorts) { + for (Port* port : disconnectedPorts) { Port_setDisconnected(port); } } -void Engine::addCable(Cable *cable) { +void Engine::addCable(Cable* cable) { assert(cable); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -658,7 +658,7 @@ void Engine::addCable(Cable *cable) { assert(cable->outputModule); assert(cable->inputModule); // Check that the cable is not already added, and that the input is not already used by another cable - for (Cable *cable2 : internal->cables) { + for (Cable* cable2 : internal->cables) { assert(cable2 != cable); assert(!(cable2->inputModule == cable->inputModule && cable2->inputId == cable->inputId)); } @@ -670,7 +670,7 @@ void Engine::addCable(Cable *cable) { else { // Manual ID // Check that the ID is not already taken - for (Cable *w : internal->cables) { + for (Cable* w : internal->cables) { assert(cable->id != w->id); } if (cable->id >= internal->nextCableId) { @@ -682,7 +682,7 @@ void Engine::addCable(Cable *cable) { Engine_updateConnected(this); } -void Engine::removeCable(Cable *cable) { +void Engine::removeCable(Cable* cable) { assert(cable); VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -694,7 +694,7 @@ void Engine::removeCable(Cable *cable) { Engine_updateConnected(this); } -void Engine::setParam(Module *module, int paramId, float value) { +void Engine::setParam(Module* module, int paramId, float value) { // TODO Does this need to be thread-safe? // If being smoothed, cancel smoothing if (internal->smoothModule == module && internal->smoothParamId == paramId) { @@ -704,11 +704,11 @@ void Engine::setParam(Module *module, int paramId, float value) { module->params[paramId].value = value; } -float Engine::getParam(Module *module, int paramId) { +float Engine::getParam(Module* module, int paramId) { return module->params[paramId].value; } -void Engine::setSmoothParam(Module *module, int paramId, float value) { +void Engine::setSmoothParam(Module* module, int paramId, float value) { // If another param is being smoothed, jump value if (internal->smoothModule && !(internal->smoothModule == module && internal->smoothParamId == paramId)) { internal->smoothModule->params[internal->smoothParamId].value = internal->smoothValue; @@ -719,24 +719,24 @@ void Engine::setSmoothParam(Module *module, int paramId, float value) { internal->smoothModule = module; } -float Engine::getSmoothParam(Module *module, int paramId) { +float Engine::getSmoothParam(Module* module, int paramId) { if (internal->smoothModule == module && internal->smoothParamId == paramId) return internal->smoothValue; return getParam(module, paramId); } -static void Engine_refreshParamHandleCache(Engine *that) { +static void Engine_refreshParamHandleCache(Engine* that) { // Clear cache that->internal->paramHandleCache.clear(); // Add active ParamHandles to cache - for (ParamHandle *paramHandle : that->internal->paramHandles) { + for (ParamHandle* paramHandle : that->internal->paramHandles) { if (paramHandle->moduleId >= 0) { that->internal->paramHandleCache[std::make_tuple(paramHandle->moduleId, paramHandle->paramId)] = paramHandle; } } } -void Engine::addParamHandle(ParamHandle *paramHandle) { +void Engine::addParamHandle(ParamHandle* paramHandle) { VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -752,7 +752,7 @@ void Engine::addParamHandle(ParamHandle *paramHandle) { internal->paramHandles.insert(paramHandle); } -void Engine::removeParamHandle(ParamHandle *paramHandle) { +void Engine::removeParamHandle(ParamHandle* paramHandle) { VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -766,7 +766,7 @@ void Engine::removeParamHandle(ParamHandle *paramHandle) { Engine_refreshParamHandleCache(this); } -ParamHandle *Engine::getParamHandle(int moduleId, int paramId) { +ParamHandle* Engine::getParamHandle(int moduleId, int paramId) { // Don't lock because this method is called potentially thousands of times per screen frame. auto it = internal->paramHandleCache.find(std::make_tuple(moduleId, paramId)); @@ -775,11 +775,11 @@ ParamHandle *Engine::getParamHandle(int moduleId, int paramId) { return it->second; } -ParamHandle *Engine::getParamHandle(Module *module, int paramId) { +ParamHandle* Engine::getParamHandle(Module* module, int paramId) { return getParamHandle(module->id, paramId); } -void Engine::updateParamHandle(ParamHandle *paramHandle, int moduleId, int paramId, bool overwrite) { +void Engine::updateParamHandle(ParamHandle* paramHandle, int moduleId, int paramId, bool overwrite) { VIPLock vipLock(internal->vipMutex); std::lock_guard lock(internal->mutex); @@ -795,7 +795,7 @@ void Engine::updateParamHandle(ParamHandle *paramHandle, int moduleId, int param if (paramHandle->moduleId >= 0) { // Replace old ParamHandle, or reset the current ParamHandle - ParamHandle *oldParamHandle = getParamHandle(moduleId, paramId); + ParamHandle* oldParamHandle = getParamHandle(moduleId, paramId); if (oldParamHandle) { if (overwrite) { oldParamHandle->moduleId = -1; diff --git a/src/engine/Module.cpp b/src/engine/Module.cpp index b15dfa28..6fa78044 100644 --- a/src/engine/Module.cpp +++ b/src/engine/Module.cpp @@ -9,7 +9,7 @@ Module::Module() { } Module::~Module() { - for (ParamQuantity *paramQuantity : paramQuantities) { + for (ParamQuantity* paramQuantity : paramQuantities) { if (paramQuantity) delete paramQuantity; } @@ -29,8 +29,8 @@ void Module::config(int numParams, int numInputs, int numOutputs, int numLights) } } -json_t *Module::toJson() { - json_t *rootJ = json_object(); +json_t* Module::toJson() { + json_t* rootJ = json_object(); // id json_object_set_new(rootJ, "id", json_integer(id)); @@ -45,13 +45,13 @@ json_t *Module::toJson() { json_object_set_new(rootJ, "model", json_string(model->slug.c_str())); // params - json_t *paramsJ = json_array(); + json_t* paramsJ = json_array(); for (size_t paramId = 0; paramId < params.size(); paramId++) { // Don't serialize unbounded Params if (!paramQuantities[paramId]->isBounded()) continue; - json_t *paramJ = json_object(); + json_t* paramJ = json_object(); json_object_set_new(paramJ, "id", json_integer(paramId)); @@ -75,7 +75,7 @@ json_t *Module::toJson() { json_object_set_new(rootJ, "rightModuleId", json_integer(rightExpander.moduleId)); // data - json_t *dataJ = dataToJson(); + json_t* dataJ = dataToJson(); if (dataJ) { json_object_set_new(rootJ, "data", dataJ); } @@ -83,9 +83,9 @@ json_t *Module::toJson() { return rootJ; } -void Module::fromJson(json_t *rootJ) { +void Module::fromJson(json_t* rootJ) { // Check if plugin and model are incorrect - json_t *pluginJ = json_object_get(rootJ, "plugin"); + json_t* pluginJ = json_object_get(rootJ, "plugin"); std::string pluginSlug; if (pluginJ) { pluginSlug = json_string_value(pluginJ); @@ -95,7 +95,7 @@ void Module::fromJson(json_t *rootJ) { } } - json_t *modelJ = json_object_get(rootJ, "model"); + json_t* modelJ = json_object_get(rootJ, "model"); std::string modelSlug; if (modelJ) { modelSlug = json_string_value(modelJ); @@ -106,7 +106,7 @@ void Module::fromJson(json_t *rootJ) { } // Check plugin version - json_t *versionJ = json_object_get(rootJ, "version"); + json_t* versionJ = json_object_get(rootJ, "version"); if (versionJ) { std::string version = json_string_value(versionJ); if (version != model->plugin->version) { @@ -117,18 +117,18 @@ void Module::fromJson(json_t *rootJ) { // Only set ID if unset if (id < 0) { // id - json_t *idJ = json_object_get(rootJ, "id"); + json_t* idJ = json_object_get(rootJ, "id"); if (idJ) id = json_integer_value(idJ); } // params - json_t *paramsJ = json_object_get(rootJ, "params"); + json_t* paramsJ = json_object_get(rootJ, "params"); size_t i; - json_t *paramJ; + json_t* paramJ; json_array_foreach(paramsJ, i, paramJ) { // Get paramId - json_t *paramIdJ = json_object_get(paramJ, "id"); + json_t* paramIdJ = json_object_get(paramJ, "id"); // Legacy v0.6 to isBounded()) continue; - json_t *valueJ = json_object_get(paramJ, "value"); + json_t* valueJ = json_object_get(paramJ, "value"); if (valueJ) params[paramId].setValue(json_number_value(valueJ)); } // bypass - json_t *bypassJ = json_object_get(rootJ, "bypass"); + json_t* bypassJ = json_object_get(rootJ, "bypass"); if (bypassJ) bypass = json_boolean_value(bypassJ); @@ -169,7 +169,7 @@ void Module::fromJson(json_t *rootJ) { // rightExpander.moduleId = json_integer_value(rightModuleIdJ); // data - json_t *dataJ = json_object_get(rootJ, "data"); + json_t* dataJ = json_object_get(rootJ, "data"); if (dataJ) dataFromJson(dataJ); } diff --git a/src/engine/ParamQuantity.cpp b/src/engine/ParamQuantity.cpp index fd20bd06..8177d95d 100644 --- a/src/engine/ParamQuantity.cpp +++ b/src/engine/ParamQuantity.cpp @@ -7,7 +7,7 @@ namespace rack { namespace engine { -engine::Param *ParamQuantity::getParam() { +engine::Param* ParamQuantity::getParam() { assert(module); return &module->params[paramId]; } diff --git a/src/event.cpp b/src/event.cpp index 69f06101..f2bc88ed 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -8,7 +8,7 @@ namespace rack { namespace event { -void State::setHovered(widget::Widget *w) { +void State::setHovered(widget::Widget* w) { if (w == hoveredWidget) return; @@ -30,7 +30,7 @@ void State::setHovered(widget::Widget *w) { } } -void State::setDragged(widget::Widget *w, int button) { +void State::setDragged(widget::Widget* w, int button) { if (w == draggedWidget) return; @@ -56,7 +56,7 @@ void State::setDragged(widget::Widget *w, int button) { } } -void State::setDragHovered(widget::Widget *w) { +void State::setDragHovered(widget::Widget* w) { if (w == dragHoveredWidget) return; @@ -82,7 +82,7 @@ void State::setDragHovered(widget::Widget *w) { } } -void State::setSelected(widget::Widget *w) { +void State::setSelected(widget::Widget* w) { if (w == selectedWidget) return; @@ -104,12 +104,17 @@ void State::setSelected(widget::Widget *w) { } } -void State::finalizeWidget(widget::Widget *w) { - if (hoveredWidget == w) setHovered(NULL); - if (draggedWidget == w) setDragged(NULL, 0); - if (dragHoveredWidget == w) setDragHovered(NULL); - if (selectedWidget == w) setSelected(NULL); - if (lastClickedWidget == w) lastClickedWidget = NULL; +void State::finalizeWidget(widget::Widget* w) { + if (hoveredWidget == w) + setHovered(NULL); + if (draggedWidget == w) + setDragged(NULL, 0); + if (dragHoveredWidget == w) + setDragHovered(NULL); + if (selectedWidget == w) + setSelected(NULL); + if (lastClickedWidget == w) + lastClickedWidget = NULL; } bool State::handleButton(math::Vec pos, int button, int action, int mods) { @@ -122,7 +127,7 @@ bool State::handleButton(math::Vec pos, int button, int action, int mods) { eButton.action = action; eButton.mods = mods; rootWidget->onButton(eButton); - widget::Widget *clickedWidget = cButton.target; + widget::Widget* clickedWidget = cButton.target; if (action == GLFW_PRESS) { setDragged(clickedWidget, button); @@ -151,8 +156,8 @@ bool State::handleButton(math::Vec pos, int button, int action, int mods) { const double doubleClickDuration = 0.3; double clickTime = glfwGetTime(); if (clickedWidget - && clickTime - lastClickTime <= doubleClickDuration - && lastClickedWidget == clickedWidget) { + && clickTime - lastClickTime <= doubleClickDuration + && lastClickedWidget == clickedWidget) { // DoubleClick DoubleClick eDoubleClick; clickedWidget->onDoubleClick(eDoubleClick); @@ -231,7 +236,7 @@ bool State::handleScroll(math::Vec pos, math::Vec scrollDelta) { return !!cHoverScroll.target; } -bool State::handleDrop(math::Vec pos, const std::vector &paths) { +bool State::handleDrop(math::Vec pos, const std::vector& paths) { // PathDrop Context cPathDrop; PathDrop ePathDrop(paths); diff --git a/src/gamepad.cpp b/src/gamepad.cpp index e49d3f88..4dc3d9b0 100644 --- a/src/gamepad.cpp +++ b/src/gamepad.cpp @@ -12,7 +12,7 @@ struct Driver; static const int DRIVER = -10; -static Driver *driver = NULL; +static Driver* driver = NULL; struct InputDevice : midi::InputDevice { @@ -25,9 +25,9 @@ struct InputDevice : midi::InputDevice { // Get gamepad state int numAxes; - const float *axes = glfwGetJoystickAxes(deviceId, &numAxes); + const float* axes = glfwGetJoystickAxes(deviceId, &numAxes); int numButtons; - const unsigned char *buttons = glfwGetJoystickButtons(deviceId, &numButtons); + const unsigned char* buttons = glfwGetJoystickButtons(deviceId, &numButtons); // Convert axes and buttons to MIDI CC int numCcs = std::min(numAxes + numButtons, 128); @@ -68,7 +68,9 @@ struct Driver : midi::Driver { } } - std::string getName() override {return "Gamepad";} + std::string getName() override { + return "Gamepad"; + } std::vector getInputDeviceIds() override { std::vector deviceIds; @@ -84,14 +86,14 @@ struct Driver : midi::Driver { if (!(0 <= deviceId && deviceId < 16)) return ""; - const char *name = glfwGetJoystickName(deviceId); + const char* name = glfwGetJoystickName(deviceId); if (name) { return name; } return string::f(" %d (unavailable)", deviceId + 1); } - midi::InputDevice *subscribeInput(int deviceId, midi::Input *input) override { + midi::InputDevice* subscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < 16)) return NULL; @@ -99,7 +101,7 @@ struct Driver : midi::Driver { return &devices[deviceId]; } - void unsubscribeInput(int deviceId, midi::Input *input) override { + void unsubscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < 16)) return; diff --git a/src/history.cpp b/src/history.cpp index b7241e8a..914e1b05 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -10,25 +10,25 @@ namespace history { ComplexAction::~ComplexAction() { - for (Action *action : actions) { + for (Action* action : actions) { delete action; } } void ComplexAction::undo() { for (auto it = actions.rbegin(); it != actions.rend(); it++) { - Action *action = *it; + Action* action = *it; action->undo(); } } void ComplexAction::redo() { - for (Action *action : actions) { + for (Action* action : actions) { action->redo(); } } -void ComplexAction::push(Action *action) { +void ComplexAction::push(Action* action) { actions.push_back(action); } @@ -41,7 +41,7 @@ ModuleAdd::~ModuleAdd() { json_decref(moduleJ); } -void ModuleAdd::setModule(app::ModuleWidget *mw) { +void ModuleAdd::setModule(app::ModuleWidget* mw) { model = mw->model; assert(mw->module); moduleId = mw->module->id; @@ -52,14 +52,14 @@ void ModuleAdd::setModule(app::ModuleWidget *mw) { } void ModuleAdd::undo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); APP->scene->rack->removeModule(mw); delete mw; } void ModuleAdd::redo() { - app::ModuleWidget *mw = model->createModuleWidget(); + app::ModuleWidget* mw = model->createModuleWidget(); assert(mw); assert(mw->module); mw->module->id = moduleId; @@ -70,26 +70,26 @@ void ModuleAdd::redo() { void ModuleMove::undo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->box.pos = oldPos; } void ModuleMove::redo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->box.pos = newPos; } void ModuleBypass::undo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); APP->engine->bypassModule(mw->module, !bypass); } void ModuleBypass::redo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); APP->engine->bypassModule(mw->module, bypass); } @@ -101,32 +101,32 @@ ModuleChange::~ModuleChange() { } void ModuleChange::undo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->fromJson(oldModuleJ); } void ModuleChange::redo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->fromJson(newModuleJ); } void ParamChange::undo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->module->params[paramId].value = oldValue; } void ParamChange::redo() { - app::ModuleWidget *mw = APP->scene->rack->getModule(moduleId); + app::ModuleWidget* mw = APP->scene->rack->getModule(moduleId); assert(mw); mw->module->params[paramId].value = newValue; } -void CableAdd::setCable(app::CableWidget *cw) { +void CableAdd::setCable(app::CableWidget* cw) { assert(cw->cable); assert(cw->cable->id >= 0); cableId = cw->cable->id; @@ -140,24 +140,24 @@ void CableAdd::setCable(app::CableWidget *cw) { } void CableAdd::undo() { - app::CableWidget *cw = APP->scene->rack->getCable(cableId); + app::CableWidget* cw = APP->scene->rack->getCable(cableId); APP->scene->rack->removeCable(cw); delete cw; } void CableAdd::redo() { - app::CableWidget *cw = new app::CableWidget; + app::CableWidget* cw = new app::CableWidget; cw->cable->id = cableId; - app::ModuleWidget *outputModule = APP->scene->rack->getModule(outputModuleId); + app::ModuleWidget* outputModule = APP->scene->rack->getModule(outputModuleId); assert(outputModule); - app::PortWidget *outputPort = outputModule->getOutput(outputId); + app::PortWidget* outputPort = outputModule->getOutput(outputId); assert(outputPort); cw->setOutput(outputPort); - app::ModuleWidget *inputModule = APP->scene->rack->getModule(inputModuleId); + app::ModuleWidget* inputModule = APP->scene->rack->getModule(inputModuleId); assert(inputModule); - app::PortWidget *inputPort = inputModule->getInput(inputId); + app::PortWidget* inputPort = inputModule->getInput(inputId); assert(inputPort); cw->setInput(inputPort); @@ -176,7 +176,7 @@ State::~State() { } void State::clear() { - for (Action *action : actions) { + for (Action* action : actions) { delete action; } actions.clear(); @@ -184,7 +184,7 @@ void State::clear() { savedIndex = -1; } -void State::push(Action *action) { +void State::push(Action* action) { for (int i = actionIndex; i < (int) actions.size(); i++) { delete actions[i]; } diff --git a/src/keyboard.cpp b/src/keyboard.cpp index b3659a65..af5d4b5f 100644 --- a/src/keyboard.cpp +++ b/src/keyboard.cpp @@ -12,7 +12,7 @@ struct Driver; static const int DRIVER = -11; -static Driver *driver = NULL; +static Driver* driver = NULL; enum { CMD_OCTAVE_DOWN = -1, @@ -158,7 +158,9 @@ struct Driver : midi::Driver { devices[1].octave = 3; } - std::string getName() override {return "Computer keyboard";} + std::string getName() override { + return "Computer keyboard"; + } std::vector getInputDeviceIds() override { std::vector deviceIds; @@ -176,14 +178,14 @@ struct Driver : midi::Driver { return ""; } - midi::InputDevice *subscribeInput(int deviceId, midi::Input *input) override { + midi::InputDevice* subscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < deviceCount)) return NULL; devices[deviceId].subscribe(input); return &devices[deviceId]; } - void unsubscribeInput(int deviceId, midi::Input *input) override { + void unsubscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < deviceCount)) return; devices[deviceId].unsubscribe(input); diff --git a/src/logger.cpp b/src/logger.cpp index 85af9252..20383c3a 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -9,7 +9,7 @@ namespace rack { namespace logger { -static FILE *outputFile = NULL; +static FILE* outputFile = NULL; static std::chrono::high_resolution_clock::time_point startTime; static std::mutex logMutex; @@ -47,7 +47,7 @@ static const int levelColors[] = { 31 }; -static void logVa(Level level, const char *filename, int line, const char *format, va_list args) { +static void logVa(Level level, const char* filename, int line, const char* format, va_list args) { std::lock_guard lock(logMutex); auto nowTime = std::chrono::high_resolution_clock::now(); @@ -62,7 +62,7 @@ static void logVa(Level level, const char *filename, int line, const char *forma fflush(outputFile); } -void log(Level level, const char *filename, int line, const char *format, ...) { +void log(Level level, const char* filename, int line, const char* format, ...) { va_list args; va_start(args, format); logVa(level, filename, line, format, args); diff --git a/src/main.cpp b/src/main.cpp index a88d1c5a..6ee1bb2a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -46,7 +46,7 @@ static void fatalSignalHandler(int sig) { } -int main(int argc, char *argv[]) { +int main(int argc, char* argv[]) { #if defined ARCH_WIN // Windows global mutex to prevent multiple instances // Handle will be closed by Windows when the process ends @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) { try { settings::load(asset::settingsPath); } - catch (UserException &e) { + catch (UserException& e) { std::string msg = e.what(); msg += "\n\nReset settings to default?"; if (!osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK_CANCEL, msg.c_str())) { @@ -161,7 +161,7 @@ int main(int argc, char *argv[]) { INFO("Initializing app"); appInit(); - const char *openedFilename = glfwGetOpenedFilename(); + const char* openedFilename = glfwGetOpenedFilename(); if (openedFilename) { patchPath = openedFilename; } diff --git a/src/midi.cpp b/src/midi.cpp index 219f4837..b555841c 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -16,11 +16,11 @@ static std::map drivers; // Device //////////////////// -void InputDevice::subscribe(Input *input) { +void InputDevice::subscribe(Input* input) { subscribed.insert(input); } -void InputDevice::unsubscribe(Input *input) { +void InputDevice::unsubscribe(Input* input) { // Remove Input from subscriptions auto it = subscribed.find(input); if (it != subscribed.end()) @@ -28,7 +28,7 @@ void InputDevice::unsubscribe(Input *input) { } void InputDevice::onMessage(Message message) { - for (Input *input : subscribed) { + for (Input* input : subscribed) { // Filter channel if (input->channel < 0 || message.getStatus() == 0xf || message.getChannel() == input->channel) { input->onMessage(message); @@ -36,11 +36,11 @@ void InputDevice::onMessage(Message message) { } } -void OutputDevice::subscribe(Output *output) { +void OutputDevice::subscribe(Output* output) { subscribed.insert(output); } -void OutputDevice::unsubscribe(Output *output) { +void OutputDevice::unsubscribe(Output* output) { // Remove Output from subscriptions auto it = subscribed.find(output); if (it != subscribed.end()) @@ -90,8 +90,8 @@ void Port::setChannel(int channel) { this->channel = channel; } -json_t *Port::toJson() { - json_t *rootJ = json_object(); +json_t* Port::toJson() { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "driver", json_integer(driverId)); std::string deviceName = getDeviceName(deviceId); if (!deviceName.empty()) @@ -100,12 +100,12 @@ json_t *Port::toJson() { return rootJ; } -void Port::fromJson(json_t *rootJ) { - json_t *driverJ = json_object_get(rootJ, "driver"); +void Port::fromJson(json_t* rootJ) { + json_t* driverJ = json_object_get(rootJ, "driver"); if (driverJ) setDriverId(json_integer_value(driverJ)); - json_t *deviceNameJ = json_object_get(rootJ, "deviceName"); + json_t* deviceNameJ = json_object_get(rootJ, "deviceName"); if (deviceNameJ) { std::string deviceName = json_string_value(deviceNameJ); // Search for device with equal name @@ -117,7 +117,7 @@ void Port::fromJson(json_t *rootJ) { } } - json_t *channelJ = json_object_get(rootJ, "channel"); + json_t* channelJ = json_object_get(rootJ, "channel"); if (channelJ) channel = json_integer_value(channelJ); } @@ -185,7 +185,7 @@ void InputQueue::onMessage(Message message) { queue.push(message); } -bool InputQueue::shift(Message *message) { +bool InputQueue::shift(Message* message) { if (!message) return false; if (!queue.empty()) { @@ -274,13 +274,13 @@ void init() { void destroy() { driverIds.clear(); - for (auto &pair : drivers) { + for (auto& pair : drivers) { delete pair.second; } drivers.clear(); } -void addDriver(int driverId, Driver *driver) { +void addDriver(int driverId, Driver* driver) { assert(driver); driverIds.push_back(driverId); drivers[driverId] = driver; diff --git a/src/network.cpp b/src/network.cpp index ff84e2f7..2fe28477 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -8,8 +8,8 @@ namespace rack { namespace network { -static CURL *createCurl() { - CURL *curl = curl_easy_init(); +static CURL* createCurl() { + CURL* curl = curl_easy_init(); assert(curl); // curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); @@ -22,17 +22,17 @@ static CURL *createCurl() { } -static size_t writeStringCallback(char *ptr, size_t size, size_t nmemb, void *userdata) { - std::string *str = (std::string*) userdata; +static size_t writeStringCallback(char* ptr, size_t size, size_t nmemb, void* userdata) { + std::string* str = (std::string*) userdata; size_t len = size * nmemb; str->append(ptr, len); return len; } -json_t *requestJson(Method method, std::string url, json_t *dataJ) { - CURL *curl = createCurl(); - char *reqStr = NULL; +json_t* requestJson(Method method, std::string url, json_t* dataJ) { + CURL* curl = createCurl(); + char* reqStr = NULL; // Process data if (dataJ) { @@ -40,17 +40,17 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { // Append ?key=value&... to url url += "?"; bool isFirst = true; - const char *key; - json_t *value; + const char* key; + json_t* value; json_object_foreach(dataJ, key, value) { if (json_is_string(value)) { if (!isFirst) url += "&"; url += key; url += "="; - const char *str = json_string_value(value); + const char* str = json_string_value(value); size_t len = json_string_length(value); - char *escapedStr = curl_easy_escape(curl, str, len); + char* escapedStr = curl_easy_escape(curl, str, len); url += escapedStr; curl_free(escapedStr); isFirst = false; @@ -81,7 +81,7 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { } // Set headers - struct curl_slist *headers = NULL; + struct curl_slist* headers = NULL; headers = curl_slist_append(headers, "Accept: application/json"); headers = curl_slist_append(headers, "Content-Type: application/json"); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); @@ -106,15 +106,15 @@ json_t *requestJson(Method method, std::string url, json_t *dataJ) { if (res == CURLE_OK) { // Parse JSON response json_error_t error; - json_t *rootJ = json_loads(resText.c_str(), 0, &error); + json_t* rootJ = json_loads(resText.c_str(), 0, &error); return rootJ; } return NULL; } -static int xferInfoCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { - float *progress = (float*) clientp; +static int xferInfoCallback(void* clientp, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { + float* progress = (float*) clientp; if (progress) { if (dltotal <= 0) *progress = 0.f; @@ -124,10 +124,10 @@ static int xferInfoCallback(void *clientp, curl_off_t dltotal, curl_off_t dlnow, return 0; } -bool requestDownload(std::string url, const std::string &filename, float *progress) { - CURL *curl = createCurl(); +bool requestDownload(std::string url, const std::string& filename, float* progress) { + CURL* curl = createCurl(); - FILE *file = fopen(filename.c_str(), "wb"); + FILE* file = fopen(filename.c_str(), "wb"); if (!file) return false; @@ -151,24 +151,24 @@ bool requestDownload(std::string url, const std::string &filename, float *progre return res == CURLE_OK; } -std::string encodeUrl(const std::string &s) { - CURL *curl = curl_easy_init(); +std::string encodeUrl(const std::string& s) { + CURL* curl = curl_easy_init(); assert(curl); - char *escaped = curl_easy_escape(curl, s.c_str(), s.size()); + char* escaped = curl_easy_escape(curl, s.c_str(), s.size()); std::string ret = escaped; curl_free(escaped); curl_easy_cleanup(curl); return ret; } -std::string urlPath(const std::string &url) { - CURLU *curl = curl_url(); +std::string urlPath(const std::string& url) { + CURLU* curl = curl_url(); DEFER({ curl_url_cleanup(curl); }); if (curl_url_set(curl, CURLUPART_URL, url.c_str(), 0)) return ""; - char *buf; + char* buf; if (curl_url_get(curl, CURLUPART_PATH, &buf, 0)) return ""; std::string ret = buf; diff --git a/src/patch.cpp b/src/patch.cpp index 3cfa849b..e67251b4 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -82,7 +82,7 @@ void PatchManager::resetDialog() { void PatchManager::save(std::string path) { INFO("Saving patch %s", path.c_str()); - json_t *rootJ = toJson(); + json_t* rootJ = toJson(); if (!rootJ) return; DEFER({ @@ -91,7 +91,7 @@ void PatchManager::save(std::string path) { // Write to temporary path and then rename it to the correct path std::string tmpPath = path + ".tmp"; - FILE *file = std::fopen(tmpPath.c_str(), "w"); + FILE* file = std::fopen(tmpPath.c_str(), "w"); if (!file) { // Fail silently return; @@ -124,12 +124,12 @@ void PatchManager::saveAsDialog() { filename = string::filename(path); } - osdialog_filters *filters = osdialog_filters_parse(PATCH_FILTERS); + osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); DEFER({ osdialog_filters_free(filters); }); - char *pathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), filters); + char* pathC = osdialog_file(OSDIALOG_SAVE, dir.c_str(), filename.c_str(), filters); if (!pathC) { // Fail silently return; @@ -159,7 +159,7 @@ void PatchManager::saveTemplateDialog() { bool PatchManager::load(std::string path) { INFO("Loading patch %s", path.c_str()); - FILE *file = std::fopen(path.c_str(), "r"); + FILE* file = std::fopen(path.c_str(), "r"); if (!file) { // Exit silently return false; @@ -169,7 +169,7 @@ bool PatchManager::load(std::string path) { }); json_error_t error; - json_t *rootJ = json_loadf(file, 0, &error); + json_t* rootJ = json_loadf(file, 0, &error); if (!rootJ) { std::string message = string::f("JSON parsing error at %s %d:%d %s", error.source, error.line, error.column, error.text); osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, message.c_str()); @@ -200,12 +200,12 @@ void PatchManager::loadDialog() { dir = string::directory(path); } - osdialog_filters *filters = osdialog_filters_parse(PATCH_FILTERS); + osdialog_filters* filters = osdialog_filters_parse(PATCH_FILTERS); DEFER({ osdialog_filters_free(filters); }); - char *pathC = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters); + char* pathC = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters); if (!pathC) { // Fail silently return; @@ -242,16 +242,16 @@ void PatchManager::disconnectDialog() { APP->scene->rack->clearCablesAction(); } -json_t *PatchManager::toJson() { +json_t* PatchManager::toJson() { // root - json_t *rootJ = json_object(); + json_t* rootJ = json_object(); // version - json_t *versionJ = json_string(app::APP_VERSION.c_str()); + json_t* versionJ = json_string(app::APP_VERSION.c_str()); json_object_set_new(rootJ, "version", versionJ); // Merge with RackWidget JSON - json_t *rackJ = APP->scene->rack->toJson(); + json_t* rackJ = APP->scene->rack->toJson(); // Merge with rootJ json_object_update(rootJ, rackJ); json_decref(rackJ); @@ -259,12 +259,12 @@ json_t *PatchManager::toJson() { return rootJ; } -void PatchManager::fromJson(json_t *rootJ) { +void PatchManager::fromJson(json_t* rootJ) { legacy = 0; // version std::string version; - json_t *versionJ = json_object_get(rootJ, "version"); + json_t* versionJ = json_object_get(rootJ, "version"); if (versionJ) version = json_string_value(versionJ); if (version != app::APP_VERSION) { diff --git a/src/plugin.cpp b/src/plugin.cpp index 2ada1639..3f936ae6 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -22,11 +22,11 @@ #include #if defined ARCH_WIN -#include -#include -#define mkdir(_dir, _perms) _mkdir(_dir) + #include + #include + #define mkdir(_dir, _perms) _mkdir(_dir) #else -#include + #include #endif #include #include @@ -35,7 +35,7 @@ namespace rack { namespace core { -void init(rack::plugin::Plugin *plugin); +void init(rack::plugin::Plugin* plugin); } // namespace core namespace plugin { @@ -47,7 +47,7 @@ namespace plugin { typedef void (*InitCallback)(Plugin*); -static InitCallback loadLibrary(Plugin *plugin) { +static InitCallback loadLibrary(Plugin* plugin) { // Load plugin library std::string libraryFilename; #if defined ARCH_LIN @@ -73,7 +73,7 @@ static InitCallback loadLibrary(Plugin *plugin) { throw UserException(string::f("Failed to load library %s: code %d", libraryFilename.c_str(), error)); } #else - void *handle = dlopen(libraryFilename.c_str(), RTLD_NOW); + void* handle = dlopen(libraryFilename.c_str(), RTLD_NOW); if (!handle) { throw UserException(string::f("Failed to load library %s: %s", libraryFilename.c_str(), dlerror())); } @@ -96,8 +96,8 @@ static InitCallback loadLibrary(Plugin *plugin) { /** If path is blank, loads Core */ -static Plugin *loadPlugin(std::string path) { - Plugin *plugin = new Plugin; +static Plugin* loadPlugin(std::string path) { + Plugin* plugin = new Plugin; try { plugin->path = path; @@ -118,7 +118,7 @@ static Plugin *loadPlugin(std::string path) { // Load plugin.json std::string metadataFilename = (path == "") ? asset::system("Core.json") : (path + "/plugin.json"); - FILE *file = fopen(metadataFilename.c_str(), "r"); + FILE* file = fopen(metadataFilename.c_str(), "r"); if (!file) { throw UserException(string::f("Metadata file %s does not exist", metadataFilename.c_str())); } @@ -127,7 +127,7 @@ static Plugin *loadPlugin(std::string path) { }); json_error_t error; - json_t *rootJ = json_loadf(file, 0, &error); + json_t* rootJ = json_loadf(file, 0, &error); if (!rootJ) { throw UserException(string::f("JSON parsing error at %s %d:%d %s", metadataFilename.c_str(), error.line, error.column, error.text)); } @@ -149,7 +149,7 @@ static Plugin *loadPlugin(std::string path) { plugin->fromJson(rootJ); // Reject plugin if slug already exists - Plugin *oldPlugin = getPlugin(plugin->slug); + Plugin* oldPlugin = getPlugin(plugin->slug); if (oldPlugin) { throw UserException(string::f("Plugin %s is already loaded, not attempting to load it again", plugin->slug.c_str())); } @@ -157,7 +157,7 @@ static Plugin *loadPlugin(std::string path) { INFO("Loaded plugin %s v%s from %s", plugin->slug.c_str(), plugin->version.c_str(), path.c_str()); plugins.push_back(plugin); } - catch (UserException &e) { + catch (UserException& e) { WARN("Could not load plugin %s: %s", path.c_str(), e.what()); delete plugin; plugin = NULL; @@ -176,7 +176,7 @@ static void loadPlugins(std::string path) { } /** Returns 0 if successful */ -static int extractZipHandle(zip_t *za, std::string dir) { +static int extractZipHandle(zip_t* za, std::string dir) { int err; for (int i = 0; i < zip_get_num_entries(za, 0); i++) { zip_stat_t zs; @@ -193,18 +193,18 @@ static int extractZipHandle(zip_t *za, std::string dir) { // HACK // Create and delete file to update the directory's mtime. std::string tmpPath = path + "/.tmp"; - FILE *tmpFile = fopen(tmpPath.c_str(), "w"); + FILE* tmpFile = fopen(tmpPath.c_str(), "w"); fclose(tmpFile); std::remove(tmpPath.c_str()); } else { - zip_file_t *zf = zip_fopen_index(za, i, 0); + zip_file_t* zf = zip_fopen_index(za, i, 0); if (!zf) { WARN("zip_fopen_index() failed"); return -1; } - FILE *outFile = fopen(path.c_str(), "wb"); + FILE* outFile = fopen(path.c_str(), "wb"); if (!outFile) continue; @@ -230,7 +230,7 @@ static int extractZipHandle(zip_t *za, std::string dir) { /** Returns 0 if successful */ static int extractZip(std::string filename, std::string path) { int err; - zip_t *za = zip_open(filename.c_str(), 0, &err); + zip_t* za = zip_open(filename.c_str(), 0, &err); if (!za) { WARN("Could not open zip %s: error %d", filename.c_str(), err); return err; @@ -304,7 +304,7 @@ void init() { } void destroy() { - for (Plugin *plugin : plugins) { + for (Plugin* plugin : plugins) { // Free library handle #if defined ARCH_WIN if (plugin->handle) @@ -321,13 +321,13 @@ void destroy() { plugins.clear(); } -void logIn(const std::string &email, const std::string &password) { +void logIn(const std::string& email, const std::string& password) { loginStatus = "Logging in..."; - json_t *reqJ = json_object(); + json_t* reqJ = json_object(); json_object_set(reqJ, "email", json_string(email.c_str())); json_object_set(reqJ, "password", json_string(password.c_str())); std::string url = app::API_URL + "/token"; - json_t *resJ = network::requestJson(network::METHOD_POST, url, reqJ); + json_t* resJ = network::requestJson(network::METHOD_POST, url, reqJ); json_decref(reqJ); if (!resJ) { @@ -338,20 +338,20 @@ void logIn(const std::string &email, const std::string &password) { json_decref(resJ); }); - json_t *errorJ = json_object_get(resJ, "error"); + json_t* errorJ = json_object_get(resJ, "error"); if (errorJ) { - const char *errorStr = json_string_value(errorJ); + const char* errorStr = json_string_value(errorJ); loginStatus = errorStr; return; } - json_t *tokenJ = json_object_get(resJ, "token"); + json_t* tokenJ = json_object_get(resJ, "token"); if (!tokenJ) { loginStatus = "No token in response"; return; } - const char *tokenStr = json_string_value(tokenJ); + const char* tokenStr = json_string_value(tokenJ); settings::token = tokenStr; loginStatus = ""; queryUpdates(); @@ -375,9 +375,9 @@ void queryUpdates() { // Get user's plugins list std::string pluginsUrl = app::API_URL + "/plugins"; - json_t *pluginsReqJ = json_object(); + json_t* pluginsReqJ = json_object(); json_object_set(pluginsReqJ, "token", json_string(settings::token.c_str())); - json_t *pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ); + json_t* pluginsResJ = network::requestJson(network::METHOD_GET, pluginsUrl, pluginsReqJ); json_decref(pluginsReqJ); if (!pluginsResJ) { WARN("Request for user's plugins failed"); @@ -388,7 +388,7 @@ void queryUpdates() { json_decref(pluginsResJ); }); - json_t *errorJ = json_object_get(pluginsResJ, "error"); + json_t* errorJ = json_object_get(pluginsResJ, "error"); if (errorJ) { WARN("Request for user's plugins returned an error: %s", json_string_value(errorJ)); updateStatus = "Could not query updates"; @@ -397,9 +397,9 @@ void queryUpdates() { // Get library manifests std::string manifestsUrl = app::API_URL + "/library/manifests"; - json_t *manifestsReq = json_object(); + json_t* manifestsReq = json_object(); json_object_set(manifestsReq, "version", json_string(app::API_VERSION.c_str())); - json_t *manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, manifestsReq); + json_t* manifestsResJ = network::requestJson(network::METHOD_GET, manifestsUrl, manifestsReq); json_decref(manifestsReq); if (!manifestsResJ) { WARN("Request for library manifests failed"); @@ -410,28 +410,28 @@ void queryUpdates() { json_decref(manifestsResJ); }); - json_t *manifestsJ = json_object_get(manifestsResJ, "manifests"); - json_t *pluginsJ = json_object_get(pluginsResJ, "plugins"); + json_t* manifestsJ = json_object_get(manifestsResJ, "manifests"); + json_t* pluginsJ = json_object_get(pluginsResJ, "plugins"); size_t pluginIndex; - json_t *pluginJ; + json_t* pluginJ; json_array_foreach(pluginsJ, pluginIndex, pluginJ) { Update update; // Get plugin manifest update.pluginSlug = json_string_value(pluginJ); - json_t *manifestJ = json_object_get(manifestsJ, update.pluginSlug.c_str()); + json_t* manifestJ = json_object_get(manifestsJ, update.pluginSlug.c_str()); if (!manifestJ) { WARN("VCV account has plugin %s but no manifest was found", update.pluginSlug.c_str()); continue; } // Get plugin name - json_t *nameJ = json_object_get(manifestJ, "name"); + json_t* nameJ = json_object_get(manifestJ, "name"); if (nameJ) update.pluginName = json_string_value(nameJ); // Get version - json_t *versionJ = json_object_get(manifestJ, "version"); + json_t* versionJ = json_object_get(manifestJ, "version"); if (!versionJ) { WARN("Plugin %s has no version in manifest", update.pluginSlug.c_str()); continue; @@ -439,12 +439,12 @@ void queryUpdates() { update.version = json_string_value(versionJ); // Check if update is needed - Plugin *p = getPlugin(update.pluginSlug); + Plugin* p = getPlugin(update.pluginSlug); if (p && p->version == update.version) continue; // Check status - json_t *statusJ = json_object_get(manifestJ, "status"); + json_t* statusJ = json_object_get(manifestJ, "status"); if (!statusJ) continue; std::string status = json_string_value(statusJ); @@ -452,7 +452,7 @@ void queryUpdates() { continue; // Get changelog URL - json_t *changelogUrlJ = json_object_get(manifestJ, "changelogUrl"); + json_t* changelogUrlJ = json_object_get(manifestJ, "changelogUrl"); if (changelogUrlJ) { update.changelogUrl = json_string_value(changelogUrlJ); } @@ -464,7 +464,7 @@ void queryUpdates() { } bool hasUpdates() { - for (Update &update : updates) { + for (Update& update : updates) { if (update.progress < 1.f) return true; } @@ -474,7 +474,7 @@ bool hasUpdates() { static bool isSyncingUpdate = false; static bool isSyncingUpdates = false; -void syncUpdate(Update *update) { +void syncUpdate(Update* update) { isSyncingUpdate = true; DEFER({ isSyncingUpdate = false; @@ -505,7 +505,7 @@ void syncUpdates() { if (settings::token.empty()) return; - for (Update &update : updates) { + for (Update& update : updates) { if (update.progress < 1.f) syncUpdate(&update); } @@ -516,9 +516,9 @@ bool isSyncing() { return isSyncingUpdate || isSyncingUpdates; } -Plugin *getPlugin(const std::string &pluginSlug) { +Plugin* getPlugin(const std::string& pluginSlug) { std::string slug = normalizeSlug(pluginSlug); - for (Plugin *plugin : plugins) { + for (Plugin* plugin : plugins) { if (plugin->slug == slug) { return plugin; } @@ -526,11 +526,11 @@ Plugin *getPlugin(const std::string &pluginSlug) { return NULL; } -Model *getModel(const std::string &pluginSlug, const std::string &modelSlug) { - Plugin *plugin = getPlugin(pluginSlug); +Model* getModel(const std::string& pluginSlug, const std::string& modelSlug) { + Plugin* plugin = getPlugin(pluginSlug); if (!plugin) return NULL; - Model *model = plugin->getModel(modelSlug); + Model* model = plugin->getModel(modelSlug); if (!model) return NULL; return model; @@ -621,21 +621,21 @@ const std::map tagAliases = { }; -std::string normalizeTag(const std::string &tag) { +std::string normalizeTag(const std::string& tag) { std::string lowercaseTag = string::lowercase(tag); // Transform aliases auto it = tagAliases.find(lowercaseTag); if (it != tagAliases.end()) lowercaseTag = it->second; // Find allowed tag - for (const std::string &allowedTag : allowedTags) { + for (const std::string& allowedTag : allowedTags) { if (lowercaseTag == string::lowercase(allowedTag)) return allowedTag; } return ""; } -bool isSlugValid(const std::string &slug) { +bool isSlugValid(const std::string& slug) { for (char c : slug) { if (!(std::isalnum(c) || c == '-' || c == '_')) return false; @@ -643,7 +643,7 @@ bool isSlugValid(const std::string &slug) { return true; } -std::string normalizeSlug(const std::string &slug) { +std::string normalizeSlug(const std::string& slug) { std::string s; for (char c : slug) { if (!(std::isalnum(c) || c == '-' || c == '_')) diff --git a/src/plugin/Model.cpp b/src/plugin/Model.cpp index 9bacd8f6..d6bbebf2 100644 --- a/src/plugin/Model.cpp +++ b/src/plugin/Model.cpp @@ -9,25 +9,25 @@ namespace rack { namespace plugin { -void Model::fromJson(json_t *rootJ) { +void Model::fromJson(json_t* rootJ) { assert(plugin); - json_t *nameJ = json_object_get(rootJ, "name"); + json_t* nameJ = json_object_get(rootJ, "name"); if (nameJ) name = json_string_value(nameJ); if (name == "") throw UserException(string::f("No module name for slug %s", slug.c_str())); - json_t *descriptionJ = json_object_get(rootJ, "description"); + json_t* descriptionJ = json_object_get(rootJ, "description"); if (descriptionJ) description = json_string_value(descriptionJ); // Tags tags.clear(); - json_t *tagsJ = json_object_get(rootJ, "tags"); + json_t* tagsJ = json_object_get(rootJ, "tags"); if (tagsJ) { size_t i; - json_t *tagJ; + json_t* tagJ; json_array_foreach(tagsJ, i, tagJ) { std::string tag = json_string_value(tagJ); // Normalize tag @@ -40,7 +40,7 @@ void Model::fromJson(json_t *rootJ) { // Preset paths presetPaths.clear(); std::string presetDir = asset::plugin(plugin, "presets/" + slug); - for (const std::string &presetPath : system::getEntries(presetDir)) { + for (const std::string& presetPath : system::getEntries(presetDir)) { presetPaths.push_back(presetPath); } } diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 8f370077..92f72dc5 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -9,21 +9,21 @@ namespace plugin { Plugin::~Plugin() { - for (Model *model : models) { + for (Model* model : models) { delete model; } } -void Plugin::addModel(Model *model) { +void Plugin::addModel(Model* model) { // Check that the model is not added to a plugin already assert(!model->plugin); model->plugin = this; models.push_back(model); } -Model *Plugin::getModel(std::string slug) { +Model* Plugin::getModel(std::string slug) { slug = normalizeSlug(slug); - for (Model *model : models) { + for (Model* model : models) { if (model->slug == slug) { return model; } @@ -31,9 +31,9 @@ Model *Plugin::getModel(std::string slug) { return NULL; } -void Plugin::fromJson(json_t *rootJ) { +void Plugin::fromJson(json_t* rootJ) { // Slug - json_t *slugJ = json_object_get(rootJ, "slug"); + json_t* slugJ = json_object_get(rootJ, "slug"); if (slugJ) slug = json_string_value(slugJ); if (slug == "") @@ -42,73 +42,73 @@ void Plugin::fromJson(json_t *rootJ) { throw UserException(string::f("Plugin slug \"%s\" is invalid", slug.c_str())); // Version - json_t *versionJ = json_object_get(rootJ, "version"); + json_t* versionJ = json_object_get(rootJ, "version"); if (versionJ) version = json_string_value(versionJ); if (version == "") throw UserException("No plugin version"); // Name - json_t *nameJ = json_object_get(rootJ, "name"); + json_t* nameJ = json_object_get(rootJ, "name"); if (nameJ) name = json_string_value(nameJ); if (name == "") throw UserException("No plugin name"); // Brand - json_t *brandJ = json_object_get(rootJ, "brand"); + json_t* brandJ = json_object_get(rootJ, "brand"); if (brandJ) brand = json_string_value(brandJ); // Use name for brand name by default if (brand == "") brand = name; - json_t *authorJ = json_object_get(rootJ, "author"); + json_t* authorJ = json_object_get(rootJ, "author"); if (authorJ) author = json_string_value(authorJ); - json_t *licenseJ = json_object_get(rootJ, "license"); + json_t* licenseJ = json_object_get(rootJ, "license"); if (licenseJ) license = json_string_value(licenseJ); - json_t *authorEmailJ = json_object_get(rootJ, "authorEmail"); + json_t* authorEmailJ = json_object_get(rootJ, "authorEmail"); if (authorEmailJ) authorEmail = json_string_value(authorEmailJ); - json_t *pluginUrlJ = json_object_get(rootJ, "pluginUrl"); + json_t* pluginUrlJ = json_object_get(rootJ, "pluginUrl"); if (pluginUrlJ) pluginUrl = json_string_value(pluginUrlJ); - json_t *authorUrlJ = json_object_get(rootJ, "authorUrl"); + json_t* authorUrlJ = json_object_get(rootJ, "authorUrl"); if (authorUrlJ) authorUrl = json_string_value(authorUrlJ); - json_t *manualUrlJ = json_object_get(rootJ, "manualUrl"); + json_t* manualUrlJ = json_object_get(rootJ, "manualUrl"); if (manualUrlJ) manualUrl = json_string_value(manualUrlJ); - json_t *sourceUrlJ = json_object_get(rootJ, "sourceUrl"); + json_t* sourceUrlJ = json_object_get(rootJ, "sourceUrl"); if (sourceUrlJ) sourceUrl = json_string_value(sourceUrlJ); - json_t *donateUrlJ = json_object_get(rootJ, "donateUrl"); + json_t* donateUrlJ = json_object_get(rootJ, "donateUrl"); if (donateUrlJ) donateUrl = json_string_value(donateUrlJ); - json_t *modulesJ = json_object_get(rootJ, "modules"); + json_t* modulesJ = json_object_get(rootJ, "modules"); if (modulesJ) { size_t moduleId; - json_t *moduleJ; + json_t* moduleJ; json_array_foreach(modulesJ, moduleId, moduleJ) { // Check if module is disabled - json_t *disabledJ = json_object_get(moduleJ, "disabled"); + json_t* disabledJ = json_object_get(moduleJ, "disabled"); if (disabledJ) { if (json_boolean_value(disabledJ)) continue; } // Get model slug - json_t *modelSlugJ = json_object_get(moduleJ, "slug"); + json_t* modelSlugJ = json_object_get(moduleJ, "slug"); if (!modelSlugJ) { throw UserException(string::f("No slug found for module entry %d", moduleId)); } @@ -120,7 +120,7 @@ void Plugin::fromJson(json_t *rootJ) { } // Get model - Model *model = getModel(modelSlug); + Model* model = getModel(modelSlug); if (!model) { throw UserException(string::f("Manifest contains module %s but it is not defined in the plugin", modelSlug.c_str())); } @@ -132,7 +132,7 @@ void Plugin::fromJson(json_t *rootJ) { // Remove models without names // This is a hacky way of matching JSON models with C++ models. for (auto it = models.begin(); it != models.end();) { - Model *model = *it; + Model* model = *it; if (model->name == "") { it = models.erase(it); delete model; diff --git a/src/rtmidi.cpp b/src/rtmidi.cpp index 4979ea82..df24af92 100644 --- a/src/rtmidi.cpp +++ b/src/rtmidi.cpp @@ -4,7 +4,7 @@ #pragma GCC diagnostic push #ifndef __clang__ -#pragma GCC diagnostic ignored "-Wsuggest-override" + #pragma GCC diagnostic ignored "-Wsuggest-override" #endif #include #pragma GCC diagnostic pop @@ -14,7 +14,7 @@ namespace rack { struct RtMidiInputDevice : midi::InputDevice { - RtMidiIn *rtMidiIn; + RtMidiIn* rtMidiIn; RtMidiInputDevice(int driverId, int deviceId) { rtMidiIn = new RtMidiIn((RtMidi::Api) driverId, "VCV Rack"); @@ -29,13 +29,13 @@ struct RtMidiInputDevice : midi::InputDevice { delete rtMidiIn; } - static void midiInputCallback(double timeStamp, std::vector *message, void *userData) { + static void midiInputCallback(double timeStamp, std::vector* message, void* userData) { if (!message) return; if (!userData) return; - RtMidiInputDevice *midiInputDevice = (RtMidiInputDevice*) userData; + RtMidiInputDevice* midiInputDevice = (RtMidiInputDevice*) userData; if (!midiInputDevice) return; @@ -54,7 +54,7 @@ struct RtMidiInputDevice : midi::InputDevice { struct RtMidiOutputDevice : midi::OutputDevice { - RtMidiOut *rtMidiOut; + RtMidiOut* rtMidiOut; RtMidiOutputDevice(int driverId, int deviceId) { rtMidiOut = new RtMidiOut((RtMidi::Api) driverId, "VCV Rack"); @@ -76,8 +76,8 @@ struct RtMidiOutputDevice : midi::OutputDevice { struct RtMidiDriver : midi::Driver { int driverId; /** Just for querying MIDI driver information */ - RtMidiIn *rtMidiIn; - RtMidiOut *rtMidiOut; + RtMidiIn* rtMidiIn; + RtMidiOut* rtMidiOut; std::map inputDevices; std::map outputDevices; @@ -121,10 +121,10 @@ struct RtMidiDriver : midi::Driver { return ""; } - midi::InputDevice *subscribeInput(int deviceId, midi::Input *input) override { + midi::InputDevice* subscribeInput(int deviceId, midi::Input* input) override { if (!(0 <= deviceId && deviceId < (int) rtMidiIn->getPortCount())) return NULL; - RtMidiInputDevice *device = inputDevices[deviceId]; + RtMidiInputDevice* device = inputDevices[deviceId]; if (!device) { inputDevices[deviceId] = device = new RtMidiInputDevice(driverId, deviceId); } @@ -133,11 +133,11 @@ struct RtMidiDriver : midi::Driver { return device; } - void unsubscribeInput(int deviceId, midi::Input *input) override { + void unsubscribeInput(int deviceId, midi::Input* input) override { auto it = inputDevices.find(deviceId); if (it == inputDevices.end()) return; - RtMidiInputDevice *device = it->second; + RtMidiInputDevice* device = it->second; device->unsubscribe(input); // Destroy device if nothing is subscribed anymore @@ -162,10 +162,10 @@ struct RtMidiDriver : midi::Driver { return ""; } - midi::OutputDevice *subscribeOutput(int deviceId, midi::Output *output) override { + midi::OutputDevice* subscribeOutput(int deviceId, midi::Output* output) override { if (!(0 <= deviceId && deviceId < (int) rtMidiOut->getPortCount())) return NULL; - RtMidiOutputDevice *device = outputDevices[deviceId]; + RtMidiOutputDevice* device = outputDevices[deviceId]; if (!device) { outputDevices[deviceId] = device = new RtMidiOutputDevice(driverId, deviceId); } @@ -174,11 +174,11 @@ struct RtMidiDriver : midi::Driver { return device; } - void unsubscribeOutput(int deviceId, midi::Output *output) override { + void unsubscribeOutput(int deviceId, midi::Output* output) override { auto it = outputDevices.find(deviceId); if (it == outputDevices.end()) return; - RtMidiOutputDevice *device = it->second; + RtMidiOutputDevice* device = it->second; device->unsubscribe(output); // Destroy device if nothing is subscribed anymore @@ -195,7 +195,7 @@ void rtmidiInit() { RtMidi::getCompiledApi(rtApis); for (RtMidi::Api api : rtApis) { int driverId = (int) api; - midi::Driver *driver = new RtMidiDriver(driverId); + midi::Driver* driver = new RtMidiDriver(driverId); midi::addDriver(driverId, driver); } } diff --git a/src/settings.cpp b/src/settings.cpp index 409368ae..954a0952 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -42,15 +42,15 @@ std::vector cableColors = { }; -json_t *toJson() { - json_t *rootJ = json_object(); +json_t* toJson() { + json_t* rootJ = json_object(); json_object_set_new(rootJ, "token", json_string(token.c_str())); - json_t *windowSizeJ = json_pack("[f, f]", windowSize.x, windowSize.y); + json_t* windowSizeJ = json_pack("[f, f]", windowSize.x, windowSize.y); json_object_set_new(rootJ, "windowSize", windowSizeJ); - json_t *windowPosJ = json_pack("[f, f]", windowPos.x, windowPos.y); + json_t* windowPosJ = json_pack("[f, f]", windowPos.x, windowPos.y); json_object_set_new(rootJ, "windowPos", windowPosJ); json_object_set_new(rootJ, "zoom", json_real(zoom)); @@ -87,7 +87,7 @@ json_t *toJson() { json_object_set_new(rootJ, "patchPath", json_string(patchPath.c_str())); - json_t *cableColorsJ = json_array(); + json_t* cableColorsJ = json_array(); for (NVGcolor cableColor : cableColors) { std::string colorStr = color::toHexString(cableColor); json_array_append_new(cableColorsJ, json_string(colorStr.c_str())); @@ -97,94 +97,94 @@ json_t *toJson() { return rootJ; } -void fromJson(json_t *rootJ) { - json_t *tokenJ = json_object_get(rootJ, "token"); +void fromJson(json_t* rootJ) { + json_t* tokenJ = json_object_get(rootJ, "token"); if (tokenJ) token = json_string_value(tokenJ); - json_t *windowSizeJ = json_object_get(rootJ, "windowSize"); + json_t* windowSizeJ = json_object_get(rootJ, "windowSize"); if (windowSizeJ) { double x, y; json_unpack(windowSizeJ, "[F, F]", &x, &y); windowSize = math::Vec(x, y); } - json_t *windowPosJ = json_object_get(rootJ, "windowPos"); + json_t* windowPosJ = json_object_get(rootJ, "windowPos"); if (windowPosJ) { double x, y; json_unpack(windowPosJ, "[F, F]", &x, &y); windowPos = math::Vec(x, y); } - json_t *zoomJ = json_object_get(rootJ, "zoom"); + json_t* zoomJ = json_object_get(rootJ, "zoom"); if (zoomJ) zoom = json_number_value(zoomJ); - json_t *invertZoomJ = json_object_get(rootJ, "invertZoom"); + json_t* invertZoomJ = json_object_get(rootJ, "invertZoom"); if (invertZoomJ) invertZoom = json_boolean_value(invertZoomJ); - json_t *cableOpacityJ = json_object_get(rootJ, "cableOpacity"); + json_t* cableOpacityJ = json_object_get(rootJ, "cableOpacity"); if (cableOpacityJ) cableOpacity = json_number_value(cableOpacityJ); - json_t *tensionJ = json_object_get(rootJ, "cableTension"); + json_t* tensionJ = json_object_get(rootJ, "cableTension"); if (tensionJ) cableTension = json_number_value(tensionJ); - json_t *allowCursorLockJ = json_object_get(rootJ, "allowCursorLock"); + json_t* allowCursorLockJ = json_object_get(rootJ, "allowCursorLock"); if (allowCursorLockJ) allowCursorLock = json_is_true(allowCursorLockJ); - json_t *realTimeJ = json_object_get(rootJ, "realTime"); + json_t* realTimeJ = json_object_get(rootJ, "realTime"); if (realTimeJ) realTime = json_boolean_value(realTimeJ); - json_t *sampleRateJ = json_object_get(rootJ, "sampleRate"); + json_t* sampleRateJ = json_object_get(rootJ, "sampleRate"); if (sampleRateJ) sampleRate = json_number_value(sampleRateJ); - json_t *threadCountJ = json_object_get(rootJ, "threadCount"); + json_t* threadCountJ = json_object_get(rootJ, "threadCount"); if (threadCountJ) threadCount = json_integer_value(threadCountJ); - json_t *paramTooltipJ = json_object_get(rootJ, "paramTooltip"); + json_t* paramTooltipJ = json_object_get(rootJ, "paramTooltip"); if (paramTooltipJ) paramTooltip = json_boolean_value(paramTooltipJ); - json_t *cpuMeterJ = json_object_get(rootJ, "cpuMeter"); + json_t* cpuMeterJ = json_object_get(rootJ, "cpuMeter"); if (cpuMeterJ) cpuMeter = json_boolean_value(cpuMeterJ); - json_t *lockModulesJ = json_object_get(rootJ, "lockModules"); + json_t* lockModulesJ = json_object_get(rootJ, "lockModules"); if (lockModulesJ) lockModules = json_boolean_value(lockModulesJ); - json_t *frameRateLimitJ = json_object_get(rootJ, "frameRateLimit"); + json_t* frameRateLimitJ = json_object_get(rootJ, "frameRateLimit"); if (frameRateLimitJ) frameRateLimit = json_number_value(frameRateLimitJ); - json_t *frameRateSyncJ = json_object_get(rootJ, "frameRateSync"); + json_t* frameRateSyncJ = json_object_get(rootJ, "frameRateSync"); if (frameRateSyncJ) frameRateSync = json_boolean_value(frameRateSyncJ); - json_t *autosavePeriodJ = json_object_get(rootJ, "autosavePeriod"); + json_t* autosavePeriodJ = json_object_get(rootJ, "autosavePeriod"); if (autosavePeriodJ) autosavePeriod = json_number_value(autosavePeriodJ); - json_t *skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch"); + json_t* skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch"); if (skipLoadOnLaunchJ) skipLoadOnLaunch = json_boolean_value(skipLoadOnLaunchJ); - json_t *patchPathJ = json_object_get(rootJ, "patchPath"); + json_t* patchPathJ = json_object_get(rootJ, "patchPath"); if (patchPathJ) patchPath = json_string_value(patchPathJ); - json_t *cableColorsJ = json_object_get(rootJ, "cableColors"); + json_t* cableColorsJ = json_object_get(rootJ, "cableColors"); if (cableColorsJ) { cableColors.clear(); size_t i; - json_t *cableColorJ; + json_t* cableColorJ; json_array_foreach(cableColorsJ, i, cableColorJ) { std::string colorStr = json_string_value(cableColorJ); cableColors.push_back(color::fromHexString(colorStr)); @@ -192,13 +192,13 @@ void fromJson(json_t *rootJ) { } } -void save(const std::string &path) { +void save(const std::string& path) { INFO("Saving settings %s", path.c_str()); - json_t *rootJ = toJson(); + json_t* rootJ = toJson(); if (!rootJ) return; - FILE *file = fopen(path.c_str(), "w"); + FILE* file = fopen(path.c_str(), "w"); if (!file) return; DEFER({ @@ -209,9 +209,9 @@ void save(const std::string &path) { json_decref(rootJ); } -void load(const std::string &path) { +void load(const std::string& path) { INFO("Loading settings %s", path.c_str()); - FILE *file = fopen(path.c_str(), "r"); + FILE* file = fopen(path.c_str(), "r"); if (!file) return; DEFER({ @@ -219,7 +219,7 @@ void load(const std::string &path) { }); json_error_t error; - json_t *rootJ = json_loadf(file, 0, &error); + json_t* rootJ = json_loadf(file, 0, &error); if (!rootJ) throw UserException(string::f("Settings file has invalid JSON at %d:%d %s", error.line, error.column, error.text)); diff --git a/src/string.cpp b/src/string.cpp index 0ad4b8a0..e1838b82 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -10,19 +10,19 @@ namespace rack { namespace string { -std::string fromWstring(const std::wstring &s) { +std::string fromWstring(const std::wstring& s) { std::wstring_convert> converter; return converter.to_bytes(s); } -std::wstring toWstring(const std::string &s) { +std::wstring toWstring(const std::string& s) { std::wstring_convert> converter; return converter.from_bytes(s); } -std::string f(const char *format, ...) { +std::string f(const char* format, ...) { va_list args; va_start(args, format); // Compute size of required buffer @@ -40,21 +40,25 @@ std::string f(const char *format, ...) { } -std::string lowercase(const std::string &s) { +std::string lowercase(const std::string& s) { std::string r = s; - std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) { return std::tolower(c); }); + std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) { + return std::tolower(c); + }); return r; } -std::string uppercase(const std::string &s) { +std::string uppercase(const std::string& s) { std::string r = s; - std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) { return std::toupper(c); }); + std::transform(r.begin(), r.end(), r.begin(), [](unsigned char c) { + return std::toupper(c); + }); return r; } -std::string trim(const std::string &s) { +std::string trim(const std::string& s) { const std::string whitespace = " \n\r\t"; size_t first = s.find_first_not_of(whitespace); if (first == std::string::npos) @@ -66,7 +70,7 @@ std::string trim(const std::string &s) { } -std::string ellipsize(const std::string &s, size_t len) { +std::string ellipsize(const std::string& s, size_t len) { if (s.size() <= len) return s; else @@ -74,7 +78,7 @@ std::string ellipsize(const std::string &s, size_t len) { } -std::string ellipsizePrefix(const std::string &s, size_t len) { +std::string ellipsizePrefix(const std::string& s, size_t len) { if (s.size() <= len) return s; else @@ -82,33 +86,33 @@ std::string ellipsizePrefix(const std::string &s, size_t len) { } -bool startsWith(const std::string &str, const std::string &prefix) { +bool startsWith(const std::string& str, const std::string& prefix) { return str.substr(0, prefix.size()) == prefix; } -bool endsWith(const std::string &str, const std::string &suffix) { +bool endsWith(const std::string& str, const std::string& suffix) { return str.substr(str.size() - suffix.size(), suffix.size()) == suffix; } -std::string directory(const std::string &path) { - char *pathDup = strdup(path.c_str()); +std::string directory(const std::string& path) { + char* pathDup = strdup(path.c_str()); std::string directory = dirname(pathDup); free(pathDup); return directory; } -std::string filename(const std::string &path) { - char *pathDup = strdup(path.c_str()); +std::string filename(const std::string& path) { + char* pathDup = strdup(path.c_str()); std::string filename = basename(pathDup); free(pathDup); return filename; } -std::string filenameBase(const std::string &filename) { +std::string filenameBase(const std::string& filename) { size_t pos = filename.rfind('.'); if (pos == std::string::npos) return filename; @@ -116,7 +120,7 @@ std::string filenameBase(const std::string &filename) { } -std::string filenameExtension(const std::string &filename) { +std::string filenameExtension(const std::string& filename) { size_t pos = filename.rfind('.'); if (pos == std::string::npos) return ""; @@ -124,16 +128,16 @@ std::string filenameExtension(const std::string &filename) { } -std::string absolutePath(const std::string &path) { +std::string absolutePath(const std::string& path) { #if defined ARCH_LIN || defined ARCH_MAC char buf[PATH_MAX]; - char *absPathC = realpath(path.c_str(), buf); + char* absPathC = realpath(path.c_str(), buf); if (absPathC) return absPathC; #elif defined ARCH_WIN std::wstring pathW = toWstring(path); wchar_t buf[PATH_MAX]; - wchar_t *absPathC = _wfullpath(buf, pathW.c_str(), PATH_MAX); + wchar_t* absPathC = _wfullpath(buf, pathW.c_str(), PATH_MAX); if (absPathC) return fromWstring(absPathC); #endif @@ -141,12 +145,12 @@ std::string absolutePath(const std::string &path) { } -float fuzzyScore(const std::string &s, const std::string &query) { +float fuzzyScore(const std::string& s, const std::string& query) { size_t pos = s.find(query); if (pos == std::string::npos) return 0.f; - return (float) (query.size() + 1) / (s.size() + 1); + return (float)(query.size() + 1) / (s.size() + 1); } diff --git a/src/svg.cpp b/src/svg.cpp index 077fea48..889c05c4 100644 --- a/src/svg.cpp +++ b/src/svg.cpp @@ -10,15 +10,15 @@ namespace rack { static NVGcolor getNVGColor(uint32_t color) { return nvgRGBA( - (color >> 0) & 0xff, - (color >> 8) & 0xff, - (color >> 16) & 0xff, - (color >> 24) & 0xff); + (color >> 0) & 0xff, + (color >> 8) & 0xff, + (color >> 16) & 0xff, + (color >> 24) & 0xff); } -static NVGpaint getPaint(NVGcontext *vg, NSVGpaint *p) { +static NVGpaint getPaint(NVGcontext* vg, NSVGpaint* p) { assert(p->type == NSVG_PAINT_LINEAR_GRADIENT || p->type == NSVG_PAINT_RADIAL_GRADIENT); - NSVGgradient *g = p->gradient; + NSVGgradient* g = p->gradient; assert(g->nstops >= 1); NVGcolor icol = getNVGColor(g->stops[0].color); NVGcolor ocol = getNVGColor(g->stops[g->nstops - 1].color); @@ -53,11 +53,11 @@ static float getLineCrossing(math::Vec p0, math::Vec p1, math::Vec p2, math::Vec return -(d.x * b.y - d.y * b.x) / m; } -void svgDraw(NVGcontext *vg, NSVGimage *svg) { +void svgDraw(NVGcontext* vg, NSVGimage* svg) { DEBUG_ONLY(printf("new image: %g x %g px\n", svg->width, svg->height);) int shapeIndex = 0; // Iterate shape linked list - for (NSVGshape *shape = svg->shapes; shape; shape = shape->next, shapeIndex++) { + for (NSVGshape* shape = svg->shapes; shape; shape = shape->next, shapeIndex++) { DEBUG_ONLY(printf(" new shape: %d id \"%s\", fillrule %d, from (%f, %f) to (%f, %f)\n", shapeIndex, shape->id, shape->fillRule, shape->bounds[0], shape->bounds[1], shape->bounds[2], shape->bounds[3]);) // Visibility @@ -74,12 +74,12 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { nvgBeginPath(vg); // Iterate path linked list - for (NSVGpath *path = shape->paths; path; path = path->next) { + for (NSVGpath* path = shape->paths; path; path = path->next) { DEBUG_ONLY(printf(" new path: %d points, %s, from (%f, %f) to (%f, %f)\n", path->npts, path->closed ? "closed" : "open", path->bounds[0], path->bounds[1], path->bounds[2], path->bounds[3]);) nvgMoveTo(vg, path->pts[0], path->pts[1]); for (int i = 1; i < path->npts; i += 3) { - float *p = &path->pts[2*i]; + float* p = &path->pts[2 * i]; nvgBezierTo(vg, p[0], p[1], p[2], p[3], p[4], p[5]); // nvgLineTo(vg, p[4], p[5]); DEBUG_ONLY(printf(" bezier (%f, %f) to (%f, %f)\n", p[-2], p[-1], p[4], p[5]);) @@ -97,7 +97,7 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { math::Vec p0 = math::Vec(path->pts[0], path->pts[1]); math::Vec p1 = math::Vec(path->bounds[0] - 1.0, path->bounds[1] - 1.0); // Iterate all other paths - for (NSVGpath *path2 = shape->paths; path2; path2 = path2->next) { + for (NSVGpath* path2 = shape->paths; path2; path2 = path2->next) { if (path2 == path) continue; @@ -105,7 +105,7 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { if (path2->npts < 4) continue; for (int i = 1; i < path2->npts + 3; i += 3) { - float *p = &path2->pts[2*i]; + float* p = &path2->pts[2 * i]; // The previous point math::Vec p2 = math::Vec(p[-2], p[-1]); // The current point @@ -123,7 +123,7 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { else nvgPathWinding(vg, NVG_HOLE); -/* + /* // Shoelace algorithm for computing the area, and thus the winding direction float area = 0.0; math::Vec p0 = math::Vec(path->pts[0], path->pts[1]); @@ -140,7 +140,7 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { nvgPathWinding(vg, NVG_CCW); else nvgPathWinding(vg, NVG_CW); -*/ + */ } // Fill shape @@ -153,7 +153,7 @@ void svgDraw(NVGcontext *vg, NSVGimage *svg) { } break; case NSVG_PAINT_LINEAR_GRADIENT: case NSVG_PAINT_RADIAL_GRADIENT: { - NSVGgradient *g = shape->fill.gradient; + NSVGgradient* g = shape->fill.gradient; (void)g; DEBUG_ONLY(printf(" gradient: type: %s xform: %f %f %f %f %f %f spread: %d fx: %f fy: %f nstops: %d\n", (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT ? "linear" : "radial"), g->xform[0], g->xform[1], g->xform[2], g->xform[3], g->xform[4], g->xform[5], g->spread, g->fx, g->fy, g->nstops);) for (int i = 0; i < g->nstops; i++) { diff --git a/src/system.cpp b/src/system.cpp index f3215650..a6d0e715 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -27,11 +27,11 @@ namespace rack { namespace system { -std::list getEntries(const std::string &path) { +std::list getEntries(const std::string& path) { std::list filenames; - DIR *dir = opendir(path.c_str()); + DIR* dir = opendir(path.c_str()); if (dir) { - struct dirent *d; + struct dirent* d; while ((d = readdir(dir))) { std::string filename = d->d_name; if (filename == "." || filename == "..") @@ -45,7 +45,7 @@ std::list getEntries(const std::string &path) { } -bool isFile(const std::string &path) { +bool isFile(const std::string& path) { struct stat statbuf; if (stat(path.c_str(), &statbuf)) return false; @@ -53,7 +53,7 @@ bool isFile(const std::string &path) { } -bool isDirectory(const std::string &path) { +bool isDirectory(const std::string& path) { struct stat statbuf; if (stat(path.c_str(), &statbuf)) return false; @@ -61,7 +61,7 @@ bool isDirectory(const std::string &path) { } -void moveFile(const std::string &srcPath, const std::string &destPath) { +void moveFile(const std::string& srcPath, const std::string& destPath) { std::remove(destPath.c_str()); // Whether this overwrites existing files is implementation-defined. // i.e. Mingw64 fails to overwrite. @@ -70,23 +70,23 @@ void moveFile(const std::string &srcPath, const std::string &destPath) { } -void copyFile(const std::string &srcPath, const std::string &destPath) { +void copyFile(const std::string& srcPath, const std::string& destPath) { // Open source - FILE *source = fopen(srcPath.c_str(), "rb"); + FILE* source = fopen(srcPath.c_str(), "rb"); if (!source) return; DEFER({ fclose(source); }); // Open destination - FILE *dest = fopen(destPath.c_str(), "wb"); + FILE* dest = fopen(destPath.c_str(), "wb"); if (!dest) return; DEFER({ fclose(dest); }); // Copy buffer - const int bufferSize = (1<<15); + const int bufferSize = (1 << 15); char buffer[bufferSize]; while (1) { size_t size = fread(buffer, 1, bufferSize, source); @@ -99,7 +99,7 @@ void copyFile(const std::string &srcPath, const std::string &destPath) { } -void createDirectory(const std::string &path) { +void createDirectory(const std::string& path) { #if defined ARCH_WIN std::wstring pathW = string::toWstring(path); CreateDirectoryW(pathW.c_str(), NULL); @@ -114,7 +114,7 @@ int getLogicalCoreCount() { } -void setThreadName(const std::string &name) { +void setThreadName(const std::string& name) { #if defined ARCH_LIN pthread_setname_np(pthread_self(), name.c_str()); #elif defined ARCH_WIN @@ -161,12 +161,12 @@ void setThreadRealTime(bool realTime) { std::string getStackTrace() { int stackLen = 128; - void *stack[stackLen]; + void* stack[stackLen]; std::string s; #if defined ARCH_LIN || defined ARCH_MAC stackLen = backtrace(stack, stackLen); - char **strings = backtrace_symbols(stack, stackLen); + char** strings = backtrace_symbols(stack, stackLen); // Skip the first line because it's this function. for (int i = 1; i < stackLen; i++) { @@ -181,7 +181,7 @@ std::string getStackTrace() { s += "("; std::string symbol = match[2].str(); // Demangle symbol - char *symbolD = __cxxabiv1::__cxa_demangle(symbol.c_str(), NULL, NULL, NULL); + char* symbolD = __cxxabiv1::__cxa_demangle(symbol.c_str(), NULL, NULL, NULL); if (symbolD) { symbol = symbolD; free(symbolD); @@ -203,7 +203,7 @@ std::string getStackTrace() { SymInitialize(process, NULL, true); stackLen = CaptureStackBackTrace(0, stackLen, stack, NULL); - SYMBOL_INFO *symbol = (SYMBOL_INFO*) calloc(sizeof(SYMBOL_INFO) + 256, 1); + SYMBOL_INFO* symbol = (SYMBOL_INFO*) calloc(sizeof(SYMBOL_INFO) + 256, 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFO); @@ -218,7 +218,7 @@ std::string getStackTrace() { } -void openBrowser(const std::string &url) { +void openBrowser(const std::string& url) { #if defined ARCH_LIN std::string command = "xdg-open \"" + url + "\""; (void) std::system(command.c_str()); @@ -234,7 +234,7 @@ void openBrowser(const std::string &url) { } -void openFolder(const std::string &path) { +void openFolder(const std::string& path) { #if defined ARCH_LIN std::string command = "xdg-open \"" + path + "\""; (void) std::system(command.c_str()); @@ -250,7 +250,7 @@ void openFolder(const std::string &path) { } -void runProcessDetached(const std::string &path) { +void runProcessDetached(const std::string& path) { #if defined ARCH_WIN SHELLEXECUTEINFOW shExInfo; ZeroMemory(&shExInfo, sizeof(shExInfo)); diff --git a/src/ui.cpp b/src/ui.cpp index b645ad51..cf957a0d 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -5,7 +5,7 @@ namespace rack { namespace ui { -void init(){ +void init() { setTheme(nvgRGB(0x33, 0x33, 0x33), nvgRGB(0xf0, 0xf0, 0xf0)); } diff --git a/src/ui/Button.cpp b/src/ui/Button.cpp index 00550174..b7325161 100644 --- a/src/ui/Button.cpp +++ b/src/ui/Button.cpp @@ -11,7 +11,7 @@ Button::Button() { box.size.y = BND_WIDGET_HEIGHT; } -void Button::draw(const DrawArgs &args) { +void Button::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; @@ -20,7 +20,7 @@ void Button::draw(const DrawArgs &args) { bndToolButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, text.c_str()); } -void Button::onDragStart(const event::DragStart &e) { +void Button::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; @@ -28,12 +28,12 @@ void Button::onDragStart(const event::DragStart &e) { quantity->setMax(); } -void Button::onDragEnd(const event::DragEnd &e) { +void Button::onDragEnd(const event::DragEnd& e) { if (quantity) quantity->setMin(); } -void Button::onDragDrop(const event::DragDrop &e) { +void Button::onDragDrop(const event::DragDrop& e) { if (e.origin == this) { event::Action eAction; onAction(eAction); diff --git a/src/ui/ChoiceButton.cpp b/src/ui/ChoiceButton.cpp index 18fb7aa8..19face2d 100644 --- a/src/ui/ChoiceButton.cpp +++ b/src/ui/ChoiceButton.cpp @@ -7,7 +7,7 @@ namespace rack { namespace ui { -void ChoiceButton::draw(const DrawArgs &args) { +void ChoiceButton::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; diff --git a/src/ui/Label.cpp b/src/ui/Label.cpp index cb07c707..a95e1546 100644 --- a/src/ui/Label.cpp +++ b/src/ui/Label.cpp @@ -11,7 +11,7 @@ Label::Label() { color = bndGetTheme()->regularTheme.textColor; } -void Label::draw(const DrawArgs &args) { +void Label::draw(const DrawArgs& args) { // TODO // Custom font sizes do not work with right or center alignment float x; diff --git a/src/ui/List.cpp b/src/ui/List.cpp index 7be7a371..289b74e0 100644 --- a/src/ui/List.cpp +++ b/src/ui/List.cpp @@ -10,7 +10,7 @@ void List::step() { // Set positions of children box.size.y = 0.0; - for (widget::Widget *child : children) { + for (widget::Widget* child : children) { if (!child->visible) continue; // Set position of child diff --git a/src/ui/MarginLayout.cpp b/src/ui/MarginLayout.cpp index b3aecacd..ebaf73da 100644 --- a/src/ui/MarginLayout.cpp +++ b/src/ui/MarginLayout.cpp @@ -10,7 +10,7 @@ void MarginLayout::step() { Widget::step(); math::Rect childBox = box.zeroPos().grow(margin.neg()); - for (Widget *child : children) { + for (Widget* child : children) { child->box = childBox; } } diff --git a/src/ui/Menu.cpp b/src/ui/Menu.cpp index 5aa7bbdf..577330fd 100644 --- a/src/ui/Menu.cpp +++ b/src/ui/Menu.cpp @@ -12,7 +12,7 @@ Menu::~Menu() { setChildMenu(NULL); } -void Menu::setChildMenu(Menu *menu) { +void Menu::setChildMenu(Menu* menu) { if (childMenu) { childMenu->parent->removeChild(childMenu); delete childMenu; @@ -30,7 +30,7 @@ void Menu::step() { // Set positions of children box.size = math::Vec(0, 0); - for (widget::Widget *child : children) { + for (widget::Widget* child : children) { if (!child->visible) continue; // Increment height, set position of child @@ -43,7 +43,7 @@ void Menu::step() { } // Set widths of all children to maximum width - for (widget::Widget *child : children) { + for (widget::Widget* child : children) { child->box.size.x = box.size.x; } @@ -52,12 +52,12 @@ void Menu::step() { box = box.nudge(parent->box.zeroPos()); } -void Menu::draw(const DrawArgs &args) { +void Menu::draw(const DrawArgs& args) { bndMenuBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE); Widget::draw(args); } -void Menu::onHoverScroll(const event::HoverScroll &e) { +void Menu::onHoverScroll(const event::HoverScroll& e) { if (parent && !parent->box.isContaining(box)) box.pos.y += e.scrollDelta.y; } diff --git a/src/ui/MenuItem.cpp b/src/ui/MenuItem.cpp index 7aeb974d..33c40700 100644 --- a/src/ui/MenuItem.cpp +++ b/src/ui/MenuItem.cpp @@ -9,14 +9,14 @@ namespace ui { #define BND_LABEL_FONT_SIZE 13 -void MenuItem::draw(const DrawArgs &args) { +void MenuItem::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; // Set active state if this MenuItem - Menu *parentMenu = dynamic_cast(parent); + Menu* parentMenu = dynamic_cast(parent); if (parentMenu && parentMenu->activeEntry == this) state = BND_ACTIVE; @@ -44,15 +44,15 @@ void MenuItem::step() { Widget::step(); } -void MenuItem::onEnter(const event::Enter &e) { - Menu *parentMenu = dynamic_cast(parent); +void MenuItem::onEnter(const event::Enter& e) { + Menu* parentMenu = dynamic_cast(parent); if (!parentMenu) return; parentMenu->activeEntry = NULL; // Try to create child menu - Menu *childMenu = createChildMenu(); + Menu* childMenu = createChildMenu(); if (childMenu) { parentMenu->activeEntry = this; childMenu->box.pos = parent->box.pos.plus(box.getTopRight()); @@ -60,7 +60,7 @@ void MenuItem::onEnter(const event::Enter &e) { parentMenu->setChildMenu(childMenu); } -void MenuItem::onDragDrop(const event::DragDrop &e) { +void MenuItem::onDragDrop(const event::DragDrop& e) { if (e.origin != this) return; doAction(); @@ -79,7 +79,7 @@ void MenuItem::doAction() { if (!cAction.target) return; - MenuOverlay *overlay = getAncestorOfType(); + MenuOverlay* overlay = getAncestorOfType(); if (overlay) { overlay->requestDelete(); } diff --git a/src/ui/MenuLabel.cpp b/src/ui/MenuLabel.cpp index 78de441b..2659c908 100644 --- a/src/ui/MenuLabel.cpp +++ b/src/ui/MenuLabel.cpp @@ -6,7 +6,7 @@ namespace rack { namespace ui { -void MenuLabel::draw(const DrawArgs &args) { +void MenuLabel::draw(const DrawArgs& args) { bndMenuLabel(args.vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); } diff --git a/src/ui/MenuOverlay.cpp b/src/ui/MenuOverlay.cpp index 3b65225f..bc1bf472 100644 --- a/src/ui/MenuOverlay.cpp +++ b/src/ui/MenuOverlay.cpp @@ -12,7 +12,7 @@ void MenuOverlay::step() { Widget::step(); } -void MenuOverlay::onButton(const event::Button &e) { +void MenuOverlay::onButton(const event::Button& e) { OpaqueWidget::onButton(e); if (e.isConsumed() && e.getTarget() != this) return; @@ -23,7 +23,7 @@ void MenuOverlay::onButton(const event::Button &e) { } } -void MenuOverlay::onHoverKey(const event::HoverKey &e) { +void MenuOverlay::onHoverKey(const event::HoverKey& e) { OpaqueWidget::onHoverKey(e); if (e.isConsumed()) return; diff --git a/src/ui/MenuSeparator.cpp b/src/ui/MenuSeparator.cpp index 54faadeb..43edd55c 100644 --- a/src/ui/MenuSeparator.cpp +++ b/src/ui/MenuSeparator.cpp @@ -9,7 +9,7 @@ MenuSeparator::MenuSeparator() { box.size.y = BND_WIDGET_HEIGHT / 2; } -void MenuSeparator::draw(const DrawArgs &args) { +void MenuSeparator::draw(const DrawArgs& args) { nvgBeginPath(args.vg); const float margin = 8.0; nvgMoveTo(args.vg, margin, box.size.y / 2.0); diff --git a/src/ui/PasswordField.cpp b/src/ui/PasswordField.cpp index 86157b4b..d127f7dc 100644 --- a/src/ui/PasswordField.cpp +++ b/src/ui/PasswordField.cpp @@ -5,7 +5,7 @@ namespace rack { namespace ui { -void PasswordField::draw(const DrawArgs &args) { +void PasswordField::draw(const DrawArgs& args) { std::string textTmp = text; text = std::string(textTmp.size(), '*'); TextField::draw(args); diff --git a/src/ui/ProgressBar.cpp b/src/ui/ProgressBar.cpp index 9899357a..8c9f0149 100644 --- a/src/ui/ProgressBar.cpp +++ b/src/ui/ProgressBar.cpp @@ -9,7 +9,7 @@ ProgressBar::ProgressBar() { box.size.y = BND_WIDGET_HEIGHT; } -void ProgressBar::draw(const DrawArgs &args) { +void ProgressBar::draw(const DrawArgs& args) { float progress = quantity ? quantity->getScaledValue() : 0.f; std::string text = quantity ? quantity->getString() : ""; bndSlider(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_ALL, BND_DEFAULT, progress, text.c_str(), NULL); diff --git a/src/ui/RadioButton.cpp b/src/ui/RadioButton.cpp index 37ee685f..c7fcb5b0 100644 --- a/src/ui/RadioButton.cpp +++ b/src/ui/RadioButton.cpp @@ -9,7 +9,7 @@ RadioButton::RadioButton() { box.size.y = BND_WIDGET_HEIGHT; } -void RadioButton::draw(const DrawArgs &args) { +void RadioButton::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; @@ -23,7 +23,7 @@ void RadioButton::draw(const DrawArgs &args) { bndRadioButton(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, -1, label.c_str()); } -void RadioButton::onDragDrop(const event::DragDrop &e) { +void RadioButton::onDragDrop(const event::DragDrop& e) { if (e.origin == this) { if (quantity) { if (quantity->isMax()) diff --git a/src/ui/ScrollBar.cpp b/src/ui/ScrollBar.cpp index d38ae9a0..75ccd560 100644 --- a/src/ui/ScrollBar.cpp +++ b/src/ui/ScrollBar.cpp @@ -12,7 +12,7 @@ ScrollBar::ScrollBar() { box.size = math::Vec(BND_SCROLLBAR_WIDTH, BND_SCROLLBAR_HEIGHT); } -void ScrollBar::draw(const DrawArgs &args) { +void ScrollBar::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; @@ -22,17 +22,17 @@ void ScrollBar::draw(const DrawArgs &args) { bndScrollBar(args.vg, 0.0, 0.0, box.size.x, box.size.y, state, offset, size); } -void ScrollBar::onDragStart(const event::DragStart &e) { +void ScrollBar::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; APP->window->cursorLock(); } -void ScrollBar::onDragMove(const event::DragMove &e) { +void ScrollBar::onDragMove(const event::DragMove& e) { const float sensitivity = 1.f; - ScrollWidget *scrollWidget = dynamic_cast(parent); + ScrollWidget* scrollWidget = dynamic_cast(parent); assert(scrollWidget); if (orientation == HORIZONTAL) scrollWidget->offset.x += sensitivity * e.mouseDelta.x; @@ -40,7 +40,7 @@ void ScrollBar::onDragMove(const event::DragMove &e) { scrollWidget->offset.y += sensitivity * e.mouseDelta.y; } -void ScrollBar::onDragEnd(const event::DragEnd &e) { +void ScrollBar::onDragEnd(const event::DragEnd& e) { APP->window->cursorUnlock(); } diff --git a/src/ui/ScrollWidget.cpp b/src/ui/ScrollWidget.cpp index ebf41d0e..ce691871 100644 --- a/src/ui/ScrollWidget.cpp +++ b/src/ui/ScrollWidget.cpp @@ -26,7 +26,7 @@ void ScrollWidget::scrollTo(math::Rect r) { offset = offset.clampSafe(bound); } -void ScrollWidget::draw(const DrawArgs &args) { +void ScrollWidget::draw(const DrawArgs& args) { nvgScissor(args.vg, RECT_ARGS(args.clipBox)); Widget::draw(args); nvgResetScissor(args.vg); @@ -63,7 +63,7 @@ void ScrollWidget::step() { verticalScrollBar->box.size.y = horizontalScrollBar->visible ? inner.y : box.size.y; } -void ScrollWidget::onButton(const event::Button &e) { +void ScrollWidget::onButton(const event::Button& e) { Widget::onButton(e); if (e.isConsumed()) return; @@ -77,13 +77,13 @@ void ScrollWidget::onButton(const event::Button &e) { } } -void ScrollWidget::onDragStart(const event::DragStart &e) { +void ScrollWidget::onDragStart(const event::DragStart& e) { if (e.button == GLFW_MOUSE_BUTTON_MIDDLE) { e.consume(this); } } -void ScrollWidget::onDragMove(const event::DragMove &e) { +void ScrollWidget::onDragMove(const event::DragMove& e) { // Scroll only if the scrollbars are visible if (!(horizontalScrollBar->visible || verticalScrollBar->visible)) return; @@ -91,7 +91,7 @@ void ScrollWidget::onDragMove(const event::DragMove &e) { offset = offset.minus(e.mouseDelta); } -void ScrollWidget::onHoverScroll(const event::HoverScroll &e) { +void ScrollWidget::onHoverScroll(const event::HoverScroll& e) { OpaqueWidget::onHoverScroll(e); if (e.isConsumed()) return; diff --git a/src/ui/SequentialLayout.cpp b/src/ui/SequentialLayout.cpp index 99e8a9d7..77519d2b 100644 --- a/src/ui/SequentialLayout.cpp +++ b/src/ui/SequentialLayout.cpp @@ -17,7 +17,7 @@ void SequentialLayout::step() { std::vector> rows; rows.resize(1); float rowWidth = 0.0; - for (widget::Widget *child : children) { + for (widget::Widget* child : children) { if (!child->visible) continue; @@ -33,12 +33,12 @@ void SequentialLayout::step() { // Position widgets math::Vec p; - for (auto &row : rows) { + for (auto& row : rows) { // For center and right alignment, compute offset from the left margin float offset = 0.0; if (alignment != LEFT_ALIGNMENT) { float rowWidth = 0.0; - for (widget::Widget *child : row) { + for (widget::Widget* child : row) { rowWidth += X(child->box.size) + X(spacing); } rowWidth -= X(spacing); @@ -50,7 +50,7 @@ void SequentialLayout::step() { } float maxHeight = 0.0; - for (widget::Widget *child : row) { + for (widget::Widget* child : row) { child->box.pos = p; X(child->box.pos) += offset; diff --git a/src/ui/Slider.cpp b/src/ui/Slider.cpp index 4fa6849c..ee667ccc 100644 --- a/src/ui/Slider.cpp +++ b/src/ui/Slider.cpp @@ -12,7 +12,7 @@ Slider::Slider() { box.size.y = BND_WIDGET_HEIGHT; } -void Slider::draw(const DrawArgs &args) { +void Slider::draw(const DrawArgs& args) { BNDwidgetState state = BND_DEFAULT; if (APP->event->hoveredWidget == this) state = BND_HOVER; @@ -24,24 +24,24 @@ void Slider::draw(const DrawArgs &args) { bndSlider(args.vg, 0.0, 0.0, box.size.x, box.size.y, BND_CORNER_NONE, state, progress, text.c_str(), NULL); } -void Slider::onDragStart(const event::DragStart &e) { +void Slider::onDragStart(const event::DragStart& e) { if (e.button != GLFW_MOUSE_BUTTON_LEFT) return; APP->window->cursorLock(); } -void Slider::onDragMove(const event::DragMove &e) { +void Slider::onDragMove(const event::DragMove& e) { if (quantity) { quantity->moveScaledValue(SENSITIVITY * e.mouseDelta.x); } } -void Slider::onDragEnd(const event::DragEnd &e) { +void Slider::onDragEnd(const event::DragEnd& e) { APP->window->cursorUnlock(); } -void Slider::onDoubleClick(const event::DoubleClick &e) { +void Slider::onDoubleClick(const event::DoubleClick& e) { if (quantity) quantity->reset(); } diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index d0eb0d2f..cdaf90d1 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -8,7 +8,7 @@ TextField::TextField() { box.size.y = BND_WIDGET_HEIGHT; } -void TextField::draw(const DrawArgs &args) { +void TextField::draw(const DrawArgs& args) { nvgScissor(args.vg, RECT_ARGS(args.clipBox)); BNDwidgetState state; @@ -30,7 +30,7 @@ void TextField::draw(const DrawArgs &args) { nvgResetScissor(args.vg); } -void TextField::onDragHover(const event::DragHover &e) { +void TextField::onDragHover(const event::DragHover& e) { OpaqueWidget::onDragHover(e); if (e.origin == this) { @@ -39,7 +39,7 @@ void TextField::onDragHover(const event::DragHover &e) { } } -void TextField::onButton(const event::Button &e) { +void TextField::onButton(const event::Button& e) { OpaqueWidget::onButton(e); if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT) { @@ -47,7 +47,7 @@ void TextField::onButton(const event::Button &e) { } } -void TextField::onSelectText(const event::SelectText &e) { +void TextField::onSelectText(const event::SelectText& e) { if (e.codepoint < 128) { std::string newText(1, (char) e.codepoint); insertText(newText); @@ -55,7 +55,7 @@ void TextField::onSelectText(const event::SelectText &e) { e.consume(this); } -void TextField::onSelectKey(const event::SelectKey &e) { +void TextField::onSelectKey(const event::SelectKey& e) { if (e.action == GLFW_PRESS || e.action == GLFW_REPEAT) { switch (e.key) { case GLFW_KEY_BACKSPACE: { @@ -126,7 +126,7 @@ void TextField::onSelectKey(const event::SelectKey &e) { } break; case GLFW_KEY_V: { if ((e.mods & RACK_MOD_MASK) == RACK_MOD_CTRL) { - const char *newText = glfwGetClipboardString(APP->window->win); + const char* newText = glfwGetClipboardString(APP->window->win); if (newText) insertText(newText); } diff --git a/src/ui/Tooltip.cpp b/src/ui/Tooltip.cpp index bb684f8f..a9f83700 100644 --- a/src/ui/Tooltip.cpp +++ b/src/ui/Tooltip.cpp @@ -20,7 +20,7 @@ void Tooltip::step() { Widget::step(); } -void Tooltip::draw(const DrawArgs &args) { +void Tooltip::draw(const DrawArgs& args) { bndTooltipBackground(args.vg, 0.0, 0.0, box.size.x, box.size.y); bndMenuLabel(args.vg, 0.0, 0.0, box.size.x, box.size.y, -1, text.c_str()); Widget::draw(args); diff --git a/src/updater.cpp b/src/updater.cpp index 0f0443ac..5b2f7a7f 100644 --- a/src/updater.cpp +++ b/src/updater.cpp @@ -21,7 +21,7 @@ static std::string downloadUrl; static void checkVersion() { std::string versionUrl = app::API_URL + "/version"; - json_t *resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL); + json_t* resJ = network::requestJson(network::METHOD_GET, versionUrl, NULL); if (!resJ) { WARN("Request for version failed"); return; @@ -30,17 +30,17 @@ static void checkVersion() { json_decref(resJ); }); - json_t *versionJ = json_object_get(resJ, "version"); + json_t* versionJ = json_object_get(resJ, "version"); if (versionJ) version = json_string_value(versionJ); - json_t *changelogUrlJ = json_object_get(resJ, "changelogUrl"); + json_t* changelogUrlJ = json_object_get(resJ, "changelogUrl"); if (changelogUrlJ) changelogUrl = json_string_value(changelogUrlJ); - json_t *downloadUrlsJ = json_object_get(resJ, "downloadUrls"); + json_t* downloadUrlsJ = json_object_get(resJ, "downloadUrls"); if (downloadUrlsJ) { - json_t *downloadUrlJ = json_object_get(downloadUrlsJ, app::APP_ARCH.c_str()); + json_t* downloadUrlJ = json_object_get(downloadUrlsJ, app::APP_ARCH.c_str()); if (downloadUrlJ) downloadUrl = json_string_value(downloadUrlJ); } diff --git a/src/widget/FramebufferWidget.cpp b/src/widget/FramebufferWidget.cpp index 78d1b63d..0505d73b 100644 --- a/src/widget/FramebufferWidget.cpp +++ b/src/widget/FramebufferWidget.cpp @@ -32,7 +32,7 @@ void FramebufferWidget::step() { // In case we fail drawing the framebuffer, don't try again the next frame, so reset `dirty` here. dirty = false; - NVGcontext *vg = APP->window->vg; + NVGcontext* vg = APP->window->vg; fbScale = scale; // Set scale to zero so we must wait for the next draw() call before drawing the framebuffer again. @@ -81,7 +81,7 @@ void FramebufferWidget::step() { // If oversampling, create another framebuffer and copy it to actual size. if (oversample != 1.0) { - NVGLUframebuffer *newFb = nvgluCreateFramebuffer(vg, fbSize.x, fbSize.y, 0); + NVGLUframebuffer* newFb = nvgluCreateFramebuffer(vg, fbSize.x, fbSize.y, 0); if (!newFb) { WARN("Non-oversampled framebuffer of size (%f, %f) could not be created for FramebufferWidget.", VEC_ARGS(fbSize)); return; @@ -96,7 +96,7 @@ void FramebufferWidget::step() { nvgBeginPath(vg); nvgRect(vg, 0.0, 0.0, fbSize.x, fbSize.y); NVGpaint paint = nvgImagePattern(vg, 0.0, 0.0, fbSize.x, fbSize.y, - 0.0, fb->image, 1.0); + 0.0, fb->image, 1.0); nvgFillPaint(vg, paint); nvgFill(vg); @@ -114,7 +114,7 @@ void FramebufferWidget::step() { } } -void FramebufferWidget::draw(const DrawArgs &args) { +void FramebufferWidget::draw(const DrawArgs& args) { // Draw directly if already drawing in a framebuffer if (bypass || args.fb) { Widget::draw(args); @@ -150,14 +150,14 @@ void FramebufferWidget::draw(const DrawArgs &args) { nvgBeginPath(args.vg); nvgRect(args.vg, - offsetI.x + fbBox.pos.x, - offsetI.y + fbBox.pos.y, - fbBox.size.x * scaleRatio.x, fbBox.size.y * scaleRatio.y); + offsetI.x + fbBox.pos.x, + offsetI.y + fbBox.pos.y, + fbBox.size.x * scaleRatio.x, fbBox.size.y * scaleRatio.y); NVGpaint paint = nvgImagePattern(args.vg, - offsetI.x + fbBox.pos.x, - offsetI.y + fbBox.pos.y, - fbBox.size.x * scaleRatio.x, fbBox.size.y * scaleRatio.y, - 0.0, fb->image, 1.0); + offsetI.x + fbBox.pos.x, + offsetI.y + fbBox.pos.y, + fbBox.size.x * scaleRatio.x, fbBox.size.y * scaleRatio.y, + 0.0, fb->image, 1.0); nvgFillPaint(args.vg, paint); nvgFill(args.vg); @@ -170,7 +170,7 @@ void FramebufferWidget::draw(const DrawArgs &args) { } void FramebufferWidget::drawFramebuffer() { - NVGcontext *vg = APP->window->vg; + NVGcontext* vg = APP->window->vg; float pixelRatio = fbSize.x * oversample / fbBox.size.x; nvgBeginFrame(vg, fbBox.size.x, fbBox.size.y, pixelRatio); diff --git a/src/widget/SvgWidget.cpp b/src/widget/SvgWidget.cpp index e33380d1..9db7a614 100644 --- a/src/widget/SvgWidget.cpp +++ b/src/widget/SvgWidget.cpp @@ -20,7 +20,7 @@ void SvgWidget::setSvg(std::shared_ptr svg) { wrap(); } -void SvgWidget::draw(const DrawArgs &args) { +void SvgWidget::draw(const DrawArgs& args) { if (svg && svg->handle) { svgDraw(args.vg, svg->handle); } diff --git a/src/widget/Widget.cpp b/src/widget/Widget.cpp index ba51b6da..0030c32c 100644 --- a/src/widget/Widget.cpp +++ b/src/widget/Widget.cpp @@ -52,7 +52,7 @@ void Widget::requestDelete() { math::Rect Widget::getChildrenBoundingBox() { math::Vec min = math::Vec(INFINITY, INFINITY); math::Vec max = math::Vec(-INFINITY, -INFINITY); - for (Widget *child : children) { + for (Widget* child : children) { if (!child->visible) continue; min = min.min(child->box.getTopLeft()); @@ -61,7 +61,7 @@ math::Rect Widget::getChildrenBoundingBox() { return math::Rect::fromMinMax(min, max); } -math::Vec Widget::getRelativeOffset(math::Vec v, Widget *relative) { +math::Vec Widget::getRelativeOffset(math::Vec v, Widget* relative) { if (this == relative) { return v; } @@ -84,7 +84,7 @@ math::Rect Widget::getViewport(math::Rect r) { return r.clamp(bound); } -void Widget::addChild(Widget *child) { +void Widget::addChild(Widget* child) { assert(child); assert(!child->parent); child->parent = this; @@ -94,7 +94,7 @@ void Widget::addChild(Widget *child) { child->onAdd(eAdd); } -void Widget::addChildBottom(Widget *child) { +void Widget::addChildBottom(Widget* child) { assert(child); assert(!child->parent); child->parent = this; @@ -104,7 +104,7 @@ void Widget::addChildBottom(Widget *child) { child->onAdd(eAdd); } -void Widget::removeChild(Widget *child) { +void Widget::removeChild(Widget* child) { assert(child); // Make sure `this` is the child's parent assert(child->parent == this); @@ -122,7 +122,7 @@ void Widget::removeChild(Widget *child) { } void Widget::clearChildren() { - for (Widget *child : children) { + for (Widget* child : children) { // event::Remove event::Remove eRemove; child->onRemove(eRemove); @@ -135,7 +135,7 @@ void Widget::clearChildren() { void Widget::step() { for (auto it = children.begin(); it != children.end();) { - Widget *child = *it; + Widget* child = *it; // Delete children if a delete is requested if (child->requestedDelete) { // event::Remove @@ -153,9 +153,9 @@ void Widget::step() { } } -void Widget::draw(const DrawArgs &args) { +void Widget::draw(const DrawArgs& args) { // Iterate children - for (Widget *child : children) { + for (Widget* child : children) { // Don't draw if invisible if (!child->visible) continue; diff --git a/src/widget/ZoomWidget.cpp b/src/widget/ZoomWidget.cpp index 1f40920e..4543c160 100644 --- a/src/widget/ZoomWidget.cpp +++ b/src/widget/ZoomWidget.cpp @@ -5,7 +5,7 @@ namespace rack { namespace widget { -math::Vec ZoomWidget::getRelativeOffset(math::Vec v, Widget *relative) { +math::Vec ZoomWidget::getRelativeOffset(math::Vec v, Widget* relative) { return Widget::getRelativeOffset(v.mult(zoom), relative); } @@ -29,7 +29,7 @@ void ZoomWidget::setZoom(float zoom) { Widget::onZoom(eZoom); } -void ZoomWidget::draw(const DrawArgs &args) { +void ZoomWidget::draw(const DrawArgs& args) { DrawArgs zoomCtx = args; zoomCtx.clipBox.pos = zoomCtx.clipBox.pos.div(zoom); zoomCtx.clipBox.size = zoomCtx.clipBox.size.div(zoom); diff --git a/src/window.cpp b/src/window.cpp index 01bd0e36..4759e7e5 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -15,8 +15,8 @@ #include #if defined ARCH_MAC -// For CGAssociateMouseAndMouseCursorPosition -#include + // For CGAssociateMouseAndMouseCursorPosition + #include #endif #include @@ -26,7 +26,7 @@ namespace rack { -void Font::loadFile(const std::string &filename, NVGcontext *vg) { +void Font::loadFile(const std::string& filename, NVGcontext* vg) { this->vg = vg; handle = nvgCreateFont(vg, filename.c_str(), filename.c_str()); if (handle >= 0) { @@ -41,11 +41,11 @@ Font::~Font() { // There is no NanoVG deleteFont() function yet, so do nothing } -std::shared_ptr Font::load(const std::string &filename) { +std::shared_ptr Font::load(const std::string& filename) { return APP->window->loadFont(filename); } -void Image::loadFile(const std::string &filename, NVGcontext *vg) { +void Image::loadFile(const std::string& filename, NVGcontext* vg) { this->vg = vg; handle = nvgCreateImage(vg, filename.c_str(), NVG_IMAGE_REPEATX | NVG_IMAGE_REPEATY); if (handle > 0) { @@ -62,11 +62,11 @@ Image::~Image() { nvgDeleteImage(vg, handle); } -std::shared_ptr Image::load(const std::string &filename) { +std::shared_ptr Image::load(const std::string& filename) { return APP->window->loadImage(filename); } -void Svg::loadFile(const std::string &filename) { +void Svg::loadFile(const std::string& filename) { handle = nsvgParseFromFile(filename.c_str(), "px", app::SVG_DPI); if (handle) { INFO("Loaded SVG %s", filename.c_str()); @@ -81,7 +81,7 @@ Svg::~Svg() { nsvgDelete(handle); } -std::shared_ptr Svg::load(const std::string &filename) { +std::shared_ptr Svg::load(const std::string& filename) { return APP->window->loadSvg(filename); } @@ -96,12 +96,12 @@ struct Window::Internal { }; -static void windowSizeCallback(GLFWwindow *win, int width, int height) { +static void windowSizeCallback(GLFWwindow* win, int width, int height) { // Do nothing. Window size is reset each frame anyway. } -static void mouseButtonCallback(GLFWwindow *win, int button, int action, int mods) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void mouseButtonCallback(GLFWwindow* win, int button, int action, int mods) { + Window* window = (Window*) glfwGetWindowUserPointer(win); #if defined ARCH_MAC // Remap Ctrl-left click to right click on Mac if (button == GLFW_MOUSE_BUTTON_LEFT && (mods & RACK_MOD_MASK) == GLFW_MOD_CONTROL) { @@ -118,8 +118,8 @@ static void mouseButtonCallback(GLFWwindow *win, int button, int action, int mod APP->event->handleButton(window->mousePos, button, action, mods); } -static void cursorPosCallback(GLFWwindow *win, double xpos, double ypos) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void cursorPosCallback(GLFWwindow* win, double xpos, double ypos) { + Window* window = (Window*) glfwGetWindowUserPointer(win); math::Vec mousePos = math::Vec(xpos, ypos).div(window->pixelRatio / window->windowRatio).round(); math::Vec mouseDelta = mousePos.minus(window->mousePos); @@ -144,14 +144,14 @@ static void cursorPosCallback(GLFWwindow *win, double xpos, double ypos) { APP->event->handleHover(mousePos, mouseDelta); } -static void cursorEnterCallback(GLFWwindow *win, int entered) { +static void cursorEnterCallback(GLFWwindow* win, int entered) { if (!entered) { APP->event->handleLeave(); } } -static void scrollCallback(GLFWwindow *win, double x, double y) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void scrollCallback(GLFWwindow* win, double x, double y) { + Window* window = (Window*) glfwGetWindowUserPointer(win); math::Vec scrollDelta = math::Vec(x, y); #if defined ARCH_MAC scrollDelta = scrollDelta.mult(10.0); @@ -162,13 +162,13 @@ static void scrollCallback(GLFWwindow *win, double x, double y) { APP->event->handleScroll(window->mousePos, scrollDelta); } -static void charCallback(GLFWwindow *win, unsigned int codepoint) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void charCallback(GLFWwindow* win, unsigned int codepoint) { + Window* window = (Window*) glfwGetWindowUserPointer(win); APP->event->handleText(window->mousePos, codepoint); } -static void keyCallback(GLFWwindow *win, int key, int scancode, int action, int mods) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void keyCallback(GLFWwindow* win, int key, int scancode, int action, int mods) { + Window* window = (Window*) glfwGetWindowUserPointer(win); if (APP->event->handleKey(window->mousePos, key, scancode, action, mods)) return; @@ -181,8 +181,8 @@ static void keyCallback(GLFWwindow *win, int key, int scancode, int action, int } } -static void dropCallback(GLFWwindow *win, int count, const char **paths) { - Window *window = (Window*) glfwGetWindowUserPointer(win); +static void dropCallback(GLFWwindow* win, int count, const char** paths) { + Window* window = (Window*) glfwGetWindowUserPointer(win); std::vector pathsVec; for (int i = 0; i < count; i++) { pathsVec.push_back(paths[i]); @@ -190,7 +190,7 @@ static void dropCallback(GLFWwindow *win, int count, const char **paths) { APP->event->handleDrop(window->mousePos, pathsVec); } -static void errorCallback(int error, const char *description) { +static void errorCallback(int error, const char* description) { WARN("GLFW error %d: %s", error, description); } @@ -262,8 +262,8 @@ Window::Window() { exit(1); } - const GLubyte *renderer = glGetString(GL_RENDERER); - const GLubyte *version = glGetString(GL_VERSION); + const GLubyte* renderer = glGetString(GL_RENDERER); + const GLubyte* version = glGetString(GL_VERSION); INFO("Renderer: %s", renderer); INFO("OpenGL: %s", version); @@ -413,10 +413,10 @@ void Window::screenshot(float zoom) { // Iterate plugins and create directories std::string screenshotsDir = asset::user("screenshots"); system::createDirectory(screenshotsDir); - for (plugin::Plugin *p : plugin::plugins) { + for (plugin::Plugin* p : plugin::plugins) { std::string dir = screenshotsDir + "/" + p->slug; system::createDirectory(dir); - for (plugin::Model *model : p->models) { + for (plugin::Model* model : p->models) { std::string filename = dir + "/" + model->slug + ".png"; // Skip model if screenshot already exists if (system::isFile(filename)) @@ -424,8 +424,8 @@ void Window::screenshot(float zoom) { INFO("Screenshotting %s %s to %s", p->slug.c_str(), model->slug.c_str(), filename.c_str()); // Create widgets - app::ModuleWidget *mw = model->createModuleWidgetNull(); - widget::FramebufferWidget *fb = new widget::FramebufferWidget; + app::ModuleWidget* mw = model->createModuleWidgetNull(); + widget::FramebufferWidget* fb = new widget::FramebufferWidget; fb->oversample = 2; fb->addChild(mw); fb->scale = math::Vec(zoom, zoom); @@ -438,7 +438,7 @@ void Window::screenshot(float zoom) { // Read pixels int width, height; nvgImageSize(vg, fb->getImageHandle(), &width, &height); - uint8_t *data = new uint8_t[height * width * 4]; + uint8_t* data = new uint8_t[height * width * 4]; glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data); // Flip image vertically @@ -501,14 +501,14 @@ void Window::setFullScreen(bool fullScreen) { else { glfwGetWindowPos(win, &internal->lastWindowX, &internal->lastWindowY); glfwGetWindowSize(win, &internal->lastWindowWidth, &internal->lastWindowHeight); - GLFWmonitor *monitor = glfwGetPrimaryMonitor(); + GLFWmonitor* monitor = glfwGetPrimaryMonitor(); const GLFWvidmode* mode = glfwGetVideoMode(monitor); glfwSetWindowMonitor(win, monitor, 0, 0, mode->width, mode->height, mode->refreshRate); } } bool Window::isFullScreen() { - GLFWmonitor *monitor = glfwGetWindowMonitor(win); + GLFWmonitor* monitor = glfwGetWindowMonitor(win); return monitor != NULL; } @@ -519,7 +519,7 @@ bool Window::isFrameOverdue() { return frameDuration > 1.0 / settings::frameRateLimit; } -std::shared_ptr Window::loadFont(const std::string &filename) { +std::shared_ptr Window::loadFont(const std::string& filename) { auto sp = fontCache[filename].lock(); if (!sp) { fontCache[filename] = sp = std::make_shared(); @@ -528,7 +528,7 @@ std::shared_ptr Window::loadFont(const std::string &filename) { return sp; } -std::shared_ptr Window::loadImage(const std::string &filename) { +std::shared_ptr Window::loadImage(const std::string& filename) { auto sp = imageCache[filename].lock(); if (!sp) { imageCache[filename] = sp = std::make_shared(); @@ -537,7 +537,7 @@ std::shared_ptr Window::loadImage(const std::string &filename) { return sp; } -std::shared_ptr Window::loadSvg(const std::string &filename) { +std::shared_ptr Window::loadSvg(const std::string& filename) { auto sp = svgCache[filename].lock(); if (!sp) { svgCache[filename] = sp = std::make_shared();