Ability to make cursor invisible again (both OS-cursor and oculus rectile) and js-interface to cursorVisible boolean
Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -230,6 +230,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 229 unmodified lines | ||
| 230 | 230 | _touchAvgX(0.0f), |
| 231 | 231 | _touchAvgY(0.0f), |
| 232 | 232 | _isTouchPressed(false), |
| 233 | + _cursorVisible(true), | |
| 233 | 234 | _mousePressed(false), |
| 234 | 235 | _enableProcessOctreeThread(true), |
| 235 | 236 | _octreeProcessor(), |
| @@ -1480,6 +1481,8 @@ void Application::setEnableVRMode(bool enableVRMode) { · 1244 unmodified lines | ||
| 1480 | 1481 | |
| 1481 | 1482 | auto glCanvas = DependencyManager::get<GLCanvas>(); |
| 1482 | 1483 | resizeGL(glCanvas->getDeviceWidth(), glCanvas->getDeviceHeight()); |
| 1484 | + | |
| 1485 | + updateCursorVisibility(); | |
| 1483 | 1486 | } |
| 1484 | 1487 | |
| 1485 | 1488 | void Application::setLowVelocityFilter(bool lowVelocityFilter) { |
| @@ -1947,35 +1950,22 @@ void Application::updateCursor(float deltaTime) { · 461 unmodified lines | ||
| 1947 | 1950 | |
| 1948 | 1951 | static QPoint lastMousePos = QPoint(); |
| 1949 | 1952 | _lastMouseMove = (lastMousePos == QCursor::pos()) ? _lastMouseMove : usecTimestampNow(); |
| 1950 | − bool hideMouse = false; | |
| 1951 | − bool underMouse = QGuiApplication::topLevelAt(QCursor::pos()) == | |
| 1952 | − Application::getInstance()->getWindow()->windowHandle(); | |
| 1953 | − | |
| 1954 | − static const int HIDE_CURSOR_TIMEOUT = 3 * USECS_PER_SECOND; // 3 second | |
| 1955 | − int elapsed = usecTimestampNow() - _lastMouseMove; | |
| 1956 | − if ((elapsed > HIDE_CURSOR_TIMEOUT) || | |
| 1957 | − (OculusManager::isConnected() && Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode))) { | |
| 1958 | − hideMouse = underMouse; | |
| 1959 | − } | |
| 1960 | − | |
| 1961 | − setCursorVisible(!hideMouse); | |
| 1962 | 1953 | lastMousePos = QCursor::pos(); |
| 1963 | 1954 | } |
| 1964 | 1955 | |
| 1965 | −void Application::setCursorVisible(bool visible) { | |
| 1966 | − if (visible) { | |
| 1967 | − if (overrideCursor() != NULL) { | |
| 1968 | − restoreOverrideCursor(); | |
| 1969 | − } | |
| 1956 | +void Application::updateCursorVisibility() { | |
| 1957 | + if (!_cursorVisible || Menu::getInstance()->isOptionChecked(MenuOption::EnableVRMode)) { | |
| 1958 | + DependencyManager::get<GLCanvas>()->setCursor(Qt::BlankCursor); | |
| 1970 | 1959 | } else { |
| 1971 | − if (overrideCursor() != NULL) { | |
| 1972 | − changeOverrideCursor(Qt::BlankCursor); | |
| 1973 | − } else { | |
| 1974 | − setOverrideCursor(Qt::BlankCursor); | |
| 1975 | − } | |
| 1960 | + DependencyManager::get<GLCanvas>()->unsetCursor(); | |
| 1976 | 1961 | } |
| 1977 | 1962 | } |
| 1978 | 1963 | |
| 1964 | +void Application::setCursorVisible(bool visible) { | |
| 1965 | + _cursorVisible = visible; | |
| 1966 | + updateCursorVisibility(); | |
| 1967 | +} | |
| 1968 | + | |
| 1979 | 1969 | void Application::update(float deltaTime) { |
| 1980 | 1970 | bool showWarnings = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings); |
| 1981 | 1971 | PerformanceWarning warn(showWarnings, "Application::update()"); |