Introduce dark/light mode switch, EXPERIMENTAL
This commit is contained in:
parent
dd185edf96
commit
187b1c72dd
11 changed files with 202 additions and 49 deletions
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "plugincontext.hpp"
|
||||
#include "ModuleWidgets.hpp"
|
||||
|
||||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -170,7 +171,7 @@ struct HostTime : TerminalModule {
|
|||
// --------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef HEADLESS
|
||||
struct HostTimeWidget : ModuleWidget {
|
||||
struct HostTimeWidget : ModuleWidgetWith8HP {
|
||||
static constexpr const float startX = 10.0f;
|
||||
static constexpr const float startY_top = 71.0f;
|
||||
static constexpr const float startY_cv = 115.0f;
|
||||
|
|
@ -186,10 +187,7 @@ struct HostTimeWidget : ModuleWidget {
|
|||
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/HostTime.svg")));
|
||||
monoFontPath = asset::system("res/fonts/ShareTechMono-Regular.ttf");
|
||||
|
||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||
createAndAddScrews();
|
||||
|
||||
addOutput(createOutput<PJ301MPort>(Vec(startX, startY_cv + 0 * padding), m, HostTime::kHostTimeRolling));
|
||||
addOutput(createOutput<PJ301MPort>(Vec(startX, startY_cv + 1 * padding), m, HostTime::kHostTimeReset));
|
||||
|
|
@ -214,20 +212,16 @@ struct HostTimeWidget : ModuleWidget {
|
|||
const float y = startY_cv + offset * padding;
|
||||
nvgBeginPath(vg);
|
||||
nvgRoundedRect(vg, startX - 1.0f, y - 2.f, box.size.x - startX * 2 + 2.f, 28.f, 4);
|
||||
nvgFillColor(vg, nvgRGB(0xd0, 0xd0, 0xd0));
|
||||
nvgFillColor(vg, rack::settings::darkMode ? nvgRGB(0xd0, 0xd0, 0xd0) : nvgRGB(0x2f, 0x2f, 0x2f));
|
||||
nvgFill(vg);
|
||||
nvgBeginPath(vg);
|
||||
nvgFillColor(vg, color::BLACK);
|
||||
nvgFillColor(vg, rack::settings::darkMode ? color::BLACK : color::WHITE);
|
||||
nvgText(vg, startX + 36, y + 16, text, nullptr);
|
||||
}
|
||||
|
||||
void draw(const DrawArgs& args) override
|
||||
{
|
||||
nvgBeginPath(args.vg);
|
||||
nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
|
||||
nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 0, box.size.y,
|
||||
nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22)));
|
||||
nvgFill(args.vg);
|
||||
drawBackground(args.vg);
|
||||
|
||||
nvgFontFaceId(args.vg, 0);
|
||||
nvgFontSize(args.vg, 14);
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "color.hpp"
|
||||
#include "rack.hpp"
|
||||
#include "settings.hpp"
|
||||
|
||||
#ifdef NDEBUG
|
||||
# undef DEBUG
|
||||
|
|
@ -66,22 +68,26 @@ struct ModuleWidgetWithSideScrews : ModuleWidget {
|
|||
void drawBackground(NVGcontext* const vg) {
|
||||
nvgBeginPath(vg);
|
||||
nvgRect(vg, 0, 0, box.size.x, box.size.y);
|
||||
nvgFillPaint(vg, nvgLinearGradient(vg, 0, 0, 0, box.size.y,
|
||||
nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22)));
|
||||
if (rack::settings::darkMode)
|
||||
nvgFillPaint(vg, nvgLinearGradient(vg, 0, 0, 0, box.size.y,
|
||||
nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22)));
|
||||
else
|
||||
nvgFillPaint(vg, nvgLinearGradient(vg, 0, 0, 0, box.size.y,
|
||||
nvgRGB(0xe7, 0xe6, 0xe6), nvgRGB(0xde, 0xdd, 0xdd)));
|
||||
nvgFill(vg);
|
||||
}
|
||||
|
||||
void drawOutputJacksArea(NVGcontext* const vg, const int numOutputs) {
|
||||
nvgBeginPath(vg);
|
||||
nvgRoundedRect(vg, startX_Out - 2.5f, startY - 2.0f, padding, padding * numOutputs, 4);
|
||||
nvgFillColor(vg, nvgRGB(0xd0, 0xd0, 0xd0));
|
||||
nvgFillColor(vg, rack::settings::darkMode ? nvgRGB(0xd0, 0xd0, 0xd0) : nvgRGB(0x2f, 0x2f, 0x2f));
|
||||
nvgFill(vg);
|
||||
}
|
||||
|
||||
void drawTextLine(NVGcontext* const vg, const uint posY, const char* const text) {
|
||||
const float y = startY + posY * padding;
|
||||
nvgBeginPath(vg);
|
||||
nvgFillColor(vg, color::WHITE);
|
||||
nvgFillColor(vg, rack::settings::darkMode ? color::WHITE : color::BLACK);
|
||||
nvgText(vg, box.size.x * 0.5f, y + 16, text, nullptr);
|
||||
}
|
||||
|
||||
|
|
@ -96,3 +102,4 @@ typedef ModuleWidgetWithSideScrews<3> ModuleWidgetWith3HP;
|
|||
typedef ModuleWidgetWithSideScrews<8> ModuleWidgetWith8HP;
|
||||
typedef ModuleWidgetWithSideScrews<9> ModuleWidgetWith9HP;
|
||||
typedef ModuleWidgetWithSideScrews<11> ModuleWidgetWith11HP;
|
||||
typedef ModuleWidgetWithSideScrews<25> ModuleWidgetWith25HP;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#ifndef HEADLESS
|
||||
# include "glBars.hpp"
|
||||
# include "ModuleWidgets.hpp"
|
||||
# include "Widgets.hpp"
|
||||
#else
|
||||
# include "plugin.hpp"
|
||||
|
|
@ -129,16 +130,13 @@ struct glBarsRendererWidget : OpenGlWidgetWithBrowserPreview {
|
|||
}
|
||||
};
|
||||
|
||||
struct glBarsWidget : ModuleWidget {
|
||||
struct glBarsWidget : ModuleWidgetWith25HP {
|
||||
glBarsWidget(glBarsModule* const module)
|
||||
{
|
||||
setModule(module);
|
||||
setPanel(APP->window->loadSvg(asset::plugin(pluginInstance, "res/glBars.svg")));
|
||||
|
||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||
addChild(createWidget<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
|
||||
createAndAddScrews();
|
||||
|
||||
addInput(createInput<PJ301MPort>(Vec(135.0f, 20.0f), module, glBarsModule::IN1_INPUT));
|
||||
|
||||
|
|
@ -151,13 +149,8 @@ struct glBarsWidget : ModuleWidget {
|
|||
|
||||
void draw(const DrawArgs& args) override
|
||||
{
|
||||
nvgBeginPath(args.vg);
|
||||
nvgRect(args.vg, 0, 0, box.size.x, box.size.y);
|
||||
nvgFillPaint(args.vg, nvgLinearGradient(args.vg, 0, 0, 0, box.size.y,
|
||||
nvgRGB(0x18, 0x19, 0x19), nvgRGB(0x21, 0x22, 0x22)));
|
||||
nvgFill(args.vg);
|
||||
|
||||
ModuleWidget::draw(args);
|
||||
drawBackground(args.vg);
|
||||
ModuleWidgetWith25HP::draw(args);
|
||||
}
|
||||
};
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ void writeThemeAndContrastAsDefault() {}
|
|||
void saveThemeAndContrastAsDefault(int, float) {}
|
||||
|
||||
void loadThemeAndContrastFromDefault(int* panelTheme, float* panelContrast) {
|
||||
*panelTheme = 1;
|
||||
*panelTheme = rack::settings::darkMode ? 1 : 0;
|
||||
*panelContrast = panelContrastDefault;
|
||||
}
|
||||
|
||||
bool isDark(int*) {
|
||||
return true;
|
||||
return rack::settings::darkMode;
|
||||
}
|
||||
|
||||
void readThemeAndContrastFromDefault() {}
|
||||
|
|
@ -47,7 +47,7 @@ void PanelBaseWidget::draw(const DrawArgs& args) {
|
|||
|
||||
void InverterWidget::draw(const DrawArgs& args) {
|
||||
TransparentWidget::draw(args);
|
||||
{
|
||||
if (rack::settings::darkMode) {
|
||||
// nvgSave(args.vg);
|
||||
nvgBeginPath(args.vg);
|
||||
nvgFillColor(args.vg, SCHEME_WHITE);// this is the source, the current framebuffer is the dest
|
||||
|
|
@ -64,4 +64,3 @@ void InverterWidget::draw(const DrawArgs& args) {
|
|||
// nvgRestore(args.vg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue