From cc610760d6380582248a910ec36ac594523b647d Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 7 Nov 2021 03:21:21 +0000 Subject: [PATCH] Full dark mode --- src/override/dep.cpp | 294 ++++++++++++++++++++++++++++++++----------- 1 file changed, 222 insertions(+), 72 deletions(-) diff --git a/src/override/dep.cpp b/src/override/dep.cpp index ef5ef35..c3ea953 100644 --- a/src/override/dep.cpp +++ b/src/override/dep.cpp @@ -45,170 +45,263 @@ float FollowerBase::efGainMaxDecibelsDebug = 12.0f; // Custom Cardinal filtering static const struct { - const char* filename; + const char* const filename; const char* shapes[4]; } pathsToFilterOut[] = { { - "Core/AudioInterface.svg", + "/Core/AudioInterface.svg", {"path39377","path39381","path39383","path39379"} }, { - "Core/AudioInterface2.svg", + "/Core/AudioInterface2.svg", {"path18733","path18737","path18731","path18735"} }, { - "Core/AudioInterface16.svg", + "/Core/AudioInterface16.svg", {"path40283","path40287","path40289","path40285"} }, { - "Core/CV-CC.svg", + "/Core/CV-CC.svg", {"path12881","path12885","path12887","path12883"} }, { - "Core/CV-Gate.svg", + "/Core/CV-Gate.svg", {"path13127","path13131","path13133","path13129"} }, { - "Core/CV-MIDI.svg", + "/Core/CV-MIDI.svg", {"path12747","path12751","path12753","path12749"} }, { - "Core/MIDI-CC.svg", + "/Core/MIDI-CC.svg", {"path9740","path9744","path9746","path9742"} }, { - "Core/MIDI-CV.svg", + "/Core/MIDI-CV.svg", {"path11803","path11807","path11809","path11805"} }, { - "Core/MIDI-Gate.svg", + "/Core/MIDI-Gate.svg", {"path11634","path11638","path11640","path11636"} }, { - "Core/MIDI-Map.svg", + "/Core/MIDI-Map.svg", {"path21209","path21213","path21215","path21211"} }, { - "Core/Notes.svg", + "/Core/Notes.svg", {"path6935","path6939","path6941","path6937"} }, { - "Fundamental/8vert.svg", + "/Fundamental/8vert.svg", {"path69642","path69646","path69640","path69644"} }, { - "Fundamental/ADSR.svg", + "/Fundamental/ADSR.svg", {"path33693","path33697","path33699","path33695"} }, { - "Fundamental/Delay.svg", + "/Fundamental/Delay.svg", {"path25369","path25373","path25375","path25371"} }, { - "Fundamental/LFO-1.svg", + "/Fundamental/LFO-1.svg", {"path35889","path35893","path35895","path35891"} }, { - "Fundamental/LFO-2.svg", + "/Fundamental/LFO-2.svg", {"path36131","path36135","path36137","path36133"} }, { - "Fundamental/Merge.svg", + "/Fundamental/Merge.svg", {"path29991","path29995","path29989","path29993"} }, { - "Fundamental/MidSide.svg", + "/Fundamental/MidSide.svg", {"path44181","path44185","path44179","path44183"} }, { - "Fundamental/Mutes.svg", + "/Fundamental/Mutes.svg", {"path21613","path21617","path21611","path21615"} }, { - "Fundamental/Noise.svg", + "/Fundamental/Noise.svg", {"path105594","path105598","path105592","path105596"} }, { - "Fundamental/Octave.svg", + "/Fundamental/Octave.svg", {"path38471","path38475","path38469","path38473"} }, { - "Fundamental/Pulses.svg", + "/Fundamental/Pulses.svg", {"path46241","path46245","path46239","path46243"} }, { - "Fundamental/Quantizer.svg", + "/Fundamental/Quantizer.svg", {"path38549","path38553","path38547","path38551"} }, { - "Fundamental/Random.svg", + "/Fundamental/Random.svg", {"path89732","path89736","path89730","path89734"} }, { - "Fundamental/SEQ3.svg", + "/Fundamental/SEQ3.svg", {"path35687","path35691","path35693","path35689"} }, { - "Fundamental/Scope.svg", + "/Fundamental/Scope.svg", {"path33887","path33891","path33893","path33889"} }, - // These 2 do not have logos on them { - "Fundamental/SequentialSwitch1.svg", - {nullptr,nullptr,nullptr,nullptr} - }, - { - "Fundamental/SequentialSwitch2.svg", - {nullptr,nullptr,nullptr,nullptr} - }, - { - "Fundamental/Split.svg", + "/Fundamental/Split.svg", {"path29999","path30003","path29997","path30001"} }, { - "Fundamental/Sum.svg", + "/Fundamental/Sum.svg", {"path10913","path10917","path10911","path10915"} }, { - "Fundamental/Unity.svg", + "/Fundamental/Unity.svg", {"path21219","path21223","path21217","path21221"} }, - // These 2 also do not have logos on them - { - "Fundamental/VCA-1.svg", - {nullptr,nullptr,nullptr,nullptr} - }, - { - "Fundamental/VCA.svg", - {nullptr,nullptr,nullptr,nullptr} - }, { - "Fundamental/VCF.svg", + "/Fundamental/VCF.svg", {"path25239","path25243","path25245","path25241"} }, { - "Fundamental/VCMixer.svg", + "/Fundamental/VCMixer.svg", {"path125839","path125843","path125845","path125841"} }, { - "Fundamental/VCO-1.svg", + "/Fundamental/VCO-1.svg", {"path33533","path33537","path33539","path33535"} }, { - "Fundamental/VCO-2.svg", + "/Fundamental/VCO-2.svg", {"path37557","path37561","path37563","path37559"} }, { - "Fundamental/Viz.svg", + "/Fundamental/Viz.svg", {"path41769","path41773","path41767","path41771"} }, }; +static const struct { + const char* const filename; + const char* shapeIdsToIgnore[5]; + const int shapeNumberToIgnore; +} svgFilesToInvert[] = { + { "/AnimatedCircuits/FoldingLight.svg", {}, -1 }, + { "/AudibleInstruments/Blinds.svg", {}, -1 }, + { "/AudibleInstruments/Braids.svg", {}, -1 }, + { "/AudibleInstruments/Branches.svg", {}, -1 }, + { "/AudibleInstruments/Clouds.svg", {}, -1 }, + { "/AudibleInstruments/Elements.svg", {}, -1 }, + { "/AudibleInstruments/Frames.svg", {}, -1 }, + { "/AudibleInstruments/Kinks.svg", {}, -1 }, + { "/AudibleInstruments/Links.svg", {}, -1 }, + { "/AudibleInstruments/Marbles.svg", {}, -1 }, + { "/AudibleInstruments/Peaks.svg", {}, -1 }, + { "/AudibleInstruments/Plaits.svg", {}, -1 }, + { "/AudibleInstruments/Rings.svg", {}, -1 }, + { "/AudibleInstruments/Ripples.svg", {}, -1 }, + { "/AudibleInstruments/Shades.svg", {}, -1 }, + { "/AudibleInstruments/Sheep.svg", {}, -1 }, + { "/AudibleInstruments/Shelves.svg", {}, -1 }, + { "/AudibleInstruments/Stages.svg", {}, -1 }, + { "/AudibleInstruments/Streams.svg", {}, -1 }, + { "/AudibleInstruments/Tides.svg", {}, -1 }, + { "/AudibleInstruments/Tides2.svg", {}, -1 }, + { "/AudibleInstruments/Veils.svg", {}, -1 }, + { "/AudibleInstruments/Warps.svg", {}, -1 }, + { "/Bidoo/ACNE.svg", {}, -1 }, + { "/Bidoo/ANTN.svg", {}, -1 }, + { "/Bidoo/BAFIS.svg", {}, -1 }, + { "/Bidoo/BAR.svg", {"rect833"}, -1 }, + { "/Bidoo/BISTROT.svg", {}, -1 }, + { "/Bidoo/BORDL.svg", {"rect959-3-0-7-5","rect959-3-0-7","rect959-3-0","rect959-3"}, -1 }, + { "/Bidoo/CANARD.svg", {"rect959-3-7"}, -1 }, + { "/Bidoo/CHUTE.svg", {}, -1 }, + { "/Bidoo/DFUZE.svg", {}, -1 }, + { "/Bidoo/DIKTAT.svg", {"rect843","rect843-0","rect843-0-8"}, -1 }, + { "/Bidoo/DTROY.svg", {"rect959-3"}, -1 }, + { "/Bidoo/DUKE.svg", {}, -1 }, + { "/Bidoo/EMILE.svg", {}, -1 }, + { "/Bidoo/FLAME.svg", {}, -1 }, + { "/Bidoo/FORK.svg", {}, -1 }, + { "/Bidoo/FREIN.svg", {}, -1 }, + { "/Bidoo/HCTIP.svg", {}, -1 }, + { "/Bidoo/HUITRE.svg", {}, -1 }, + { "/Bidoo/LATE.svg", {}, -1 }, + { "/Bidoo/LIMBO.svg", {}, -1 }, + { "/Bidoo/LIMONADE.svg", {"rect839","rect839-6"}, -1 }, + { "/Bidoo/LOURDE.svg", {}, -1 }, + { "/Bidoo/MAGMA.svg", {}, -1 }, + { "/Bidoo/MINIBAR.svg", {"rect833"}, -1 }, + { "/Bidoo/MOIRE.svg", {"rect843","rect843-7"}, -1 }, + { "/Bidoo/MS.svg", {}, -1 }, + { "/Bidoo/MU.svg", {"rect864"}, -1 }, + { "/Bidoo/OAI.svg", {}, -1 }, + { "/Bidoo/OUAIVE.svg", {"rect959-3-7"}, -1 }, + { "/Bidoo/PERCO.svg", {}, -1 }, + { "/Bidoo/PILOT.svg", {"rect843-6-4-5","rect843","rect843-4","rect843-6-4","rect843-6-7"}, -1 }, + { "/Bidoo/POUPRE.svg", {}, -1 }, + { "/Bidoo/RABBIT.svg", {}, -1 }, + { "/Bidoo/REI.svg", {}, -1 }, + { "/Bidoo/SIGMA.svg", {}, -1 }, + { "/Bidoo/TIARE.svg", {}, -1 }, + { "/Bidoo/TOCANTE.svg", {"rect843"}, -1 }, + { "/Bidoo/VOID.svg", {}, -1 }, + { "/Bidoo/ZINC.svg", {}, -1 }, + { "/Bidoo/ZOUMAI.svg", {}, -1 }, + { "/cf/ALGEBRA.svg", {}, -1 }, + { "/cf/BUFFER.svg", {}, -1 }, + { "/cf/CHOKE.svg", {}, -1 }, + { "/cf/CUBE.svg", {}, -1 }, + { "/cf/CUTS.svg", {}, -1 }, + { "/cf/DISTO.svg", {}, -1 }, + { "/cf/EACH.svg", {}, -1 }, + { "/cf/FOUR.svg", {}, -1 }, + { "/cf/FUNKTION.svg", {}, -1 }, + { "/cf/L3DS3Q.svg", {}, 3 }, + { "/cf/LABEL.svg", {}, -1 }, + { "/cf/LEDS.svg", {}, -1 }, + { "/cf/LEDSEQ.svg", {}, 3 }, + { "/cf/MASTER.svg", {}, -1 }, + { "/cf/METRO.svg", {}, -1 }, + { "/cf/MONO.svg", {}, -1 }, + { "/cf/PATCH.svg", {}, -1 }, + { "/cf/PEAK.svg", {}, -1 }, + { "/cf/PLAY.svg", {}, -1 }, + { "/cf/PLAYER.svg", {}, -1 }, + { "/cf/SLIDERSEQ.svg", {}, -1 }, + { "/cf/STEPS.svg", {}, -1 }, + { "/cf/STEREO.svg", {}, -1 }, + { "/cf/SUB.svg", {}, -1 }, + { "/cf/trSEQ.svg", {}, -1 }, + { "/cf/VARIABLE.svg", {}, -1 }, + { "/DrumKit/Baronial.svg", {}, -1 }, + { "/DrumKit/BD9.svg", {}, -1 }, + { "/DrumKit/ClosedHH.svg", {}, -1 }, + { "/DrumKit/CR78.svg", {}, -1 }, + { "/DrumKit/DMX.svg", {}, -1 }, + { "/DrumKit/Gnome.svg", {}, -1 }, + { "/DrumKit/Marionette.svg", {}, -1 }, + { "/DrumKit/OpenHH.svg", {}, -1 }, + { "/DrumKit/SBD.svg", {}, -1 }, + { "/DrumKit/Sequencer.svg", {}, -1 }, + { "/DrumKit/Snare.svg", {}, -1 }, + { "/DrumKit/Tomi.svg", {}, -1 }, + { "/Fundamental/SequentialSwitch1.svg", {}, -1 }, + { "/Fundamental/SequentialSwitch2.svg", {}, -1 }, + { "/Fundamental/VCA-1.svg", {}, -1 }, + { "/Fundamental/VCA.svg", {}, -1 }, +}; static void removeShape(NSVGimage* const handle, const char* const id) { for (NSVGshape *shape = handle->shapes, *old = nullptr; shape != nullptr; old = shape, shape = shape->next) { - if (strcmp(shape->id, id) != 0) + if (std::strcmp(shape->id, id) != 0) continue; if (old != nullptr) @@ -222,28 +315,48 @@ static void removeShape(NSVGimage* const handle, const char* const id) } } -static void invertPaint(NSVGpaint& paint) +static bool invertPaint(NSVGpaint& paint, const char* const svgFileToInvert = nullptr) { + // Special case for DrumKit background grandient + if (paint.type == NSVG_PAINT_LINEAR_GRADIENT && svgFileToInvert != nullptr && std::strncmp(svgFileToInvert, "/DrumKit/", 9) == 0) + { + paint.type = NSVG_PAINT_COLOR; + paint.color = 0xff000000; + return true; + } + if (paint.type != NSVG_PAINT_COLOR) - return; + return false; + + // Special case for Bidoo red color + if (paint.color == 0xff001fcd && svgFileToInvert != nullptr && std::strncmp(svgFileToInvert, "/Bidoo/", 7) == 0) + { + paint.color = 0xcf8b94c4; + return true; + } switch (paint.color) { - // scope (do nothing) + // scopes or other special things (do nothing) case 0x40ffffff: + case 0xff004200: case 0xff2b281e: - break; + case 0xff2d2827: + case 0xff303030: + case 0xff362c23: + case 0xff40352c: + return false; // pure black (convert to not quite pure white) case 0xff000000: paint.color = 0xffd0d0d0; - break; + return true; // all others (direct invert) default: paint.color = (paint.color & 0xff000000) | (0xff0000 - (paint.color & 0xff0000)) | (0xff00 - (paint.color & 0xff00)) | (0xff - (paint.color & 0xff)); - break; + return true; } } @@ -263,24 +376,61 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con if (filenamelen < filterlen) continue; + if (std::strncmp(filename + (filenamelen-filterlen), pathToFilterOut, filterlen) != 0) + continue; + + puts("Removing CC-ND deadlock from file..."); + removeShape(handle, pathsToFilterOut[i].shapes[0]); + removeShape(handle, pathsToFilterOut[i].shapes[1]); + removeShape(handle, pathsToFilterOut[i].shapes[2]); + removeShape(handle, pathsToFilterOut[i].shapes[3]); - if (std::strncmp(filename + (filenamelen-filterlen), pathToFilterOut, filterlen) == 0) + for (NSVGshape* shape = handle->shapes; shape != nullptr; shape = shape->next) { - if (pathsToFilterOut[i].shapes[0] != nullptr) - { - puts("Removing CC-ND deadlock from file..."); - removeShape(handle, pathsToFilterOut[i].shapes[0]); - removeShape(handle, pathsToFilterOut[i].shapes[1]); - removeShape(handle, pathsToFilterOut[i].shapes[2]); - removeShape(handle, pathsToFilterOut[i].shapes[3]); - } + invertPaint(shape->fill); + invertPaint(shape->stroke); + } + + return handle; + } + + for (size_t i = 0; i < sizeof(svgFilesToInvert)/sizeof(svgFilesToInvert[0]); ++i) + { + const char* const svgFileToInvert = svgFilesToInvert[i].filename; + const size_t filenamelen = std::strlen(filename); + const size_t filterlen = std::strlen(svgFileToInvert); - for (NSVGshape* shape = handle->shapes; shape != nullptr; shape = shape->next) + if (filenamelen < filterlen) + continue; + if (std::strncmp(filename + (filenamelen-filterlen), svgFileToInvert, filterlen) != 0) + continue; + + const char* const* const shapeIdsToIgnore = svgFilesToInvert[i].shapeIdsToIgnore; + const int shapeNumberToIgnore = svgFilesToInvert[i].shapeNumberToIgnore; + int shapeCounter = 0; + + for (NSVGshape* shape = handle->shapes; shape != nullptr; shape = shape->next, ++shapeCounter) + { + if (shapeNumberToIgnore == shapeCounter) + continue; + + bool ignore = false; + for (size_t j = 0; j < 5 && shapeIdsToIgnore[j] != nullptr; ++j) { - invertPaint(shape->fill); - invertPaint(shape->stroke); + if (std::strcmp(shape->id, shapeIdsToIgnore[j]) == 0) + { + ignore = true; + break; + } } + if (ignore) + continue; + + if (invertPaint(shape->fill, svgFileToInvert)) + invertPaint(shape->stroke, svgFileToInvert); } + + return handle; } return handle;