Skip to content

Commit

Permalink
More tweaks for 2.4 update
Browse files Browse the repository at this point in the history
Signed-off-by: falkTX <[email protected]>
  • Loading branch information
falkTX committed Dec 17, 2023
1 parent 1895052 commit 241df7f
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 36 deletions.
31 changes: 25 additions & 6 deletions include/simd/common.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
/*
* DISTRHO Cardinal Plugin
* Copyright (C) 2021-2023 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the LICENSE file.
*/

#pragma once

#ifdef __SSE4_2__
#include <nmmintrin.h>
#else
#define SIMDE_ENABLE_NATIVE_ALIASES
#include <simde/x86/sse4.2.h>
#endif
#include "emmintrin.h"
#include "immintrin.h"
#include "pmmintrin.h"

#define SIMDE_ENABLE_NATIVE_ALIASES
#include "simde/x86/ssse3.h"
#include "simde/x86/sse4.1.h"
#include "simde/x86/sse4.2.h"
22 changes: 22 additions & 0 deletions include/simd/functions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* DISTRHO Cardinal Plugin
* Copyright (C) 2021-2023 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 3 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the LICENSE file.
*/

#pragma once

#include "simd/common.hpp"
#include_next "simd/functions.hpp"
#undef SIMDE_MM_FROUND_NO_EXC
2 changes: 1 addition & 1 deletion plugins/GlueTheGiant
6 changes: 3 additions & 3 deletions plugins/ImpromptuModularDark/PanelTheme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ void writeThemeAndContrastAsDefault() {}
void saveThemeAndContrastAsDefault(int, float) {}

void loadThemeAndContrastFromDefault(int* panelTheme, float* panelContrast) {
*panelTheme = rack::settings::darkMode ? 1 : 0;
*panelTheme = rack::settings::preferDarkPanels ? 1 : 0;
*panelContrast = panelContrastDefault;
}

bool isDark(int*) {
return rack::settings::darkMode;
return rack::settings::preferDarkPanels;
}

