From 96698b4d7a3a81011b891e5334d28dbdd78e7ecb Mon Sep 17 00:00:00 2001 From: AdamPorcineFudgepuppy <> Date: Thu, 4 Jul 2024 12:05:15 -0500 Subject: [PATCH] labels for compoly out widget --- src/ComputerscareNomplex.cpp | 16 ++++---- src/complex/ComplexWidgets.hpp | 73 +++++++++++++++++++++++++--------- 2 files changed, 62 insertions(+), 27 deletions(-) diff --git a/src/ComputerscareNomplex.cpp b/src/ComputerscareNomplex.cpp index 3a76630..d615ced 100644 --- a/src/ComputerscareNomplex.cpp +++ b/src/ComputerscareNomplex.cpp @@ -338,7 +338,7 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget const int rectInSectionY = 70; - const int polarInSectionY = 220; + const int polarInSectionY = 240; const int leftInputX = 25; const int rightInputX = 100; @@ -353,7 +353,7 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget cpx::ComplexXY* xy = new cpx::ComplexXY(module,ComputerscareNomplexPumbers::COMPLEX_CONSTANT_A); xy->box.size=Vec(30,30); - xy->box.pos=Vec(70,40); + xy->box.pos=Vec(60,30); addChild(xy); @@ -366,11 +366,11 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget addParam(createParam(Vec(rightInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::IMAGINARY_INPUT_OFFSET)); addParam(createParam(Vec(rightInputX, rectInSectionY).plus(trimRelPos), module, ComputerscareNomplexPumbers::IMAGINARY_INPUT_TRIM)); - cpx::CompolyOutWidget* outRect1 = new cpx::CompolyOutWidget(Vec(output1X, rectInSectionY+30),module,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT_MODE); + cpx::CompolyOutWidget* outRect1 = new cpx::CompolyOutWidget(Vec(output1X, rectInSectionY+40),module,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT_MODE); addChild(outRect1); - cpx::CompolyOutWidget* outRect2 = new cpx::CompolyOutWidget(Vec(output1X, rectInSectionY+70),module,ComputerscareNomplexPumbers::RECT_IN_POLAR_OUT,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT_MODE+1); + cpx::CompolyOutWidget* outRect2 = new cpx::CompolyOutWidget(Vec(output1X, rectInSectionY+90),module,ComputerscareNomplexPumbers::RECT_IN_POLAR_OUT,ComputerscareNomplexPumbers::RECT_IN_RECT_OUT_MODE+1); addChild(outRect2); rectInChannelWidget = new PolyOutputChannelsWidget(Vec(output2X+64, rectInSectionY+26).plus(channelsKnobRelPos), module, ComputerscareNomplexPumbers::COMPOLY_CHANNELS_RECT_IN,&module->compolyChannelsRectIn); @@ -378,8 +378,8 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget addChild(rectInChannelWidget); cpx::ComplexXY* uv = new cpx::ComplexXY(module,ComputerscareNomplexPumbers::COMPLEX_CONSTANT_U); - uv->box.size=Vec(15,15); - uv->box.pos=Vec(70,180); + uv->box.size=Vec(30,30); + uv->box.pos=Vec(60,200); addChild(uv); addInput(createInput(Vec(leftInputX, polarInSectionY), module, ComputerscareNomplexPumbers::MODULUS_IN)); @@ -391,11 +391,11 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget addParam(createParam(Vec(rightInputX, polarInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::ARGUMENT_INPUT_OFFSET)); addParam(createParam(Vec(rightInputX, polarInSectionY).plus(trimRelPos), module, ComputerscareNomplexPumbers::ARGUMENT_INPUT_TRIM)); - cpx::CompolyOutWidget* outPolar1 = new cpx::CompolyOutWidget(Vec(output1X, polarInSectionY+30),module,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT_MODE); + cpx::CompolyOutWidget* outPolar1 = new cpx::CompolyOutWidget(Vec(output1X, polarInSectionY+40),module,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT_MODE); addChild(outPolar1); - cpx::CompolyOutWidget* outPolar2 = new cpx::CompolyOutWidget(Vec(output1X, polarInSectionY+70),module,ComputerscareNomplexPumbers::POLAR_IN_POLAR_OUT,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT_MODE+1); + cpx::CompolyOutWidget* outPolar2 = new cpx::CompolyOutWidget(Vec(output1X, polarInSectionY+90),module,ComputerscareNomplexPumbers::POLAR_IN_POLAR_OUT,ComputerscareNomplexPumbers::POLAR_IN_RECT_OUT_MODE+1); addChild(outPolar2); polarInChannelWidget = new PolyOutputChannelsWidget(Vec(output2X+64, polarInSectionY+30).plus(channelsKnobRelPos), module, ComputerscareNomplexPumbers::COMPOLY_CHANNELS_POLAR_IN,&module->compolyChannelsPolarIn); diff --git a/src/complex/ComplexWidgets.hpp b/src/complex/ComplexWidgets.hpp index 73e2479..320cdbf 100644 --- a/src/complex/ComplexWidgets.hpp +++ b/src/complex/ComplexWidgets.hpp @@ -242,6 +242,22 @@ namespace cpx { } }; + struct ScaledSvgWidget : TransformWidget { + SvgWidget* svg; + ScaledSvgWidget(float scale) { + TransformWidget* tw = new TransformWidget(); + tw->scale(scale); + svg = new SvgWidget(); + + tw->addChild(svg); + + addChild(tw); + } + void setSVG(std::string path) { + svg->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, path))); + } + }; + @@ -252,37 +268,56 @@ struct CompolyInOrOutWidget : Widget { int numPorts = 2; int lastOutMode = -1; std::vector ports; - SvgWidget* leftLabel; - SvgWidget* rightLabel; + ScaledSvgWidget* leftLabel; + ScaledSvgWidget* rightLabel; + TransformWidget* leftTW; + TransformWidget* rightTW; - CompolyInOrOutWidget() { - TransformWidget* tw = new TransformWidget(); + CompolyInOrOutWidget(math::Vec pos) { + /*Widget* leftLabelWidget = new Widget(); + Widget* rightLabelWidget = new Widget(); + + leftTW = new TransformWidget(); + rightTW = new TransformWidget(); + + leftTW->scale(0.7); + rightTW->scale(1.2);*/ + + // leftTW->box.pos = pos; + //rightTW->box.pos = pos; + //tw->box.pos = pos.minus(Vec(20,0)); - tw->scale(1.0); + //tw->scale(1.0); - leftLabel = new SvgWidget(); - leftLabel->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/complex-labels/r.svg"))); + leftLabel = new ScaledSvgWidget(0.5); + leftLabel->box.pos = pos.minus(Vec(0,10)); + leftLabel->setSVG("res/complex-labels/r.svg"); //leftLabel->box.pos = box.pos; - tw->addChild(leftLabel); + //leftTW->addChild(leftLabel); - rightLabel = new SvgWidget(); - rightLabel->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/complex-labels/r.svg"))); + rightLabel = new ScaledSvgWidget(0.5); + rightLabel->box.pos = pos.plus(Vec(50,-10)); + rightLabel->setSVG("res/complex-labels/r.svg"); //rightLabel->box.pos = box.pos.plus(Vec(20,0)); - tw->addChild(rightLabel); + //rightTW->addChild(rightLabel); + + //leftLabelWidget->addChild(leftTW); + //rightLabelWidget->addChild(rightTW); //tw->addChild(compolyLabel); - addChild(tw); + addChild(leftLabel); + addChild(rightLabel); } void setLabels(std::string leftFilename,std:: string rightFilename) { - leftLabel->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/complex-labels/"+leftFilename))); - rightLabel->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/complex-labels/"+rightFilename))); + leftLabel->setSVG("res/complex-labels/"+leftFilename); + rightLabel->setSVG("res/complex-labels/"+rightFilename); rightLabel->visible=true; } void setLabels(std::string leftFilename) { - leftLabel->setSVG(APP->window->loadSvg(asset::plugin(pluginInstance, "res/complex-labels/"+leftFilename))); + leftLabel->setSVG("res/complex-labels/"+leftFilename); rightLabel->visible=false; } @@ -344,14 +379,14 @@ struct CompolyInOrOutWidget : Widget { struct CompolyOutWidget : CompolyInOrOutWidget { ComplexOutport* port; - CompolyOutWidget(math::Vec pos,ComputerscareComplexBase *cModule, int firstPortID,int compolyTypeParamID,float scale=1.0,bool isOutput=true) { + CompolyOutWidget(math::Vec pos,ComputerscareComplexBase *cModule, int firstPortID,int compolyTypeParamID,float scale=1.0,bool isOutput=true) : CompolyInOrOutWidget(pos) { module=cModule; paramID = compolyTypeParamID; CompolyTypeLabelSwitch* compolyLabel = createParam(Vec(0,0),cModule,compolyTypeParamID); TransformWidget* tw = new TransformWidget(); - tw->box.pos = pos.minus(Vec(20,0)); + tw->box.pos = pos.minus(Vec(40,0)); tw->scale(scale); tw->addChild(compolyLabel); @@ -371,8 +406,8 @@ struct CompolyInOrOutWidget : Widget { addChild(port); } - leftLabel->box.pos = Vec(pos.plus(Vec(0,-25))); - rightLabel->box.pos = Vec(pos.plus(Vec(35,-25))); + //leftLabel->box.pos = Vec(pos.plus(Vec(0,-25))); + //rightLabel->box.pos = Vec(pos.plus(Vec(35,-25))); //CompolyInOrOutWidget::CompolyInOrOutWidget(pos);