From 33ca4dac2d6517e265dfce8abed164755067a9d0 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 18 Oct 2017 19:29:46 -0400 Subject: [PATCH] Add override keyword everywhere --- compile.mk | 5 +- include/app.hpp | 92 +++++++++++----------- include/components.hpp | 8 +- include/rack.hpp | 2 +- include/widgets.hpp | 130 ++++++++++++++++---------------- src/app/ModuleWidget.cpp | 10 +-- src/app/PluginManagerWidget.cpp | 16 ++-- src/app/RackWidget.cpp | 6 +- src/app/SVGPanel.cpp | 2 +- src/app/Toolbar.cpp | 20 ++--- src/core/AudioInterface.cpp | 26 +++---- src/core/Blank.cpp | 8 +- src/core/Bridge.cpp | 2 +- src/core/core.hpp | 10 +-- 14 files changed, 169 insertions(+), 168 deletions(-) diff --git a/compile.mk b/compile.mk index 1f66e0f3..1c794024 100644 --- a/compile.mk +++ b/compile.mk @@ -4,10 +4,11 @@ endif # Generate dependency files alongside the object files FLAGS += -MMD +FLAGS += -g # Optimization FLAGS += -O3 -march=nocona -ffast-math -FLAGS += -Wall -Wextra -Wno-unused-parameter -Wsuggest-override -FLAGS += -g +FLAGS += -Wall -Wextra -Wno-unused-parameter +CXXFLAGS += -Wsuggest-override CXXFLAGS += -std=c++11 diff --git a/include/app.hpp b/include/app.hpp index de2a04ab..66cd3a9b 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -57,15 +57,15 @@ struct ModuleWidget : OpaqueWidget { virtual void randomize(); virtual Menu *createContextMenu(); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; Vec dragPos; - Widget *onMouseMove(Vec pos, Vec mouseRel); - Widget *onHoverKey(Vec pos, int key); - void onDragStart(); - void onDragMove(Vec mouseRel); - void onDragEnd(); - void onMouseDownOpaque(int button); + Widget *onMouseMove(Vec pos, Vec mouseRel) override; + Widget *onHoverKey(Vec pos, int key) override; + void onDragStart() override; + void onDragMove(Vec mouseRel) override; + void onDragEnd() override; + void onMouseDownOpaque(int button) override; }; struct ValueLight; @@ -85,7 +85,7 @@ struct WireWidget : OpaqueWidget { void updateWire(); Vec getOutputPos(); Vec getInputPos(); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; void drawPlugs(NVGcontext *vg); }; @@ -99,7 +99,7 @@ struct WireContainer : TransparentWidget { void removeAllWires(Port *port); /** Returns the most recently added wire connected to the given Port, i.e. the top of the stack */ WireWidget *getTopWire(Port *port); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct RackWidget : OpaqueWidget { @@ -131,20 +131,20 @@ struct RackWidget : OpaqueWidget { bool requestModuleBox(ModuleWidget *m, Rect box); /** Moves a module to the closest non-colliding position */ bool requestModuleBoxNearest(ModuleWidget *m, Rect box); - void step(); - void draw(NVGcontext *vg); + void step() override; + void draw(NVGcontext *vg) override; - void onMouseDownOpaque(int button); + void onMouseDownOpaque(int button) override; }; struct RackRail : TransparentWidget { - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct Panel : TransparentWidget { NVGcolor backgroundColor; std::shared_ptr backgroundImage; - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct SVGPanel : FramebufferWidget { @@ -157,13 +157,13 @@ struct SVGPanel : FramebufferWidget { struct CircularShadow : TransparentWidget { float blur = 0.0; - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct Light : TransparentWidget { NVGcolor bgColor = nvgRGBf(0, 0, 0); NVGcolor color = nvgRGBf(1, 1, 1); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct ParamWidget : OpaqueWidget, QuantityWidget { @@ -177,8 +177,8 @@ struct ParamWidget : OpaqueWidget, QuantityWidget { json_t *toJson(); void fromJson(json_t *rootJ); virtual void randomize(); - void onMouseDownOpaque(int button); - void onChange(); + void onMouseDownOpaque(int button) override; + void onChange() override; }; /** Implements vertical dragging behavior for ParamWidgets */ @@ -186,16 +186,16 @@ struct Knob : ParamWidget { /** Snap to nearest integer while dragging */ bool snap = false; float dragValue; - void onDragStart(); - void onDragMove(Vec mouseRel); - void onDragEnd(); + void onDragStart() override; + void onDragMove(Vec mouseRel) override; + void onDragEnd() override; /** Tell engine to smoothly vary this parameter */ - void onChange(); + void onChange() override; }; struct SpriteKnob : virtual Knob, SpriteWidget { int minIndex, maxIndex, spriteCount; - void step(); + void step() override; }; /** A knob which rotates an SVG and caches it in a framebuffer */ @@ -208,8 +208,8 @@ struct SVGKnob : virtual Knob, FramebufferWidget { SVGKnob(); void setSVG(std::shared_ptr svg); - void step(); - void onChange(); + void step() override; + void onChange() override; }; struct SVGSlider : Knob, FramebufferWidget { @@ -220,8 +220,8 @@ struct SVGSlider : Knob, FramebufferWidget { SVGWidget *handle; SVGSlider(); - void step(); - void onChange(); + void step() override; + void onChange() override; }; struct Switch : ParamWidget { @@ -235,13 +235,13 @@ struct SVGSwitch : virtual Switch, FramebufferWidget { SVGSwitch(); /** Adds an SVG file to represent the next switch position */ void addFrame(std::shared_ptr svg); - void step(); - void onChange(); + void step() override; + void onChange() override; }; /** A switch that cycles through each mechanical position */ struct ToggleSwitch : virtual Switch { - void onDragStart() { + void onDragStart() override { // Cycle through values // e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3. if (value >= maxValue) @@ -254,11 +254,11 @@ struct ToggleSwitch : virtual Switch { /** A switch that is turned on when held */ struct MomentarySwitch : virtual Switch { /** Don't randomize state */ - void randomize() {} - void onDragStart() { + void randomize() override {} + void onDragStart() override { setValue(maxValue); } - void onDragEnd() { + void onDragEnd() override { setValue(minValue); } }; @@ -278,20 +278,20 @@ struct Port : OpaqueWidget { int portId; ~Port(); - void draw(NVGcontext *vg); - void onMouseDownOpaque(int button); - void onDragEnd(); - void onDragStart(); - void onDragDrop(Widget *origin); - void onDragEnter(Widget *origin); - void onDragLeave(Widget *origin); + void draw(NVGcontext *vg) override; + void onMouseDownOpaque(int button) override; + void onDragEnd() override; + void onDragStart() override; + void onDragDrop(Widget *origin) override; + void onDragEnter(Widget *origin) override; + void onDragLeave(Widget *origin) override; }; struct SVGPort : Port, FramebufferWidget { SVGWidget *background; SVGPort(); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; /** If you don't add these to your ModuleWidget, they will fall out of the rack... */ @@ -312,7 +312,7 @@ struct Toolbar : OpaqueWidget { RadioButton *plugLightButton; Toolbar(); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct PluginManagerWidget : Widget { @@ -320,7 +320,7 @@ struct PluginManagerWidget : Widget { Widget *manageWidget; Widget *downloadWidget; PluginManagerWidget(); - void step(); + void step() override; }; struct RackScene : Scene { @@ -328,9 +328,9 @@ struct RackScene : Scene { ZoomWidget *zoomWidget; RackScene(); - void step(); - void draw(NVGcontext *vg); - Widget *onHoverKey(Vec pos, int key); + void step() override; + void draw(NVGcontext *vg) override; + Widget *onHoverKey(Vec pos, int key) override; }; //////////////////// diff --git a/include/components.hpp b/include/components.hpp index 87d7276c..a9b02a22 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -438,7 +438,7 @@ struct CL1362Port : SVGPort { struct ValueLight : Light { float *value = NULL; virtual void setValue(float v) {} - void step() { + void step() override { if (value) setValue(*value); } @@ -446,7 +446,7 @@ struct ValueLight : Light { struct ColorValueLight : ValueLight { NVGcolor baseColor; - void setValue(float v) { + void setValue(float v) override { v = sqrtBipolar(v); color = baseColor; color.a *= clampf(v, 0.0, 1.0); @@ -474,7 +474,7 @@ struct GreenValueLight : ColorValueLight { struct PolarityLight : ValueLight { NVGcolor posColor; NVGcolor negColor; - void setValue(float v) { + void setValue(float v) override { v = sqrtBipolar(v); color = (v >= 0.0) ? posColor : negColor; color.a *= clampf(fabsf(v), 0.0, 1.0); @@ -490,7 +490,7 @@ struct GreenRedPolarityLight : PolarityLight { struct ModeValueLight : ValueLight { std::vector colors; - void setValue(float v) { + void setValue(float v) override { int mode = clampi((int)roundf(v), 0, colors.size()); color = colors[mode]; } diff --git a/include/rack.hpp b/include/rack.hpp index e6f398dc..abf27412 100644 --- a/include/rack.hpp +++ b/include/rack.hpp @@ -20,7 +20,7 @@ namespace rack { template Model *createModel(Plugin *plugin, std::string slug, std::string name) { struct TModel : Model { - ModuleWidget *createModuleWidget() { + ModuleWidget *createModuleWidget() override { ModuleWidget *moduleWidget = new TModuleWidget(); moduleWidget->model = this; return moduleWidget; diff --git a/include/widgets.hpp b/include/widgets.hpp index 7fafc368..16795064 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -141,7 +141,7 @@ struct TransformWidget : Widget { void translate(Vec delta); void rotate(float angle); void scale(Vec s); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; @@ -151,33 +151,33 @@ struct TransformWidget : Widget { /** Widget that does not respond to events */ struct TransparentWidget : virtual Widget { - Widget *onMouseDown(Vec pos, int button) {return NULL;} - Widget *onMouseUp(Vec pos, int button) {return NULL;} - Widget *onMouseMove(Vec pos, Vec mouseRel) {return NULL;} - Widget *onScroll(Vec pos, Vec scrollRel) {return NULL;} + Widget *onMouseDown(Vec pos, int button) override {return NULL;} + Widget *onMouseUp(Vec pos, int button) override {return NULL;} + Widget *onMouseMove(Vec pos, Vec mouseRel) override {return NULL;} + Widget *onScroll(Vec pos, Vec scrollRel) override {return NULL;} }; /** Widget that automatically responds to all mouse events but gives a chance for children to respond instead */ struct OpaqueWidget : virtual Widget { - Widget *onMouseDown(Vec pos, int button) { + Widget *onMouseDown(Vec pos, int button) override { Widget *w = Widget::onMouseDown(pos, button); if (w) return w; onMouseDownOpaque(button); return this; } - Widget *onMouseUp(Vec pos, int button) { + Widget *onMouseUp(Vec pos, int button) override { Widget *w = Widget::onMouseUp(pos, button); if (w) return w; onMouseUpOpaque(button); return this; } - Widget *onMouseMove(Vec pos, Vec mouseRel) { + Widget *onMouseMove(Vec pos, Vec mouseRel) override { Widget *w = Widget::onMouseMove(pos, mouseRel); if (w) return w; onMouseMoveOpaque(mouseRel); return this; } - Widget *onScroll(Vec pos, Vec scrollRel) { + Widget *onScroll(Vec pos, Vec scrollRel) override { Widget *w = Widget::onScroll(pos, scrollRel); if (w) return w; if (onScrollOpaque(scrollRel)) @@ -199,22 +199,22 @@ struct SpriteWidget : virtual Widget { Vec spriteSize; std::shared_ptr spriteImage; int index = 0; - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct SVGWidget : virtual Widget { std::shared_ptr svg; /** Sets the box size to the svg image size */ void wrap(); - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; /** Caches a widget's draw() result to a framebuffer so it is called less frequently -When `dirty` is true, its children will be re-rendered on the next call to step(). +When `dirty` is true, its children will be re-rendered on the next call to step() override. Events are not passed to the underlying scene. */ struct FramebufferWidget : virtual Widget { - /** Set this to true to re-render the children to the framebuffer in the next step() */ + /** Set this to true to re-render the children to the framebuffer in the next step() override */ bool dirty = true; /** A margin in pixels around the children in the framebuffer This prevents cutting the rendered SVG off on the box edges. @@ -228,8 +228,8 @@ struct FramebufferWidget : virtual Widget { FramebufferWidget(); ~FramebufferWidget(); - void step(); - void draw(NVGcontext *vg); + void step() override; + void draw(NVGcontext *vg) override; int getImageHandle(); }; @@ -263,14 +263,14 @@ struct Label : Widget { Label() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; // Deletes itself from parent when clicked struct MenuOverlay : OpaqueWidget { - void onDragDrop(Widget *origin); - bool onScrollOpaque(Vec scrollRel) {return true;} - Widget *onHoverKey(Vec pos, int key); + void onDragDrop(Widget *origin) override; + bool onScrollOpaque(Vec scrollRel) override {return true;} + Widget *onHoverKey(Vec pos, int key) override; }; struct MenuEntry; @@ -289,9 +289,9 @@ struct Menu : OpaqueWidget { void pushChild(Widget *child); void setChildMenu(Menu *menu); void fit(); - void step(); - void draw(NVGcontext *vg); - bool onScrollOpaque(Vec scrollRel); + void step() override; + void draw(NVGcontext *vg) override; + bool onScrollOpaque(Vec scrollRel) override; }; struct MenuEntry : OpaqueWidget { @@ -304,16 +304,16 @@ struct MenuEntry : OpaqueWidget { }; struct MenuLabel : MenuEntry { - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct MenuItem : MenuEntry { - float computeMinWidth(NVGcontext *vg); - void draw(NVGcontext *vg); + float computeMinWidth(NVGcontext *vg) override; + void draw(NVGcontext *vg) override; virtual Menu *createChildMenu() {return NULL;} - void onMouseEnter(); - void onDragDrop(Widget *origin); + void onMouseEnter() override; + void onDragDrop(Widget *origin) override; }; struct Button : OpaqueWidget { @@ -323,16 +323,16 @@ struct Button : OpaqueWidget { Button() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); - void onMouseEnter(); - void onMouseLeave(); - void onDragStart(); - void onDragEnd(); - void onDragDrop(Widget *origin); + void draw(NVGcontext *vg) override; + void onMouseEnter() override; + void onMouseLeave() override; + void onDragStart() override; + void onDragEnd() override; + void onDragDrop(Widget *origin) override; }; struct ChoiceButton : Button { - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct RadioButton : OpaqueWidget, QuantityWidget { @@ -341,10 +341,10 @@ struct RadioButton : OpaqueWidget, QuantityWidget { RadioButton() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); - void onMouseEnter(); - void onMouseLeave(); - void onDragDrop(Widget *origin); + void draw(NVGcontext *vg) override; + void onMouseEnter() override; + void onMouseLeave() override; + void onDragDrop(Widget *origin) override; }; struct Slider : OpaqueWidget, QuantityWidget { @@ -353,10 +353,10 @@ struct Slider : OpaqueWidget, QuantityWidget { Slider() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); - void onDragStart(); - void onDragMove(Vec mouseRel); - void onDragEnd(); + void draw(NVGcontext *vg) override; + void onDragStart() override; + void onDragMove(Vec mouseRel) override; + void onDragEnd() override; }; /** Parent must be a ScrollWidget */ @@ -367,10 +367,10 @@ struct ScrollBar : OpaqueWidget { ScrollBar() { box.size = Vec(BND_SCROLLBAR_WIDTH, BND_SCROLLBAR_HEIGHT); } - void draw(NVGcontext *vg); - void onDragStart(); - void onDragMove(Vec mouseRel); - void onDragEnd(); + void draw(NVGcontext *vg) override; + void onDragStart() override; + void onDragMove(Vec mouseRel) override; + void onDragEnd() override; }; /** Handles a container with ScrollBar */ @@ -381,19 +381,19 @@ struct ScrollWidget : OpaqueWidget { Vec offset; ScrollWidget(); - void step(); - Widget *onMouseMove(Vec pos, Vec mouseRel); - bool onScrollOpaque(Vec scrollRel); + void step() override; + Widget *onMouseMove(Vec pos, Vec mouseRel) override; + bool onScrollOpaque(Vec scrollRel) override; }; struct ZoomWidget : Widget { float zoom = 1.0; - void draw(NVGcontext *vg); - Widget *onMouseDown(Vec pos, int button); - Widget *onMouseUp(Vec pos, int button); - Widget *onMouseMove(Vec pos, Vec mouseRel); - Widget *onHoverKey(Vec pos, int key); - Widget *onScroll(Vec pos, Vec scrollRel); + void draw(NVGcontext *vg) override; + Widget *onMouseDown(Vec pos, int button) override; + Widget *onMouseUp(Vec pos, int button) override; + Widget *onMouseMove(Vec pos, Vec mouseRel) override; + Widget *onHoverKey(Vec pos, int key) override; + Widget *onScroll(Vec pos, Vec scrollRel) override; }; struct TextField : OpaqueWidget { @@ -405,36 +405,36 @@ struct TextField : OpaqueWidget { TextField() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); - Widget *onMouseDown(Vec pos, int button); - bool onFocusText(int codepoint); - bool onFocusKey(int scancode); - bool onFocus(); + void draw(NVGcontext *vg) override; + Widget *onMouseDown(Vec pos, int button) override; + bool onFocusText(int codepoint) override; + bool onFocusKey(int key) override; + bool onFocus() override; void insertText(std::string newText); virtual void onTextChange() {} }; struct PasswordField : TextField { - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct ProgressBar : TransparentWidget, QuantityWidget { ProgressBar() { box.size.y = BND_WIDGET_HEIGHT; } - void draw(NVGcontext *vg); + void draw(NVGcontext *vg) override; }; struct Tooltip : Widget { - void step(); - void draw(NVGcontext *vg); + void step() override; + void draw(NVGcontext *vg) override; }; struct Scene : OpaqueWidget { Widget *overlay = NULL; void setOverlay(Widget *w); Menu *createMenu(); - void step(); + void step() override; }; diff --git a/src/app/ModuleWidget.cpp b/src/app/ModuleWidget.cpp index 3852eed6..f9a19314 100644 --- a/src/app/ModuleWidget.cpp +++ b/src/app/ModuleWidget.cpp @@ -206,35 +206,35 @@ void ModuleWidget::onDragEnd() { struct DisconnectMenuItem : MenuItem { ModuleWidget *moduleWidget; - void onAction() { + void onAction() override { moduleWidget->disconnect(); } }; struct InitializeMenuItem : MenuItem { ModuleWidget *moduleWidget; - void onAction() { + void onAction() override { moduleWidget->initialize(); } }; struct RandomizeMenuItem : MenuItem { ModuleWidget *moduleWidget; - void onAction() { + void onAction() override { moduleWidget->randomize(); } }; struct CloneMenuItem : MenuItem { ModuleWidget *moduleWidget; - void onAction() { + void onAction() override { gRackWidget->cloneModule(moduleWidget); } }; struct DeleteMenuItem : MenuItem { ModuleWidget *moduleWidget; - void onAction() { + void onAction() override { gRackWidget->deleteModule(moduleWidget); moduleWidget->finalizeEvents(); delete moduleWidget; diff --git a/src/app/PluginManagerWidget.cpp b/src/app/PluginManagerWidget.cpp index ba8e74fc..8e4b6023 100644 --- a/src/app/PluginManagerWidget.cpp +++ b/src/app/PluginManagerWidget.cpp @@ -15,7 +15,7 @@ PluginManagerWidget::PluginManagerWidget() { Vec pos = Vec(0, 0); struct RegisterButton : Button { - void onAction() { + void onAction() override { std::thread t(openBrowser, "https://vcvrack.com/"); t.detach(); } @@ -46,7 +46,7 @@ PluginManagerWidget::PluginManagerWidget() { struct LogInButton : Button { TextField *emailField; TextField *passwordField; - void onAction() { + void onAction() override { std::thread t(pluginLogIn, emailField->text, passwordField->text); t.detach(); passwordField->text = ""; @@ -63,7 +63,7 @@ PluginManagerWidget::PluginManagerWidget() { pos.x += logInButton->box.size.x; struct StatusLabel : Label { - void step() { + void step() override { text = pluginGetLoginStatus(); } }; @@ -79,7 +79,7 @@ PluginManagerWidget::PluginManagerWidget() { Vec pos = Vec(0, 0); struct ManageButton : Button { - void onAction() { + void onAction() override { std::thread t(openBrowser, "https://vcvrack.com/"); t.detach(); } @@ -92,7 +92,7 @@ PluginManagerWidget::PluginManagerWidget() { pos.x += manageButton->box.size.x; struct RefreshButton : Button { - void onAction() { + void onAction() override { std::thread t(pluginRefresh); t.detach(); } @@ -106,7 +106,7 @@ PluginManagerWidget::PluginManagerWidget() { pos.x += refreshButton->box.size.x; struct LogOutButton : Button { - void onAction() { + void onAction() override { pluginLogOut(); } }; @@ -125,7 +125,7 @@ PluginManagerWidget::PluginManagerWidget() { Vec pos = Vec(0, 0); struct DownloadProgressBar : ProgressBar { - void step() { + void step() override { label = "Downloading"; std::string name = pluginGetDownloadName(); if (name != "") @@ -142,7 +142,7 @@ PluginManagerWidget::PluginManagerWidget() { pos.x += downloadProgress->box.size.x; // struct CancelButton : Button { - // void onAction() { + // void onAction() override { // pluginCancelDownload(); // } // }; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 3326fa41..e00e3c08 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -369,7 +369,7 @@ void RackWidget::draw(NVGcontext *vg) { struct AddModuleMenuItem : MenuItem { Model *model; Vec modulePos; - void onAction() { + void onAction() override { ModuleWidget *moduleWidget = model->createModuleWidget(); gRackWidget->moduleContainer->addChild(moduleWidget); // Move module nearest to the mouse position @@ -382,7 +382,7 @@ struct AddModuleMenuItem : MenuItem { struct UrlItem : MenuItem { std::string url; - void onAction() { + void onAction() override { std::thread t(openBrowser, url); t.detach(); } @@ -391,7 +391,7 @@ struct UrlItem : MenuItem { struct AddPluginMenuItem : MenuItem { Plugin *plugin; Vec modulePos; - Menu *createChildMenu() { + Menu *createChildMenu() override { // Model items Menu *menu = new Menu(); for (Model *model : plugin->models) { diff --git a/src/app/SVGPanel.cpp b/src/app/SVGPanel.cpp index a0419c4a..815a89fb 100644 --- a/src/app/SVGPanel.cpp +++ b/src/app/SVGPanel.cpp @@ -5,7 +5,7 @@ namespace rack { struct PanelBorder : TransparentWidget { - void draw(NVGcontext *vg) { + void draw(NVGcontext *vg) override { NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5); nvgBeginPath(vg); nvgRect(vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0); diff --git a/src/app/Toolbar.cpp b/src/app/Toolbar.cpp index d14b37d9..d6681788 100644 --- a/src/app/Toolbar.cpp +++ b/src/app/Toolbar.cpp @@ -7,37 +7,37 @@ namespace rack { struct NewItem : MenuItem { - void onAction() { + void onAction() override { gRackWidget->initialize(); } }; struct OpenItem : MenuItem { - void onAction() { + void onAction() override { gRackWidget->openDialog(); } }; struct SaveItem : MenuItem { - void onAction() { + void onAction() override { gRackWidget->saveDialog(); } }; struct SaveAsItem : MenuItem { - void onAction() { + void onAction() override { gRackWidget->saveAsDialog(); } }; struct QuitItem : MenuItem { - void onAction() { + void onAction() override { guiClose(); } }; struct FileChoice : ChoiceButton { - void onAction() { + void onAction() override { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y)); menu->box.size.x = box.size.x; @@ -54,21 +54,21 @@ struct FileChoice : ChoiceButton { struct PauseItem : MenuItem { - void onAction() { + void onAction() override { gPaused = !gPaused; } }; struct SampleRateItem : MenuItem { float sampleRate; - void onAction() { + void onAction() override { engineSetSampleRate(sampleRate); gPaused = false; } }; struct SampleRateChoice : ChoiceButton { - void onAction() { + void onAction() override { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y)); menu->box.size.x = box.size.x; @@ -86,7 +86,7 @@ struct SampleRateChoice : ChoiceButton { menu->pushChild(item); } } - void step() { + void step() override { if (gPaused) text = "Paused"; else diff --git a/src/core/AudioInterface.cpp b/src/core/AudioInterface.cpp index c9e4f6ce..fde48012 100644 --- a/src/core/AudioInterface.cpp +++ b/src/core/AudioInterface.cpp @@ -65,7 +65,7 @@ struct AudioInterface : Module { closeDevice(); } - void step(); + void step() override; void stepStream(const float *input, float *output, int numFrames); int getDeviceCount(); @@ -84,7 +84,7 @@ struct AudioInterface : Module { openDevice(deviceId, sampleRate, blockSize); } - json_t *toJson() { + json_t *toJson() override { json_t *rootJ = json_object(); if (deviceId >= 0) { std::string deviceName = getDeviceName(deviceId); @@ -95,7 +95,7 @@ struct AudioInterface : Module { return rootJ; } - void fromJson(json_t *rootJ) { + void fromJson(json_t *rootJ) override { json_t *deviceNameJ = json_object_get(rootJ, "deviceName"); if (deviceNameJ) { std::string deviceName = json_string_value(deviceNameJ); @@ -118,7 +118,7 @@ struct AudioInterface : Module { } } - void initialize() { + void initialize() override { closeDevice(); } }; @@ -326,14 +326,14 @@ void AudioInterface::closeDevice() { struct AudioItem : MenuItem { AudioInterface *audioInterface; int deviceId; - void onAction() { + void onAction() override { audioInterface->setDeviceId(deviceId); } }; struct AudioChoice : ChoiceButton { AudioInterface *audioInterface; - void onAction() { + void onAction() override { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y)); menu->box.size.x = box.size.x; @@ -354,7 +354,7 @@ struct AudioChoice : ChoiceButton { menu->pushChild(audioItem); } } - void step() { + void step() override { std::string name = audioInterface->getDeviceName(audioInterface->deviceId); text = ellipsize(name, 24); } @@ -364,14 +364,14 @@ struct AudioChoice : ChoiceButton { struct SampleRateItem : MenuItem { AudioInterface *audioInterface; float sampleRate; - void onAction() { + void onAction() override { audioInterface->setSampleRate(sampleRate); } }; struct SampleRateChoice : ChoiceButton { AudioInterface *audioInterface; - void onAction() { + void onAction() override { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y)); menu->box.size.x = box.size.x; @@ -386,7 +386,7 @@ struct SampleRateChoice : ChoiceButton { menu->pushChild(item); } } - void step() { + void step() override { this->text = stringf("%.0f Hz", audioInterface->sampleRate); } }; @@ -395,14 +395,14 @@ struct SampleRateChoice : ChoiceButton { struct BlockSizeItem : MenuItem { AudioInterface *audioInterface; int blockSize; - void onAction() { + void onAction() override { audioInterface->setBlockSize(blockSize); } }; struct BlockSizeChoice : ChoiceButton { AudioInterface *audioInterface; - void onAction() { + void onAction() override { Menu *menu = gScene->createMenu(); menu->box.pos = getAbsolutePos().plus(Vec(0, box.size.y)); menu->box.size.x = box.size.x; @@ -417,7 +417,7 @@ struct BlockSizeChoice : ChoiceButton { menu->pushChild(item); } } - void step() { + void step() override { this->text = stringf("%d", audioInterface->blockSize); } }; diff --git a/src/core/Blank.cpp b/src/core/Blank.cpp index 80a5fb7b..ca1db935 100644 --- a/src/core/Blank.cpp +++ b/src/core/Blank.cpp @@ -10,17 +10,17 @@ struct ModuleResizeHandle : Widget { ModuleResizeHandle() { box.size = Vec(RACK_GRID_WIDTH * 1, RACK_GRID_HEIGHT); } - Widget *onMouseDown(Vec pos, int button) { + Widget *onMouseDown(Vec pos, int button) override { if (button == 0) return this; return NULL; } - void onDragStart() { + void onDragStart() override { assert(parent); originalWidth = parent->box.size.x; totalX = 0.0; } - void onDragMove(Vec mouseRel) { + void onDragMove(Vec mouseRel) override { ModuleWidget *m = dynamic_cast(parent); assert(m); totalX += mouseRel.x; @@ -38,7 +38,7 @@ struct ModuleResizeHandle : Widget { } gRackWidget->requestModuleBox(m, newBox); } - void draw(NVGcontext *vg) { + void draw(NVGcontext *vg) override { for (float x = 5.0; x <= 10.0; x += 5.0) { nvgBeginPath(vg); const float margin = 5.0; diff --git a/src/core/Bridge.cpp b/src/core/Bridge.cpp index b5f6edb9..bb7ade53 100644 --- a/src/core/Bridge.cpp +++ b/src/core/Bridge.cpp @@ -18,7 +18,7 @@ struct Bridge : Module { } ~Bridge() { } - void step(); + void step() override; }; diff --git a/src/core/core.hpp b/src/core/core.hpp index f16502c8..41cefe8f 100644 --- a/src/core/core.hpp +++ b/src/core/core.hpp @@ -14,12 +14,12 @@ struct AudioInterfaceWidget : ModuleWidget { struct MidiToCVWidget : ModuleWidget { MidiToCVWidget(); - void step(); + void step() override; }; struct MIDICCToCVWidget : ModuleWidget { MIDICCToCVWidget(); - void step(); + void step() override; }; struct BridgeWidget : ModuleWidget { @@ -32,7 +32,7 @@ struct BlankWidget : ModuleWidget { Widget *bottomRightScrew; Widget *rightHandle; BlankWidget(); - void step(); - json_t *toJson(); - void fromJson(json_t *rootJ); + void step() override; + json_t *toJson() override; + void fromJson(json_t *rootJ) override; };