handle startup overlay visibility correctly

This commit is contained in:
Brad Hefta-Gaub 2016-02-25 14:46:08 -08:00
parent 526f9dc248
commit 366aa39be8
7 changed files with 24 additions and 14 deletions

View file

@ -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<OffscreenUi>();
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)) {

View file

@ -272,6 +272,7 @@ public slots:
void cycleCamera();
void cameraMenuChanged();
void toggleOverlays();
void setOverlaysVisible(bool visible);
void reloadResourceCaches();

View file

@ -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");

View file

@ -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 };

View file

@ -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) {

View file

@ -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>();
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;
}
}

View file

@ -29,8 +29,8 @@ private:
STANDING
};
Mode _mode = FLAT;
bool _enabled = true;
Mode _mode { FLAT };
bool _enabled { false };
};
#endif