mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 05:23:33 +02:00
Merge pull request #7194 from ZappoMan/toggleOverlay
add toggleOverlays menu item and action
This commit is contained in:
commit
3c53078178
10 changed files with 52 additions and 24 deletions
|
@ -815,6 +815,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
||||||
} else if (action == controller::toInt(controller::Action::RETICLE_Y)) {
|
} else if (action == controller::toInt(controller::Action::RETICLE_Y)) {
|
||||||
auto oldPos = _compositor.getReticlePosition();
|
auto oldPos = _compositor.getReticlePosition();
|
||||||
_compositor.setReticlePosition({ oldPos.x, oldPos.y + state });
|
_compositor.setReticlePosition({ oldPos.x, oldPos.y + state });
|
||||||
|
} else if (action == controller::toInt(controller::Action::TOGGLE_OVERLAY)) {
|
||||||
|
toggleOverlays();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1197,7 +1199,6 @@ void Application::initializeUi() {
|
||||||
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
||||||
// support the window management and scripting proxies for VR use
|
// support the window management and scripting proxies for VR use
|
||||||
offscreenUi->createDesktop(QString("hifi/Desktop.qml"));
|
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
|
// FIXME either expose so that dialogs can set this themselves or
|
||||||
// do better detection in the offscreen UI of what has focus
|
// do better detection in the offscreen UI of what has focus
|
||||||
|
@ -2025,9 +2026,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson));
|
Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, !Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson));
|
||||||
cameraMenuChanged();
|
cameraMenuChanged();
|
||||||
break;
|
break;
|
||||||
case Qt::Key_O:
|
|
||||||
_overlayConductor.setEnabled(!_overlayConductor.getEnabled());
|
|
||||||
break;
|
|
||||||
case Qt::Key_Slash:
|
case Qt::Key_Slash:
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Stats);
|
Menu::getInstance()->triggerOption(MenuOption::Stats);
|
||||||
break;
|
break;
|
||||||
|
@ -2432,6 +2431,19 @@ void Application::idle(uint64_t now) {
|
||||||
return; // bail early, nothing to do here.
|
return; // bail early, nothing to do here.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Stats::getInstance()->updateStats();
|
||||||
|
AvatarInputs::getInstance()->update();
|
||||||
|
|
||||||
|
// These tasks need to be done on our first idle, because we don't want the showing of
|
||||||
|
// overlay subwindows to do a showDesktop() until after the first time through
|
||||||
|
static bool firstIdle = true;
|
||||||
|
if (firstIdle) {
|
||||||
|
firstIdle = false;
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
|
||||||
|
_overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays));
|
||||||
|
}
|
||||||
|
|
||||||
auto displayPlugin = getActiveDisplayPlugin();
|
auto displayPlugin = getActiveDisplayPlugin();
|
||||||
// depending on whether we're throttling or not.
|
// depending on whether we're throttling or not.
|
||||||
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
// Once rendering is off on another thread we should be able to have Application::idle run at start(0) in
|
||||||
|
@ -2975,6 +2987,16 @@ void Application::updateThreads(float deltaTime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::toggleOverlays() {
|
||||||
|
auto newOverlaysVisible = !_overlayConductor.getEnabled();
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, newOverlaysVisible);
|
||||||
|
_overlayConductor.setEnabled(newOverlaysVisible);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::setOverlaysVisible(bool visible) {
|
||||||
|
_overlayConductor.setEnabled(visible);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::cycleCamera() {
|
void Application::cycleCamera() {
|
||||||
auto menu = Menu::getInstance();
|
auto menu = Menu::getInstance();
|
||||||
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
if (menu->isOptionChecked(MenuOption::FullscreenMirror)) {
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; }
|
const ApplicationOverlay& getApplicationOverlay() const { return _applicationOverlay; }
|
||||||
ApplicationCompositor& getApplicationCompositor() { return _compositor; }
|
ApplicationCompositor& getApplicationCompositor() { return _compositor; }
|
||||||
const ApplicationCompositor& getApplicationCompositor() const { return _compositor; }
|
const ApplicationCompositor& getApplicationCompositor() const { return _compositor; }
|
||||||
|
|
||||||
Overlays& getOverlays() { return _overlays; }
|
Overlays& getOverlays() { return _overlays; }
|
||||||
|
|
||||||
bool isForeground() const { return _isForeground; }
|
bool isForeground() const { return _isForeground; }
|
||||||
|
@ -270,6 +271,8 @@ public slots:
|
||||||
|
|
||||||
void cycleCamera();
|
void cycleCamera();
|
||||||
void cameraMenuChanged();
|
void cameraMenuChanged();
|
||||||
|
void toggleOverlays();
|
||||||
|
void setOverlaysVisible(bool visible);
|
||||||
|
|
||||||
void reloadResourceCaches();
|
void reloadResourceCaches();
|
||||||
|
|
||||||
|
|
|
@ -247,6 +247,9 @@ Menu::Menu() {
|
||||||
0, true, qApp, SLOT(rotationModeChanged()),
|
0, true, qApp, SLOT(rotationModeChanged()),
|
||||||
UNSPECIFIED_POSITION, "Advanced");
|
UNSPECIFIED_POSITION, "Advanced");
|
||||||
|
|
||||||
|
// View > Overlays
|
||||||
|
addCheckableActionToQMenuAndActionHash(viewMenu, MenuOption::Overlays, 0, true,
|
||||||
|
qApp, SLOT(setOverlaysVisible(bool)));
|
||||||
|
|
||||||
// Navigate menu ----------------------------------
|
// Navigate menu ----------------------------------
|
||||||
MenuWrapper* navigateMenu = addMenu("Navigate");
|
MenuWrapper* navigateMenu = addMenu("Navigate");
|
||||||
|
|
|
@ -247,6 +247,7 @@ namespace MenuOption {
|
||||||
const QString OnePointCalibration = "1 Point Calibration";
|
const QString OnePointCalibration = "1 Point Calibration";
|
||||||
const QString OnlyDisplayTopTen = "Only Display Top Ten";
|
const QString OnlyDisplayTopTen = "Only Display Top Ten";
|
||||||
const QString OutputMenu = "Display";
|
const QString OutputMenu = "Display";
|
||||||
|
const QString Overlays = "Overlays";
|
||||||
const QString PackageModel = "Package Model...";
|
const QString PackageModel = "Package Model...";
|
||||||
const QString Pair = "Pair";
|
const QString Pair = "Pair";
|
||||||
const QString PhysicsShowHulls = "Draw Collision Hulls";
|
const QString PhysicsShowHulls = "Draw Collision Hulls";
|
||||||
|
|
|
@ -131,7 +131,7 @@ private:
|
||||||
float _textureAspectRatio { 1.0f };
|
float _textureAspectRatio { 1.0f };
|
||||||
int _hemiVerticesID { GeometryCache::UNKNOWN_ID };
|
int _hemiVerticesID { GeometryCache::UNKNOWN_ID };
|
||||||
|
|
||||||
float _alpha { 1.0f };
|
float _alpha { 0.0f }; // hidden by default
|
||||||
float _prevAlpha { 1.0f };
|
float _prevAlpha { 1.0f };
|
||||||
float _fadeInAlpha { true };
|
float _fadeInAlpha { true };
|
||||||
float _oculusUIRadius { 1.0f };
|
float _oculusUIRadius { 1.0f };
|
||||||
|
|
|
@ -58,10 +58,6 @@ void ApplicationOverlay::renderOverlay(RenderArgs* renderArgs) {
|
||||||
CHECK_GL_ERROR();
|
CHECK_GL_ERROR();
|
||||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "ApplicationOverlay::displayOverlay()");
|
||||||
|
|
||||||
// TODO move to Application::idle()?
|
|
||||||
Stats::getInstance()->updateStats();
|
|
||||||
AvatarInputs::getInstance()->update();
|
|
||||||
|
|
||||||
buildFramebufferObject();
|
buildFramebufferObject();
|
||||||
|
|
||||||
if (!_overlayFramebuffer) {
|
if (!_overlayFramebuffer) {
|
||||||
|
|
|
@ -110,19 +110,12 @@ void OverlayConductor::setEnabled(bool enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, enabled);
|
||||||
|
|
||||||
|
_enabled = enabled; // set the new value
|
||||||
|
|
||||||
|
// if the new state is visible/enabled...
|
||||||
if (_enabled) {
|
if (_enabled) {
|
||||||
// alpha fadeOut the overlay mesh.
|
|
||||||
qApp->getApplicationCompositor().fadeOut();
|
|
||||||
|
|
||||||
// disable mouse clicks from script
|
|
||||||
qApp->getOverlays().disable();
|
|
||||||
|
|
||||||
// disable QML events
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
offscreenUi->getRootItem()->setEnabled(false);
|
|
||||||
|
|
||||||
_enabled = false;
|
|
||||||
} else {
|
|
||||||
// alpha fadeIn the overlay mesh.
|
// alpha fadeIn the overlay mesh.
|
||||||
qApp->getApplicationCompositor().fadeIn();
|
qApp->getApplicationCompositor().fadeIn();
|
||||||
|
|
||||||
|
@ -142,8 +135,16 @@ void OverlayConductor::setEnabled(bool enabled) {
|
||||||
t.setRotation(glm::quat_cast(camMat));
|
t.setRotation(glm::quat_cast(camMat));
|
||||||
qApp->getApplicationCompositor().setModelTransform(t);
|
qApp->getApplicationCompositor().setModelTransform(t);
|
||||||
}
|
}
|
||||||
|
} else { // other wise, if the new state is hidden/not enabled
|
||||||
|
// alpha fadeOut the overlay mesh.
|
||||||
|
qApp->getApplicationCompositor().fadeOut();
|
||||||
|
|
||||||
_enabled = true;
|
// disable mouse clicks from script
|
||||||
|
qApp->getOverlays().disable();
|
||||||
|
|
||||||
|
// disable QML events
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
offscreenUi->getRootItem()->setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@ private:
|
||||||
STANDING
|
STANDING
|
||||||
};
|
};
|
||||||
|
|
||||||
Mode _mode = FLAT;
|
Mode _mode { FLAT };
|
||||||
bool _enabled = true;
|
bool _enabled { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace controller {
|
||||||
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
makeButtonPair(Action::CONTEXT_MENU, "ContextMenu"),
|
||||||
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
makeButtonPair(Action::TOGGLE_MUTE, "ToggleMute"),
|
||||||
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
makeButtonPair(Action::CYCLE_CAMERA, "CycleCamera"),
|
||||||
|
makeButtonPair(Action::TOGGLE_OVERLAY, "ToggleOverlay"),
|
||||||
|
|
||||||
makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"),
|
makeAxisPair(Action::RETICLE_CLICK, "ReticleClick"),
|
||||||
makeAxisPair(Action::RETICLE_X, "ReticleX"),
|
makeAxisPair(Action::RETICLE_X, "ReticleX"),
|
||||||
|
|
|
@ -52,6 +52,7 @@ enum class Action {
|
||||||
CONTEXT_MENU,
|
CONTEXT_MENU,
|
||||||
TOGGLE_MUTE,
|
TOGGLE_MUTE,
|
||||||
CYCLE_CAMERA,
|
CYCLE_CAMERA,
|
||||||
|
TOGGLE_OVERLAY,
|
||||||
|
|
||||||
SHIFT,
|
SHIFT,
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue