Skip to content

Commit

Permalink
labels for compoly out widget
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamPorcineFudgepuppy committed Jul 4, 2024
1 parent c007381 commit 96698b4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 27 deletions.
16 changes: 8 additions & 8 deletions src/ComputerscareNomplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);


Expand All @@ -366,20 +366,20 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget
addParam(createParam<SmoothKnob>(Vec(rightInputX, rectInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::IMAGINARY_INPUT_OFFSET));
addParam(createParam<SmallKnob>(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);

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<InPort>(Vec(leftInputX, polarInSectionY), module, ComputerscareNomplexPumbers::MODULUS_IN));
Expand All @@ -391,11 +391,11 @@ struct ComputerscareNomplexPumbersWidget : ModuleWidget
addParam(createParam<SmoothKnob>(Vec(rightInputX, polarInSectionY).plus(offsetRelPos), module, ComputerscareNomplexPumbers::ARGUMENT_INPUT_OFFSET));
addParam(createParam<SmallKnob>(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);
Expand Down
73 changes: 54 additions & 19 deletions src/complex/ComplexWidgets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}
};




Expand All @@ -252,37 +268,56 @@ struct CompolyInOrOutWidget : Widget {
int numPorts = 2;
int lastOutMode = -1;
std::vector<BASE*> 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;
}

Expand Down Expand Up @@ -344,14 +379,14 @@ struct CompolyInOrOutWidget : Widget {
struct CompolyOutWidget : CompolyInOrOutWidget<ComplexOutport> {
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<CompolyTypeLabelSwitch>(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);
Expand All @@ -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<ComplexOutport>::CompolyInOrOutWidget(pos);

Expand Down

0 comments on commit 96698b4

Please sign in to comment.