mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 17:00:13 +02:00
Simplify overlay conductor, menu interation
This commit is contained in:
parent
6ad1008a56
commit
33e9caa636
4 changed files with 42 additions and 110 deletions
|
@ -16,6 +16,8 @@ Window {
|
||||||
height: 50
|
height: 50
|
||||||
clip: true
|
clip: true
|
||||||
visible: true
|
visible: true
|
||||||
|
// Disable this window from being able to call 'desktop.raise() and desktop.showDesktop'
|
||||||
|
activator: Item {}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
width: 50
|
width: 50
|
||||||
|
@ -28,7 +30,7 @@ Window {
|
||||||
MouseArea {
|
MouseArea {
|
||||||
readonly property string overlayMenuItem: "Overlays"
|
readonly property string overlayMenuItem: "Overlays"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onClicked: MenuInterface.setIsOptionChecked(overlayMenuItem, !MenuInterface.isOptionChecked(overlayMenuItem))
|
onClicked: MenuInterface.setIsOptionChecked(overlayMenuItem, !MenuInterface.isOptionChecked(overlayMenuItem));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2716,7 +2716,6 @@ void Application::idle(float nsecsElapsed) {
|
||||||
if (firstIdle) {
|
if (firstIdle) {
|
||||||
firstIdle = false;
|
firstIdle = false;
|
||||||
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
|
connect(offscreenUi.data(), &OffscreenUi::showDesktop, this, &Application::showDesktop);
|
||||||
_overlayConductor.setEnabled(Menu::getInstance()->isOptionChecked(MenuOption::Overlays));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PROFILE_RANGE(__FUNCTION__);
|
PROFILE_RANGE(__FUNCTION__);
|
||||||
|
@ -3217,13 +3216,13 @@ void Application::updateThreads(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleOverlays() {
|
void Application::toggleOverlays() {
|
||||||
auto newOverlaysVisible = !_overlayConductor.getEnabled();
|
auto menu = Menu::getInstance();
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, newOverlaysVisible);
|
menu->setIsOptionChecked(MenuOption::Overlays, menu->isOptionChecked(MenuOption::Overlays));
|
||||||
_overlayConductor.setEnabled(newOverlaysVisible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::setOverlaysVisible(bool visible) {
|
void Application::setOverlaysVisible(bool visible) {
|
||||||
_overlayConductor.setEnabled(visible);
|
auto menu = Menu::getInstance();
|
||||||
|
menu->setIsOptionChecked(MenuOption::Overlays, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::cycleCamera() {
|
void Application::cycleCamera() {
|
||||||
|
@ -5306,9 +5305,7 @@ void Application::readArgumentsFromLocalSocket() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::showDesktop() {
|
void Application::showDesktop() {
|
||||||
if (!_overlayConductor.getEnabled()) {
|
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, true);
|
||||||
_overlayConductor.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositorHelper& Application::getApplicationCompositor() const {
|
CompositorHelper& Application::getApplicationCompositor() const {
|
||||||
|
|
|
@ -99,104 +99,50 @@ void OverlayConductor::centerUI() {
|
||||||
qApp->getApplicationCompositor().setModelTransform(Transform(camMat));
|
qApp->getApplicationCompositor().setModelTransform(Transform(camMat));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayConductor::userWishesToHide() const {
|
|
||||||
// user pressed toggle button.
|
|
||||||
return Menu::getInstance()->isOptionChecked(MenuOption::Overlays) != _prevOverlayMenuChecked && Menu::getInstance()->isOptionChecked(MenuOption::Overlays);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OverlayConductor::userWishesToShow() const {
|
|
||||||
// user pressed toggle button.
|
|
||||||
return Menu::getInstance()->isOptionChecked(MenuOption::Overlays) != _prevOverlayMenuChecked && !Menu::getInstance()->isOptionChecked(MenuOption::Overlays);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverlayConductor::setState(State state) {
|
|
||||||
#ifdef WANT_DEBUG
|
|
||||||
static QString stateToString[NumStates] = { "Enabled", "DisabledByDrive", "DisabledByHead", "DisabledByToggle" };
|
|
||||||
qDebug() << "OverlayConductor " << stateToString[state] << "<--" << stateToString[_state];
|
|
||||||
#endif
|
|
||||||
_state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
OverlayConductor::State OverlayConductor::getState() const {
|
|
||||||
return _state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OverlayConductor::update(float dt) {
|
void OverlayConductor::update(float dt) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
bool currentVisible = !offscreenUi->getDesktop()->property("pinned").toBool();
|
||||||
|
|
||||||
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
MyAvatar* myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||||
|
// centerUI when hmd mode is first enabled and mounted
|
||||||
// centerUI when hmd mode is first enabled
|
if (qApp->isHMDMode() && qApp->getActiveDisplayPlugin()->isDisplayVisible() && !_hmdMode) {
|
||||||
if (qApp->isHMDMode() && !_hmdMode) {
|
_hmdMode = true;
|
||||||
centerUI();
|
centerUI();
|
||||||
|
} else {
|
||||||
|
_hmdMode = false;
|
||||||
}
|
}
|
||||||
_hmdMode = qApp->isHMDMode();
|
|
||||||
|
|
||||||
bool prevDriving = _currentDriving;
|
bool prevDriving = _currentDriving;
|
||||||
bool isDriving = updateAvatarHasDriveInput();
|
bool isDriving = updateAvatarHasDriveInput();
|
||||||
bool drivingChanged = prevDriving != isDriving;
|
bool drivingChanged = prevDriving != isDriving;
|
||||||
|
|
||||||
bool isAtRest = updateAvatarIsAtRest();
|
bool isAtRest = updateAvatarIsAtRest();
|
||||||
|
|
||||||
switch (getState()) {
|
if (_flags & SuppressedByDrive) {
|
||||||
case Enabled:
|
if (!isDriving) {
|
||||||
if (myAvatar->getClearOverlayWhenDriving() && qApp->isHMDMode() && headOutsideOverlay()) {
|
_flags &= ~SuppressedByDrive;
|
||||||
setState(DisabledByHead);
|
}
|
||||||
setEnabled(false);
|
} else {
|
||||||
}
|
if (myAvatar->getClearOverlayWhenDriving() && drivingChanged && isDriving) {
|
||||||
if (userWishesToHide()) {
|
_flags |= SuppressedByDrive;
|
||||||
setState(DisabledByToggle);
|
}
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
if (myAvatar->getClearOverlayWhenDriving() && drivingChanged && isDriving) {
|
|
||||||
setState(DisabledByDrive);
|
|
||||||
setEnabled(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DisabledByDrive:
|
|
||||||
if (!isDriving || userWishesToShow()) {
|
|
||||||
setState(Enabled);
|
|
||||||
setEnabled(true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DisabledByHead:
|
|
||||||
if (isAtRest || userWishesToShow()) {
|
|
||||||
setState(Enabled);
|
|
||||||
setEnabled(true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case DisabledByToggle:
|
|
||||||
if (userWishesToShow()) {
|
|
||||||
setState(Enabled);
|
|
||||||
setEnabled(true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_prevOverlayMenuChecked = Menu::getInstance()->isOptionChecked(MenuOption::Overlays);
|
if (_flags & SuppressedByHead) {
|
||||||
}
|
if (isAtRest) {
|
||||||
|
_flags &= ~SuppressedByHead;
|
||||||
void OverlayConductor::setEnabled(bool enabled) {
|
}
|
||||||
if (enabled == _enabled) {
|
} else {
|
||||||
return;
|
if (_hmdMode && headOutsideOverlay()) {
|
||||||
|
_flags |= SuppressedByHead;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_enabled = enabled; // set the new value
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
|
||||||
offscreenUi->setPinned(!_enabled);
|
|
||||||
|
|
||||||
// ensure that the the state of the menu item reflects the state of the overlay.
|
bool targetVisible = Menu::getInstance()->isOptionChecked(MenuOption::Overlays) && (0 == (_flags & SuppressMask));
|
||||||
Menu::getInstance()->setIsOptionChecked(MenuOption::Overlays, _enabled);
|
if (targetVisible != currentVisible) {
|
||||||
_prevOverlayMenuChecked = _enabled;
|
offscreenUi->setPinned(!targetVisible);
|
||||||
|
if (targetVisible && _hmdMode) {
|
||||||
// if the new state is visible/enabled...
|
centerUI();
|
||||||
if (_enabled && qApp->isHMDMode()) {
|
}
|
||||||
centerUI();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OverlayConductor::getEnabled() const {
|
|
||||||
return _enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -17,33 +17,20 @@ public:
|
||||||
~OverlayConductor();
|
~OverlayConductor();
|
||||||
|
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
void setEnabled(bool enable);
|
|
||||||
bool getEnabled() const;
|
|
||||||
|
|
||||||
void centerUI();
|
void centerUI();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool headOutsideOverlay() const;
|
bool headOutsideOverlay() const;
|
||||||
bool updateAvatarHasDriveInput();
|
bool updateAvatarHasDriveInput();
|
||||||
bool updateAvatarIsAtRest();
|
bool updateAvatarIsAtRest();
|
||||||
bool userWishesToHide() const;
|
|
||||||
bool userWishesToShow() const;
|
|
||||||
|
|
||||||
enum State {
|
enum SupressionFlags {
|
||||||
Enabled = 0,
|
SuppressedByDrive = 0x01,
|
||||||
DisabledByDrive,
|
SuppressedByHead = 0x02,
|
||||||
DisabledByHead,
|
SuppressMask = 0x03,
|
||||||
DisabledByToggle,
|
|
||||||
NumStates
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void setState(State state);
|
uint8_t _flags { SuppressedByDrive };
|
||||||
State getState() const;
|
|
||||||
|
|
||||||
State _state { DisabledByDrive };
|
|
||||||
|
|
||||||
bool _prevOverlayMenuChecked { true };
|
|
||||||
bool _enabled { false };
|
|
||||||
bool _hmdMode { false };
|
bool _hmdMode { false };
|
||||||
|
|
||||||
// used by updateAvatarHasDriveInput
|
// used by updateAvatarHasDriveInput
|
||||||
|
|
Loading…
Reference in a new issue