From 4b96600f110fc3019e04f3480ae07ce698b3af31 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 3 Nov 2021 01:39:51 -0400 Subject: [PATCH] Rename LED* component classes to VCV*. --- include/componentlibrary.hpp | 125 ++++++++++-------- .../{LEDBezel.svg => VCVBezel.svg} | 0 .../{LEDButton.svg => VCVButton_0.svg} | 0 .../{LEDButton_1.svg => VCVButton_1.svg} | 0 .../{LEDSlider.svg => VCVSlider.svg} | 0 ...EDSliderHandle.svg => VCVSliderHandle.svg} | 0 ...{LEDSliderLight.svg => VCVSliderLight.svg} | 0 7 files changed, 73 insertions(+), 52 deletions(-) rename res/ComponentLibrary/{LEDBezel.svg => VCVBezel.svg} (100%) rename res/ComponentLibrary/{LEDButton.svg => VCVButton_0.svg} (100%) rename res/ComponentLibrary/{LEDButton_1.svg => VCVButton_1.svg} (100%) rename res/ComponentLibrary/{LEDSlider.svg => VCVSlider.svg} (100%) rename res/ComponentLibrary/{LEDSliderHandle.svg => VCVSliderHandle.svg} (100%) rename res/ComponentLibrary/{LEDSliderLight.svg => VCVSliderLight.svg} (100%) diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 04c4eb0d..de0637bb 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -57,7 +57,7 @@ E.g. `RectangleLight` Although this paradigm might seem confusing at first, it ends up being extremely simple in your plugin code and perfect for "decorating" your classes with appearance traits and behavioral properties. For example, need a slider with a green LED? Just use - createLightParamCentered>(...) + createLightParamCentered>(...) */ template @@ -79,7 +79,7 @@ struct TSvgLight : TBase { this->box.size = sw->box.size; } }; -typedef TSvgLight<> SvgLight; +using SvgLight = TSvgLight<>; template struct TGrayModuleLightWidget : TBase { @@ -88,7 +88,7 @@ struct TGrayModuleLightWidget : TBase { this->borderColor = nvgRGBA(0, 0, 0, 53); } }; -typedef TGrayModuleLightWidget<> GrayModuleLightWidget; +using GrayModuleLightWidget = TGrayModuleLightWidget<>; template struct TWhiteLight : TBase { @@ -96,7 +96,7 @@ struct TWhiteLight : TBase { this->addBaseColor(SCHEME_WHITE); } }; -typedef TWhiteLight<> WhiteLight; +using WhiteLight = TWhiteLight<>; template struct TRedLight : TBase { @@ -104,7 +104,7 @@ struct TRedLight : TBase { this->addBaseColor(SCHEME_RED); } }; -typedef TRedLight<> RedLight; +using RedLight = TRedLight<>; template struct TGreenLight : TBase { @@ -112,7 +112,7 @@ struct TGreenLight : TBase { this->addBaseColor(SCHEME_GREEN); } }; -typedef TGreenLight<> GreenLight; +using GreenLight = TGreenLight<>; template struct TBlueLight : TBase { @@ -120,7 +120,7 @@ struct TBlueLight : TBase { this->addBaseColor(SCHEME_BLUE); } }; -typedef TBlueLight<> BlueLight; +using BlueLight = TBlueLight<>; template struct TYellowLight : TBase { @@ -128,7 +128,7 @@ struct TYellowLight : TBase { this->addBaseColor(SCHEME_YELLOW); } }; -typedef TYellowLight<> YellowLight; +using YellowLight = TYellowLight<>; /** Reads two adjacent lightIds, so `lightId` and `lightId + 1` must be defined */ template @@ -138,7 +138,7 @@ struct TGreenRedLight : TBase { this->addBaseColor(SCHEME_RED); } }; -typedef TGreenRedLight<> GreenRedLight; +using GreenRedLight = TGreenRedLight<>; template struct TRedGreenBlueLight : TBase { @@ -148,7 +148,7 @@ struct TRedGreenBlueLight : TBase { this->addBaseColor(SCHEME_BLUE); } }; -typedef TRedGreenBlueLight<> RedGreenBlueLight; +using RedGreenBlueLight = TRedGreenBlueLight<>; /** Based on the size of 5mm LEDs */ template @@ -250,15 +250,17 @@ struct RectangleLight : TBase { } }; -/** A light for displaying on top of PB61303. Must add a color by subclassing or templating. */ +/** A light for displaying on top of VCVBezel. Must add a color by subclassing or templating. */ template -struct LEDBezelLight : TBase { - LEDBezelLight() { +struct VCVBezelLight : TBase { + VCVBezelLight() { this->borderColor = color::BLACK_TRANSPARENT; this->bgColor = color::BLACK_TRANSPARENT; this->box.size = math::Vec(17.545, 17.545); } }; +template +using LEDBezelLight = VCVBezelLight; /** A light to displayed over PB61303. Must add a color by subclassing or templating. */ @@ -669,27 +671,33 @@ struct BefacoSlidePot : app::SvgSlider { } }; -struct LEDSlider : app::SvgSlider { - LEDSlider() { - setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSlider.svg"))); - setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHandle.svg"))); +struct VCVSlider : app::SvgSlider { + VCVSlider() { + setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSlider.svg"))); + setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderHandle.svg"))); setHandlePosCentered( math::Vec(19.84260/2, 76.53517 - 11.74218/2), math::Vec(19.84260/2, 0.0 + 11.74218/2) ); } }; +using LEDSlider = VCVSlider; -// TODO Modernize -struct LEDSliderHorizontal : app::SvgSlider { - LEDSliderHorizontal() { +struct VCVSliderHorizontal : app::SvgSlider { + VCVSliderHorizontal() { horizontal = true; + // TODO Fix positions maxHandlePos = mm2px(math::Vec(22.078, 0.738).plus(math::Vec(0, 2))); minHandlePos = mm2px(math::Vec(0.738, 0.738).plus(math::Vec(0, 2))); - setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHorizontal.svg"))); + // TODO Fix SVG + setBackgroundSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderHorizontal.svg"))); } }; +using LEDSliderHorizontal = VCVSliderHorizontal; +/** An SvgSlider with an attached light. +Construct with createLightParamCentered() helper function. +*/ template struct LightSlider : TBase { app::ModuleLightWidget* light; @@ -713,32 +721,39 @@ struct LightSlider : TBase { }; template -struct LEDSliderLight : RectangleLight> { - LEDSliderLight() { - this->setSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderLight.svg"))); +struct VCVSliderLight : RectangleLight> { + VCVSliderLight() { + this->setSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderLight.svg"))); } }; +template +using LEDSliderLight = VCVSliderLight; template -struct LEDLightSlider : LightSlider> { - LEDLightSlider() {} +struct VCVLightSlider : LightSlider> { + VCVLightSlider() {} }; +template +using LEDLightSlider = VCVLightSlider; -/** Deprecated. Use LEDSliderLight with your preferred LightWidget. */ -struct LEDSliderGreen : LEDLightSlider {}; -struct LEDSliderRed : LEDLightSlider {}; -struct LEDSliderYellow : LEDLightSlider {}; -struct LEDSliderBlue : LEDLightSlider {}; -struct LEDSliderWhite : LEDLightSlider {}; +/** Deprecated. Use VCVSliderLight with your preferred LightWidget. */ +struct LEDSliderGreen : VCVLightSlider {}; +struct LEDSliderRed : VCVLightSlider {}; +struct LEDSliderYellow : VCVLightSlider {}; +struct LEDSliderBlue : VCVLightSlider {}; +struct LEDSliderWhite : VCVLightSlider {}; -// TODO Modernize template -struct LEDLightSliderHorizontal : LightSlider { - LEDLightSliderHorizontal() { - this->setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/LEDSliderHorizontalHandle.svg"))); +struct VCVLightSliderHorizontal : LightSlider { + VCVLightSliderHorizontal() { + // TODO Fix positions this->light->box.size = mm2px(math::Vec(3.276, 1.524)); + // TODO Fix SVG + this->setHandleSvg(Svg::load(asset::system("res/ComponentLibrary/VCVSliderHorizontalHandle.svg"))); } }; +template +using LEDLightSliderHorizontal = VCVLightSliderHorizontal; //////////////////// @@ -825,26 +840,27 @@ struct TL1105 : app::SvgSwitch { } }; -struct LEDButton : app::SvgSwitch { - LEDButton() { +struct VCVButton : app::SvgSwitch { + VCVButton() { momentary = true; - addFrame(Svg::load(asset::system("res/ComponentLibrary/LEDButton.svg"))); - addFrame(Svg::load(asset::system("res/ComponentLibrary/LEDButton_1.svg"))); + addFrame(Svg::load(asset::system("res/ComponentLibrary/VCVButton_0.svg"))); + addFrame(Svg::load(asset::system("res/ComponentLibrary/VCVButton_1.svg"))); } }; +using LEDButton = VCVButton; -struct LEDLatch : LEDButton { - LEDLatch() { +struct VCVLatch : VCVButton { + VCVLatch() { momentary = false; latch = true; } }; template -struct LEDLightButton : LEDButton { +struct VCVLightButton : VCVButton { app::ModuleLightWidget* light; - LEDLightButton() { + VCVLightButton() { light = new TLight; // Move center of light to center of box light->box.pos = box.size.div(2).minus(light->box.size.div(2)); @@ -855,10 +871,12 @@ struct LEDLightButton : LEDButton { return light; } }; +template +using LEDLightButton = VCVLightButton; template -struct LEDLightLatch : LEDLightButton { - LEDLightLatch() { +struct VCVLightLatch : VCVLightButton { + VCVLightLatch() { this->momentary = false; this->latch = true; } @@ -880,19 +898,20 @@ struct BefacoPush : app::SvgSwitch { } }; -struct LEDBezel : app::SvgSwitch { - LEDBezel() { +struct VCVBezel : app::SvgSwitch { + VCVBezel() { momentary = true; - addFrame(Svg::load(asset::system("res/ComponentLibrary/LEDBezel.svg"))); + addFrame(Svg::load(asset::system("res/ComponentLibrary/VCVBezel.svg"))); } }; +using LEDBezel = VCVBezel; template -struct LEDLightBezel : LEDBezel { +struct VCVLightBezel : VCVBezel { app::ModuleLightWidget* light; - LEDLightBezel() { - light = new LEDBezelLight; + VCVLightBezel() { + light = new VCVBezelLight; // Move center of light to center of box light->box.pos = box.size.div(2).minus(light->box.size.div(2)); addChild(light); @@ -902,6 +921,8 @@ struct LEDLightBezel : LEDBezel { return light; } }; +template +using LEDLightBezel = VCVLightBezel; struct PB61303 : app::SvgSwitch { PB61303() { diff --git a/res/ComponentLibrary/LEDBezel.svg b/res/ComponentLibrary/VCVBezel.svg similarity index 100% rename from res/ComponentLibrary/LEDBezel.svg rename to res/ComponentLibrary/VCVBezel.svg diff --git a/res/ComponentLibrary/LEDButton.svg b/res/ComponentLibrary/VCVButton_0.svg similarity index 100% rename from res/ComponentLibrary/LEDButton.svg rename to res/ComponentLibrary/VCVButton_0.svg diff --git a/res/ComponentLibrary/LEDButton_1.svg b/res/ComponentLibrary/VCVButton_1.svg similarity index 100% rename from res/ComponentLibrary/LEDButton_1.svg rename to res/ComponentLibrary/VCVButton_1.svg diff --git a/res/ComponentLibrary/LEDSlider.svg b/res/ComponentLibrary/VCVSlider.svg similarity index 100% rename from res/ComponentLibrary/LEDSlider.svg rename to res/ComponentLibrary/VCVSlider.svg diff --git a/res/ComponentLibrary/LEDSliderHandle.svg b/res/ComponentLibrary/VCVSliderHandle.svg similarity index 100% rename from res/ComponentLibrary/LEDSliderHandle.svg rename to res/ComponentLibrary/VCVSliderHandle.svg diff --git a/res/ComponentLibrary/LEDSliderLight.svg b/res/ComponentLibrary/VCVSliderLight.svg similarity index 100% rename from res/ComponentLibrary/LEDSliderLight.svg rename to res/ComponentLibrary/VCVSliderLight.svg