void readThemeAndContrastFromDefault() {}
Expand All @@ -47,7 +47,7 @@ void PanelBaseWidget::draw(const DrawArgs& args) {

void InverterWidget::draw(const DrawArgs& args) {
TransparentWidget::draw(args);
if (rack::settings::darkMode) {
if (rack::settings::preferDarkPanels) {
// nvgSave(args.vg);
nvgBeginPath(args.vg);
nvgFillColor(args.vg, SCHEME_WHITE);// this is the source, the current framebuffer is the dest
Expand Down
2 changes: 1 addition & 1 deletion plugins/RebelTech
4 changes: 2 additions & 2 deletions plugins/plugins-mini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void initStatic__BogaudioModules()
{
// Make sure to use match Cardinal theme
Skins& skins(Skins::skins());
skins._default = settings::darkMode ? "dark" : "light";
skins._default = settings::preferDarkPanels ? "dark" : "light";

p->addModel(modelAD);
p->addModel(modelBogaudioLFO);
Expand Down Expand Up @@ -649,7 +649,7 @@ void destroyStaticPlugins()

void updateStaticPluginsDarkMode()
{
const bool darkMode = settings::darkMode;
const bool darkMode = settings::preferDarkPanels;
// bogaudio
{
Skins& skins(Skins::skins());
Expand Down
8 changes: 4 additions & 4 deletions plugins/surgext-helper/surgext-helper.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* DISTRHO Cardinal Plugin
* Copyright (C) 2021-2022 Filipe Coelho <[email protected]>
* Copyright (C) 2021-2023 Filipe Coelho <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
Expand All @@ -23,15 +23,15 @@ using namespace sst::surgext_rack::style;

void surgext_rack_initialize()
{
BaconStyle::get()->activeStyle = rack::settings::darkMode ? BaconStyle::DARK : BaconStyle::LIGHT;
BaconStyle::get()->activeStyle = rack::settings::preferDarkPanels ? BaconStyle::DARK : BaconStyle::LIGHT;
XTStyle::initialize();
}

void surgext_rack_update_theme()
{
BaconStyle::get()->activeStyle = rack::settings::darkMode ? BaconStyle::DARK : BaconStyle::LIGHT;
BaconStyle::get()->activeStyle = rack::settings::preferDarkPanels ? BaconStyle::DARK : BaconStyle::LIGHT;
BaconStyle::get()->notifyStyleListeners();

XTStyle::setGlobalStyle(rack::settings::darkMode ? XTStyle::Style::DARK : XTStyle::Style::LIGHT);
XTStyle::setGlobalStyle(rack::settings::preferDarkPanels ? XTStyle::Style::DARK : XTStyle::Style::LIGHT);
XTStyle::notifyStyleListeners();
}
2 changes: 1 addition & 1 deletion src/CardinalCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Initializer::Initializer(const CardinalBasePlugin* const plugin, const CardinalB
settings::browserZoom = -1.f;
settings::invertZoom = false;
settings::squeezeModules = true;
settings::darkMode = true;
settings::preferDarkPanels = true;
settings::uiTheme = "dark";

// runtime behaviour
Expand Down
11 changes: 0 additions & 11 deletions src/custom/asset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
namespace rack {
namespace asset {

#ifndef HEADLESS
extern bool forceBlackScrew;
extern bool forceSilverScrew;
#endif

std::string configDir; // points to writable config dir (might be equal to userDir)
std::string userDir; // points to common writable dir
std::string systemDir; // points to plugin resources dir (or installed/local Rack dir)
Expand All @@ -59,12 +54,6 @@ static inline std::string& trim(std::string& s)

// get system resource, trimming "res/" prefix if we are loaded as a plugin bundle
std::string system(std::string filename) {
#ifndef HEADLESS
/**/ if (forceBlackScrew && string::endsWith(filename, "/ScrewBlack.svg"))
filename = filename.substr(0, filename.size()-15) + "/./ScrewBlack.svg";
else if (forceSilverScrew && string::endsWith(filename, "/ScrewSilver.svg"))
filename = filename.substr(0, filename.size()-16) + "/./ScrewSilver.svg";
#endif
return system::join(systemDir, bundlePath.empty() ? filename : trim(filename));
}

Expand Down
9 changes: 4 additions & 5 deletions src/custom/dep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ void updateStaticPluginsDarkMode();
}
namespace settings {
int rateLimit = 0;
extern bool preferDarkPanels;
extern std::string uiTheme;
}
namespace ui {
Expand Down Expand Up @@ -1405,7 +1406,7 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con
const ExtendedNSVGimage ext = { handle, handleOrig, handleMOD, shapesOrig, shapesMOD };
loadedDarkSVGs.push_back(ext);

if (rack::settings::darkMode)
if (rack::settings::preferDarkPanels)
{
if (shapesMOD != nullptr)
handle->shapes = shapesMOD;
Expand All @@ -1419,7 +1420,7 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con
const ExtendedNSVGimage ext = { handle, handleOrig, handleMOD, shapesOrig, shapesMOD };
loadedLightSVGs.push_back(ext);

if (!rack::settings::darkMode)
if (!rack::settings::preferDarkPanels)
{
if (shapesMOD != nullptr)
handle->shapes = shapesMOD;
Expand Down Expand Up @@ -1471,9 +1472,7 @@ namespace rack {
void switchDarkMode(const bool darkMode)
{
#ifndef HEADLESS
// TODO sort this out after build with Rack2.4 succeeds
return;

settings::preferDarkPanels = darkMode;
settings::uiTheme = darkMode ? "dark" : "light";
ui::refreshTheme();
plugin::updateStaticPluginsDarkMode();
Expand Down
4 changes: 2 additions & 2 deletions src/override/MenuBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,10 +625,10 @@ struct ViewButton : MenuButton {

#if DISTRHO_PLUGIN_WANT_DIRECT_ACCESS
std::string darkModeText;
if (settings::darkMode)
if (settings::preferDarkPanels)
darkModeText = CHECKMARK_STRING;
menu->addChild(createMenuItem("Dark Mode", darkModeText, []() {
switchDarkMode(!settings::darkMode);
switchDarkMode(!settings::preferDarkPanels);
setAllFramebufferWidgetsDirty(APP->scene);
}));
#endif
Expand Down

0 comments on commit 241df7f

Please sign in to comment.