diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 45fa27db78..6845524631 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1200,7 +1200,6 @@ void Application::initializeUi() { // OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to // support the window management and scripting proxies for VR use offscreenUi->createDesktop(QString("hifi/Desktop.qml")); - connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); // FIXME either expose so that dialogs can set this themselves or // do better detection in the offscreen UI of what has focus @@ -2435,6 +2434,17 @@ void Application::idle(uint64_t now) { if (_aboutToQuit) { return; // bail early, nothing to do here. } + + Stats::getInstance()->updateStats(); + AvatarInputs::getInstance()->update(); + + static bool firstIdle = true; + if (firstIdle) { + firstIdle = false; + auto offscreenUi = DependencyManager::get(); + connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop); + } + auto displayPlugin = getActiveDisplayPlugin(); // depending on whether we're throttling or not. @@ -2998,6 +3008,10 @@ void Application::toggleOverlays() { _overlayConductor.setEnabled(overlaysVisible); } +void Application::setOverlaysVisible(bool visible) { + _overlayConductor.setEnabled(visible); +} + void Application::cycleCamera() { auto menu = Menu::getInstance(); if (menu->isOptionChecked(MenuOption::FullscreenMirror)) { diff --git a/interface/src/Application.h b/interface/src/Application.h index 13dab6137e..aacf0b5b08 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -272,6 +272,7 @@ public slots: void cycleCamera(); void cameraMenuChanged(); void toggleOverlays(); + void setOverlaysVisible(bool visible); void reloadResourceCaches(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index bf8cd2e61e..a5795c5a3b 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -257,7 +257,7 @@ Menu::Menu() { // View > Overlays addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Overlays, 0, true, - qApp, SLOT(toggleOverlays())); + qApp, SLOT(setOverlaysVisible(bool))); // Navigate menu ---------------------------------- MenuWrapper* navigateMenu = addMenu("Navigate"); diff --git a/interface/src/ui/ApplicationCompositor.h b/interface/src/ui/ApplicationCompositor.h index 7bdb97727f..b94afd2cce 100644 --- a/interface/src/ui/ApplicationCompositor.h +++ b/interface/src/ui/ApplicationCompositor.h @@ -131,7 +131,7 @@ private: float _textureAspectRatio { 1.0f }; int _hemiVerticesID { GeometryCache::UNKNOWN_ID }; - float _alpha { 1.0f }; + float _alpha { 0.0f }; // hidden by default float _prevAlpha { 1.0f }; float _fadeInAlpha { true }; float _oculusUIRadius { 1.0f }; diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index 67b5135e0c..998a64d81a 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -58,10 +58,6 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) { CHECK_GL_ERROR(); PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()"); - // TODO move to Application::idle()? - Stats::getInstance()->updateStats(); - AvatarInputs::getInstance()->update(); - buildFramebufferObject(); if (!_overlayFramebuffer) { diff --git a/interface/src/ui/OverlayConductor.cpp b/interface/src/ui/OverlayConductor.cpp index 4cc5e6d534..21b1aa879e 100644 --- a/interface/src/ui/OverlayConductor.cpp +++ b/interface/src/ui/OverlayConductor.cpp @@ -110,9 +110,12 @@ void OverlayConductor::setEnabled(bool enabled) { return; } + qDebug() << "OverlayConductor::setEnabled() enabled:" << enabled; Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled); - if (_enabled) { + _enabled = enabled; // set the new value + + if (!_enabled) { // alpha fadeOut the overlay mesh. qApp->getApplicationCompositor().fadeOut(); @@ -122,8 +125,6 @@ void OverlayConductor::setEnabled(bool enabled) { // disable QML events auto offscreenUi = DependencyManager::get(); offscreenUi->getRootItem()->setEnabled(false); - - _enabled = false; } else { // alpha fadeIn the overlay mesh. qApp->getApplicationCompositor().fadeIn(); @@ -144,8 +145,6 @@ void OverlayConductor::setEnabled(bool enabled) { t.setRotation(glm::quat_cast(camMat)); qApp->getApplicationCompositor().setModelTransform(t); } - - _enabled = true; } } diff --git a/interface/src/ui/OverlayConductor.h b/interface/src/ui/OverlayConductor.h index 4b8c0134b5..b94c5be7dd 100644 --- a/interface/src/ui/OverlayConductor.h +++ b/interface/src/ui/OverlayConductor.h @@ -29,8 +29,8 @@ private: STANDING }; - Mode _mode = FLAT; - bool _enabled = true; + Mode _mode { FLAT }; + bool _enabled { false }; }; #endif