diff --git a/include/app.hpp b/include/app.hpp index 6ebc23cd..99fd78ee 100644 --- a/include/app.hpp +++ b/include/app.hpp @@ -145,7 +145,6 @@ struct SVGKnob : Knob, FramebufferWidget { /** Not owned */ TransformWidget *tw; SVGWidget *sw; - CircularShadow *shadow; SVGKnob(); void setSVG(std::shared_ptr svg); diff --git a/include/components.hpp b/include/components.hpp index 9ab83697..d1cfc543 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -5,21 +5,6 @@ namespace rack { -enum ColorNames { - COLOR_BLACK, - COLOR_WHITE, - COLOR_RED, - COLOR_ORANGE, - COLOR_YELLOW, - COLOR_GREEN, - COLOR_CYAN, - COLOR_BLUE, - COLOR_PURPLE, - NUM_COLORS -}; - -extern const NVGcolor colors[NUM_COLORS]; - //////////////////// // Knobs //////////////////// @@ -286,6 +271,24 @@ struct Davies1900hRedKnob : Davies1900hKnob { } }; +struct Davies1900hLargeWhiteKnob : Davies1900hKnob { + Davies1900hLargeWhiteKnob() { + setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeWhite.svg")); + } +}; + +struct Davies1900hLargeBlackKnob : Davies1900hKnob { + Davies1900hLargeBlackKnob() { + setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeBlack.svg")); + } +}; + +struct Davies1900hLargeRedKnob : Davies1900hKnob { + Davies1900hLargeRedKnob() { + setSVG(SVG::load("res/ComponentLibrary/Davies1900hLargeRed.svg")); + } +}; + struct Trimpot : SVGKnob { Trimpot() { box.size = Vec(17, 17); @@ -366,30 +369,49 @@ struct ValueLight : Light { float *value; }; -template struct ColorValueLight : ValueLight { + NVGcolor baseColor; void step() { float v = sqrtBipolar(getf(value)); - color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR], v); + color = baseColor; + color.a = clampf(v, 0.0, 1.0); + } +}; + +struct RedValueLight : ColorValueLight { + RedValueLight() { + baseColor = nvgRGB(0xed, 0x2c, 0x24); } }; -typedef ColorValueLight RedValueLight; -typedef ColorValueLight YellowValueLight; -typedef ColorValueLight GreenValueLight; +struct YellowValueLight : ColorValueLight { + YellowValueLight() { + baseColor = nvgRGB(0xf9, 0xdf, 0x1c); + } +}; + +struct GreenValueLight : ColorValueLight { + GreenValueLight() { + baseColor = nvgRGB(0x90, 0xc7, 0x3e); + } +}; -template struct PolarityLight : ValueLight { + NVGcolor posColor; + NVGcolor negColor; void step() { float v = sqrtBipolar(getf(value)); - if (v >= 0.0) - color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_POS], v); - else - color = nvgLerpRGBA(colors[COLOR_BLACK], colors[COLOR_NEG], -v); + color = (v >= 0.0) ? posColor : negColor; + color.a = clampf(fabsf(v), 0.0, 1.0); } }; -typedef PolarityLight GreenRedPolarityLight; +struct GreenRedPolarityLight : PolarityLight { + GreenRedPolarityLight() { + posColor = nvgRGB(0x90, 0xc7, 0x3e); + negColor = nvgRGB(0xed, 0x2c, 0x24); + } +}; template struct LargeLight : BASE { @@ -418,9 +440,9 @@ struct SmallLight : BASE { struct NKK : SVGSwitch, ToggleSwitch { NKK() { - addFrame(SVG::load("res/ComponentLibrary/NKK0.svg")); - addFrame(SVG::load("res/ComponentLibrary/NKK1.svg")); - addFrame(SVG::load("res/ComponentLibrary/NKK2.svg")); + addFrame(SVG::load("res/ComponentLibrary/NKK_0.svg")); + addFrame(SVG::load("res/ComponentLibrary/NKK_1.svg")); + addFrame(SVG::load("res/ComponentLibrary/NKK_2.svg")); sw->wrap(); box.size = sw->box.size; } @@ -428,8 +450,8 @@ struct NKK : SVGSwitch, ToggleSwitch { struct CKSS : SVGSwitch, ToggleSwitch { CKSS() { - addFrame(SVG::load("res/ComponentLibrary/CKSS0.svg")); - addFrame(SVG::load("res/ComponentLibrary/CKSS1.svg")); + addFrame(SVG::load("res/ComponentLibrary/CKSS_0.svg")); + addFrame(SVG::load("res/ComponentLibrary/CKSS_1.svg")); sw->wrap(); box.size = sw->box.size; } diff --git a/src/app/Light.cpp b/src/app/Light.cpp index 68479ce7..79db79a4 100644 --- a/src/app/Light.cpp +++ b/src/app/Light.cpp @@ -5,32 +5,36 @@ namespace rack { void Light::draw(NVGcontext *vg) { - NVGcolor colorOutline = nvgLerpRGBA(color, nvgRGBf(0.0, 0.0, 0.0), 0.5); + NVGcolor bgColor = nvgRGBf(0.0, 0.0, 0.0); float radius = box.size.x / 2.0; + float oradius = radius + 30.0; // Solid nvgBeginPath(vg); nvgCircle(vg, radius, radius, radius); - nvgFillColor(vg, color); + nvgFillColor(vg, bgColor); nvgFill(vg); // Border nvgStrokeWidth(vg, 1.0); - nvgStrokeColor(vg, colorOutline); + nvgStrokeColor(vg, nvgTransRGBAf(bgColor, 0.5)); nvgStroke(vg); - // Glow + // Inner glow nvgGlobalCompositeOperation(vg, NVG_LIGHTER); + nvgFillColor(vg, color); + nvgFill(vg); + + // Outer glow + nvgBeginPath(vg); + nvgRect(vg, radius - oradius, radius - oradius, 2*oradius, 2*oradius); NVGpaint paint; NVGcolor icol = color; - icol.a = 0.1; + icol.a *= 0.1; NVGcolor ocol = color; ocol.a = 0.0; - float oradius = radius + 30.0; paint = nvgRadialGradient(vg, radius, radius, radius, oradius, icol, ocol); nvgFillPaint(vg, paint); - nvgBeginPath(vg); - nvgRect(vg, radius - oradius, radius - oradius, 2*oradius, 2*oradius); nvgFill(vg); } diff --git a/src/app/SVGKnob.cpp b/src/app/SVGKnob.cpp index f8366a82..61f31c8f 100644 --- a/src/app/SVGKnob.cpp +++ b/src/app/SVGKnob.cpp @@ -7,12 +7,6 @@ namespace rack { SVGKnob::SVGKnob() { padding = Vec(1, 1); - shadow = new CircularShadow(); - shadow->blur = 5.0; - shadow->box.pos = Vec(0, 1); - // TODO Remove shadow entirely - // addChild(shadow); - tw = new TransformWidget(); addChild(tw); @@ -23,31 +17,27 @@ SVGKnob::SVGKnob() { void SVGKnob::setSVG(std::shared_ptr svg) { sw->svg = svg; sw->wrap(); + tw->box.size = sw->box.size; + box.size = sw->box.size; } void SVGKnob::step() { // Re-transform TransformWidget if dirty if (dirty) { float angle = mapf(value, minValue, maxValue, minAngle, maxAngle); - tw->box.size = box.size; tw->identity(); - // Resize SVG - Vec scale = Vec(box.size.x / sw->box.size.x, box.size.y / sw->box.size.y); - tw->scale(scale); // Rotate SVG Vec center = sw->box.getCenter(); tw->translate(center); tw->rotate(angle); tw->translate(center.neg()); - // Resize shadow - shadow->box.size = box.size; } FramebufferWidget::step(); } void SVGKnob::onChange() { dirty = true; - ParamWidget::onChange(); + Knob::onChange(); } diff --git a/src/app/SVGSwitch.cpp b/src/app/SVGSwitch.cpp index 4d3d10f6..d55bfd93 100644 --- a/src/app/SVGSwitch.cpp +++ b/src/app/SVGSwitch.cpp @@ -28,6 +28,7 @@ void SVGSwitch::onChange() { if (0 <= index && index < (int)frames.size()) sw->svg = frames[index]; dirty = true; + ParamWidget::onChange(); } diff --git a/src/components.cpp b/src/components.cpp deleted file mode 100644 index dad6ae23..00000000 --- a/src/components.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "components.hpp" - - -namespace rack { - -const NVGcolor colors[NUM_COLORS] = { - nvgRGB(0x00, 0x00, 0x00), - nvgRGB(0xff, 0xff, 0xff), - nvgRGB(0xed, 0x2c, 0x24), - nvgRGB(0xf2, 0xb1, 0x20), - nvgRGB(0xf9, 0xdf, 0x1c), - nvgRGB(0x90, 0xc7, 0x3e), - nvgRGB(0x22, 0xe6, 0xef), - nvgRGB(0x29, 0xb2, 0xef), - nvgRGB(0xd5, 0x2b, 0xed), -}; - - -} // namespace rack diff --git a/src/widgets/SVGWidget.cpp b/src/widgets/SVGWidget.cpp index a91a1eea..e71afaa8 100644 --- a/src/widgets/SVGWidget.cpp +++ b/src/widgets/SVGWidget.cpp @@ -112,7 +112,7 @@ static void drawSVG(NVGcontext *vg, NSVGimage *svg) { void SVGWidget::wrap() { - if (svg) { + if (svg && svg->handle) { box.size = Vec(svg->handle->width, svg->handle->height); } else {