Add panel for midi in expander

This commit is contained in:
falkTX 2022-02-03 01:34:57 +00:00
parent 54fccf2a9e
commit 4a629b46c3
9 changed files with 311 additions and 35 deletions

View file

@ -0,0 +1,107 @@
<?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="15.24mm"
height="128.5mm"
viewBox="0 0 15.24 128.5"
version="1.1"
id="svg4620"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="ExpanderMIDI.svg">
<defs
id="defs4614">
<style
id="style6"
type="text/css">
.str0 {stroke:#565656;stroke-width:0.0966867}
.str1 {stroke:#4F4F4F;stroke-width:0.193345}
.fil0 {fill:none}
.fil2 {fill:#2B2A29}
.fil1 {fill:#6B6B6B}
</style>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="-89.97092"
inkscape:cy="317.24373"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1015"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="0" />
<metadata
id="metadata4617">
<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(0,-168.5)">
<g
style="fill-rule:evenodd"
id="g5299"
transform="matrix(6.342689,0,0,6.342689,4.4921904,175.6457)">
<g
transform="translate(-1.6191379e-5,-0.08553947)"
id="Layer_x0020_1"
inkscape:label="Layer 1">
<metadata
id="CorelCorpID_0Corel-Layer" />
<circle
style="fill:none;stroke:#ffffff;stroke-width:0.0966867;stroke-opacity:1"
id="circle10"
r="0.15916"
cy="0.61075097"
cx="0.525226"
class="fil0 str0" />
<circle
style="fill:none;stroke:#ffffff;stroke-width:0.193345;stroke-opacity:1"
id="circle12"
r="0.42853901"
cy="0.61075097"
cx="0.525226"
class="fil0 str1" />
</g>
</g>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58329964px;line-height:1.25;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke:none;stroke-width:0.26458299"
x="2.3347058"
y="188.65312"
id="text845"><tspan
sodipodi:role="line"
id="tspan843"
x="2.3347058"
y="188.65312"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888998px;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke-width:0.26458299">MIDI</tspan></text>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -0,0 +1,117 @@
<?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="15.24mm"
height="128.5mm"
viewBox="0 0 15.24 128.5"
version="1.1"
id="svg4620"
inkscape:version="0.92.3 (2405546, 2018-03-11)"
sodipodi:docname="ExpanderMIDI.svg">
<defs
id="defs4614">
<style
id="style6"
type="text/css">
.str0 {stroke:#565656;stroke-width:0.0966867}
.str1 {stroke:#4F4F4F;stroke-width:0.193345}
.fil0 {fill:none}
.fil2 {fill:#2B2A29}
.fil1 {fill:#6B6B6B}
</style>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="1.979899"
inkscape:cx="-188.96587"
inkscape:cy="317.24373"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1015"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="0" />
<metadata
id="metadata4617">
<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 />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-168.5)">
<g
style="fill-rule:evenodd"
id="g5299"
transform="matrix(6.342689,0,0,6.342689,4.4921904,175.6457)">
<g
transform="translate(-1.6191379e-5,-0.08553947)"
id="Layer_x0020_1"
inkscape:label="Layer 1">
<metadata
id="CorelCorpID_0Corel-Layer" />
<circle
style="fill:none;stroke:#ffffff;stroke-width:0.0966867;stroke-opacity:1"
id="circle10"
r="0.15916"
cy="0.61075097"
cx="0.525226"
class="fil0 str0" />
<circle
style="fill:none;stroke:#ffffff;stroke-width:0.193345;stroke-opacity:1"
id="circle12"
r="0.42853901"
cy="0.61075097"
cx="0.525226"
class="fil0 str1" />
</g>
</g>
<g
aria-label="MIDI"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.58329964px;line-height:1.25;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke:none;stroke-width:0.26458299"
id="text845">
<path
d="m 2.8194309,185.05265 h 0.7258818 l 0.9188071,2.45015 0.9236303,-2.45015 h 0.7258818 v 3.60047 H 5.6385531 v -3.16156 L 4.7100997,187.961 H 4.2205515 l -0.9284534,-2.46944 v 3.16156 H 2.8194309 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888998px;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke-width:0.26458299"
id="path820" />
<path
d="m 7.0830818,185.05265 h 0.4871366 v 3.60047 H 7.0830818 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888998px;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke-width:0.26458299"
id="path822" />
<path
d="m 9.0268052,185.45297 v 2.79983 h 0.5884225 q 0.7451743,0 1.0900283,-0.33762 0.347266,-0.33762 0.347266,-1.06591 0,-0.72347 -0.347266,-1.05868 -0.344854,-0.33762 -1.0900283,-0.33762 z m -0.4871366,-0.40032 h 1.0008005 q 1.0466199,0 1.5361679,0.4365 0.489549,0.43408 0.489549,1.36012 0,0.93086 -0.49196,1.36736 -0.49196,0.43649 -1.5337569,0.43649 H 8.5396686 Z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888998px;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke-width:0.26458299"
id="path824" />
<path
d="m 12.340298,185.05265 h 0.487137 v 3.60047 h -0.487137 z"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:4.93888998px;font-family:'DejaVu Sans';-inkscape-font-specification:'DejaVu Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:start;writing-mode:lr-tb;text-anchor:start;fill:#808a8a;fill-opacity:1;stroke-width:0.26458299"
id="path826" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.6 KiB

View file

@ -16,10 +16,9 @@
*/
#include "plugincontext.hpp"
#include "ModuleWidgets.hpp"
#include "extra/Thread.hpp"
#include "dgl/src/nanovg/nanovg.h"
#include "CarlaNativePlugin.h"
#ifndef HEADLESS
@ -470,7 +469,7 @@ struct AudioFileListWidget : ImGuiWidget {
}
};
struct AudioFileWidget : ModuleWidget {
struct AudioFileWidget : ModuleWidgetWithSideScrews<> {
static constexpr const float padding = 29.0f;
CarlaInternalPluginModule* const module;
@ -479,16 +478,12 @@ struct AudioFileWidget : ModuleWidget {
float lastPosition = 0.0f;
AudioFileWidget(CarlaInternalPluginModule* const m)
: ModuleWidget(),
module(m)
: module(m)
{
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/AudioFile.svg")));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
createAndAddScrews();
addOutput(createOutput<PJ301MPort>(Vec(box.size.x - RACK_GRID_WIDTH * 5/2 - padding,
RACK_GRID_HEIGHT - RACK_GRID_WIDTH - padding), module, 0));

View file

@ -453,7 +453,8 @@ struct CarlaModuleWidget : ModuleWidgetWith9HP, IdleCallback {
{
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/Carla.svg")));
setSideScrews();
createAndAddScrews();
for (uint i=0; i<CarlaModule::NUM_INPUTS; ++i)
createAndAddInput(i);

View file

@ -16,6 +16,7 @@
*/
#include "Expander.hpp"
#include "ModuleWidgets.hpp"
// --------------------------------------------------------------------------------------------------------------------
@ -205,19 +206,63 @@ struct CardinalExpanderForInputMIDI : CardinalExpanderFromCVToCarlaMIDI {
// --------------------------------------------------------------------------------------------------------------------
struct CardinalExpanderForInputMIDIWidget : ModuleWidget {
struct CardinalExpanderForInputMIDIWidget : ModuleWidgetWithSideScrews<> {
static constexpr const float startX = 14.0f;
static constexpr const float startY = 90.0f;
static constexpr const float padding = 49.0f;
CardinalExpanderForInputMIDIWidget(CardinalExpanderForInputMIDI* const module)
{
setModule(module);
box.size.x = RACK_GRID_WIDTH * 2;
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/ExpanderMIDI.svg")));
addChild(createWidget<ScrewBlack>(Vec(0, 0)));
addChild(createWidget<ScrewBlack>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
for (int i=0; i<6; ++i)
addInput(createInput<PJ301MPort>(Vec(15, 50 + 29 * i), module, i));
for (int i=0; i<CardinalExpanderForInputMIDI::NUM_INPUTS; ++i)
addInput(createInput<PJ301MPort>(Vec(startX + 5.0f, startY + padding * i), module, i));
}
void drawOutputJacksArea(NVGcontext* const vg, const int numOutputs) {
nvgBeginPath(vg);
nvgRoundedRect(vg, 12.0f, startY - 2.0f, box.size.x - 12.0f, padding * numOutputs, 4);
nvgFillColor(vg, nvgRGB(0xd0, 0xd0, 0xd0));
nvgFill(vg);
}
void draw(const DrawArgs& args) override
{
drawBackground(args.vg);
nvgScissor(args.vg, startX, 0.0f, box.size.x - startX, box.size.y);
for (int i=0; i<CardinalExpanderForInputMIDI::NUM_INPUTS; ++i)
{
const float y = startY + i* padding;
nvgBeginPath(args.vg);
nvgRoundedRect(args.vg, startX, y - 19.0f, box.size.x, padding - 4.0f, 4);
nvgFillColor(args.vg, nvgRGB(0xd0, 0xd0, 0xd0));
nvgFill(args.vg);
}
nvgResetScissor(args.vg);
nvgBeginPath(args.vg);
nvgRect(args.vg, box.size.x * 0.5f, 0, box.size.x, box.size.y);
nvgFillColor(args.vg, color::BLACK);
nvgFontFaceId(args.vg, 0);
nvgFontSize(args.vg, 11);
nvgTextAlign(args.vg, NVG_ALIGN_CENTER);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 0 - 4.0f, "V/Oct", nullptr);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 1 - 4.0f, "Gate", nullptr);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 2 - 4.0f, "Vel", nullptr);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 3 - 4.0f, "Aft", nullptr);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 4 - 4.0f, "PW", nullptr);
nvgText(args.vg, box.size.x * 0.666f, startY + padding * 5 - 4.0f, "MW", nullptr);
ModuleWidgetWithSideScrews::draw(args);
}
};

View file

@ -213,7 +213,8 @@ struct HostAudioWidget : ModuleWidgetWith8HP {
{
setModule(m);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostAudio.svg")));
setSideScrews();
createAndAddScrews();
for (uint i=0; i<numIO; ++i)
{

View file

@ -104,7 +104,8 @@ struct HostCVWidget : ModuleWidgetWith8HP {
{
setModule(module);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostCV.svg")));
setSideScrews();
createAndAddScrews();
for (uint i=0; i<HostCV::NUM_INPUTS; ++i)
createAndAddInput(i);

View file

@ -670,7 +670,8 @@ struct HostMIDIWidget : ModuleWidgetWith9HP {
{
setModule(m);
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostMIDI.svg")));
setSideScrews();
createAndAddScrews();
createAndAddInput(0, HostMIDI::PITCH_INPUT);
createAndAddInput(1, HostMIDI::GATE_INPUT);

View file

@ -25,28 +25,13 @@
using namespace rack;
template<int startX_Out>
template<int startX_Out = 0>
struct ModuleWidgetWithSideScrews : ModuleWidget {
static constexpr const float startX_In = 14.0f;
static constexpr const float startY = 74.0f;
static constexpr const float padding = 29.0f;
static constexpr const float middleX = startX_In + (startX_Out - startX_In) * 0.5f + padding * 0.35f;
void setSideScrews() {
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
}
void setupTextLines(NVGcontext* const vg) {
nvgBeginPath(vg);
nvgRect(vg, startX_Out - 2.5f, startY - 2.0f, padding, padding);
nvgFontFaceId(vg, 0);
nvgFontSize(vg, 11);
nvgTextAlign(vg, NVG_ALIGN_CENTER);
}
void createAndAddInput(const uint paramId) {
createAndAddInput(paramId, paramId);
}
@ -63,6 +48,20 @@ struct ModuleWidgetWithSideScrews : ModuleWidget {
addOutput(createOutput<PJ301MPort>(Vec(startX_Out, startY + padding * posY), module, paramId));
}
void createAndAddScrews() {
if (box.size.x > RACK_GRID_WIDTH * 3) {
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
} else {
addChild(createWidget<ScrewBlack>(Vec(0, 0)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - RACK_GRID_WIDTH, 0)));
addChild(createWidget<ScrewBlack>(Vec(0, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
addChild(createWidget<ScrewBlack>(Vec(box.size.x - RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
}
}
void drawBackground(NVGcontext* const vg) {
nvgBeginPath(vg);
nvgRect(vg, 0, 0, box.size.x, box.size.y);
@ -84,7 +83,16 @@ struct ModuleWidgetWithSideScrews : ModuleWidget {
nvgFillColor(vg, color::WHITE);
nvgText(vg, middleX, y + 16, text, nullptr);
}
void setupTextLines(NVGcontext* const vg) {
nvgBeginPath(vg);
nvgRect(vg, startX_Out - 2.5f, startY - 2.0f, padding, padding);
nvgFontFaceId(vg, 0);
nvgFontSize(vg, 11);
nvgTextAlign(vg, NVG_ALIGN_CENTER);
}
};
typedef ModuleWidgetWithSideScrews<0> ModuleWidgetWith3HP;
typedef ModuleWidgetWithSideScrews<81> ModuleWidgetWith8HP;
typedef ModuleWidgetWithSideScrews<96> ModuleWidgetWith9HP;