@@ -274,11 +274,11 @@ struct SpriteKnob : Knob, SpriteWidget { | |||||
/** A knob which rotates an SVG and caches it in a framebuffer */ | /** A knob which rotates an SVG and caches it in a framebuffer */ | ||||
struct SVGKnob : Knob, FramebufferWidget { | struct SVGKnob : Knob, FramebufferWidget { | ||||
/** Angles in radians */ | |||||
float minAngle, maxAngle; | |||||
TransformWidget *tw; | TransformWidget *tw; | ||||
SVGWidget *sw; | SVGWidget *sw; | ||||
CircularShadow *shadow; | CircularShadow *shadow; | ||||
/** Angles in radians */ | |||||
float minAngle, maxAngle; | |||||
SVGKnob(); | SVGKnob(); | ||||
void setSVG(std::shared_ptr<SVG> svg); | void setSVG(std::shared_ptr<SVG> svg); | ||||
@@ -289,18 +289,22 @@ struct SVGKnob : Knob, FramebufferWidget { | |||||
/** Behaves like a knob but linearly moves an SVGWidget between two points. | /** Behaves like a knob but linearly moves an SVGWidget between two points. | ||||
Can be used for horizontal or vertical linear faders. | Can be used for horizontal or vertical linear faders. | ||||
*/ | */ | ||||
struct SVGFader : Knob, FramebufferWidget { | |||||
/** Intermediate positions will be interpolated between these positions */ | |||||
Vec minHandlePos, maxHandlePos; | |||||
/** Not owned */ | |||||
struct SVGSlider : Knob, FramebufferWidget { | |||||
SVGWidget *background; | SVGWidget *background; | ||||
SVGWidget *handle; | SVGWidget *handle; | ||||
/** Intermediate positions will be interpolated between these positions */ | |||||
Vec minHandlePos, maxHandlePos; | |||||
SVGFader(); | |||||
SVGSlider(); | |||||
void setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG); | |||||
void step() override; | void step() override; | ||||
void onChange(EventChange &e) override; | void onChange(EventChange &e) override; | ||||
}; | }; | ||||
/** Deprecated name for SVGSlider */ | |||||
typedef SVGSlider SVGFader; | |||||
/** A Parameter with multiple frames corresponding to its value */ | |||||
struct SVGSwitch : virtual Parameter, FramebufferWidget { | struct SVGSwitch : virtual Parameter, FramebufferWidget { | ||||
std::vector<std::shared_ptr<SVG>> frames; | std::vector<std::shared_ptr<SVG>> frames; | ||||
SVGWidget *sw; | SVGWidget *sw; | ||||
@@ -446,13 +450,11 @@ struct ModuleLightWidget : MultiLightWidget { | |||||
// ports | // ports | ||||
//////////////////// | //////////////////// | ||||
struct Port : OpaqueWidget { | |||||
struct Port : Component { | |||||
enum PortType { | enum PortType { | ||||
INPUT, | INPUT, | ||||
OUTPUT | OUTPUT | ||||
}; | }; | ||||
Module *module = NULL; | |||||
PortType type = INPUT; | PortType type = INPUT; | ||||
int portId; | int portId; | ||||
MultiLightWidget *plugLight; | MultiLightWidget *plugLight; | ||||
@@ -470,9 +472,8 @@ struct Port : OpaqueWidget { | |||||
template <typename T = Port> | template <typename T = Port> | ||||
static T *create(Vec pos, PortType type, Module *module, int portId) { | static T *create(Vec pos, PortType type, Module *module, int portId) { | ||||
T *o = Widget::create<T>(pos); | |||||
T *o = Component::create<T>(pos, module); | |||||
o->type = type; | o->type = type; | ||||
o->module = module; | |||||
o->portId = portId; | o->portId = portId; | ||||
return o; | return o; | ||||
} | } | ||||
@@ -480,8 +481,10 @@ struct Port : OpaqueWidget { | |||||
struct SVGPort : Port, FramebufferWidget { | struct SVGPort : Port, FramebufferWidget { | ||||
SVGWidget *background; | SVGWidget *background; | ||||
CircularShadow *shadow; | |||||
SVGPort(); | SVGPort(); | ||||
void setSVG(std::shared_ptr<SVG> svg); | |||||
void draw(NVGcontext *vg) override; | void draw(NVGcontext *vg) override; | ||||
}; | }; | ||||
@@ -322,45 +322,75 @@ struct BefacoTinyKnob : SVGKnob { | |||||
} | } | ||||
}; | }; | ||||
struct BefacoSlidePot : SVGFader { | |||||
struct BefacoSlidePot : SVGSlider { | |||||
BefacoSlidePot() { | BefacoSlidePot() { | ||||
Vec margin = Vec(3.5, 3.5); | Vec margin = Vec(3.5, 3.5); | ||||
maxHandlePos = Vec(-1, -2).plus(margin); | maxHandlePos = Vec(-1, -2).plus(margin); | ||||
minHandlePos = Vec(-1, 87).plus(margin); | minHandlePos = Vec(-1, 87).plus(margin); | ||||
background->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePot.svg")); | |||||
background->wrap(); | |||||
setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePot.svg")), SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePotHandle.svg"))); | |||||
background->box.pos = margin; | background->box.pos = margin; | ||||
box.size = background->box.size.plus(margin.mult(2)); | box.size = background->box.size.plus(margin.mult(2)); | ||||
handle->svg = SVG::load(assetGlobal("res/ComponentLibrary/BefacoSlidePotHandle.svg")); | |||||
handle->wrap(); | |||||
} | |||||
}; | |||||
struct LEDSlider : SVGSlider { | |||||
LEDSlider() { | |||||
maxHandlePos = mm2px(Vec(0.738, 0.738).plus(Vec(2, 0))); | |||||
minHandlePos = mm2px(Vec(0.738, 22.078).plus(Vec(2, 0))); | |||||
setSVGs(SVG::load(assetGlobal("res/ComponentLibrary/LEDSlider.svg")), NULL); | |||||
} | |||||
}; | |||||
/** API is unstable for LEDSlider. Will add a LightWidget later. */ | |||||
struct LEDSliderGreen : LEDSlider { | |||||
LEDSliderGreen() { | |||||
handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderGreenHandle.svg"))); | |||||
} | |||||
}; | |||||
struct LEDSliderRed : LEDSlider { | |||||
LEDSliderRed() { | |||||
handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderRedHandle.svg"))); | |||||
} | |||||
}; | |||||
struct LEDSliderYellow : LEDSlider { | |||||
LEDSliderYellow() { | |||||
handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderYellowHandle.svg"))); | |||||
} | |||||
}; | |||||
struct LEDSliderBlue : LEDSlider { | |||||
LEDSliderBlue() { | |||||
handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderBlueHandle.svg"))); | |||||
} | |||||
}; | |||||
struct LEDSliderWhite : LEDSlider { | |||||
LEDSliderWhite() { | |||||
handle->setSVG(SVG::load(assetGlobal("res/ComponentLibrary/LEDSliderWhiteHandle.svg"))); | |||||
} | } | ||||
}; | }; | ||||
//////////////////// | //////////////////// | ||||
// Jacks | |||||
// Ports | |||||
//////////////////// | //////////////////// | ||||
struct PJ301MPort : SVGPort { | struct PJ301MPort : SVGPort { | ||||
PJ301MPort() { | PJ301MPort() { | ||||
background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ301M.svg")); | |||||
background->wrap(); | |||||
box.size = background->box.size; | |||||
setSVG(SVG::load(assetGlobal("res/ComponentLibrary/PJ301M.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct PJ3410Port : SVGPort { | struct PJ3410Port : SVGPort { | ||||
PJ3410Port() { | PJ3410Port() { | ||||
background->svg = SVG::load(assetGlobal("res/ComponentLibrary/PJ3410.svg")); | |||||
background->wrap(); | |||||
box.size = background->box.size; | |||||
setSVG(SVG::load(assetGlobal("res/ComponentLibrary/PJ3410.svg"))); | |||||
} | } | ||||
}; | }; | ||||
struct CL1362Port : SVGPort { | struct CL1362Port : SVGPort { | ||||
CL1362Port() { | CL1362Port() { | ||||
background->svg = SVG::load(assetGlobal("res/ComponentLibrary/CL1362.svg")); | |||||
background->wrap(); | |||||
box.size = background->box.size; | |||||
setSVG(SVG::load(assetGlobal("res/ComponentLibrary/CL1362.svg"))); | |||||
} | } | ||||
}; | }; | ||||
@@ -0,0 +1,66 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="7.00002mm" | |||||
height="26.999905mm" | |||||
viewBox="0 0 7.00002 26.999905" | |||||
version="1.1" | |||||
id="svg163547" | |||||
sodipodi:docname="LEDSlider.svg" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06"> | |||||
<defs | |||||
id="defs163541" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="1.979899" | |||||
inkscape:cx="-33.18202" | |||||
inkscape:cy="22.493378" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="2" | |||||
fit-margin-right="2" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata163544"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-105.35713,-95.267905)"> | |||||
<path | |||||
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 110.35715,95.267905 v 26.999905 h -3.00002 V 95.267905 Z m 0,0" | |||||
id="path159840" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -0,0 +1,71 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="1.52411mm" | |||||
height="4.1437631mm" | |||||
viewBox="0 0 1.52411 4.143763" | |||||
version="1.1" | |||||
id="svg164153" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06" | |||||
sodipodi:docname="LEDSliderBlueHandle.svg"> | |||||
<defs | |||||
id="defs164147" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="7.9195959" | |||||
inkscape:cx="-27.821283" | |||||
inkscape:cy="-9.1133715" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="0" | |||||
fit-margin-right="0" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata164150"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-120.21393,-92.817187)"> | |||||
<path | |||||
style="fill:#5c5c5c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 121.73804,92.817187 v 4.143763 h -1.52411 v -4.143763 z m 0,0" | |||||
id="path162658" | |||||
inkscape:connector-curvature="0" /> | |||||
<path | |||||
style="fill:#4cc7f3;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 121.73804,93.251269 v 3.275599 h -1.52411 v -3.275599 z m 0,0" | |||||
id="path162660" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -0,0 +1,71 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="1.52411mm" | |||||
height="4.1423831mm" | |||||
viewBox="0 0 1.52411 4.1423831" | |||||
version="1.1" | |||||
id="svg164153" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06" | |||||
sodipodi:docname="LEDSliderGreenHandle.svg"> | |||||
<defs | |||||
id="defs164147" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="7.9195959" | |||||
inkscape:cx="-42.017793" | |||||
inkscape:cy="0.48214362" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="0" | |||||
fit-margin-right="0" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata164150"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-123.97009,-95.35738)"> | |||||
<path | |||||
style="fill:#5c5c5c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 125.4942,95.35738 v 4.142383 h -1.52411 V 95.35738 Z m 0,0" | |||||
id="path162646" | |||||
inkscape:connector-curvature="0" /> | |||||
<path | |||||
style="fill:#8fc53d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 125.4942,95.790083 v 3.276977 h -1.52411 v -3.276977 z m 0,0" | |||||
id="path162648" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -0,0 +1,71 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="1.52414mm" | |||||
height="4.1423802mm" | |||||
viewBox="0 0 1.52414 4.1423802" | |||||
version="1.1" | |||||
id="svg164153" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06" | |||||
sodipodi:docname="LEDSliderRedHandle.svg"> | |||||
<defs | |||||
id="defs164147" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="7.9195959" | |||||
inkscape:cx="-23.101371" | |||||
inkscape:cy="2.1230781" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="0" | |||||
fit-margin-right="0" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata164150"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-118.96512,-95.791547)"> | |||||
<path | |||||
style="fill:#5c5c5c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 120.48926,95.791547 v 4.14238 h -1.52414 v -4.14238 z m 0,0" | |||||
id="path162650" | |||||
inkscape:connector-curvature="0" /> | |||||
<path | |||||
style="fill:#f82b1c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 120.48926,96.225629 v 3.275595 h -1.52414 v -3.275595 z m 0,0" | |||||
id="path162652" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -0,0 +1,71 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="1.52411mm" | |||||
height="4.1423841mm" | |||||
viewBox="0 0 1.52411 4.142384" | |||||
version="1.1" | |||||
id="svg164153" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06" | |||||
sodipodi:docname="LEDSliderWhiteHandle.svg"> | |||||
<defs | |||||
id="defs164147" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="7.9195959" | |||||
inkscape:cx="-27.719009" | |||||
inkscape:cy="-12.144383" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="0" | |||||
fit-margin-right="0" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata164150"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-120.18687,-92.016611)"> | |||||
<path | |||||
style="fill:#5c5c5c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 121.71098,92.016611 v 4.142384 h -1.52411 v -4.142384 z m 0,0" | |||||
id="path162662" | |||||
inkscape:connector-curvature="0" /> | |||||
<path | |||||
style="fill:#eeeeee;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 121.71098,92.449314 v 3.276974 h -1.52411 v -3.276974 z m 0,0" | |||||
id="path162664" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -0,0 +1,71 @@ | |||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | |||||
<!-- Created with Inkscape (http://www.inkscape.org/) --> | |||||
<svg | |||||
xmlns:dc="http://purl.org/dc/elements/1.1/" | |||||
xmlns:cc="http://creativecommons.org/ns#" | |||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | |||||
xmlns:svg="http://www.w3.org/2000/svg" | |||||
xmlns="http://www.w3.org/2000/svg" | |||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" | |||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" | |||||
width="1.52411mm" | |||||
height="4.1423841mm" | |||||
viewBox="0 0 1.52411 4.142384" | |||||
version="1.1" | |||||
id="svg164153" | |||||
inkscape:version="0.92.2 5c3e80d, 2017-08-06" | |||||
sodipodi:docname="LEDSliderYellowHandle.svg"> | |||||
<defs | |||||
id="defs164147" /> | |||||
<sodipodi:namedview | |||||
id="base" | |||||
pagecolor="#ffffff" | |||||
bordercolor="#666666" | |||||
borderopacity="1.0" | |||||
inkscape:pageopacity="0.0" | |||||
inkscape:pageshadow="2" | |||||
inkscape:zoom="7.9195959" | |||||
inkscape:cx="-37.393768" | |||||
inkscape:cy="-10.378115" | |||||
inkscape:document-units="mm" | |||||
inkscape:current-layer="layer1" | |||||
showgrid="false" | |||||
fit-margin-top="0" | |||||
fit-margin-left="0" | |||||
fit-margin-right="0" | |||||
fit-margin-bottom="0" | |||||
inkscape:window-width="2560" | |||||
inkscape:window-height="1422" | |||||
inkscape:window-x="0" | |||||
inkscape:window-y="18" | |||||
inkscape:window-maximized="0" /> | |||||
<metadata | |||||
id="metadata164150"> | |||||
<rdf:RDF> | |||||
<cc:Work | |||||
rdf:about=""> | |||||
<dc:format>image/svg+xml</dc:format> | |||||
<dc:type | |||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> | |||||
<dc:title></dc:title> | |||||
</cc:Work> | |||||
</rdf:RDF> | |||||
</metadata> | |||||
<g | |||||
inkscape:label="Layer 1" | |||||
inkscape:groupmode="layer" | |||||
id="layer1" | |||||
transform="translate(-122.74665,-92.483936)"> | |||||
<path | |||||
style="fill:#5c5c5c;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 124.27076,92.483936 v 4.142384 h -1.52411 v -4.142384 z m 0,0" | |||||
id="path162654" | |||||
inkscape:connector-curvature="0" /> | |||||
<path | |||||
style="fill:#ffd714;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" | |||||
d="m 124.27076,92.918018 v 3.275599 h -1.52411 v -3.275599 z m 0,0" | |||||
id="path162656" | |||||
inkscape:connector-curvature="0" /> | |||||
</g> | |||||
</svg> |
@@ -7,8 +7,6 @@ namespace rack { | |||||
CircularShadow::CircularShadow() { | CircularShadow::CircularShadow() { | ||||
blurRadius = 0; | blurRadius = 0; | ||||
opacity = 0.15; | opacity = 0.15; | ||||
// blurRadius = 0; | |||||
// opacity = 0.15; | |||||
} | } | ||||
void CircularShadow::draw(NVGcontext *vg) { | void CircularShadow::draw(NVGcontext *vg) { | ||||
@@ -30,6 +30,7 @@ void Knob::onDragMove(EventDragMove &e) { | |||||
if (windowIsModPressed()) | if (windowIsModPressed()) | ||||
delta /= 16.0; | delta /= 16.0; | ||||
dragValue += delta; | dragValue += delta; | ||||
dragValue = clamp(dragValue, minValue, maxValue); | |||||
if (snap) | if (snap) | ||||
setValue(roundf(dragValue)); | setValue(roundf(dragValue)); | ||||
else | else | ||||
@@ -1,30 +0,0 @@ | |||||
#include "app.hpp" | |||||
namespace rack { | |||||
SVGFader::SVGFader() { | |||||
background = new SVGWidget(); | |||||
addChild(background); | |||||
handle = new SVGWidget(); | |||||
addChild(handle); | |||||
} | |||||
void SVGFader::step() { | |||||
if (dirty) { | |||||
// Update handle position | |||||
Vec handlePos = Vec(rescale(value, minValue, maxValue, minHandlePos.x, maxHandlePos.x), rescale(value, minValue, maxValue, minHandlePos.y, maxHandlePos.y)); | |||||
handle->box.pos = handlePos; | |||||
} | |||||
FramebufferWidget::step(); | |||||
} | |||||
void SVGFader::onChange(EventChange &e) { | |||||
dirty = true; | |||||
Knob::onChange(e); | |||||
} | |||||
} // namespace rack |
@@ -5,10 +5,24 @@ namespace rack { | |||||
SVGPort::SVGPort() { | SVGPort::SVGPort() { | ||||
shadow = new CircularShadow(); | |||||
addChild(shadow); | |||||
// Avoid breakage if plugins fail to call setSVG() | |||||
// In that case, just disable the shadow. | |||||
shadow->box.size = Vec(); | |||||
background = new SVGWidget(); | background = new SVGWidget(); | ||||
addChild(background); | addChild(background); | ||||
} | } | ||||
void SVGPort::setSVG(std::shared_ptr<SVG> svg) { | |||||
background->setSVG(svg); | |||||
box.size = background->box.size; | |||||
shadow->box.size = background->box.size; | |||||
shadow->box.pos = Vec(0, background->box.size.y * 0.1); | |||||
// shadow->box = shadow->box.grow(Vec(2, 2)); | |||||
} | |||||
void SVGPort::draw(NVGcontext *vg) { | void SVGPort::draw(NVGcontext *vg) { | ||||
Port::draw(vg); | Port::draw(vg); | ||||
FramebufferWidget::draw(vg); | FramebufferWidget::draw(vg); | ||||
@@ -0,0 +1,37 @@ | |||||
#include "app.hpp" | |||||
namespace rack { | |||||
SVGSlider::SVGSlider() { | |||||
background = new SVGWidget(); | |||||
addChild(background); | |||||
handle = new SVGWidget(); | |||||
addChild(handle); | |||||
} | |||||
void SVGSlider::setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG) { | |||||
background->setSVG(backgroundSVG); | |||||
box.size = background->box.size; | |||||
if (handleSVG) { | |||||
handle->setSVG(handleSVG); | |||||
} | |||||
} | |||||
void SVGSlider::step() { | |||||
if (dirty) { | |||||
// Interpolate handle position | |||||
handle->box.pos = Vec(rescale(value, minValue, maxValue, minHandlePos.x, maxHandlePos.x), rescale(value, minValue, maxValue, minHandlePos.y, maxHandlePos.y)); | |||||
} | |||||
FramebufferWidget::step(); | |||||
} | |||||
void SVGSlider::onChange(EventChange &e) { | |||||
dirty = true; | |||||
Knob::onChange(e); | |||||
} | |||||
} // namespace rack |