From cdc44cda7141a8df1e3a03bbfc1863a3895f4feb Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 9 Jun 2021 23:25:40 -0400 Subject: [PATCH] Add bgColor to MenuOverlay --- include/ui/MenuOverlay.hpp | 3 +++ src/app/ModuleBrowser.cpp | 1 + src/app/TipWindow.cpp | 1 + src/ui/MenuOverlay.cpp | 16 +++++++++++----- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/include/ui/MenuOverlay.hpp b/include/ui/MenuOverlay.hpp index a77a7c24..e5cf600d 100644 --- a/include/ui/MenuOverlay.hpp +++ b/include/ui/MenuOverlay.hpp @@ -9,6 +9,9 @@ namespace ui { /** Deletes itself from parent when clicked */ struct MenuOverlay : widget::OpaqueWidget { + NVGcolor bgColor; + + MenuOverlay(); void draw(const DrawArgs& args) override; void step() override; void onButton(const ButtonEvent& e) override; diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 3feb7ac5..5e905a18 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -915,6 +915,7 @@ inline void ZoomItem::onAction(const ActionEvent& e) { widget::Widget* moduleBrowserCreate() { moduleBrowser::BrowserOverlay* overlay = new moduleBrowser::BrowserOverlay; + overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33); moduleBrowser::ModuleBrowser* browser = new moduleBrowser::ModuleBrowser; overlay->addChild(browser); diff --git a/src/app/TipWindow.cpp b/src/app/TipWindow.cpp index ad9c06df..13fdacfc 100644 --- a/src/app/TipWindow.cpp +++ b/src/app/TipWindow.cpp @@ -174,6 +174,7 @@ struct TipWindow : widget::OpaqueWidget { widget::Widget* tipWindowCreate() { ui::MenuOverlay* overlay = new ui::MenuOverlay; + overlay->bgColor = nvgRGBAf(0, 0, 0, 0.33); TipWindow* tipWindow = new TipWindow; overlay->addChild(tipWindow); diff --git a/src/ui/MenuOverlay.cpp b/src/ui/MenuOverlay.cpp index 4312c4e2..9db889a4 100644 --- a/src/ui/MenuOverlay.cpp +++ b/src/ui/MenuOverlay.cpp @@ -5,12 +5,18 @@ namespace rack { namespace ui { +MenuOverlay::MenuOverlay() { + bgColor = nvgRGBA(0, 0, 0, 0); +} + + void MenuOverlay::draw(const DrawArgs& args) { - // Translucent background - // nvgBeginPath(args.vg); - // nvgRect(args.vg, 0, 0, VEC_ARGS(box.size)); - // nvgFillColor(args.vg, nvgRGBAf(0, 0, 0, 0.33)); - // nvgFill(args.vg); + if (bgColor.a > 0.f) { + nvgBeginPath(args.vg); + nvgRect(args.vg, 0, 0, VEC_ARGS(box.size)); + nvgFillColor(args.vg, bgColor); + nvgFill(args.vg); + } OpaqueWidget::draw(args); }