Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Cardinal specific changes #1

Merged
merged 4 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion res/09 Output Plug.svg

This file was deleted.

63 changes: 54 additions & 9 deletions src/Computerscare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static const NVGcolor COLOR_COMPUTERSCARE_YELLOW = nvgRGB(0xE4, 0xC4, 0x21);
static const NVGcolor COLOR_COMPUTERSCARE_BLUE = nvgRGB(0x24, 0x44, 0xC1);
static const NVGcolor COLOR_COMPUTERSCARE_PINK = nvgRGB(0xAA, 0x18, 0x31);
static const NVGcolor COLOR_COMPUTERSCARE_TRANSPARENT = nvgRGBA(0x00, 0x00, 0x00, 0x00);
static const NVGcolor BLACK = nvgRGB(0x00, 0x00, 0x00);
static const NVGcolor COLOR_COMPUTERSCARE_BLACK = nvgRGB(0x00, 0x00, 0x00);


namespace rack {
Expand Down Expand Up @@ -73,10 +73,10 @@ struct ComputerscareSvgPort : PortWidget {

} // namespace app
} // namespace rack
struct BGPanel : Widget {
struct ComputerscareBGPanel : Widget {
NVGcolor color;

BGPanel(NVGcolor _color) {
ComputerscareBGPanel(NVGcolor _color) {
color = _color;
}

Expand Down Expand Up @@ -375,8 +375,8 @@ struct SmoothKnobNoRandom : RoundKnob {
setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-medium-knob-effed.svg")));
}
};
struct SmallKnob : RoundKnob {
SmallKnob() {
struct ComputerscareSmallKnob : RoundKnob {
ComputerscareSmallKnob() {
setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-small-knob-effed.svg")));
}
};
Expand Down Expand Up @@ -424,7 +424,7 @@ struct BigSmoothKnob : RoundKnob {
setSvg(APP->window->loadSvg(asset::plugin(pluginInstance, "res/computerscare-big-knob-effed.svg")));
}
};
struct ComputerscareDotKnob : SmallKnob {
struct ComputerscareDotKnob : ComputerscareSmallKnob {
ComputerscareDotKnob() {

}
Expand Down Expand Up @@ -456,21 +456,21 @@ struct ComputerscareTextField : ui::TextField {
nvgFillColor(args.vg, COLOR_COMPUTERSCARE_PINK);
}
else {
nvgFillColor(args.vg, nvgRGB(0x00, 0x00, 0x00));
nvgFillColor(args.vg, rack::settings::preferDarkPanels ? nvgRGB(0x1f, 0x1f, 0x26) : nvgRGB(0x00, 0x00, 0x00));
}
nvgFill(args.vg);

if (dimWithRoom) {
drawText(args);
}
}
void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
void drawLayer(const ComputerscareBGPanel::DrawArgs& args, int layer) override {
if (layer == 1 && !dimWithRoom) {
drawText(args);
}
Widget::drawLayer(args, layer);
}
void drawText(const BGPanel::DrawArgs& args) {
void drawText(const ComputerscareBGPanel::DrawArgs& args) {
std::shared_ptr<Font> font = APP->window->loadFont(asset::system(fontPath));
if (font) {
// Text
Expand Down Expand Up @@ -572,6 +572,51 @@ struct SmallLetterDisplay : Widget {
}
};

struct SmallLetterDisplayThemed : Widget {

std::string value;
std::string fontPath;
int fontSize = 19;
std::string defaultFontPath = "res/Oswald-Regular.ttf";
NVGcolor baseColor = COLOR_COMPUTERSCARE_TRANSPARENT;
Vec textOffset = Vec(0, 0);

float letterSpacing = 2.5;
int textAlign = 1;
bool active = false;
bool blink = false;
bool doubleblink = false;
float breakRowWidth = 80.f;

SmallLetterDisplayThemed() {
value = "";
fontPath = asset::plugin(pluginInstance, defaultFontPath);
};
SmallLetterDisplayThemed(std::string providedFontPath) {
value = "";
fontPath = asset::plugin(pluginInstance, providedFontPath);
};

void draw(const DrawArgs &ctx) override
{
// labels
std::shared_ptr<Font> font = APP->window->loadFont(fontPath);
if (font) {
nvgFontFaceId(ctx.vg, font->handle);
nvgFontSize(ctx.vg, fontSize);

nvgTextLetterSpacing(ctx.vg, letterSpacing);
nvgTextLineHeight(ctx.vg, 0.7);
nvgTextAlign(ctx.vg, textAlign);

Vec textPos = Vec(6.0f, 12.0f).plus(textOffset);
nvgFillColor(ctx.vg, rack::settings::preferDarkPanels ? nvgRGB(0xef, 0xef, 0xff) : nvgRGB(0x10, 0x10, 0x00));
nvgTextBox(ctx.vg, textPos.x, textPos.y, breakRowWidth, value.c_str(), NULL);
}

}
};

#include "pointFunctions.hpp"
#include "drawFunctions.hpp"
#include "ComputerscarePolyModule.hpp"
Expand Down
29 changes: 24 additions & 5 deletions src/ComputerscareBlank.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <algorithm>

struct ComputerscareBlank : ComputerscareMenuParamModule {
ComputerscareBlank *module;
bool loading = true;
bool loadedJSON = false;
bool jsonFlag = false;
Expand Down Expand Up @@ -343,11 +344,21 @@ struct ComputerscareBlank : ComputerscareMenuParamModule {
}
void loadImageDialog(int index = 0) {
std::string dir = this->paths[index].empty() ? asset::user("../") : asset::user(this->paths[index]);
#ifdef USING_CARDINAL_NOT_RACK
ComputerscareBlank *module = this->module;
async_dialog_filebrowser(false, NULL, dir.c_str(), "Load image", [this](char* pathC) {
pathSelected(pathC);
});
#else
char* pathC = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, NULL);
pathSelected(pathC);
#endif
}

void pathSelected(char* pathC) {
if (!pathC) {
return;
}

std::string path = pathC;
std::free(pathC);

Expand Down Expand Up @@ -892,7 +903,7 @@ struct tPNGDisplay : TBase {

void setOffsets() {
}
void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
void drawLayer(const ComputerscareBGPanel::DrawArgs& args, int layer) override {
if (layer == 1 && lightWidgetMode) {
drawImage(args);
}
Expand All @@ -904,7 +915,7 @@ struct tPNGDisplay : TBase {
}
}

void drawImage(const BGPanel::DrawArgs& args) {
void drawImage(const ComputerscareBGPanel::DrawArgs& args) {
if (blankModule && blankModule->loadedJSON) {
std::string modulePath = blankModule->getPath();
if (path != modulePath) {
Expand Down Expand Up @@ -1087,7 +1098,7 @@ struct ComputerscareBlankWidget : ModuleWidget {
box.size = Vec(8 * 15, 380);
}
{
BGPanel *bgPanel = new BGPanel(nvgRGB(0xE0, 0xE0, 0xD9));
ComputerscareBGPanel *bgPanel = new ComputerscareBGPanel(nvgRGBA(0x00, 0x00, 0x00, 0x00));
bgPanel->box.size = box.size;
this->bgPanel = bgPanel;
addChild(bgPanel);
Expand Down Expand Up @@ -1124,6 +1135,14 @@ struct ComputerscareBlankWidget : ModuleWidget {

}

void draw(const rack::Widget::DrawArgs &args) {
nvgBeginPath(args.vg);
nvgRect(args.vg, 0.0, 0.0, box.size.x, box.size.y);
nvgFillColor(args.vg, rack::settings::preferDarkPanels ? nvgRGB(0x1f, 0x1f, 0x26) : nvgRGB(0xe0, 0xe0, 0xd9));
nvgFill(args.vg);
ModuleWidget::draw(args);
}

void appendContextMenu(Menu* menu) override {
ComputerscareBlank* blank = dynamic_cast<ComputerscareBlank*>(this->blankModule);

Expand Down Expand Up @@ -1308,7 +1327,7 @@ struct ComputerscareBlankWidget : ModuleWidget {
ComputerscareBlank *blankModule;
PNGDisplay *pngDisplay;
ComputerscareSVGPanel *panel;
BGPanel *bgPanel;
ComputerscareBGPanel *bgPanel;
TransparentWidget *display;
ComputerscareResizeHandle *leftHandle;
ComputerscareResizeHandle *rightHandle;
Expand Down
8 changes: 4 additions & 4 deletions src/ComputerscareBlankExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,18 @@ struct ComputerscareBlankExpander : Module {
scrubbing = scrub;
}
};
struct FrameScrubKnob : SmallKnob {
struct FrameScrubKnob : ComputerscareSmallKnob {
ComputerscareBlankExpander* module;
void onDragStart(const event::DragStart& e) override {
module->setScrubbing(true);
SmallKnob::onDragStart(e);
ComputerscareSmallKnob::onDragStart(e);
}
void onDragEnd(const event::DragEnd& e) override {
module->setScrubbing(false);
SmallKnob::onDragEnd(e);
ComputerscareSmallKnob::onDragEnd(e);
}
void onDragMove(const event::DragMove& e) override {
SmallKnob::onDragMove(e);
ComputerscareSmallKnob::onDragMove(e);
};
};
struct ClockModeButton : app::SvgSwitch {
Expand Down
8 changes: 4 additions & 4 deletions src/ComputerscareDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ struct StringDisplayWidget3 : Widget {
void draw(const DrawArgs &ctx) override
{
// Background
NVGcolor backgroundColor = nvgRGB(0x10, 0x00, 0x10);
NVGcolor backgroundColor = rack::settings::preferDarkPanels ? nvgRGB(0x1f, 0x1f, 0x26) : nvgRGB(0x10, 0x00, 0x10);
NVGcolor StrokeColor = nvgRGB(0xC0, 0xC7, 0xDE);
nvgBeginPath(ctx.vg);
nvgRoundedRect(ctx.vg, -1.0, -1.0, box.size.x + 2, box.size.y + 2, 4.0);
Expand All @@ -361,7 +361,7 @@ struct StringDisplayWidget3 : Widget {
nvgFillColor(ctx.vg, backgroundColor);
nvgFill(ctx.vg);
}
void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
void drawLayer(const ComputerscareBGPanel::DrawArgs& args, int layer) override {
if (layer == 1) {

std::shared_ptr<Font> font = APP->window->loadFont(asset::plugin(pluginInstance, fontPath));
Expand All @@ -380,7 +380,7 @@ struct StringDisplayWidget3 : Widget {
Widget::drawLayer(args, layer);
}
};
struct ConnectedSmallLetter : SmallLetterDisplay {
struct ConnectedSmallLetter : SmallLetterDisplayThemed {
ComputerscareDebug *module;
int index;
ConnectedSmallLetter(int dex) {
Expand Down Expand Up @@ -410,7 +410,7 @@ struct ConnectedSmallLetter : SmallLetterDisplay {
}
}
}
SmallLetterDisplay::draw(ctx);
SmallLetterDisplayThemed::draw(ctx);
}
};
struct ComputerscareDebugWidget : ModuleWidget {
Expand Down
4 changes: 2 additions & 2 deletions src/ComputerscareFolyPace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ struct FolyPaceDisplay : TransparentWidget {
}
}
}
void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
void drawLayer(const ComputerscareBGPanel::DrawArgs& args, int layer) override {
if (layer == 1 && module) {
if (module->faceEmitsLight) {
drawFace(args, module->bufferX[0][0], module->bufferX[1][0], module->bufferX[2][0], module->bufferX[3][0], module->bufferX[4][0], module->bufferX[5][0], module->bufferX[6][0], module->bufferX[7][0], module->bufferX[8][0], module->bufferX[9][0], module->bufferX[10][0], module->bufferX[11][0], module->bufferX[12][0], module->bufferX[13][0], module->bufferX[14][0], module->bufferX[15][0]);
Expand Down Expand Up @@ -403,7 +403,7 @@ struct FolyPaceWidget : ModuleWidget {
}

addInput(createInput<PointingUpPentagonPort>(Vec(1, 353), module, FolyPace::X_INPUT));
addParam(createParam<SmallKnob>(Vec(31, 357), module, FolyPace::TRIM));
addParam(createParam<ComputerscareSmallKnob>(Vec(31, 357), module, FolyPace::TRIM));
addParam(createParam<SmoothKnob>(Vec(51, 353), module, FolyPace::OFFSET));
addParam(createParam<ScrambleKnob>(Vec(81, 357), module, FolyPace::SCRAMBLE));
}
Expand Down
6 changes: 3 additions & 3 deletions src/ComputerscareGolyPenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct PeneratorDisplay : TransparentWidget {
PeneratorDisplay() {

}
void drawLayer(const BGPanel::DrawArgs& args, int layer) override {
void drawLayer(const ComputerscareBGPanel::DrawArgs& args, int layer) override {
if (layer == 1) {
float valsToDraw[16] = {1.f};
int ch = 16;
Expand Down Expand Up @@ -214,8 +214,8 @@ struct ComputerscareGolyPeneratorWidget : ModuleWidget {

addLabeledKnob<ScrambleSnapKnob>("Algo", 4, 324, module, ComputerscareGolyPenerator::ALGORITHM, 0, 0, true);
addLabeledKnob<SmoothKnob>("center", 28, 80, module, ComputerscareGolyPenerator::IN_OFFSET, 0, 0);
addLabeledKnob<SmallKnob>("spread", 5, 86, module, ComputerscareGolyPenerator::IN_SCALE, 0, 0);
addLabeledKnob<SmallKnob>("scale", 33, 290, module, ComputerscareGolyPenerator::OUT_SCALE, 0, 0);
addLabeledKnob<ComputerscareSmallKnob>("spread", 5, 86, module, ComputerscareGolyPenerator::IN_SCALE, 0, 0);
addLabeledKnob<ComputerscareSmallKnob>("scale", 33, 290, module, ComputerscareGolyPenerator::OUT_SCALE, 0, 0);
addLabeledKnob<SmoothKnob>("offset", 2, 284, module, ComputerscareGolyPenerator::OUT_OFFSET, 0, 0);

channelWidget = new PolyOutputChannelsWidget(Vec(28, 309), module, ComputerscareGolyPenerator::POLY_CHANNELS);
Expand Down
4 changes: 2 additions & 2 deletions src/ComputerscareHorseADoodleDoo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,13 +958,13 @@ struct ComputerscareHorseADoodleDooWidget : ModuleWidget {
addChild(numStepsKnob);
if (knobType == 1) {
//trim knob
//addParam(createParam<SmallKnob>(Vec(x + 30, y), module, knobIndex + 1));
//addParam(createParam<ComputerscareSmallKnob>(Vec(x + 30, y), module, knobIndex + 1));
//addInput(createInput<TinyJack>(Vec(x + 40, y), module, inputIndex));
//addParam(createParam<ScrambleKnob>(Vec(x+30, y+20), module, scrambleIndex));

}
}
addParam(createParam<SmallKnob>(Vec(x + 32, y + 5), module, knobIndex + 1));
addParam(createParam<ComputerscareSmallKnob>(Vec(x + 32, y + 5), module, knobIndex + 1));
addInput(createInput<TinyJack>(Vec(x + 54, y + 6), module, inputIndex));
if (allowScrambleRandom) {
addParam(createParam<ScrambleKnob>(Vec(x + 55, y - 15), module, scrambleIndex));
Expand Down
6 changes: 3 additions & 3 deletions src/ComputerscareILoveCookies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget {


//label for knob a-z
smallLetterDisplay = new SmallLetterDisplay();
smallLetterDisplay = new SmallLetterDisplayThemed();
smallLetterDisplay->box.pos = mm2px(Vec(knobPosX + 6, knobPosY - 2));
smallLetterDisplay->box.size = Vec(20, 20);
smallLetterDisplay->value = knoblookup[index];
Expand Down Expand Up @@ -614,7 +614,7 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget {
}

//label for input A-Z
smallLetterDisplay = new SmallLetterDisplay();
smallLetterDisplay = new SmallLetterDisplayThemed();
smallLetterDisplay->box.pos = mm2px(Vec(inputPosX + 6, inputPosY - 1));
smallLetterDisplay->box.size = Vec(20, 20);
smallLetterDisplay->value = inputlookup[inputindex];
Expand Down Expand Up @@ -726,7 +726,7 @@ struct ComputerscareILoveCookiesWidget : ModuleWidget {
CookiesSmallDisplay* cookiesSmallDisplay;
CookiesSmallDisplay* cookiesSmallDisplays[numFields];

SmallLetterDisplay* smallLetterDisplay;
SmallLetterDisplayThemed* smallLetterDisplay;

CookiesCurrentStepDisplay* currentWorkingStepDisplay;
CookiesCurrentStepDisplay* currentWorkingStepDisplays[numFields];
Expand Down
8 changes: 4 additions & 4 deletions src/ComputerscareKnolyPobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ struct ComputerscareKnolyPobs : ComputerscarePolyModule {
}
};

struct NoRandomSmallKnob : SmallKnob {
struct NoRandomSmallKnob : ComputerscareSmallKnob {
NoRandomSmallKnob() {
SmallKnob();
ComputerscareSmallKnob();
};
};
struct NoRandomMediumSmallKnob : RoundKnob {
Expand Down Expand Up @@ -148,7 +148,7 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget {
}
void addLabeledKnob(std::string label, int x, int y, ComputerscareKnolyPobs *module, int index, float labelDx, float labelDy) {

smallLetterDisplay = new SmallLetterDisplay();
smallLetterDisplay = new SmallLetterDisplayThemed();
smallLetterDisplay->box.size = Vec(5, 10);
smallLetterDisplay->fontSize = 18;
smallLetterDisplay->value = label;
Expand All @@ -173,7 +173,7 @@ struct ComputerscareKnolyPobsWidget : ModuleWidget {
PolyOutputChannelsWidget* channelWidget;
PolyChannelsDisplay* channelDisplay;
DisableableSmoothKnob* fader;
SmallLetterDisplay* smallLetterDisplay;
SmallLetterDisplayThemed* smallLetterDisplay;
};

Model *modelComputerscareKnolyPobs = createModel<ComputerscareKnolyPobs, ComputerscareKnolyPobsWidget>("computerscare-knolypobs");
1 change: 1 addition & 0 deletions src/ComputerscareLaundrySoup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ struct ComputerscareLaundrySoup : Module {
shouldChange[index] = true;
}
void checkChannelCount(int index) {
channelCountEnum[index] = -1;
if (channelCountEnum[index] == -1) {
if (currentFormula[index].find("#") != std::string::npos) {
channelCount[index] = 16;
Expand Down
2 changes: 1 addition & 1 deletion src/ComputerscareOhPeas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ struct ComputerscareOhPeasWidget : ModuleWidget
y += randAmt * (random::uniform() - .5);
addInput(createInput<InPort>(mm2px(Vec(xx, y - 0.8)), module, ComputerscareOhPeas::CHANNEL_INPUT + i));

addParam(createParam<SmallKnob>(mm2px(Vec(xx + 2, y + 34)), module, ComputerscareOhPeas::SCALE_TRIM + i));
addParam(createParam<ComputerscareSmallKnob>(mm2px(Vec(xx + 2, y + 34)), module, ComputerscareOhPeas::SCALE_TRIM + i));

addInput(createInput<InPort>(mm2px(Vec(xx, y + 40)), module, ComputerscareOhPeas::SCALE_CV + i));

Expand Down
Loading