Ignore dynamic light/dark mode in headless builds
Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
parent
e4840dfbf0
commit
930a0ca31e
3 changed files with 24 additions and 0 deletions
|
|
@ -36,9 +36,11 @@
|
||||||
|
|
||||||
namespace rack {
|
namespace rack {
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
namespace asset {
|
namespace asset {
|
||||||
void updateForcingBlackSilverScrewMode(std::string slug);
|
void updateForcingBlackSilverScrewMode(std::string slug);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
struct CardinalPluginModelHelper : plugin::Model {
|
struct CardinalPluginModelHelper : plugin::Model {
|
||||||
virtual app::ModuleWidget* createModuleWidgetFromEngineLoad(engine::Module* m) = 0;
|
virtual app::ModuleWidget* createModuleWidgetFromEngineLoad(engine::Module* m) = 0;
|
||||||
|
|
@ -76,7 +78,9 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
||||||
}
|
}
|
||||||
tm = dynamic_cast<TModule*>(m);
|
tm = dynamic_cast<TModule*>(m);
|
||||||
}
|
}
|
||||||
|
#ifndef HEADLESS
|
||||||
asset::updateForcingBlackSilverScrewMode(slug);
|
asset::updateForcingBlackSilverScrewMode(slug);
|
||||||
|
#endif
|
||||||
app::ModuleWidget* const tmw = new TModuleWidget(tm);
|
app::ModuleWidget* const tmw = new TModuleWidget(tm);
|
||||||
DISTRHO_CUSTOM_SAFE_ASSERT_RETURN(m != nullptr ? m->model->name.c_str() : "null", tmw->module == m, nullptr);
|
DISTRHO_CUSTOM_SAFE_ASSERT_RETURN(m != nullptr ? m->model->name.c_str() : "null", tmw->module == m, nullptr);
|
||||||
tmw->setModel(this);
|
tmw->setModel(this);
|
||||||
|
|
@ -91,7 +95,9 @@ struct CardinalPluginModel : CardinalPluginModelHelper
|
||||||
TModule* const tm = dynamic_cast<TModule*>(m);
|
TModule* const tm = dynamic_cast<TModule*>(m);
|
||||||
DISTRHO_SAFE_ASSERT_RETURN(tm != nullptr, nullptr);
|
DISTRHO_SAFE_ASSERT_RETURN(tm != nullptr, nullptr);
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
asset::updateForcingBlackSilverScrewMode(slug);
|
asset::updateForcingBlackSilverScrewMode(slug);
|
||||||
|
#endif
|
||||||
TModuleWidget* const tmw = new TModuleWidget(tm);
|
TModuleWidget* const tmw = new TModuleWidget(tm);
|
||||||
DISTRHO_SAFE_ASSERT_RETURN(tmw->module == m, nullptr);
|
DISTRHO_SAFE_ASSERT_RETURN(tmw->module == m, nullptr);
|
||||||
tmw->setModel(this);
|
tmw->setModel(this);
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@
|
||||||
namespace rack {
|
namespace rack {
|
||||||
namespace asset {
|
namespace asset {
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
extern bool forceBlackScrew;
|
extern bool forceBlackScrew;
|
||||||
extern bool forceSilverScrew;
|
extern bool forceSilverScrew;
|
||||||
|
#endif
|
||||||
|
|
||||||
std::string userDir; // ignored
|
std::string userDir; // ignored
|
||||||
std::string systemDir; // points to plugin resources dir (or installed/local Rack dir)
|
std::string systemDir; // points to plugin resources dir (or installed/local Rack dir)
|
||||||
|
|
@ -53,10 +55,12 @@ std::string user(std::string filename) {
|
||||||
|
|
||||||
// get system resource, trimming "res/" prefix if we are loaded as a plugin bundle
|
// get system resource, trimming "res/" prefix if we are loaded as a plugin bundle
|
||||||
std::string system(std::string filename) {
|
std::string system(std::string filename) {
|
||||||
|
#ifndef HEADLESS
|
||||||
/**/ if (forceBlackScrew && string::endsWith(filename, "/ScrewBlack.svg"))
|
/**/ if (forceBlackScrew && string::endsWith(filename, "/ScrewBlack.svg"))
|
||||||
filename = filename.substr(0, filename.size()-15) + "/./ScrewBlack.svg";
|
filename = filename.substr(0, filename.size()-15) + "/./ScrewBlack.svg";
|
||||||
else if (forceSilverScrew && string::endsWith(filename, "/ScrewSilver.svg"))
|
else if (forceSilverScrew && string::endsWith(filename, "/ScrewSilver.svg"))
|
||||||
filename = filename.substr(0, filename.size()-16) + "/./ScrewSilver.svg";
|
filename = filename.substr(0, filename.size()-16) + "/./ScrewSilver.svg";
|
||||||
|
#endif
|
||||||
return system::join(systemDir, bundlePath.empty() ? filename : trim(filename));
|
return system::join(systemDir, bundlePath.empty() ? filename : trim(filename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace rack {
|
namespace rack {
|
||||||
|
#ifndef HEADLESS
|
||||||
namespace asset {
|
namespace asset {
|
||||||
bool forceBlackScrew = false;
|
bool forceBlackScrew = false;
|
||||||
bool forceSilverScrew = false;
|
bool forceSilverScrew = false;
|
||||||
|
|
@ -59,6 +60,7 @@ void updateForcingBlackSilverScrewMode(std::string slug) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
namespace settings {
|
namespace settings {
|
||||||
bool darkMode = true;
|
bool darkMode = true;
|
||||||
int rateLimit = 0;
|
int rateLimit = 0;
|
||||||
|
|
@ -92,6 +94,7 @@ NVGcolor nvgRGBblank(const unsigned char r, const unsigned char g, const unsigne
|
||||||
#undef nsvgParseFromFile
|
#undef nsvgParseFromFile
|
||||||
#include <nanosvg.h>
|
#include <nanosvg.h>
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
enum DarkMode {
|
enum DarkMode {
|
||||||
kMode21kHz,
|
kMode21kHz,
|
||||||
kModeAaronStatic,
|
kModeAaronStatic,
|
||||||
|
|
@ -1149,12 +1152,14 @@ bool invertPaintForLightMode(const LightMode mode, NSVGshape* const shape, NSVGp
|
||||||
paint.color = invertColor(paint.color);
|
paint.color = invertColor(paint.color);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif // HEADLESS
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
NSVGimage* nsvgParseFromFileCardinal(const char* filename, const char* units, float dpi);
|
NSVGimage* nsvgParseFromFileCardinal(const char* filename, const char* units, float dpi);
|
||||||
void nsvgDeleteCardinal(NSVGimage*);
|
void nsvgDeleteCardinal(NSVGimage*);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef HEADLESS
|
||||||
struct ExtendedNSVGimage {
|
struct ExtendedNSVGimage {
|
||||||
NSVGimage* const handle;
|
NSVGimage* const handle;
|
||||||
NSVGimage* handleOrig;
|
NSVGimage* handleOrig;
|
||||||
|
|
@ -1239,11 +1244,13 @@ void deleteExtendedNSVGimage(ExtendedNSVGimage& ext)
|
||||||
ext.handleOrig = nullptr;
|
ext.handleOrig = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // HEADLESS
|
||||||
|
|
||||||
NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* const units, const float dpi)
|
NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* const units, const float dpi)
|
||||||
{
|
{
|
||||||
if (NSVGimage* const handle = nsvgParseFromFile(filename, units, dpi))
|
if (NSVGimage* const handle = nsvgParseFromFile(filename, units, dpi))
|
||||||
{
|
{
|
||||||
|
#ifndef HEADLESS
|
||||||
const size_t filenamelen = std::strlen(filename);
|
const size_t filenamelen = std::strlen(filename);
|
||||||
|
|
||||||
bool hasDarkMode = false;
|
bool hasDarkMode = false;
|
||||||
|
|
@ -1419,6 +1426,7 @@ postparse:
|
||||||
std::memcpy(handle, handleMOD, sizeof(NSVGimage));
|
std::memcpy(handle, handleMOD, sizeof(NSVGimage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // HEADLESS
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
@ -1428,6 +1436,7 @@ postparse:
|
||||||
|
|
||||||
void nsvgDeleteCardinal(NSVGimage* const handle)
|
void nsvgDeleteCardinal(NSVGimage* const handle)
|
||||||
{
|
{
|
||||||
|
#ifndef HEADLESS
|
||||||
for (auto it = loadedDarkSVGs.begin(), end = loadedDarkSVGs.end(); it != end; ++it)
|
for (auto it = loadedDarkSVGs.begin(), end = loadedDarkSVGs.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
ExtendedNSVGimage& ext(*it);
|
ExtendedNSVGimage& ext(*it);
|
||||||
|
|
@ -1451,12 +1460,14 @@ void nsvgDeleteCardinal(NSVGimage* const handle)
|
||||||
loadedLightSVGs.erase(it);
|
loadedLightSVGs.erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
nsvgDelete(handle);
|
nsvgDelete(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void switchDarkMode(const bool darkMode)
|
void switchDarkMode(const bool darkMode)
|
||||||
{
|
{
|
||||||
|
#ifndef HEADLESS
|
||||||
if (rack::settings::darkMode == darkMode)
|
if (rack::settings::darkMode == darkMode)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -1477,12 +1488,14 @@ void switchDarkMode(const bool darkMode)
|
||||||
else if (ext.handleMOD != nullptr)
|
else if (ext.handleMOD != nullptr)
|
||||||
std::memcpy(ext.handle, !darkMode ? ext.handleMOD : ext.handleOrig, sizeof(NSVGimage));
|
std::memcpy(ext.handle, !darkMode ? ext.handleMOD : ext.handleOrig, sizeof(NSVGimage));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace rack {
|
namespace rack {
|
||||||
namespace asset {
|
namespace asset {
|
||||||
|
|
||||||
void destroy() {
|
void destroy() {
|
||||||
|
#ifndef HEADLESS
|
||||||
for (auto it = loadedDarkSVGs.begin(), end = loadedDarkSVGs.end(); it != end; ++it)
|
for (auto it = loadedDarkSVGs.begin(), end = loadedDarkSVGs.end(); it != end; ++it)
|
||||||
{
|
{
|
||||||
ExtendedNSVGimage& ext(*it);
|
ExtendedNSVGimage& ext(*it);
|
||||||
|
|
@ -1497,6 +1510,7 @@ void destroy() {
|
||||||
|
|
||||||
loadedDarkSVGs.clear();
|
loadedDarkSVGs.clear();
|
||||||
loadedLightSVGs.clear();
|
loadedLightSVGs.clear();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue