From cc20d1f2aca39b3b384af086b5895f782b237091 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sat, 29 May 2021 23:37:56 -0400 Subject: [PATCH] Change TGrayModuleLightWidget background color. Don't draw light halo in framebuffers. --- include/componentlibrary.hpp | 2 +- src/app/LightWidget.cpp | 9 ++++++--- src/app/RackWidget.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/include/componentlibrary.hpp b/include/componentlibrary.hpp index 0c8de42f..5a6b1786 100644 --- a/include/componentlibrary.hpp +++ b/include/componentlibrary.hpp @@ -86,7 +86,7 @@ typedef TSvgLight<> SvgLight; template struct TGrayModuleLightWidget : Base { TGrayModuleLightWidget() { - this->bgColor = nvgRGBA(0xaf, 0xaf, 0xaf, 0xff); + this->bgColor = nvgRGBA(0x55, 0x55, 0x55, 0xff); this->borderColor = nvgRGBA(0, 0, 0, 53); } }; diff --git a/src/app/LightWidget.cpp b/src/app/LightWidget.cpp index e76cd5dc..8254327a 100644 --- a/src/app/LightWidget.cpp +++ b/src/app/LightWidget.cpp @@ -14,9 +14,7 @@ void LightWidget::draw(const DrawArgs& args) { // Background if (bgColor.a > 0.0) { - // TODO Set color in TGrayModuleLightWidget instead. - nvgFillColor(args.vg, color::mult(bgColor, 0.5)); - // nvgFillColor(args.vg, bgColor); + nvgFillColor(args.vg, bgColor); nvgFill(args.vg); } @@ -33,6 +31,7 @@ void LightWidget::draw(const DrawArgs& args) { TransparentWidget::draw(args); // Dynamic light and halo + // Override tint from rack brightness adjustment nvgGlobalAlpha(args.vg, 1.0); // Use the formula `lightColor * (1 - dest) + dest` for blending nvgGlobalCompositeBlendFunc(args.vg, NVG_ONE_MINUS_DST_COLOR, NVG_ONE); @@ -53,6 +52,10 @@ void LightWidget::drawLight(const DrawArgs& args) { } void LightWidget::drawHalo(const DrawArgs& args) { + // Don't draw halo if rendering in a framebuffer, e.g. screenshots or Module Browser + if (args.fb) + return; + const float halo = settings::haloBrightness; if (halo == 0.f) return; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 023b967a..e4be9799 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -98,7 +98,7 @@ void RackWidget::step() { void RackWidget::draw(const DrawArgs& args) { // Darken all children by user setting - float b = std::pow(settings::rackBrightness, 1.f); + float b = settings::rackBrightness; nvgGlobalTint(args.vg, nvgRGBAf(b, b, b, 1)); // Resize and reposition the RackRail to align on the grid.