From 214c9c4ef7a77cb58fc6d662157a5ece48add158 Mon Sep 17 00:00:00 2001 From: HifiExperiments Date: Tue, 20 Feb 2024 14:06:39 -0800 Subject: [PATCH] fix Developer > UI > Show Overlays + snap UI not hiding --- interface/src/Menu.cpp | 13 +++++++++---- interface/src/graphics/GraphicsEngine.cpp | 2 +- interface/src/ui/ApplicationOverlay.h | 11 ++++++----- interface/src/ui/overlays/Overlays.cpp | 10 +--------- interface/src/ui/overlays/Overlays.h | 3 --- 5 files changed, 17 insertions(+), 22 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 699a21903f..aae6839282 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -388,13 +388,18 @@ Menu::Menu() { // Developer > UI >>> MenuWrapper* uiOptionsMenu = developerMenu->addMenu("UI"); + + // Developer > UI > Show Overlays + action = addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::Overlays, 0, true); + + connect(action, &QAction::triggered, [action] { + qApp->getApplicationOverlay().setEnabled(action->isChecked()); + }); + + // Developer > UI > Desktop Tablet Becomes Toolbar action = addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::DesktopTabletToToolbar, 0, qApp->getDesktopTabletBecomesToolbarSetting()); - // Developer > UI > Show Overlays - addCheckableActionToQMenuAndActionHash(uiOptionsMenu, MenuOption::Overlays, 0, true); - - // Developer > UI > Desktop Tablet Becomes Toolbar connect(action, &QAction::triggered, [action] { qApp->setDesktopTabletBecomesToolbarSetting(action->isChecked()); }); diff --git a/interface/src/graphics/GraphicsEngine.cpp b/interface/src/graphics/GraphicsEngine.cpp index bf69efd23e..5075d9b57f 100644 --- a/interface/src/graphics/GraphicsEngine.cpp +++ b/interface/src/graphics/GraphicsEngine.cpp @@ -281,7 +281,7 @@ void GraphicsEngine::render_performFrame() { { PROFILE_RANGE(render, "/runRenderFrame"); - renderArgs._hudOperator = displayPlugin->getHUDOperator(); + renderArgs._hudOperator = qApp->getApplicationOverlay().enabled() ? displayPlugin->getHUDOperator() : nullptr; renderArgs._hudTexture = qApp->getApplicationOverlay().getOverlayTexture(); renderArgs._takingSnapshot = qApp->takeSnapshotOperators(snapshotOperators); renderArgs._blitFramebuffer = finalFramebuffer; diff --git a/interface/src/ui/ApplicationOverlay.h b/interface/src/ui/ApplicationOverlay.h index 23055cf246..9db09b0b9b 100644 --- a/interface/src/ui/ApplicationOverlay.h +++ b/interface/src/ui/ApplicationOverlay.h @@ -27,18 +27,17 @@ public: void renderOverlay(RenderArgs* renderArgs); - gpu::TexturePointer getOverlayTexture(); + gpu::TexturePointer getOverlayTexture(); + + bool enabled() const { return _enabled; } + void setEnabled(bool enabled) { _enabled = enabled; } private: - void renderStatsAndLogs(RenderArgs* renderArgs); void renderDomainConnectionStatusBorder(RenderArgs* renderArgs); void renderQmlUi(RenderArgs* renderArgs); void renderOverlays(RenderArgs* renderArgs); void buildFramebufferObject(); - float _alpha{ 1.0f }; - float _trailingAudioLoudness{ 0.0f }; - int _domainStatusBorder; int _magnifierBorder; @@ -47,6 +46,8 @@ private: gpu::TexturePointer _overlayColorTexture; gpu::FramebufferPointer _overlayFramebuffer; int _qmlGeometryId { 0 }; + + bool _enabled { true }; }; #endif // hifi_ApplicationOverlay_h diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index e245acfd40..5349564043 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -153,14 +153,6 @@ void Overlays::render(RenderArgs* renderArgs) { } } -void Overlays::disable() { - _enabled = false; -} - -void Overlays::enable() { - _enabled = true; -} - Overlay::Pointer Overlays::take2DOverlay(const QUuid& id) { if (_shuttingDown) { return nullptr; @@ -378,7 +370,7 @@ QObject* Overlays::getOverlayObject(const QUuid& id) { } QUuid Overlays::getOverlayAtPoint(const glm::vec2& point) { - if (_shuttingDown || !_enabled) { + if (_shuttingDown) { return UNKNOWN_ENTITY_ID; } diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index a0f2e866e2..fcf0c71bc9 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -99,8 +99,6 @@ public: void init(); void update(float deltatime); void render(RenderArgs* renderArgs); - void disable(); - void enable(); Overlay::Pointer take2DOverlay(const QUuid& id); Overlay::Pointer get2DOverlay(const QUuid& id) const; @@ -683,7 +681,6 @@ private: unsigned int _stackOrder { 1 }; - bool _enabled { true }; std::atomic _shuttingDown { false }; PointerEvent calculateOverlayPointerEvent(const QUuid& id, const PickRay& ray, const RayToOverlayIntersectionResult& rayPickResult,