diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index 317e3302d9..125432002c 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -66,15 +66,11 @@ if (DEFINED BULLET_LIB_EXT) list(GET _LIB_PAIR 0 _LIB_VAR_NAME) list(GET _LIB_PAIR 1 _LIB_NAME) - + set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_RELEASE ${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}.${BULLET_LIB_EXT} CACHE FILEPATH "${_LIB_NAME} release library location") if (WIN32) - # on windows, we might end up with a library that ends with RelWithDebInfo if Visual Studio is building for that configuration - set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_RELEASE "${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}$<$:_RelWithDebugInfo>$<$:_MinsizeRel>.${BULLET_LIB_EXT}" CACHE FILEPATH "${_LIB_NAME} release library location") - set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_DEBUG ${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}_Debug.${BULLET_LIB_EXT} CACHE FILEPATH "${_LIB_NAME} debug library location") else () - set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_RELEASE ${BULLET_LIB_DIR}/${LIB_PREFIX}${_LIB_NAME}.${BULLET_LIB_EXT} CACHE FILEPATH "${_LIB_NAME} release library location") set(${EXTERNAL_NAME_UPPER}_${_LIB_VAR_NAME}_DEBUG "" CACHE FILEPATH "${_LIB_NAME} debug library location") endif () endforeach() diff --git a/cmake/externals/faceshift/CMakeLists.txt b/cmake/externals/faceshift/CMakeLists.txt index c4f2055435..28fbffec34 100644 --- a/cmake/externals/faceshift/CMakeLists.txt +++ b/cmake/externals/faceshift/CMakeLists.txt @@ -27,10 +27,6 @@ set(LIBRARY_RELEASE_PATH "lib/Release") if (WIN32) set(LIBRARY_PREFIX "") set(LIBRARY_EXT "lib") - # use selected configuration in release path when building on Windows - set(LIBRARY_RELEASE_PATH "$<$:build/RelWithDebInfo>") - set(LIBRARY_RELEASE_PATH "${LIBRARY_RELEASE_PATH}$<$:build/MinSizeRel>") - set(LIBRARY_RELEASE_PATH "${LIBRARY_RELEASE_PATH}$<$,$>:lib/Release>") elseif (APPLE) set(LIBRARY_EXT "a") set(LIBRARY_PREFIX "lib") diff --git a/cmake/externals/polyvox/CMakeLists.txt b/cmake/externals/polyvox/CMakeLists.txt index c799b45e78..3740e26762 100644 --- a/cmake/externals/polyvox/CMakeLists.txt +++ b/cmake/externals/polyvox/CMakeLists.txt @@ -19,7 +19,7 @@ ExternalProject_Get_Property(${EXTERNAL_NAME} INSTALL_DIR) if (APPLE) set(INSTALL_NAME_LIBRARY_DIR ${INSTALL_DIR}/lib) - + ExternalProject_Add_Step( ${EXTERNAL_NAME} change-install-name-debug @@ -29,7 +29,7 @@ if (APPLE) WORKING_DIRECTORY LOG 1 ) - + ExternalProject_Add_Step( ${EXTERNAL_NAME} change-install-name-release @@ -59,13 +59,7 @@ endif () if (WIN32) set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_DEBUG ${INSTALL_DIR}/PolyVoxCore/lib/Debug/PolyVoxCore.lib CACHE FILEPATH "polyvox core library") - - # use generator expression to ensure the correct library is found when building different configurations in VS - set(_LIB_FOLDER "$<$:PolyVoxCore/lib/RelWithDebInfo>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/library/PolyVoxCore/MinSizeRel>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:PolyVoxCore/lib/Release>") - - set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_RELEASE "${INSTALL_DIR}/${_LIB_FOLDER}/PolyVoxCore.lib" CACHE FILEPATH "polyvox core library") + set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_RELEASE ${INSTALL_DIR}/PolyVoxCore/lib/Release/PolyVoxCore.lib CACHE FILEPATH "polyvox core library") # set(${EXTERNAL_NAME_UPPER}_UTIL_LIBRARY ${INSTALL_DIR}/PolyVoxUtil/lib/PolyVoxUtil.lib CACHE FILEPATH "polyvox util library") elseif (APPLE) set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/libPolyVoxCore.dylib CACHE FILEPATH "polyvox core library") diff --git a/cmake/externals/vhacd/CMakeLists.txt b/cmake/externals/vhacd/CMakeLists.txt index 11afa255f1..efe6ed0381 100644 --- a/cmake/externals/vhacd/CMakeLists.txt +++ b/cmake/externals/vhacd/CMakeLists.txt @@ -8,7 +8,7 @@ include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} URL http://hifi-public.s3.amazonaws.com/dependencies/v-hacd-master.zip - URL_MD5 3bfc94f8dd3dfbfe8f4dc088f4820b3e + URL_MD5 3bfc94f8dd3dfbfe8f4dc088f4820b3e CMAKE_ARGS ${ANDROID_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build LOG_DOWNLOAD 1 @@ -25,13 +25,7 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) if (WIN32) set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG ${INSTALL_DIR}/lib/Debug/VHACD_LIB.lib CACHE FILEPATH "Path to V-HACD debug library") - - # use generator expression to ensure the correct library is found when building different configurations in VS - set(_LIB_FOLDER "$<$:build/src/VHACD_Lib/RelWithDebInfo>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$:build/src/VHACD_Lib/MinSizeRel>") - set(_LIB_FOLDER "${_LIB_FOLDER}$<$,$>:lib/Release>") - - set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/${_LIB_FOLDER}/VHACD_LIB.lib CACHE FILEPATH "Path to V-HACD release library") + set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/Release/VHACD_LIB.lib CACHE FILEPATH "Path to V-HACD release library") else () set(${EXTERNAL_NAME_UPPER}_LIBRARY_DEBUG "" CACHE FILEPATH "Path to V-HACD debug library") set(${EXTERNAL_NAME_UPPER}_LIBRARY_RELEASE ${INSTALL_DIR}/lib/libVHACD.a CACHE FILEPATH "Path to V-HACD release library") diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index de4ff23863..3767dc7131 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -21,7 +21,7 @@ macro(LINK_HIFI_LIBRARIES) include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") include_directories("${CMAKE_BINARY_DIR}/libraries/${HIFI_LIBRARY}/shaders") - #add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY}) + add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY}) # link the actual library - it is static so don't bubble it up target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY}) diff --git a/cmake/modules/FindKinect.cmake b/cmake/modules/FindKinect.cmake index 895c6ebe8a..7607de1f44 100644 --- a/cmake/modules/FindKinect.cmake +++ b/cmake/modules/FindKinect.cmake @@ -21,7 +21,7 @@ include("${MACRO_DIR}/HifiLibrarySearchHints.cmake") hifi_library_search_hints("kinect") -find_path(KINECT_INCLUDE_DIRS Kinect.h PATH_SUFFIXES inc HINTS $ENV{KINECT_ROOT_DIR} $ENV{KINECTSDK20_DIR}) +find_path(KINECT_INCLUDE_DIRS Kinect.h PATH_SUFFIXES inc HINTS $ENV{KINECT_ROOT_DIR}) if (WIN32) @@ -35,7 +35,7 @@ if (WIN32) KINECT_LIBRARY_RELEASE Kinect20 PATH_SUFFIXES "Lib/${ARCH_DIR}" "lib" HINTS ${KINECT_SEARCH_DIRS} - PATHS $ENV{KINECT_ROOT_DIR} $ENV{KINECTSDK20_DIR}) + PATH $ENV{KINECT_ROOT_DIR}) set(KINECT_LIBRARIES ${KINECT_LIBRARY}) diff --git a/interface/resources/html/img/controls-help-oculus.png b/interface/resources/html/img/controls-help-oculus.png index 8887bc9ab1..0bd0a656de 100644 Binary files a/interface/resources/html/img/controls-help-oculus.png and b/interface/resources/html/img/controls-help-oculus.png differ diff --git a/interface/resources/html/img/tablet-help-gamepad.jpg b/interface/resources/html/img/tablet-help-gamepad.jpg deleted file mode 100644 index 5abb38d66b..0000000000 Binary files a/interface/resources/html/img/tablet-help-gamepad.jpg and /dev/null differ diff --git a/interface/resources/html/img/tablet-help-keyboard.jpg b/interface/resources/html/img/tablet-help-keyboard.jpg deleted file mode 100644 index 40c6017561..0000000000 Binary files a/interface/resources/html/img/tablet-help-keyboard.jpg and /dev/null differ diff --git a/interface/resources/html/img/tablet-help-oculus.jpg b/interface/resources/html/img/tablet-help-oculus.jpg deleted file mode 100644 index b4f54396e0..0000000000 Binary files a/interface/resources/html/img/tablet-help-oculus.jpg and /dev/null differ diff --git a/interface/resources/html/img/tablet-help-vive.jpg b/interface/resources/html/img/tablet-help-vive.jpg deleted file mode 100644 index 98e57eef47..0000000000 Binary files a/interface/resources/html/img/tablet-help-vive.jpg and /dev/null differ diff --git a/interface/resources/html/tabletHelp.html b/interface/resources/html/tabletHelp.html deleted file mode 100644 index cbd7ffcfe7..0000000000 --- a/interface/resources/html/tabletHelp.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - Welcome to Interface - - - - - - -
- - - -
- - - diff --git a/interface/resources/icons/create-icons/20-text-01.svg b/interface/resources/icons/create-icons/20-text-01.svg deleted file mode 100644 index 337f3b70e3..0000000000 --- a/interface/resources/icons/create-icons/20-text-01.svg +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - diff --git a/interface/resources/icons/create-icons/21-cube-01.svg b/interface/resources/icons/create-icons/21-cube-01.svg deleted file mode 100644 index 21a980ca35..0000000000 --- a/interface/resources/icons/create-icons/21-cube-01.svg +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - diff --git a/interface/resources/icons/create-icons/22-sphere-01.svg b/interface/resources/icons/create-icons/22-sphere-01.svg deleted file mode 100644 index 5080a16e78..0000000000 --- a/interface/resources/icons/create-icons/22-sphere-01.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - diff --git a/interface/resources/icons/create-icons/23-zone-01.svg b/interface/resources/icons/create-icons/23-zone-01.svg deleted file mode 100644 index 5428257893..0000000000 --- a/interface/resources/icons/create-icons/23-zone-01.svg +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - diff --git a/interface/resources/icons/create-icons/24-light-01.svg b/interface/resources/icons/create-icons/24-light-01.svg deleted file mode 100644 index 028ea22793..0000000000 --- a/interface/resources/icons/create-icons/24-light-01.svg +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/interface/resources/icons/create-icons/25-web-1-01.svg b/interface/resources/icons/create-icons/25-web-1-01.svg deleted file mode 100644 index 4f0eccc11e..0000000000 --- a/interface/resources/icons/create-icons/25-web-1-01.svg +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - diff --git a/interface/resources/icons/create-icons/90-particles-01.svg b/interface/resources/icons/create-icons/90-particles-01.svg deleted file mode 100644 index 5e0105d7cd..0000000000 --- a/interface/resources/icons/create-icons/90-particles-01.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/interface/resources/icons/create-icons/94-model-01.svg b/interface/resources/icons/create-icons/94-model-01.svg deleted file mode 100644 index 5d8c4c5eca..0000000000 --- a/interface/resources/icons/create-icons/94-model-01.svg +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/interface/resources/images/sphere-01.svg b/interface/resources/images/sphere-01.svg deleted file mode 100644 index 975199c8da..0000000000 --- a/interface/resources/images/sphere-01.svg +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/interface/resources/qml/AssetServer.qml b/interface/resources/qml/AssetServer.qml index c85fd5b379..6f3076b408 100644 --- a/interface/resources/qml/AssetServer.qml +++ b/interface/resources/qml/AssetServer.qml @@ -177,7 +177,7 @@ ScrollingWindow { SHAPE_TYPE_STATIC_MESH ], checkStateOnDisable: false, - warningOnDisable: "Models with 'Exact' automatic collisions cannot be dynamic" + warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic" } }); diff --git a/interface/resources/qml/TabletLoginDialog/CompleteProfileBody.qml b/interface/resources/qml/TabletLoginDialog/CompleteProfileBody.qml deleted file mode 100644 index 6024563bcf..0000000000 --- a/interface/resources/qml/TabletLoginDialog/CompleteProfileBody.qml +++ /dev/null @@ -1,124 +0,0 @@ -// -// CompleteProfileBody.qml -// -// Created by Clement on 7/18/16 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtQuick.Controls.Styles 1.4 as OriginalStyles - -import "../controls-uit" -import "../styles-uit" - -Item { - id: completeProfileBody - clip: true - - QtObject { - id: d - function resize() {} - } - - Row { - id: buttons - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - width: 200 - - text: qsTr("Create your profile") - color: hifi.buttons.blue - - onClicked: loginDialog.createAccountFromStream() - } - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Cancel") - - onClicked: bodyLoader.popup() - } - } - - ShortcutText { - id: additionalTextContainer - anchors { - top: buttons.bottom - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: "Already have a High Fidelity profile? Link to an existing profile here." - - wrapMode: Text.WordWrap - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - - onLinkActivated: { - bodyLoader.setSource("LinkAccountBody.qml") - } - } - - InfoItem { - id: termsContainer - anchors { - top: additionalTextContainer.bottom - left: parent.left - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - - text: qsTr("By creating this user profile, you agree to High Fidelity's Terms of Service") - wrapMode: Text.WordWrap - color: hifi.colors.baseGrayHighlight - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - - onLinkActivated: loginDialog.openUrl(link) - } - - Component.onCompleted: { - loginDialogRoot.title = qsTr("Complete Your Profile") - loginDialogRoot.iconText = "<" - d.resize(); - } - - Connections { - target: loginDialog - onHandleCreateCompleted: { - console.log("Create Succeeded") - - loginDialog.loginThroughSteam() - } - onHandleCreateFailed: { - console.log("Create Failed: " + error) - - bodyLoadersetSource("UsernameCollisionBody.qml") - } - onHandleLoginCompleted: { - console.log("Login Succeeded") - - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : false }) - } - onHandleLoginFailed: { - console.log("Login Failed") - } - } -} diff --git a/interface/resources/qml/TabletLoginDialog/LinkAccountBody.qml b/interface/resources/qml/TabletLoginDialog/LinkAccountBody.qml deleted file mode 100644 index 8010a34250..0000000000 --- a/interface/resources/qml/TabletLoginDialog/LinkAccountBody.qml +++ /dev/null @@ -1,296 +0,0 @@ -// -// LinkAccountBody.qml -// -// Created by Clement on 7/18/16 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 as OriginalStyles - -import "../controls-uit" -import "../styles-uit" - -Item { - id: linkAccountBody - clip: true - height: parent.height - width: parent.width - property bool failAfterSignUp: false - - function login() { - mainTextContainer.visible = false - toggleLoading(true) - loginDialog.login(usernameField.text, passwordField.text) - } - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - QtObject { - id: d - function resize() {} - } - - function toggleLoading(isLoading) { - linkAccountSpinner.visible = isLoading - form.visible = !isLoading - - if (loginDialog.isSteamRunning()) { - additionalInformation.visible = !isLoading - } - - leftButton.visible = !isLoading - buttons.visible = !isLoading - } - - BusyIndicator { - id: linkAccountSpinner - - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: false - running: true - - width: 48 - height: 48 - } - - ShortcutText { - id: mainTextContainer - anchors { - top: parent.top - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: false - - text: qsTr("Username or password incorrect.") - wrapMode: Text.WordWrap - color: hifi.colors.redAccent - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - Column { - id: form - anchors { - top: mainTextContainer.bottom - left: parent.left - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: 2 * hifi.dimensions.contentSpacing.y - - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: usernameField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 - - label: "Username or Email" - } - - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } - - text: "Forgot Username?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - } - } - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: passwordField - anchors { - verticalCenter: parent.verticalCenter - } - width: 350 - - label: "Password" - echoMode: TextInput.Password - } - - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } - - text: "Forgot Password?" - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - linkColor: hifi.colors.blueAccent - - onLinkActivated: loginDialog.openUrl(link) - } - } - - } - - InfoItem { - id: additionalInformation - anchors { - top: form.bottom - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: loginDialog.isSteamRunning() - - text: qsTr("Your steam account informations will not be exposed to other users.") - wrapMode: Text.WordWrap - color: hifi.colors.baseGrayHighlight - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - - Row { - id: leftButton - anchors { - left: parent.left - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Sign Up") - visible: !loginDialog.isSteamRunning() - - onClicked: { - bodyLoader.setSource("SignUpBody.qml") - } - } - } - - Row { - id: buttons - anchors { - right: parent.right - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - id: linkAccountButton - anchors.verticalCenter: parent.verticalCenter - width: 200 - - text: qsTr(loginDialog.isSteamRunning() ? "Link Account" : "Login") - color: hifi.buttons.blue - - onClicked: linkAccountBody.login() - } - - Button { - anchors.verticalCenter: parent.verticalCenter - text: qsTr("Cancel") - onClicked: { - bodyLoader.popup() - } - } - } - - Component.onCompleted: { - loginDialogRoot.title = qsTr("Sign Into High Fidelity") - loginDialogRoot.iconText = "<" - keyboardEnabled = HMD.active; - d.resize(); - - if (failAfterSignUp) { - mainTextContainer.text = "Account created successfully." - mainTextContainer.visible = true - } - - usernameField.forceActiveFocus(); - } - - Connections { - target: loginDialog - onHandleLoginCompleted: { - console.log("Login Succeeded, linking steam account") - - if (loginDialog.isSteamRunning()) { - loginDialog.linkSteam() - } else { - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) - } - } - onHandleLoginFailed: { - console.log("Login Failed") - mainTextContainer.visible = true - toggleLoading(false) - } - onHandleLinkCompleted: { - console.log("Link Succeeded") - - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) - } - onHandleLinkFailed: { - console.log("Link Failed") - toggleLoading(false) - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - linkAccountBody.login() - break - } - } -} diff --git a/interface/resources/qml/TabletLoginDialog/SignInBody.qml b/interface/resources/qml/TabletLoginDialog/SignInBody.qml deleted file mode 100644 index 9cdf69c7bc..0000000000 --- a/interface/resources/qml/TabletLoginDialog/SignInBody.qml +++ /dev/null @@ -1,109 +0,0 @@ -// -// SignInBody.qml -// -// Created by Clement on 7/18/16 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtQuick.Controls.Styles 1.4 as OriginalStyles - -import "../controls-uit" -import "../styles-uit" - -Item { - id: signInBody - clip: true - - property bool required: false - - function login() { - console.log("Trying to log in") - loginDialog.loginThroughSteam() - } - - function cancel() { - bodyLoader.popup() - } - - QtObject { - id: d - function resize() {} - } - - InfoItem { - id: mainTextContainer - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: required ? qsTr("This domain's owner requires that you sign in:") - : qsTr("Sign in to access your user account:") - wrapMode: Text.WordWrap - color: hifi.colors.baseGrayHighlight - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - Row { - id: buttons - anchors { - top: mainTextContainer.bottom - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - - width: undefined // invalidate so that the image's size sets the width - height: undefined // invalidate so that the image's size sets the height - focus: true - - style: OriginalStyles.ButtonStyle { - background: Image { - id: buttonImage - source: "../../images/steam-sign-in.png" - } - } - onClicked: signInBody.login() - } - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Cancel"); - - onClicked: signInBody.cancel() - } - } - - Component.onCompleted: { - loginDialogRoot.title = required ? qsTr("Sign In Required") - : qsTr("Sign In") - loginDialogRoot.iconText = "" - d.resize(); - } - - Connections { - target: loginDialog - onHandleLoginCompleted: { - console.log("Login Succeeded") - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : true }) - } - onHandleLoginFailed: { - console.log("Login Failed") - bodyLoader.setSource("CompleteProfileBody.qml") - } - } -} diff --git a/interface/resources/qml/TabletLoginDialog/SignUpBody.qml b/interface/resources/qml/TabletLoginDialog/SignUpBody.qml deleted file mode 100644 index 2cfc0e736a..0000000000 --- a/interface/resources/qml/TabletLoginDialog/SignUpBody.qml +++ /dev/null @@ -1,276 +0,0 @@ -// -// SignUpBody.qml -// -// Created by Stephen Birarda on 7 Dec 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 as OriginalStyles - -import "../controls-uit" -import "../styles-uit" - -Item { - id: signupBody - clip: true -// height: parent.height -// width: parent.width - - function signup() { - mainTextContainer.visible = false - toggleLoading(true) - loginDialog.signup(emailField.text, usernameField.text, passwordField.text) - } - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - QtObject { - id: d - function resize() {} - } - - function toggleLoading(isLoading) { - linkAccountSpinner.visible = isLoading - form.visible = !isLoading - - leftButton.visible = !isLoading - buttons.visible = !isLoading - } - - BusyIndicator { - id: linkAccountSpinner - - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: false - running: true - - width: 48 - height: 48 - } - - ShortcutText { - id: mainTextContainer - anchors { - top: parent.top - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - visible: false - - text: qsTr("There was an unknown error while creating your account.") - wrapMode: Text.WordWrap - color: hifi.colors.redAccent - horizontalAlignment: Text.AlignLeft - } - - Column { - id: form - anchors { - top: mainTextContainer.bottom - left: parent.left - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: 2 * hifi.dimensions.contentSpacing.y - - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: emailField - anchors { - verticalCenter: parent.verticalCenter - } - width: 300 - - label: "Email" - } - } - - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: usernameField - anchors { - verticalCenter: parent.verticalCenter - } - width: 300 - - label: "Username" - } - - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } - - text: qsTr("No spaces / special chars.") - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - - color: hifi.colors.blueAccent - } - } - - Row { - spacing: hifi.dimensions.contentSpacing.x - - TextField { - id: passwordField - anchors { - verticalCenter: parent.verticalCenter - } - width: 300 - - label: "Password" - echoMode: TextInput.Password - } - - ShortcutText { - anchors { - verticalCenter: parent.verticalCenter - } - - text: qsTr("At least 6 characters") - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - - color: hifi.colors.blueAccent - } - } - - } - - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - - Row { - id: leftButton - anchors { - left: parent.left - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Existing User") - - onClicked: { - bodyLoader.setSource("LinkAccountBody.qml") - } - } - } - - Row { - id: buttons - anchors { - right: parent.right - bottom: parent.bottom - bottomMargin: hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - id: linkAccountButton - anchors.verticalCenter: parent.verticalCenter - width: 200 - - text: qsTr("Sign Up") - color: hifi.buttons.blue - - onClicked: signupBody.signup() - } - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Cancel") - - onClicked: bodyLoader.popup() - } - } - - Component.onCompleted: { - loginDialogRoot.title = qsTr("Create an Account") - loginDialogRoot.iconText = "<" - keyboardEnabled = HMD.active; - d.resize(); - - emailField.forceActiveFocus(); - } - - Connections { - target: loginDialog - onHandleSignupCompleted: { - console.log("Sign Up Succeeded"); - - // now that we have an account, login with that username and password - loginDialog.login(usernameField.text, passwordField.text) - } - onHandleSignupFailed: { - console.log("Sign Up Failed") - toggleLoading(false) - - mainTextContainer.text = errorString - mainTextContainer.visible = true - - d.resize(); - } - onHandleLoginCompleted: { - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack": false }) - } - onHandleLoginFailed: { - // we failed to login, show the LoginDialog so the user will try again - bodyLoader.setSource("LinkAccountBody.qml", { "failAfterSignUp": true }) - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - signupBody.signup() - break - } - } -} diff --git a/interface/resources/qml/TabletLoginDialog/UsernameCollisionBody.qml b/interface/resources/qml/TabletLoginDialog/UsernameCollisionBody.qml deleted file mode 100644 index 9e5b01d339..0000000000 --- a/interface/resources/qml/TabletLoginDialog/UsernameCollisionBody.qml +++ /dev/null @@ -1,157 +0,0 @@ -// -// UsernameCollisionBody.qml -// -// Created by Clement on 7/18/16 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 as OriginalStyles - -import "../controls-uit" -import "../styles-uit" - -Item { - id: usernameCollisionBody - clip: true - width: parent.width - height: parent.height - - function create() { - mainTextContainer.visible = false - loginDialog.createAccountFromStream(textField.text) - } - - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - QtObject { - id: d - function resize() {} - } - - ShortcutText { - id: mainTextContainer - anchors { - top: parent.top - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: qsTr("Your Steam username is not available.") - wrapMode: Text.WordWrap - color: hifi.colors.redAccent - lineHeight: 1 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - - TextField { - id: textField - anchors { - top: mainTextContainer.bottom - left: parent.left - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - width: 250 - - placeholderText: "Choose your own" - } - - // Override ScrollingWindow's keyboard that would be at very bottom of dialog. - Keyboard { - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: keyboardRaised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - - Row { - id: buttons - anchors { - bottom: parent.bottom - right: parent.right - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - width: 200 - - text: qsTr("Create your profile") - color: hifi.buttons.blue - - onClicked: usernameCollisionBody.create() - } - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Cancel") - onClicked: bodyLoader.popup() - } - } - - Component.onCompleted: { - loginDialogRoot.title = qsTr("Complete Your Profile") - loginDialogRoot.iconText = "<" - keyboardEnabled = HMD.active; - d.resize(); - } - - Connections { - target: loginDialog - onHandleCreateCompleted: { - console.log("Create Succeeded") - - loginDialog.loginThroughSteam() - } - onHandleCreateFailed: { - console.log("Create Failed: " + error) - - mainTextContainer.visible = true - mainTextContainer.text = "\"" + textField.text + qsTr("\" is invalid or already taken.") - } - onHandleLoginCompleted: { - console.log("Login Succeeded") - - bodyLoader.setSource("WelcomeBody.qml", { "welcomeBack" : false }) - } - onHandleLoginFailed: { - console.log("Login Failed") - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - switch (event.key) { - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - usernameCollisionBody.create() - break - } - } -} diff --git a/interface/resources/qml/TabletLoginDialog/WelcomeBody.qml b/interface/resources/qml/TabletLoginDialog/WelcomeBody.qml deleted file mode 100644 index 5ec259ca96..0000000000 --- a/interface/resources/qml/TabletLoginDialog/WelcomeBody.qml +++ /dev/null @@ -1,79 +0,0 @@ -// -// WelcomeBody.qml -// -// Created by Clement on 7/18/16 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 - -import "../controls-uit" -import "../styles-uit" - -Item { - id: welcomeBody - clip: true - - property bool welcomeBack: false - - function setTitle() { - loginDialogRoot.title = (welcomeBack ? qsTr("Welcome back ") : qsTr("Welcome ")) + Account.username + qsTr("!") - loginDialogRoot.iconText = "" - d.resize(); - } - - QtObject { - id: d - function resize() {} - } - - InfoItem { - id: mainTextContainer - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - - text: qsTr("You are now signed into High Fidelity") - wrapMode: Text.WordWrap - color: hifi.colors.baseGrayHighlight - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - } - - Row { - id: buttons - anchors { - top: mainTextContainer.bottom - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - - Button { - anchors.verticalCenter: parent.verticalCenter - - text: qsTr("Close"); - - onClicked: bodyLoader.popup() - } - } - - Component.onCompleted: { - welcomeBody.setTitle() - } - - Connections { - target: Account - onUsernameChanged: welcomeBody.setTitle() - } -} diff --git a/interface/resources/qml/controls-uit/AttachmentsTable.qml b/interface/resources/qml/controls-uit/AttachmentsTable.qml index 8ee9909ab8..7d0280b72d 100644 --- a/interface/resources/qml/controls-uit/AttachmentsTable.qml +++ b/interface/resources/qml/controls-uit/AttachmentsTable.qml @@ -120,7 +120,7 @@ TableView { } rowDelegate: Rectangle { - height: hifi.dimensions.tableRowHeight + height: (styleData.selected ? 1.2 : 1) * hifi.dimensions.tableRowHeight color: styleData.selected ? hifi.colors.primaryHighlight : tableView.isLightColorScheme diff --git a/interface/resources/qml/controls-uit/BaseWebView.qml b/interface/resources/qml/controls-uit/BaseWebView.qml index 9c22a8ff8c..763e6530fb 100644 --- a/interface/resources/qml/controls-uit/BaseWebView.qml +++ b/interface/resources/qml/controls-uit/BaseWebView.qml @@ -15,7 +15,7 @@ import HFWebEngineProfile 1.0 WebEngineView { id: root - // profile: desktop.browserProfile + profile: desktop.browserProfile Component.onCompleted: { console.log("Connecting JS messaging to Hifi Logging") diff --git a/interface/resources/qml/controls-uit/CheckBox.qml b/interface/resources/qml/controls-uit/CheckBox.qml index 60e136d13a..35b81b44b4 100644 --- a/interface/resources/qml/controls-uit/CheckBox.qml +++ b/interface/resources/qml/controls-uit/CheckBox.qml @@ -25,8 +25,6 @@ Original.CheckBox { readonly property int checkSize: Math.max(boxSize - 8, 10) readonly property int checkRadius: 2 - activeFocusOnPress: true - style: CheckBoxStyle { indicator: Rectangle { id: box diff --git a/interface/resources/qml/controls-uit/ComboBox.qml b/interface/resources/qml/controls-uit/ComboBox.qml index 2dea535c06..573fed4ef9 100644 --- a/interface/resources/qml/controls-uit/ComboBox.qml +++ b/interface/resources/qml/controls-uit/ComboBox.qml @@ -14,6 +14,7 @@ import QtQuick.Controls.Styles 1.4 import "../styles-uit" import "../controls-uit" as HifiControls +import "." as VrControls FocusScope { id: root @@ -24,7 +25,6 @@ FocusScope { readonly property alias currentText: comboBox.currentText; property alias currentIndex: comboBox.currentIndex; - property int dropdownHeight: 480 property int colorScheme: hifi.colorSchemes.light readonly property bool isLightColorScheme: colorScheme == hifi.colorSchemes.light property string label: "" @@ -32,8 +32,6 @@ FocusScope { readonly property ComboBox control: comboBox - property bool isDesktop: true - signal accepted(); implicitHeight: comboBox.height; @@ -121,17 +119,11 @@ FocusScope { } function showList() { - var r; - if (isDesktop) { - r = desktop.mapFromItem(root, 0, 0, root.width, root.height); - } else { - r = mapFromItem(root, 0, 0, root.width, root.height); - } + var r = desktop.mapFromItem(root, 0, 0, root.width, root.height); var y = r.y + r.height; var bottom = y + scrollView.height; - var height = isDesktop ? desktop.height : tabletRoot.height; - if (bottom > height) { - y -= bottom - height + 8; + if (bottom > desktop.height) { + y -= bottom - desktop.height + 8; } scrollView.x = r.x; scrollView.y = y; @@ -149,9 +141,9 @@ FocusScope { FocusScope { id: popup - parent: isDesktop ? desktop : root + parent: desktop anchors.fill: parent - z: isDesktop ? desktop.zLevels.menu : 12 + z: desktop.zLevels.menu visible: false focus: true @@ -174,7 +166,7 @@ FocusScope { ScrollView { id: scrollView - height: root.dropdownHeight + height: 480 width: root.width + 4 property bool hoverEnabled: false; @@ -186,18 +178,18 @@ FocusScope { visible: false } scrollBarBackground: Rectangle{ - implicitWidth: 20 + implicitWidth: 14 color: hifi.colors.baseGray } handle: Rectangle { - implicitWidth: 16 + implicitWidth: 8 anchors.left: parent.left anchors.leftMargin: 3 anchors.top: parent.top anchors.bottom: parent.bottom - radius: 6 + radius: 3 color: hifi.colors.lightGrayText } } @@ -241,8 +233,4 @@ FocusScope { anchors.bottomMargin: 4 visible: label != "" } - - Component.onCompleted: { - isDesktop = (typeof desktop !== "undefined"); - } } diff --git a/interface/resources/qml/controls-uit/Slider.qml b/interface/resources/qml/controls-uit/Slider.qml index 39831546e1..cf59e1d989 100644 --- a/interface/resources/qml/controls-uit/Slider.qml +++ b/interface/resources/qml/controls-uit/Slider.qml @@ -36,7 +36,7 @@ Slider { Rectangle { width: parent.height - 2 - height: slider.value * (slider.width/(slider.maximumValue - slider.minimumValue)) - 1 + height: slider.value * slider.width - 1 radius: height / 2 anchors { top: parent.top diff --git a/interface/resources/qml/controls-uit/TabletHeader.qml b/interface/resources/qml/controls-uit/TabletHeader.qml deleted file mode 100644 index 17530f81ea..0000000000 --- a/interface/resources/qml/controls-uit/TabletHeader.qml +++ /dev/null @@ -1,35 +0,0 @@ -// -// TabletHeader.qml -// -// Created by David Rowe on 11 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../styles-uit" - -Rectangle { - - property string title: "" - - HifiConstants { id: hifi } - - height: hifi.dimensions.tabletMenuHeader - z: 100 - - color: hifi.colors.darkGray - - RalewayBold { - text: title - size: 26 - color: hifi.colors.white - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.contentMargin.x - } -} diff --git a/interface/resources/qml/dialogs/CustomQueryDialog.qml b/interface/resources/qml/dialogs/CustomQueryDialog.qml index 4d6fe74bca..97f55d087b 100644 --- a/interface/resources/qml/dialogs/CustomQueryDialog.qml +++ b/interface/resources/qml/dialogs/CustomQueryDialog.qml @@ -107,10 +107,10 @@ ModalWindow { QtObject { id: d; - readonly property int minWidth: 480 - readonly property int maxWdith: 1280 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 + readonly property int minWidth: 480; + readonly property int maxWdith: 1280; + readonly property int minHeight: 120; + readonly property int maxHeight: 720; function resize() { var targetWidth = Math.max(titleWidth, pane.width); @@ -259,7 +259,6 @@ ModalWindow { visible: Boolean(root.warning); text: hifi.glyphs.alert; size: hifi.dimensions.controlLineHeight; - width: 20 // Line up with checkbox. } } diff --git a/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml b/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml deleted file mode 100644 index 7965006b8b..0000000000 --- a/interface/resources/qml/dialogs/TabletCustomQueryDialog.qml +++ /dev/null @@ -1,355 +0,0 @@ -// -// TabletCustomQueryDialog.qml -// -// Created by Vlad Stelmahovsky on 3/27/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs - -import "../controls-uit" -import "../styles-uit" -import "../windows" - -TabletModalWindow { - id: root; - HifiConstants { id: hifi; } - - anchors.fill: parent - width: parent.width - height: parent.height - - title: "" - visible: true; - property bool keyboardOverride: true - - signal selected(var result); - signal canceled(); - - property int icon: hifi.icons.none; - property string iconText: ""; - property int iconSize: 35; - onIconChanged: updateIcon(); - - property var textInput; - property var comboBox; - property var checkBox; - onTextInputChanged: { - if (textInput && textInput.text !== undefined) { - textField.text = textInput.text; - } - } - onComboBoxChanged: { - if (comboBox && comboBox.index !== undefined) { - comboBoxField.currentIndex = comboBox.index; - } - } - onCheckBoxChanged: { - if (checkBox && checkBox.checked !== undefined) { - checkBoxField.checked = checkBox.checked; - } - } - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - onKeyboardRaisedChanged: d.resize(); - - property var warning: ""; - property var result; - - property var implicitCheckState: null; - - property int titleWidth: 0; - onTitleWidthChanged: d.resize(); - - MouseArea { - width: parent.width - height: parent.height - } - - function updateIcon() { - if (!root) { - return; - } - iconText = hifi.glyphForIcon(root.icon); - } - - function updateCheckbox() { - if (checkBox.disableForItems) { - var currentItemInDisableList = false; - for (var i in checkBox.disableForItems) { - if (comboBoxField.currentIndex === checkBox.disableForItems[i]) { - currentItemInDisableList = true; - break; - } - } - - if (currentItemInDisableList) { - checkBoxField.enabled = false; - if (checkBox.checkStateOnDisable !== null && checkBox.checkStateOnDisable !== undefined) { - root.implicitCheckState = checkBoxField.checked; - checkBoxField.checked = checkBox.checkStateOnDisable; - } - root.warning = checkBox.warningOnDisable; - } else { - checkBoxField.enabled = true; - if (root.implicitCheckState !== null) { - checkBoxField.checked = root.implicitCheckState; - root.implicitCheckState = null; - } - root.warning = ""; - } - } - } - - TabletModalFrame { - id: modalWindowItem - width: parent.width - 6 - height: 240 - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - - MouseArea { - // Clicking dialog background defocuses active control. - anchors.fill: parent - onClicked: parent.forceActiveFocus(); - } - - QtObject { - id: d; - readonly property int minWidth: 470 - readonly property int maxWidth: 470 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 - - function resize() { - var targetWidth = Math.max(titleWidth, 470); - var targetHeight = (textField.visible ? textField.controlHeight + hifi.dimensions.contentSpacing.y : 0) + - (extraInputs.visible ? extraInputs.height + hifi.dimensions.contentSpacing.y : 0) + - (buttons.height + 3 * hifi.dimensions.contentSpacing.y) + - ((keyboardEnabled && keyboardRaised) ? (keyboard.raisedHeight + hifi.dimensions.contentSpacing.y) : 0); - - root.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWdith) ? d.maxWidth : targetWidth); - modalWindowItem.height = (targetHeight < d.minHeight) ? d.minHeight : ((targetHeight > d.maxHeight) ? - d.maxHeight : targetHeight); - if (checkBoxField.visible && comboBoxField.visible) { - checkBoxField.width = extraInputs.width / 2; - comboBoxField.width = extraInputs.width / 2; - } else if (!checkBoxField.visible && comboBoxField.visible) { - comboBoxField.width = extraInputs.width; - } - } - } - - Item { - anchors { - top: parent.top; - bottom: extraInputs.visible ? extraInputs.top : buttons.top; - left: parent.left; - right: parent.right; - leftMargin: 12 - rightMargin: 12 - } - - // FIXME make a text field type that can be bound to a history for autocompletion - TextField { - id: textField; - label: root.textInput.label; - focus: root.textInput ? true : false; - visible: root.textInput ? true : false; - anchors { - left: parent.left; - right: parent.right; - bottom: keyboard.top; - bottomMargin: hifi.dimensions.contentSpacing.y; - } - } - - property alias keyboardOverride: root.keyboardOverride - property alias keyboardRaised: root.keyboardRaised - property alias punctuationMode: root.punctuationMode - Keyboard { - id: keyboard - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - bottomMargin: raised ? hifi.dimensions.contentSpacing.y : 0 - } - } - } - - Item { - id: extraInputs; - visible: Boolean(root.checkBox || root.comboBox); - anchors { - left: parent.left; - right: parent.right; - bottom: buttons.top; - bottomMargin: hifi.dimensions.contentSpacing.y; - leftMargin: 12 - rightMargin: 12 - } - height: comboBoxField.controlHeight; - onHeightChanged: d.resize(); - onWidthChanged: d.resize(); - z: 20 - - CheckBox { - id: checkBoxField; - text: root.checkBox.label; - focus: Boolean(root.checkBox); - visible: Boolean(root.checkBox); - anchors { - left: parent.left; - bottom: parent.bottom; - leftMargin: 6; // Magic number to align with warning icon - bottomMargin: 6; - } - } - - ComboBox { - id: comboBoxField; - label: root.comboBox.label; - focus: Boolean(root.comboBox); - visible: Boolean(root.comboBox); - anchors { - right: parent.right; - bottom: parent.bottom; - } - model: root.comboBox ? root.comboBox.items : []; - onAccepted: { - updateCheckbox(); - focus = true; - } - } - } - - Row { - id: buttons; - focus: true; - spacing: hifi.dimensions.contentSpacing.x; - layoutDirection: Qt.RightToLeft; - onHeightChanged: d.resize(); - onWidthChanged: { - d.resize(); - resizeWarningText(); - } - z: 10 - - anchors { - bottom: parent.bottom; - left: parent.left; - right: parent.right; - bottomMargin: hifi.dimensions.contentSpacing.y; - leftMargin: 12 - rightMargin: 12 - } - - function resizeWarningText() { - var rowWidth = buttons.width; - var buttonsWidth = acceptButton.width + cancelButton.width + hifi.dimensions.contentSpacing.x * 2; - var warningIconWidth = warningIcon.width + hifi.dimensions.contentSpacing.x; - warningText.width = rowWidth - buttonsWidth - warningIconWidth; - } - - Button { - id: cancelButton; - action: cancelAction; - } - - Button { - id: acceptButton; - action: acceptAction; - } - - Text { - id: warningText; - visible: Boolean(root.warning); - text: root.warning; - wrapMode: Text.WordWrap; - font.italic: true; - maximumLineCount: 2; - } - - HiFiGlyphs { - id: warningIcon; - visible: Boolean(root.warning); - text: hifi.glyphs.alert; - size: hifi.dimensions.controlLineHeight; - width: 20 // Line up with checkbox. - } - } - - Action { - id: cancelAction; - text: qsTr("Cancel"); - shortcut: Qt.Key_Escape; - onTriggered: { - root.result = null; - root.canceled(); - root.destroy(); - } - } - - Action { - id: acceptAction; - text: qsTr("Add"); - shortcut: Qt.Key_Return; - onTriggered: { - var result = {}; - if (textInput) { - result.textInput = textField.text; - } - if (comboBox) { - result.comboBox = comboBoxField.currentIndex; - result.comboBoxText = comboBoxField.currentText; - } - if (checkBox) { - result.checkBox = checkBoxField.enabled ? checkBoxField.checked : null; - } - root.result = JSON.stringify(result); - root.selected(root.result); - root.destroy(); - } - } - } - - Keys.onPressed: { - if (!visible) { - return; - } - - switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - cancelAction.trigger(); - event.accepted = true; - break; - - case Qt.Key_Return: - case Qt.Key_Enter: - acceptAction.trigger(); - event.accepted = true; - break; - } - } - - Component.onCompleted: { - keyboardEnabled = HMD.active; - updateIcon(); - updateCheckbox(); - d.resize(); - textField.forceActiveFocus(); - } -} diff --git a/interface/resources/qml/dialogs/TabletFileDialog.qml b/interface/resources/qml/dialogs/TabletFileDialog.qml deleted file mode 100644 index 5e33663436..0000000000 --- a/interface/resources/qml/dialogs/TabletFileDialog.qml +++ /dev/null @@ -1,782 +0,0 @@ -// -// FileDialog.qml -// -// Created by Dante Ruiz on 23 Feb 2017 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Qt.labs.folderlistmodel 2.1 -import Qt.labs.settings 1.0 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs - -import ".." -import "../controls-uit" -import "../styles-uit" -import "../windows" - -import "fileDialog" - -//FIXME implement shortcuts for favorite location -TabletModalWindow { - id: root - anchors.fill: parent - width: parent.width - height: parent.height - HifiConstants { id: hifi } - - Settings { - category: "FileDialog" - property alias width: root.width - property alias height: root.height - property alias x: root.x - property alias y: root.y - } - - - // Set from OffscreenUi::getOpenFile() - property alias caption: root.title; - // Set from OffscreenUi::getOpenFile() - property alias dir: fileTableModel.folder; - // Set from OffscreenUi::getOpenFile() - property alias filter: selectionType.filtersString; - // Set from OffscreenUi::getOpenFile() - property int options; // <-- FIXME unused - - property string iconText: root.title !== "" ? hifi.glyphs.scriptUpload : "" - property int iconSize: 40 - - property bool selectDirectory: false; - property bool showHidden: false; - // FIXME implement - property bool multiSelect: false; - property bool saveDialog: false; - property var helper: fileDialogHelper - property alias model: fileTableView.model - property var drives: helper.drives() - - property int titleWidth: 0 - - signal selectedFile(var file); - signal canceled(); - - Component.onCompleted: { - fileDialogItem.keyboardEnabled = HMD.active; - - // HACK: The following lines force the model to initialize properly such that the go-up button - // works properly from the initial screen. - var initialFolder = folderListModel.folder; - fileTableModel.folder = helper.pathToUrl(drives[0]); - fileTableModel.folder = initialFolder; - - iconText = root.title !== "" ? hifi.glyphs.scriptUpload : ""; - - // Clear selection when click on external frame. - //frameClicked.connect(function() { d.clearSelection(); }); - - if (selectDirectory) { - currentSelection.text = d.capitalizeDrive(helper.urlToPath(initialFolder)); - d.currentSelectionIsFolder = true; - d.currentSelectionUrl = initialFolder; - } - - helper.contentsChanged.connect(function() { - if (folderListModel) { - // Make folderListModel refresh. - var save = folderListModel.folder; - folderListModel.folder = ""; - folderListModel.folder = save; - } - }); - - fileTableView.forceActiveFocus(); - } - - TabletModalFrame { - id: fileDialogItem - width: parent.width - 6 - height: parent.height - 6 - - anchors { - horizontalCenter: root.horizontalCenter - verticalCenter: root.verticalCenter - } - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - MouseArea { - // Clear selection when click on internal unused area. - anchors.fill: parent - onClicked: { - d.clearSelection(); - } - } - - Row { - id: navControls - anchors { - top: parent.top - topMargin: (fileDialogItem.hasTitle ? (fileDialogItem.frameMarginTop + hifi.dimensions.modalDialogMargin.y) : hifi.dimension.modalDialogMargin.y) - left: parent.left - leftMargin: hifi.dimensions.contentSpacing.x - } - spacing: hifi.dimensions.contentSpacing.x - - GlyphButton { - id: upButton - glyph: hifi.glyphs.levelUp - width: height - size: 30 - enabled: fileTableModel.parentFolder && fileTableModel.parentFolder !== "" - onClicked: d.navigateUp(); - } - - GlyphButton { - id: homeButton - property var destination: helper.home(); - glyph: hifi.glyphs.home - size: 28 - width: height - enabled: d.homeDestination ? true : false - onClicked: d.navigateHome(); - } - } - - ComboBox { - id: pathSelector - z: 10 - anchors { - top: parent.top - topMargin: (fileDialogItem.hasTitle ? (fileDialogItem.frameMarginTop + hifi.dimensions.modalDialogMargin.y) : hifi.dimension.modalDialogMargin.y) - left: navControls.right - leftMargin: hifi.dimensions.contentSpacing.x - right: parent.right - } - - property var lastValidFolder: helper.urlToPath(fileTableModel.folder) - - function calculatePathChoices(folder) { - var folders = folder.split("/"), - choices = [], - i, length; - - if (folders[folders.length - 1] === "") { - folders.pop(); - } - - choices.push(folders[0]); - - for (i = 1, length = folders.length; i < length; i++) { - choices.push(choices[i - 1] + "/" + folders[i]); - } - - if (folders[0] === "") { - // Special handling for OSX root dir. - choices[0] = "/"; - } - - choices.reverse(); - - if (drives && drives.length > 1) { - choices.push("This PC"); - } - - if (choices.length > 0) { - pathSelector.model = choices; - } - } - - onLastValidFolderChanged: { - var folder = d.capitalizeDrive(lastValidFolder); - calculatePathChoices(folder); - } - - onCurrentTextChanged: { - var folder = currentText; - - if (/^[a-zA-z]:$/.test(folder)) { - folder = "file:///" + folder + "/"; - } else if (folder === "This PC") { - folder = "file:///"; - } else { - folder = helper.pathToUrl(folder); - } - - if (helper.urlToPath(folder).toLowerCase() !== helper.urlToPath(fileTableModel.folder).toLowerCase()) { - if (root.selectDirectory) { - currentSelection.text = currentText !== "This PC" ? currentText : ""; - d.currentSelectionUrl = helper.pathToUrl(currentText); - } - fileTableModel.folder = folder; - fileTableView.forceActiveFocus(); - } - } - } - - QtObject { - id: d - property var currentSelectionUrl; - readonly property string currentSelectionPath: helper.urlToPath(currentSelectionUrl); - property bool currentSelectionIsFolder; - property var backStack: [] - property var tableViewConnection: Connections { target: fileTableView; onCurrentRowChanged: d.update(); } - property var modelConnection: Connections { target: fileTableModel; onFolderChanged: d.update(); } - property var homeDestination: helper.home(); - - function capitalizeDrive(path) { - // Consistently capitalize drive letter for Windows. - if (/[a-zA-Z]:/.test(path)) { - return path.charAt(0).toUpperCase() + path.slice(1); - } - return path; - } - - function update() { - var row = fileTableView.currentRow; - - if (row === -1) { - if (!root.selectDirectory) { - currentSelection.text = ""; - currentSelectionIsFolder = false; - } - return; - } - - currentSelectionUrl = helper.pathToUrl(fileTableView.model.get(row).filePath); - currentSelectionIsFolder = fileTableView.model.isFolder(row); - if (root.selectDirectory || !currentSelectionIsFolder) { - currentSelection.text = capitalizeDrive(helper.urlToPath(currentSelectionUrl)); - } else { - currentSelection.text = ""; - } - } - - function navigateUp() { - if (fileTableModel.parentFolder && fileTableModel.parentFolder !== "") { - fileTableModel.folder = fileTableModel.parentFolder; - return true; - } - } - - function navigateHome() { - fileTableModel.folder = homeDestination; - return true; - } - - function clearSelection() { - fileTableView.selection.clear(); - fileTableView.currentRow = -1; - update(); - } - } - - FolderListModel { - id: folderListModel - nameFilters: selectionType.currentFilter - showDirsFirst: true - showDotAndDotDot: false - showFiles: !root.selectDirectory - Component.onCompleted: { - showFiles = !root.selectDirectory - } - - onFolderChanged: { - fileTableModel.update(); // Update once the data from the folder change is available. - } - - function getItem(index, field) { - return get(index, field); - } - } - - ListModel { - // Emulates FolderListModel but contains drive data. - id: driveListModel - - property int count: 1 - - Component.onCompleted: initialize(); - - function initialize() { - var drive, - i; - - count = drives.length; - - for (i = 0; i < count; i++) { - drive = drives[i].slice(0, -1); // Remove trailing "/". - append({ - fileName: drive, - fileModified: new Date(0), - fileSize: 0, - filePath: drive + "/", - fileIsDir: true, - fileNameSort: drive.toLowerCase() - }); - } - } - - function getItem(index, field) { - return get(index)[field]; - } - } - - ListModel { - id: fileTableModel - - // FolderListModel has a couple of problems: - // 1) Files and directories sort case-sensitively: https://bugreports.qt.io/browse/QTBUG-48757 - // 2) Cannot browse up to the "computer" level to view Windows drives: https://bugreports.qt.io/browse/QTBUG-42901 - // - // To solve these problems an intermediary ListModel is used that implements proper sorting and can be populated with - // drive information when viewing at the computer level. - - property var folder - property int sortOrder: Qt.AscendingOrder - property int sortColumn: 0 - property var model: folderListModel - property string parentFolder: calculateParentFolder(); - - readonly property string rootFolder: "file:///" - - function calculateParentFolder() { - if (model === folderListModel) { - if (folderListModel.parentFolder.toString() === "" && driveListModel.count > 1) { - return rootFolder; - } else { - return folderListModel.parentFolder; - } - } else { - return ""; - } - } - - onFolderChanged: { - if (folder === rootFolder) { - model = driveListModel; - helper.monitorDirectory(""); - update(); - } else { - var needsUpdate = model === driveListModel && folder === folderListModel.folder; - - model = folderListModel; - folderListModel.folder = folder; - helper.monitorDirectory(helper.urlToPath(folder)); - - if (needsUpdate) { - update(); - } - } - } - - function isFolder(row) { - if (row === -1) { - return false; - } - return get(row).fileIsDir; - } - - function update() { - var dataFields = ["fileName", "fileModified", "fileSize"], - sortFields = ["fileNameSort", "fileModified", "fileSize"], - dataField = dataFields[sortColumn], - sortField = sortFields[sortColumn], - sortValue, - fileName, - fileIsDir, - comparisonFunction, - lower, - middle, - upper, - rows = 0, - i; - - clear(); - - comparisonFunction = sortOrder === Qt.AscendingOrder - ? function(a, b) { return a < b; } - : function(a, b) { return a > b; } - - for (i = 0; i < model.count; i++) { - fileName = model.getItem(i, "fileName"); - fileIsDir = model.getItem(i, "fileIsDir"); - - sortValue = model.getItem(i, dataField); - if (dataField === "fileName") { - // Directories first by prefixing a "*". - // Case-insensitive. - sortValue = (fileIsDir ? "*" : "") + sortValue.toLowerCase(); - } - - lower = 0; - upper = rows; - while (lower < upper) { - middle = Math.floor((lower + upper) / 2); - var lessThan; - if (comparisonFunction(sortValue, get(middle)[sortField])) { - lessThan = true; - upper = middle; - } else { - lessThan = false; - lower = middle + 1; - } - } - - insert(lower, { - fileName: fileName, - fileModified: (fileIsDir ? new Date(0) : model.getItem(i, "fileModified")), - fileSize: model.getItem(i, "fileSize"), - filePath: model.getItem(i, "filePath"), - fileIsDir: fileIsDir, - fileNameSort: (fileIsDir ? "*" : "") + fileName.toLowerCase() - }); - - rows++; - } - - d.clearSelection(); - } - } - - Table { - id: fileTableView - colorScheme: hifi.colorSchemes.light - anchors { - top: navControls.bottom - topMargin: hifi.dimensions.contentSpacing.y - left: parent.left - right: parent.right - bottom: currentSelection.top - bottomMargin: hifi.dimensions.contentSpacing.y + currentSelection.controlHeight - currentSelection.height - } - headerVisible: !selectDirectory - onClicked: navigateToRow(row); - onDoubleClicked: navigateToRow(row); - focus: true - Keys.onReturnPressed: navigateToCurrentRow(); - Keys.onEnterPressed: navigateToCurrentRow(); - - sortIndicatorColumn: 0 - sortIndicatorOrder: Qt.AscendingOrder - sortIndicatorVisible: true - - model: fileTableModel - - function updateSort() { - model.sortOrder = sortIndicatorOrder; - model.sortColumn = sortIndicatorColumn; - model.update(); - } - - onSortIndicatorColumnChanged: { updateSort(); } - - onSortIndicatorOrderChanged: { updateSort(); } - - itemDelegate: Item { - clip: true - - //FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } - //FontLoader { id: firaSansRegular; source: "../../fonts/FiraSans-Regular.ttf"; } - - FiraSansSemiBold { - text: getText(); - elide: styleData.elideMode - anchors { - left: parent.left - leftMargin: hifi.dimensions.tablePadding - right: parent.right - rightMargin: hifi.dimensions.tablePadding - verticalCenter: parent.verticalCenter - } - size: hifi.fontSizes.tableText - color: hifi.colors.baseGrayHighlight - //font.family: (styleData.row !== -1 && fileTableView.model.get(styleData.row).fileIsDir) - //? firaSansSemiBold.name : firaSansRegular.name - - function getText() { - if (styleData.row === -1) { - return styleData.value; - } - - switch (styleData.column) { - case 1: return fileTableView.model.get(styleData.row).fileIsDir ? "" : styleData.value; - case 2: return fileTableView.model.get(styleData.row).fileIsDir ? "" : formatSize(styleData.value); - default: return styleData.value; - } - } - function formatSize(size) { - var suffixes = [ "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" ]; - var suffixIndex = 0 - while ((size / 1024.0) > 1.1) { - size /= 1024.0; - ++suffixIndex; - } - - size = Math.round(size*1000)/1000; - size = size.toLocaleString() - - return size + " " + suffixes[suffixIndex]; - } - } - } - - TableViewColumn { - id: fileNameColumn - role: "fileName" - title: "Name" - width: (selectDirectory ? 1.0 : 0.5) * fileTableView.width - movable: false - resizable: true - } - TableViewColumn { - id: fileMofifiedColumn - role: "fileModified" - title: "Date" - width: 0.3 * fileTableView.width - movable: false - resizable: true - visible: !selectDirectory - } - TableViewColumn { - role: "fileSize" - title: "Size" - width: fileTableView.width - fileNameColumn.width - fileMofifiedColumn.width - movable: false - resizable: true - visible: !selectDirectory - } - - function navigateToRow(row) { - currentRow = row; - navigateToCurrentRow(); - } - - function navigateToCurrentRow() { - var row = fileTableView.currentRow - var isFolder = model.isFolder(row); - var file = model.get(row).filePath; - if (isFolder) { - fileTableView.model.folder = helper.pathToUrl(file); - } else { - okAction.trigger(); - } - } - - property string prefix: "" - - function addToPrefix(event) { - if (!event.text || event.text === "") { - return false; - } - var newPrefix = prefix + event.text.toLowerCase(); - var matchedIndex = -1; - for (var i = 0; i < model.count; ++i) { - var name = model.get(i).fileName.toLowerCase(); - if (0 === name.indexOf(newPrefix)) { - matchedIndex = i; - break; - } - } - - if (matchedIndex !== -1) { - fileTableView.selection.clear(); - fileTableView.selection.select(matchedIndex); - fileTableView.currentRow = matchedIndex; - fileTableView.prefix = newPrefix; - } - prefixClearTimer.restart(); - return true; - } - - Timer { - id: prefixClearTimer - interval: 1000 - repeat: false - running: false - onTriggered: fileTableView.prefix = ""; - } - - Keys.onPressed: { - switch (event.key) { - case Qt.Key_Backspace: - case Qt.Key_Tab: - case Qt.Key_Backtab: - event.accepted = false; - break; - - default: - if (addToPrefix(event)) { - event.accepted = true - } else { - event.accepted = false; - } - break; - } - } - } - - TextField { - id: currentSelection - label: selectDirectory ? "Directory:" : "File name:" - anchors { - left: parent.left - right: selectionType.visible ? selectionType.left: parent.right - rightMargin: hifi.dimensions.contentSpacing.x - leftMargin: hifi.dimensions.contentSpacing.x - bottom: keyboard.top - bottomMargin: hifi.dimensions.contentSpacing.y - } - readOnly: !root.saveDialog - activeFocusOnTab: !readOnly - onActiveFocusChanged: if (activeFocus) { selectAll(); } - onAccepted: okAction.trigger(); - } - - FileTypeSelection { - id: selectionType - anchors { - top: currentSelection.top - left: buttonRow.left - right: parent.right - } - visible: !selectDirectory && filtersCount > 1 - KeyNavigation.left: fileTableView - KeyNavigation.right: openButton - } - - Keyboard { - id: keyboard - raised: parent.keyboardEnabled && parent.keyboardRaised - numeric: parent.punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttonRow.top - bottomMargin: visible ? hifi.dimensions.contentSpacing.y : 0 - } - } - - Row { - id: buttonRow - anchors { - right: parent.right - bottom: parent.bottom - } - spacing: hifi.dimensions.contentSpacing.y - - Button { - id: openButton - color: hifi.buttons.blue - action: okAction - Keys.onReturnPressed: okAction.trigger() - KeyNavigation.up: selectionType - KeyNavigation.left: selectionType - KeyNavigation.right: cancelButton - } - - Button { - id: cancelButton - action: cancelAction - KeyNavigation.up: selectionType - KeyNavigation.left: openButton - KeyNavigation.right: fileTableView.contentItem - Keys.onReturnPressed: { canceled(); root.enabled = false } - } - } - - Action { - id: okAction - text: currentSelection.text ? (root.selectDirectory && fileTableView.currentRow === -1 ? "Choose" : (root.saveDialog ? "Save" : "Open")) : "Open" - enabled: currentSelection.text || !root.selectDirectory && d.currentSelectionIsFolder ? true : false - onTriggered: { - if (!root.selectDirectory && !d.currentSelectionIsFolder - || root.selectDirectory && fileTableView.currentRow === -1) { - okActionTimer.start(); - } else { - fileTableView.navigateToCurrentRow(); - } - } - } - - Timer { - id: okActionTimer - interval: 50 - running: false - repeat: false - onTriggered: { - if (!root.saveDialog) { - selectedFile(d.currentSelectionUrl); - root.destroy(); - return; - } - - // Handle the ambiguity between different cases - // * typed name (with or without extension) - // * full path vs relative vs filename only - var selection = helper.saveHelper(currentSelection.text, root.dir, selectionType.currentFilter); - - if (!selection) { - desktop.messageBox({ icon: OriginalDialogs.StandardIcon.Warning, text: "Unable to parse selection" }) - return; - } - - if (helper.urlIsDir(selection)) { - root.dir = selection; - currentSelection.text = ""; - return; - } - - // Check if the file is a valid target - if (!helper.urlIsWritable(selection)) { - desktop.messageBox({ - icon: OriginalDialogs.StandardIcon.Warning, - text: "Unable to write to location " + selection - }) - return; - } - - if (helper.urlExists(selection)) { - var messageBox = desktop.messageBox({ - icon: OriginalDialogs.StandardIcon.Question, - buttons: OriginalDialogs.StandardButton.Yes | OriginalDialogs.StandardButton.No, - text: "Do you wish to overwrite " + selection + "?", - }); - var result = messageBox.exec(); - if (OriginalDialogs.StandardButton.Yes !== result) { - return; - } - } - - console.log("Selecting " + selection) - selectedFile(selection); - root.destroy(); - } - } - - Action { - id: cancelAction - text: "Cancel" - onTriggered: { canceled();root.destroy(); } - } - } - - Keys.onPressed: { - switch (event.key) { - case Qt.Key_Backspace: - event.accepted = d.navigateUp(); - break; - - case Qt.Key_Home: - event.accepted = d.navigateHome(); - break; - - } - } -} diff --git a/interface/resources/qml/dialogs/TabletLoginDialog.qml b/interface/resources/qml/dialogs/TabletLoginDialog.qml deleted file mode 100644 index 78e5edebb5..0000000000 --- a/interface/resources/qml/dialogs/TabletLoginDialog.qml +++ /dev/null @@ -1,113 +0,0 @@ -// -// TabletLoginDialog.qml -// -// Created by Vlad Stelmahovsky on 15 Mar 2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../controls-uit" -import "../styles-uit" -import "../windows" - -TabletModalWindow { - id: loginDialogRoot - objectName: "LoginDialog" - - property var eventBridge; - signal sendToScript(var message); - property bool isHMD: false - - color: hifi.colors.baseGray - - property int colorScheme: hifi.colorSchemes.dark - property int titleWidth: 0 - property string iconText: "" - property int icon: hifi.icons.none - property int iconSize: 35 - MouseArea { - width: parent.width - height: parent.height - } - - property bool keyboardOverride: true - onIconChanged: updateIcon(); - - property var items; - property string label: "" - - onTitleWidthChanged: d.resize(); - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - signal canceled(); - - function updateIcon() { - if (!root) { - return; - } - iconText = hifi.glyphForIcon(root.icon); - } - - property alias bodyLoader: bodyLoader - property alias loginDialog: loginDialog - property alias hifi: hifi - - HifiConstants { id: hifi } - - onCanceled: { - loginDialogRoot.Stack.view.pop() - } - - LoginDialog { - id: loginDialog - width: parent.width - height: parent.height - StackView { - id: bodyLoader - property var item: currentItem - property var props - property string source: "" - - onCurrentItemChanged: { - //cleanup source for future usage - source = "" - } - - function setSource(src, props) { - source = "../TabletLoginDialog/" + src - bodyLoader.props = props - } - function popup() { - bodyLoader.pop() - - //check if last screen, if yes, dialog is popped out - if (depth === 1) - loginDialogRoot.canceled() - } - - anchors.fill: parent - anchors.margins: 10 - onSourceChanged: { - if (source !== "") { - bodyLoader.push(Qt.resolvedUrl(source), props) - } - } - Component.onCompleted: { - setSource(loginDialog.isSteamRunning() ? - "SignInBody.qml" : - "LinkAccountBody.qml") - } - } - } -} diff --git a/interface/resources/qml/dialogs/TabletMessageBox.qml b/interface/resources/qml/dialogs/TabletMessageBox.qml deleted file mode 100644 index f8876b1ec8..0000000000 --- a/interface/resources/qml/dialogs/TabletMessageBox.qml +++ /dev/null @@ -1,249 +0,0 @@ -// -// MessageDialog.qml -// -// Created by Bradley Austin Davis on 15 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs - -import "../controls-uit" -import "../styles-uit" -import "../windows" - -import "messageDialog" - -TabletModalWindow { - id: root - HifiConstants { id: hifi } - visible: true - - signal selected(int button); - - MouseArea { - id: mouse; - anchors.fill: parent - } - - function click(button) { - clickedButton = button; - selected(button); - destroy(); - } - - function exec() { - return OffscreenUi.waitForMessageBoxResult(root); - } - - property alias detailedText: detailedText.text - property alias text: mainTextContainer.text - property alias informativeText: informativeTextContainer.text - property int buttons: OriginalDialogs.StandardButton.Ok - property int icon: OriginalDialogs.StandardIcon.NoIcon - property string iconText: "" - property int iconSize: 50 - onIconChanged: updateIcon(); - property int defaultButton: OriginalDialogs.StandardButton.NoButton; - property int clickedButton: OriginalDialogs.StandardButton.NoButton; - focus: defaultButton === OriginalDialogs.StandardButton.NoButton - - property int titleWidth: 0 - onTitleWidthChanged: d.resize(); - - function updateIcon() { - if (!root) { - return; - } - iconText = hifi.glyphForIcon(root.icon); - } - - TabletModalFrame { - id: messageBox - clip: true - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width - 6 - height: 300 - - QtObject { - id: d - readonly property int minWidth: 200 - readonly property int maxWidth: 1280 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 - - function resize() { - var targetWidth = Math.max(titleWidth, mainTextContainer.contentWidth) - var targetHeight = mainTextContainer.height + 3 * hifi.dimensions.contentSpacing.y - + (informativeTextContainer.text != "" ? informativeTextContainer.contentHeight + 3 * hifi.dimensions.contentSpacing.y : 0) - + buttons.height - + (details.implicitHeight + hifi.dimensions.contentSpacing.y) + messageBox.frameMarginTop - messageBox.height = (targetHeight < d.minHeight) ? d.minHeight: ((targetHeight > d.maxHeight) ? d.maxHeight : targetHeight) - } - } - - RalewaySemiBold { - id: mainTextContainer - onTextChanged: d.resize(); - wrapMode: Text.WordWrap - size: hifi.fontSizes.sectionName - color: hifi.colors.baseGrayHighlight - width: parent.width - 6 - anchors { - top: parent.top - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y + messageBox.frameMarginTop - } - maximumLineCount: 30 - elide: Text.ElideLeft - lineHeight: 2 - lineHeightMode: Text.ProportionalHeight - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - } - - RalewaySemiBold { - id: informativeTextContainer - onTextChanged: d.resize(); - wrapMode: Text.WordWrap - size: hifi.fontSizes.sectionName - color: hifi.colors.baseGrayHighlight - anchors { - top: mainTextContainer.bottom - left: parent.left - right: parent.right - margins: 0 - topMargin: text != "" ? hifi.dimensions.contentSpacing.y : 0 - } - } - - Flow { - id: buttons - focus: true - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - layoutDirection: Qt.RightToLeft - anchors { - top: informativeTextContainer.text == "" ? mainTextContainer.bottom : informativeTextContainer.bottom - horizontalCenter: parent.horizontalCenter - margins: 0 - topMargin: 2 * hifi.dimensions.contentSpacing.y - } - MessageDialogButton { dialog: root; text: qsTr("Close"); button: OriginalDialogs.StandardButton.Close; } - MessageDialogButton { dialog: root; text: qsTr("Abort"); button: OriginalDialogs.StandardButton.Abort; } - MessageDialogButton { dialog: root; text: qsTr("Cancel"); button: OriginalDialogs.StandardButton.Cancel; } - MessageDialogButton { dialog: root; text: qsTr("Restore Defaults"); button: OriginalDialogs.StandardButton.RestoreDefaults; } - MessageDialogButton { dialog: root; text: qsTr("Reset"); button: OriginalDialogs.StandardButton.Reset; } - MessageDialogButton { dialog: root; text: qsTr("Discard"); button: OriginalDialogs.StandardButton.Discard; } - MessageDialogButton { dialog: root; text: qsTr("No to All"); button: OriginalDialogs.StandardButton.NoToAll; } - MessageDialogButton { dialog: root; text: qsTr("No"); button: OriginalDialogs.StandardButton.No; } - MessageDialogButton { dialog: root; text: qsTr("Yes to All"); button: OriginalDialogs.StandardButton.YesToAll; } - MessageDialogButton { dialog: root; text: qsTr("Yes"); button: OriginalDialogs.StandardButton.Yes; } - MessageDialogButton { dialog: root; text: qsTr("Apply"); button: OriginalDialogs.StandardButton.Apply; } - MessageDialogButton { dialog: root; text: qsTr("Ignore"); button: OriginalDialogs.StandardButton.Ignore; } - MessageDialogButton { dialog: root; text: qsTr("Retry"); button: OriginalDialogs.StandardButton.Retry; } - MessageDialogButton { dialog: root; text: qsTr("Save All"); button: OriginalDialogs.StandardButton.SaveAll; } - MessageDialogButton { dialog: root; text: qsTr("Save"); button: OriginalDialogs.StandardButton.Save; } - MessageDialogButton { dialog: root; text: qsTr("Open"); button: OriginalDialogs.StandardButton.Open; } - MessageDialogButton { dialog: root; text: qsTr("OK"); button: OriginalDialogs.StandardButton.Ok; } - - Button { - id: moreButton - text: qsTr("Show Details...") - width: 160 - onClicked: { content.state = (content.state === "" ? "expanded" : "") } - visible: detailedText && detailedText.length > 0 - } - MessageDialogButton { dialog: root; text: qsTr("Help"); button: OriginalDialogs.StandardButton.Help; } - } - - Item { - id: details - width: parent.width - implicitHeight: detailedText.implicitHeight - height: 0 - clip: true - anchors { - top: buttons.bottom - left: parent.left; - right: parent.right; - margins: 0 - topMargin: hifi.dimensions.contentSpacing.y - } - Flickable { - id: flickable - contentHeight: detailedText.height - anchors.fill: parent - anchors.topMargin: hifi.dimensions.contentSpacing.x - anchors.bottomMargin: hifi.dimensions.contentSpacing.y - TextEdit { - id: detailedText - size: hifi.fontSizes.menuItem - color: hifi.colors.baseGrayHighlight - width: details.width - wrapMode: Text.WordWrap - readOnly: true - selectByMouse: true - anchors.margins: 0 - } - } - } - - states: [ - State { - name: "expanded" - PropertyChanges { target: root; anchors.fill: undefined } - PropertyChanges { target: details; height: 120 } - PropertyChanges { target: moreButton; text: qsTr("Hide Details") } - } - ] - - Component.onCompleted: { - updateIcon(); - d.resize(); - } - onStateChanged: d.resize() - } - - Keys.onPressed: { - if (!visible) { - return - } - - if (event.modifiers === Qt.ControlModifier) - switch (event.key) { - case Qt.Key_A: - event.accepted = true - detailedText.selectAll() - break - case Qt.Key_C: - event.accepted = true - detailedText.copy() - break - case Qt.Key_Period: - if (Qt.platform.os === "osx") { - event.accepted = true - content.reject() - } - break - } else switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - event.accepted = true - root.click(OriginalDialogs.StandardButton.Cancel) - break - - case Qt.Key_Enter: - case Qt.Key_Return: - event.accepted = true - root.click(root.defaultButton) - break - } - } -} diff --git a/interface/resources/qml/dialogs/TabletQueryDialog.qml b/interface/resources/qml/dialogs/TabletQueryDialog.qml deleted file mode 100644 index e21677c12c..0000000000 --- a/interface/resources/qml/dialogs/TabletQueryDialog.qml +++ /dev/null @@ -1,206 +0,0 @@ -// -// QueryDialog.qml -// -// Created by Bradley Austin Davis on 22 Jan 2016 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs - -import "../controls-uit" -import "../styles-uit" -import "../windows" - -TabletModalWindow { - id: root - HifiConstants { id: hifi } - signal selected(var result); - signal canceled(); - layer.enabled: true - property int icon: hifi.icons.none - property string iconText: "" - property int iconSize: 35 - - MouseArea { - width: parent.width - height: parent.height - } - - property bool keyboardOverride: true - onIconChanged: updateIcon(); - - property var items; - property string label: "" - property var result; - property alias current: textResult.text - - // For text boxes - property alias placeholderText: textResult.placeholderText - - // For combo boxes - property bool editable: true; - - property int titleWidth: 0 - onTitleWidthChanged: d.resize(); - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - onKeyboardRaisedChanged: d.resize(); - - function updateIcon() { - if (!root) { - return; - } - iconText = hifi.glyphForIcon(root.icon); - } - - TabletModalFrame { - id: modalWindowItem - width: parent.width - 12 - height: 240 - anchors { - verticalCenter: parent.verticalCenter - horizontalCenter: parent.horizontalCenter - } - - QtObject { - id: d - readonly property int minWidth: 470 - readonly property int maxWidth: 470 - readonly property int minHeight: 120 - readonly property int maxHeight: 720 - - function resize() { - var targetWidth = Math.max(titleWidth, 470) - var targetHeight = (items ? comboBox.controlHeight : textResult.controlHeight) + 5 * hifi.dimensions.contentSpacing.y + buttons.height - modalWindowItem.width = (targetWidth < d.minWidth) ? d.minWidth : ((targetWidth > d.maxWdith) ? d.maxWidth : targetWidth); - modalWindowItem.height = ((targetHeight < d.minHeight) ? d.minHeight : ((targetHeight > d.maxHeight) ? d.maxHeight : targetHeight)) + ((keyboardEnabled && keyboardRaised) ? (keyboard.raisedHeight + 2 * hifi.dimensions.contentSpacing.y) : 0) + modalWindowItem.frameMarginTop - } - } - - Item { - anchors { - top: parent.top - bottom: keyboard.top; - left: parent.left; - right: parent.right; - margins: 0 - bottomMargin: 2 * hifi.dimensions.contentSpacing.y - } - - // FIXME make a text field type that can be bound to a history for autocompletion - TextField { - id: textResult - label: root.label - focus: items ? false : true - visible: items ? false : true - anchors { - left: parent.left; - right: parent.right; - bottom: parent.bottom - leftMargin: 5 - } - } - - ComboBox { - id: comboBox - label: root.label - focus: true - visible: items ? true : false - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - rightMargin: 5 - } - model: items ? items : [] - } - } - - property alias keyboardOverride: root.keyboardOverride - property alias keyboardRaised: root.keyboardRaised - property alias punctuationMode: root.punctuationMode - - Keyboard { - id: keyboard - raised: keyboardEnabled && keyboardRaised - numeric: punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: buttons.top - bottomMargin: raised ? 2 * hifi.dimensions.contentSpacing.y : 0 - } - } - - Flow { - id: buttons - focus: true - spacing: hifi.dimensions.contentSpacing.x - onHeightChanged: d.resize(); onWidthChanged: d.resize(); - layoutDirection: Qt.RightToLeft - anchors { - bottom: parent.bottom - right: parent.right - margins: 0 - bottomMargin: hifi.dimensions.contentSpacing.y - } - Button { action: cancelAction } - Button { action: acceptAction } - } - - Action { - id: cancelAction - text: qsTr("Cancel") - shortcut: Qt.Key_Escape - onTriggered: { - root.canceled(); - root.destroy(); - } - } - Action { - id: acceptAction - text: qsTr("OK") - shortcut: Qt.Key_Return - onTriggered: { - root.result = items ? comboBox.currentText : textResult.text - root.selected(root.result); - root.destroy(); - } - } - } - - Keys.onPressed: { - if (!visible) { - return - } - - switch (event.key) { - case Qt.Key_Escape: - case Qt.Key_Back: - cancelAction.trigger() - event.accepted = true; - break; - - case Qt.Key_Return: - case Qt.Key_Enter: - acceptAction.trigger() - event.accepted = true; - break; - } - } - - Component.onCompleted: { - keyboardEnabled = HMD.active; - updateIcon(); - d.resize(); - textResult.forceActiveFocus(); - } -} diff --git a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml index 7ae4fe6761..0c5c5bf630 100644 --- a/interface/resources/qml/dialogs/preferences/AvatarPreference.qml +++ b/interface/resources/qml/dialogs/preferences/AvatarPreference.qml @@ -10,8 +10,8 @@ import QtQuick 2.5 +import "../../dialogs" import "../../controls-uit" -import "../../hifi/tablet/tabletWindows/preferences" Preference { id: root @@ -82,25 +82,11 @@ Preference { verticalCenter: dataTextField.verticalCenter } onClicked: { - if (typeof desktop !== "undefined") { - // Load dialog via OffscreenUi so that JavaScript EventBridge is available. - root.browser = OffscreenUi.load("dialogs/preferences/AvatarBrowser.qml"); - root.browser.windowDestroyed.connect(function(){ - root.browser = null; - }); - } else { - root.browser = tabletAvatarBrowserBuilder.createObject(tabletRoot); - - // Make dialog modal. - tabletRoot.openModal = root.browser; - } - } - } - - Component { - id: tabletAvatarBrowserBuilder; - TabletAvatarBrowser { - eventBridge: tabletRoot.eventBridge + // Load dialog via OffscreenUi so that JavaScript EventBridge is available. + root.browser = OffscreenUi.load("dialogs/preferences/AvatarBrowser.qml"); + root.browser.windowDestroyed.connect(function(){ + root.browser = null; + }); } } } diff --git a/interface/resources/qml/hifi/Audio.qml b/interface/resources/qml/hifi/Audio.qml deleted file mode 100644 index deb44b9bd5..0000000000 --- a/interface/resources/qml/hifi/Audio.qml +++ /dev/null @@ -1,253 +0,0 @@ -// -// Audio.qml -// qml/hifi -// -// Audio setup -// -// Created by Vlad Stelmahovsky on 03/22/2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtGraphicalEffects 1.0 - -import "../styles-uit" -import "../controls-uit" as HifiControls - -import "components" - -Rectangle { - id: audio; - - //put info text here - property alias infoText: infoArea.text - - color: "#404040"; - - HifiConstants { id: hifi; } - objectName: "AudioWindow" - - property var eventBridge; - property string title: "Audio Options" - signal sendToScript(var message); - - //set models after Components is shown - Component.onCompleted: { - refreshTimer.start() - refreshTimerOutput.start() - } - - Component { - id: separator - LinearGradient { - start: Qt.point(0, 0) - end: Qt.point(0, 4) - gradient: Gradient { - GradientStop { position: 0.0; color: "#303030" } - GradientStop { position: 0.33; color: "#252525" } // Equivalent of darkGray0 over baseGray background. - GradientStop { position: 0.5; color: "#303030" } - GradientStop { position: 0.6; color: "#454a49" } - GradientStop { position: 1.0; color: "#454a49" } - } - cached: true - } - } - - Column { - anchors { left: parent.left; right: parent.right } - spacing: 8 - - RalewayRegular { - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - height: 45 - size: 20 - color: "white" - text: audio.title - } - - Loader { - width: parent.width - height: 5 - sourceComponent: separator - } - - //connections required to syncronize with Menu - Connections { - target: AudioDevice - onMuteToggled: { - audioMute.checkbox.checked = AudioDevice.getMuted() - } - } - - Connections { - target: AvatarInputs - onShowAudioToolsChanged: { - audioTools.checkbox.checked = showAudioTools - } - } - - AudioCheckbox { - id: audioMute - width: parent.width - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - checkbox.checked: AudioDevice.muted - text.text: qsTr("Mute microphone") - onCheckBoxClicked: { - AudioDevice.muted = checked - } - } - - AudioCheckbox { - id: audioTools - width: parent.width - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - checkbox.checked: AvatarInputs.showAudioTools - text.text: qsTr("Show audio level meter") - onCheckBoxClicked: { - AvatarInputs.showAudioTools = checked - } - } - - Loader { - width: parent.width - height: 5 - sourceComponent: separator - } - - Row { - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - height: 40 - spacing: 8 - - HiFiGlyphs { - text: hifi.glyphs.mic - color: hifi.colors.primaryHighlight - anchors.verticalCenter: parent.verticalCenter - font.pointSize: 27 - } - RalewayRegular { - anchors.verticalCenter: parent.verticalCenter - size: 16 - color: "#AFAFAF" - text: qsTr("CHOOSE INPUT DEVICE") - } - } - - ListView { - Timer { - id: refreshTimer - interval: 1 - repeat: false - onTriggered: { - //refresh model - inputAudioListView.model = undefined - inputAudioListView.model = AudioDevice.inputAudioDevices - } - } - id: inputAudioListView - anchors { left: parent.left; right: parent.right; leftMargin: 70 } - height: 125 - spacing: 16 - clip: true - snapMode: ListView.SnapToItem - delegate: AudioCheckbox { - width: parent.width - checkbox.checked: (modelData === AudioDevice.getInputDevice()) - text.text: modelData - onCheckBoxClicked: { - if (checked) { - AudioDevice.setInputDevice(modelData) - refreshTimer.start() - } - } - } - } - - Loader { - width: parent.width - height: 5 - sourceComponent: separator - } - - Row { - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - height: 40 - spacing: 8 - - HiFiGlyphs { - text: hifi.glyphs.unmuted - color: hifi.colors.primaryHighlight - anchors.verticalCenter: parent.verticalCenter - font.pointSize: 27 - } - RalewayRegular { - anchors.verticalCenter: parent.verticalCenter - size: 16 - color: "#AFAFAF" - text: qsTr("CHOOSE OUTPUT DEVICE") - } - } - ListView { - id: outputAudioListView - Timer { - id: refreshTimerOutput - interval: 1 - repeat: false - onTriggered: { - //refresh model - outputAudioListView.model = undefined - outputAudioListView.model = AudioDevice.outputAudioDevices - } - } - anchors { left: parent.left; right: parent.right; leftMargin: 70 } - height: 250 - spacing: 16 - clip: true - snapMode: ListView.SnapToItem - delegate: AudioCheckbox { - width: parent.width - checkbox.checked: (modelData === AudioDevice.getOutputDevice()) - text.text: modelData - onCheckBoxClicked: { - if (checked) { - AudioDevice.setOutputDevice(modelData) - refreshTimerOutput.start() - } - } - } - } - - Loader { - id: lastSeparator - width: parent.width - height: 6 - sourceComponent: separator - } - - Row { - anchors { left: parent.left; right: parent.right; leftMargin: 30 } - height: 40 - spacing: 8 - - HiFiGlyphs { - id: infoSign - text: hifi.glyphs.info - color: "#AFAFAF" - anchors.verticalCenter: parent.verticalCenter - size: 60 - } - RalewayRegular { - id: infoArea - width: parent.width - infoSign.implicitWidth - parent.spacing - 10 - wrapMode: Text.WordWrap - anchors.verticalCenter: parent.verticalCenter - size: 12 - color: hifi.colors.baseGrayHighlight - } - } - } -} diff --git a/interface/resources/qml/hifi/Card.qml b/interface/resources/qml/hifi/Card.qml index 3d1ae0e64b..f6f7e88d0c 100644 --- a/interface/resources/qml/hifi/Card.qml +++ b/interface/resources/qml/hifi/Card.qml @@ -129,7 +129,7 @@ Rectangle { property int dropSamples: 9; property int dropSpread: 0; DropShadow { - visible: true; + visible: showPlace && (desktop ? desktop.gradientsSupported : false) source: place; anchors.fill: place; horizontalOffset: dropHorizontalOffset; @@ -139,12 +139,12 @@ Rectangle { color: hifi.colors.black; spread: dropSpread; } - RalewayLight { + RalewaySemiBold { id: place; visible: showPlace; text: placeName; color: hifi.colors.white; - size: 38; + size: textSize; elide: Text.ElideRight; // requires constrained width anchors { top: parent.top; @@ -153,8 +153,7 @@ Rectangle { margins: textPadding; } } - - Row { + Row { FiraSansRegular { id: users; visible: isConcurrency; @@ -217,12 +216,6 @@ Rectangle { margins: smallMargin; } } - DropShadow { - anchors.fill: actionIcon - radius: 8.0 - color: "#80000000" - source: actionIcon - } MouseArea { id: messageArea; width: parent.width; diff --git a/interface/resources/qml/hifi/TabletTextButton.qml b/interface/resources/qml/hifi/TabletTextButton.qml deleted file mode 100644 index 12e53eb217..0000000000 --- a/interface/resources/qml/hifi/TabletTextButton.qml +++ /dev/null @@ -1,58 +0,0 @@ -// -// TabletTextButton.qml -// -// Created by Dante Ruiz on 2017/3/23 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import "../styles-uit" - -Rectangle { - property alias text: label.text - property alias pixelSize: label.font.pixelSize; - property bool selected: false - property int spacing: 2 - property var action: function () {} - property string highlightColor: hifi.colors.blueHighlight; - width: label.width + 64 - height: 32 - color: hifi.colors.white - HifiConstants { id: hifi } - RalewaySemiBold { - id: label; - color: hifi.colors.blueHighlight; - font.pixelSize: 15; - anchors { - horizontalCenter: parent.horizontalCenter; - verticalCenter: parent.verticalCenter; - } - } - - - Rectangle { - id: indicator - width: parent.width - height: 3 - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - color: hifi.colors.blueHighlight - visible: parent.selected - } - - MouseArea { - id: clickArea; - anchors.fill: parent; - acceptedButtons: Qt.LeftButton; - onClicked: action(parent); - hoverEnabled: true; - } -} - diff --git a/interface/resources/qml/hifi/components/AudioCheckbox.qml b/interface/resources/qml/hifi/components/AudioCheckbox.qml deleted file mode 100644 index a8e0441e0a..0000000000 --- a/interface/resources/qml/hifi/components/AudioCheckbox.qml +++ /dev/null @@ -1,29 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls - -Row { - id: row - spacing: 16 - property alias checkbox: cb - property alias text: txt - signal checkBoxClicked(bool checked) - - HifiControls.CheckBox { - id: cb - boxSize: 20 - colorScheme: hifi.colorSchemes.dark - anchors.verticalCenter: parent.verticalCenter - onClicked: checkBoxClicked(cb.checked) - } - RalewayBold { - id: txt - wrapMode: Text.WordWrap - width: parent.width - cb.boxSize - 30 - anchors.verticalCenter: parent.verticalCenter - size: 16 - color: "white" - } -} diff --git a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml index 12e8de3bfc..27d225b58e 100644 --- a/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml +++ b/interface/resources/qml/hifi/dialogs/AttachmentsDialog.qml @@ -1,20 +1,13 @@ -// -// AttachmentsDialog.qml -// -// Created by David Rowe on 9 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// - import QtQuick 2.5 import QtQuick.Controls 1.4 +import QtQuick.Dialogs 1.2 as OriginalDialogs import Qt.labs.settings 1.0 +import QtQuick.Controls.Styles 1.4 import "../../styles-uit" +import "../../controls-uit" as HifiControls import "../../windows" -import "content" +import "attachments" ScrollingWindow { id: root @@ -28,6 +21,9 @@ ScrollingWindow { HifiConstants { id: hifi } + readonly property var originalAttachments: MyAvatar.getAttachmentsVariant(); + property var attachments: []; + property var settings: Settings { category: "AttachmentsDialog" property alias x: root.x @@ -36,9 +32,198 @@ ScrollingWindow { property alias height: root.height } - function closeDialog() { - root.destroy(); + Component.onCompleted: { + for (var i = 0; i < originalAttachments.length; ++i) { + var attachment = originalAttachments[i]; + root.attachments.push(attachment); + listView.model.append({}); + } } - AttachmentsContent { } + Column { + width: pane.contentWidth + + Rectangle { + width: parent.width + height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) + radius: 4 + color: hifi.colors.baseGray + + Rectangle { + id: attachmentsBackground + anchors { + left: parent.left; right: parent.right; top: parent.top; bottom: newAttachmentButton.top; + margins: hifi.dimensions.contentMargin.x + bottomMargin: hifi.dimensions.contentSpacing.y + } + color: hifi.colors.baseGrayShadow + radius: 4 + + ScrollView { + id: scrollView + anchors.fill: parent + anchors.margins: 4 + + style: ScrollViewStyle { + + padding { + top: 0 + right: 0 + bottom: 0 + } + + decrementControl: Item { + visible: false + } + incrementControl: Item { + visible: false + } + scrollBarBackground: Rectangle{ + implicitWidth: 14 + color: hifi.colors.baseGray + radius: 4 + Rectangle { + // Make top left corner of scrollbar appear square + width: 8 + height: 4 + color: hifi.colors.baseGray + anchors.top: parent.top + anchors.horizontalCenter: parent.left + } + + } + handle: + Rectangle { + implicitWidth: 8 + anchors { + left: parent.left + leftMargin: 3 + top: parent.top + topMargin: 3 + bottom: parent.bottom + bottomMargin: 4 + } + radius: 4 + color: hifi.colors.lightGrayText + } + } + + ListView { + id: listView + model: ListModel {} + delegate: Item { + id: attachmentDelegate + implicitHeight: attachmentView.height + 8; + implicitWidth: attachmentView.width + Attachment { + id: attachmentView + width: scrollView.width + attachment: root.attachments[index] + onDeleteAttachment: { + attachments.splice(index, 1); + listView.model.remove(index, 1); + } + onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments); + } + } + onCountChanged: MyAvatar.setAttachmentsVariant(attachments); + } + + function scrollBy(delta) { + flickableItem.contentY += delta; + } + } + } + + HifiControls.Button { + id: newAttachmentButton + anchors { + left: parent.left + right: parent.right + bottom: buttonRow.top + margins: hifi.dimensions.contentMargin.x; + topMargin: hifi.dimensions.contentSpacing.y + bottomMargin: hifi.dimensions.contentSpacing.y + } + text: "New Attachment" + color: hifi.buttons.black + colorScheme: hifi.colorSchemes.dark + onClicked: { + var template = { + modelUrl: "", + translation: { x: 0, y: 0, z: 0 }, + rotation: { x: 0, y: 0, z: 0 }, + scale: 1, + jointName: MyAvatar.jointNames[0], + soft: false + }; + attachments.push(template); + listView.model.append({}); + MyAvatar.setAttachmentsVariant(attachments); + } + } + + Row { + id: buttonRow + spacing: 8 + anchors { + right: parent.right + bottom: parent.bottom + margins: hifi.dimensions.contentMargin.x + topMargin: hifi.dimensions.contentSpacing.y + bottomMargin: hifi.dimensions.contentSpacing.y + } + HifiControls.Button { + action: okAction + color: hifi.buttons.black + colorScheme: hifi.colorSchemes.dark + } + HifiControls.Button { + action: cancelAction + color: hifi.buttons.black + colorScheme: hifi.colorSchemes.dark + } + } + + Action { + id: cancelAction + text: "Cancel" + onTriggered: { + MyAvatar.setAttachmentsVariant(originalAttachments); + root.destroy() + } + } + + Action { + id: okAction + text: "OK" + onTriggered: { + for (var i = 0; i < attachments.length; ++i) { + console.log("Attachment " + i + ": " + attachments[i]); + } + + MyAvatar.setAttachmentsVariant(attachments); + root.destroy() + } + } + } + } + + onKeyboardRaisedChanged: { + if (keyboardEnabled && keyboardRaised) { + // Scroll to item with focus if necessary. + var footerHeight = newAttachmentButton.height + buttonRow.height + 3 * hifi.dimensions.contentSpacing.y; + var delta = activator.mouseY + - (activator.height + activator.y - 200 - footerHeight - hifi.dimensions.controlLineHeight); + + if (delta > 0) { + scrollView.scrollBy(delta); + } else { + // HACK: Work around for case where are 100% scrolled; stops window from erroneously scrolling to 100% when show keyboard. + scrollView.scrollBy(-1); + scrollView.scrollBy(1); + } + } + } } + diff --git a/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml b/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml index 44cae95696..9be1c30e55 100644 --- a/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml +++ b/interface/resources/qml/hifi/dialogs/GeneralPreferencesDialog.qml @@ -1,5 +1,5 @@ // -// GeneralPreferencesDialog.qml +// PreferencesDialog.qml // // Created by Bradley Austin Davis on 24 Jan 2016 // Copyright 2015 High Fidelity, Inc. diff --git a/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml b/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml index c427052904..7a63c0604c 100644 --- a/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml +++ b/interface/resources/qml/hifi/dialogs/ModelBrowserDialog.qml @@ -1,36 +1,92 @@ -// -// ModelBrowserDialog.qml -// -// Created by David Rowe on 11 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// - import QtQuick 2.5 import QtQuick.Controls 1.4 +import QtQuick.XmlListModel 2.0 +import QtQuick.Controls.Styles 1.4 import "../../windows" -import "content" +import "../../js/Utils.js" as Utils +import "../models" + +import "../../styles-uit" +import "../../controls-uit" as HifiControls +import "../../windows" ScrollingWindow { id: root - objectName: "ModelBrowserDialog" - title: "Attachment Model" resizable: true width: 600 height: 480 closable: false - //HifiConstants { id: hifi } + property var result; - property var result + signal selected(var modelUrl); + signal canceled(); - signal selected(var modelUrl) - signal canceled() + HifiConstants {id: hifi} - ModelBrowserContent { - id: modelBrowserContent + Column { + width: pane.contentWidth + + Rectangle { + width: parent.width + height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) + radius: 4 + color: hifi.colors.baseGray + + HifiControls.TextField { + id: filterEdit + anchors { left: parent.left; right: parent.right; top: parent.top ; margins: 8} + placeholderText: "filter" + onTextChanged: tableView.model.filter = text + colorScheme: hifi.colorSchemes.dark + } + + HifiControls.AttachmentsTable { + id: tableView + anchors { left: parent.left; right: parent.right; top: filterEdit.bottom; bottom: buttonRow.top; margins: 8; } + colorScheme: hifi.colorSchemes.dark + onCurrentRowChanged: { + if (currentRow == -1) { + root.result = null; + return; + } + result = model.baseUrl + "/" + model.get(tableView.currentRow).key; + } + } + + Row { + id: buttonRow + spacing: 8 + anchors { right: parent.right; rightMargin: 8; bottom: parent.bottom; bottomMargin: 8; } + HifiControls.Button { action: acceptAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } + HifiControls.Button { action: cancelAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } + } + + Action { + id: acceptAction + text: qsTr("OK") + enabled: root.result ? true : false + shortcut: Qt.Key_Return + onTriggered: { + root.selected(root.result); + root.destroy(); + } + } + + Action { + id: cancelAction + text: qsTr("Cancel") + shortcut: Qt.Key_Escape + onTriggered: { + root.canceled(); + root.destroy(); + } + } + } } } + + + + diff --git a/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml b/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml deleted file mode 100644 index 2460fc39d5..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml +++ /dev/null @@ -1,614 +0,0 @@ -// -// TabletAssetServer.qml -// -// Created by Vlad Stelmahovsky on 3/3/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" - -Rectangle { - id: root - objectName: "AssetServer" - - property var eventBridge; - signal sendToScript(var message); - property bool isHMD: false - - color: hifi.colors.baseGray - - property int colorScheme: hifi.colorSchemes.dark - - HifiConstants { id: hifi } - - property var scripts: ScriptDiscoveryService; - property var assetProxyModel: Assets.proxyModel; - property var assetMappingsModel: Assets.mappingModel; - property var currentDirectory; - - Settings { - category: "Overlay.AssetServer" - property alias directory: root.currentDirectory - } - - Component.onCompleted: { - isHMD = HMD.active; - ApplicationInterface.uploadRequest.connect(uploadClicked); - assetMappingsModel.errorGettingMappings.connect(handleGetMappingsError); - reload(); - } - - function doDeleteFile(path) { - console.log("Deleting " + path); - - Assets.deleteMappings(path, function(err) { - if (err) { - console.log("Asset browser - error deleting path: ", path, err); - - box = errorMessageBox("There was an error deleting:\n" + path + "\n" + err); - box.selected.connect(reload); - } else { - console.log("Asset browser - finished deleting path: ", path); - reload(); - } - }); - - } - - function doRenameFile(oldPath, newPath) { - - if (newPath[0] !== "/") { - newPath = "/" + newPath; - } - - if (oldPath[oldPath.length - 1] === '/' && newPath[newPath.length - 1] != '/') { - // this is a folder rename but the user neglected to add a trailing slash when providing a new path - newPath = newPath + "/"; - } - - if (Assets.isKnownFolder(newPath)) { - box = errorMessageBox("Cannot overwrite existing directory."); - box.selected.connect(reload); - } - - console.log("Asset browser - renaming " + oldPath + " to " + newPath); - - Assets.renameMapping(oldPath, newPath, function(err) { - if (err) { - console.log("Asset browser - error renaming: ", oldPath, "=>", newPath, " - error ", err); - box = errorMessageBox("There was an error renaming:\n" + oldPath + " to " + newPath + "\n" + err); - box.selected.connect(reload); - } else { - console.log("Asset browser - finished rename: ", oldPath, "=>", newPath); - } - - reload(); - }); - } - - function fileExists(path) { - return Assets.isKnownMapping(path); - } - - function askForOverwrite(path, callback) { - var object = tabletRoot.messageBox({ - icon: hifi.icons.question, - buttons: OriginalDialogs.StandardButton.Yes | OriginalDialogs.StandardButton.No, - defaultButton: OriginalDialogs.StandardButton.No, - title: "Overwrite File", - text: path + "\n" + "This file already exists. Do you want to overwrite it?" - }); - object.selected.connect(function(button) { - if (button === OriginalDialogs.StandardButton.Yes) { - callback(); - } - }); - } - - function canAddToWorld(path) { - var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i]; - - return supportedExtensions.reduce(function(total, current) { - return total | new RegExp(current).test(path); - }, false); - } - - function clear() { - Assets.mappingModel.clear(); - } - - function reload() { - Assets.mappingModel.refresh(); - treeView.selection.clear(); - } - - function handleGetMappingsError(errorString) { - errorMessageBox( - "There was a problem retreiving the list of assets from your Asset Server.\n" - + errorString - ); - } - - function addToWorld() { - var defaultURL = assetProxyModel.data(treeView.selection.currentIndex, 0x103); - - if (!defaultURL || !canAddToWorld(defaultURL)) { - return; - } - - var SHAPE_TYPE_NONE = 0; - var SHAPE_TYPE_SIMPLE_HULL = 1; - var SHAPE_TYPE_SIMPLE_COMPOUND = 2; - var SHAPE_TYPE_STATIC_MESH = 3; - - var SHAPE_TYPES = []; - SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision"; - SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model"; - SHAPE_TYPES[SHAPE_TYPE_SIMPLE_COMPOUND] = "Good - Sub-meshes"; - SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; - - var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; - var DYNAMIC_DEFAULT = false; - var prompt = tabletRoot.customInputDialog({ - textInput: { - label: "Model URL", - text: defaultURL - }, - comboBox: { - label: "Automatic Collisions", - index: SHAPE_TYPE_DEFAULT, - items: SHAPE_TYPES - }, - checkBox: { - label: "Dynamic", - checked: DYNAMIC_DEFAULT, - disableForItems: [ - SHAPE_TYPE_STATIC_MESH - ], - checkStateOnDisable: false, - warningOnDisable: "Models with 'Exact' automatic collisions cannot be dynamic" - } - }); - - prompt.selected.connect(function (jsonResult) { - if (jsonResult) { - var result = JSON.parse(jsonResult); - var url = result.textInput.trim(); - var shapeType; - switch (result.comboBox) { - case SHAPE_TYPE_SIMPLE_HULL: - shapeType = "simple-hull"; - break; - case SHAPE_TYPE_SIMPLE_COMPOUND: - shapeType = "simple-compound"; - break; - case SHAPE_TYPE_STATIC_MESH: - shapeType = "static-mesh"; - break; - default: - shapeType = "none"; - } - - var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; - if (shapeType === "static-mesh" && dynamic) { - // The prompt should prevent this case - print("Error: model cannot be both static mesh and dynamic. This should never happen."); - } else if (url) { - var name = assetProxyModel.data(treeView.selection.currentIndex); - var addPosition = Vec3.sum(MyAvatar.position, Vec3.multiply(2, Quat.getFront(MyAvatar.orientation))); - var gravity; - if (dynamic) { - // Create a vector <0, -10, 0>. { x: 0, y: -10, z: 0 } won't work because Qt is dumb and this is a - // different scripting engine from QTScript. - gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 10); - } else { - gravity = Vec3.multiply(Vec3.fromPolar(Math.PI / 2, 0), 0); - } - - print("Asset browser - adding asset " + url + " (" + name + ") to world."); - - // Entities.addEntity doesn't work from QML, so we use this. - Entities.addModelEntity(name, url, shapeType, dynamic, addPosition, gravity); - } - } - }); - } - - function copyURLToClipboard(index) { - if (!index) { - index = treeView.selection.currentIndex; - } - - var url = assetProxyModel.data(treeView.selection.currentIndex, 0x103); - if (!url) { - return; - } - Window.copyToClipboard(url); - } - - function renameEl(index, data) { - if (!index) { - return false; - } - - var path = assetProxyModel.data(index, 0x100); - if (!path) { - return false; - } - - var destinationPath = path.split('/'); - destinationPath[destinationPath.length - (path[path.length - 1] === '/' ? 2 : 1)] = data; - destinationPath = destinationPath.join('/').trim(); - - if (path === destinationPath) { - return; - } - if (!fileExists(destinationPath)) { - doRenameFile(path, destinationPath); - } - } - function renameFile(index) { - if (!index) { - index = treeView.selection.currentIndex; - } - - var path = assetProxyModel.data(index, 0x100); - if (!path) { - return; - } - - var object = tabletRoot.inputDialog({ - label: "Enter new path:", - current: path, - placeholderText: "Enter path here" - }); - object.selected.connect(function(destinationPath) { - destinationPath = destinationPath.trim(); - - if (path === destinationPath) { - return; - } - if (fileExists(destinationPath)) { - askForOverwrite(destinationPath, function() { - doRenameFile(path, destinationPath); - }); - } else { - doRenameFile(path, destinationPath); - } - }); - } - function deleteFile(index) { - if (!index) { - index = treeView.selection.currentIndex; - } - var path = assetProxyModel.data(index, 0x100); - if (!path) { - return; - } - - var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101); - var typeString = isFolder ? 'folder' : 'file'; - - var object = tabletRoot.messageBox({ - icon: hifi.icons.question, - buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No, - defaultButton: OriginalDialogs.StandardButton.Yes, - title: "Delete", - text: "You are about to delete the following " + typeString + ":\n" + path + "\nDo you want to continue?" - }); - object.selected.connect(function(button) { - if (button === OriginalDialogs.StandardButton.Yes) { - doDeleteFile(path); - } - }); - } - - Timer { - id: doUploadTimer - property var url - property bool isConnected: false - interval: 5 - repeat: false - running: false - } - - property bool uploadOpen: false; - Timer { - id: timer - } - function uploadClicked(fileUrl) { - if (uploadOpen) { - return; - } - uploadOpen = true; - - function doUpload(url, dropping) { - var fileUrl = fileDialogHelper.urlToPath(url); - - var path = assetProxyModel.data(treeView.selection.currentIndex, 0x100); - var directory = path ? path.slice(0, path.lastIndexOf('/') + 1) : "/"; - var filename = fileUrl.slice(fileUrl.lastIndexOf('/') + 1); - - Assets.uploadFile(fileUrl, directory + filename, - function() { - // Upload started - uploadSpinner.visible = true; - uploadButton.enabled = false; - uploadProgressLabel.text = "In progress..."; - }, - function(err, path) { - print(err, path); - if (err === "") { - uploadProgressLabel.text = "Upload Complete"; - timer.interval = 1000; - timer.repeat = false; - timer.triggered.connect(function() { - uploadSpinner.visible = false; - uploadButton.enabled = true; - uploadOpen = false; - }); - timer.start(); - console.log("Asset Browser - finished uploading: ", fileUrl); - reload(); - } else { - uploadSpinner.visible = false; - uploadButton.enabled = true; - uploadOpen = false; - - if (err !== -1) { - console.log("Asset Browser - error uploading: ", fileUrl, " - error ", err); - var box = errorMessageBox("There was an error uploading:\n" + fileUrl + "\n" + err); - box.selected.connect(reload); - } - } - }, dropping); - } - - function initiateUpload(url) { - doUpload(doUploadTimer.url, false); - } - - if (fileUrl) { - doUpload(fileUrl, true); - } else { - var browser = tabletRoot.fileDialog({ - selectDirectory: false, - dir: currentDirectory - }); - - browser.canceled.connect(function() { - uploadOpen = false; - }); - - browser.selectedFile.connect(function(url) { - currentDirectory = browser.dir; - - // Initiate upload from a timer so that file browser dialog can close beforehand. - doUploadTimer.url = url; - if (!doUploadTimer.isConnected) { - doUploadTimer.triggered.connect(function() { initiateUpload(); }); - doUploadTimer.isConnected = true; - } - doUploadTimer.start(); - }); - } - } - - function errorMessageBox(message) { - return tabletRoot.messageBox({ - icon: hifi.icons.warning, - defaultButton: OriginalDialogs.StandardButton.Ok, - title: "Error", - text: message - }); - } - - Column { - width: parent.width - y: hifi.dimensions.tabletMenuHeader //-bgNavBar - spacing: 10 - - HifiControls.TabletContentSection { - id: assetDirectory - name: "Asset Directory" - isFirst: true - - HifiControls.VerticalSpacer {} - - Row { - id: buttonRow - width: parent.width - height: 30 - spacing: hifi.dimensions.contentSpacing.x - - HifiControls.GlyphButton { - glyph: hifi.glyphs.reload - color: hifi.buttons.black - colorScheme: root.colorScheme - width: hifi.dimensions.controlLineHeight - - onClicked: root.reload() - } - - HifiControls.Button { - text: "Add To World" - color: hifi.buttons.black - colorScheme: root.colorScheme - width: 120 - - enabled: canAddToWorld(assetProxyModel.data(treeView.selection.currentIndex, 0x100)) - - onClicked: root.addToWorld() - } - - HifiControls.Button { - text: "Rename" - color: hifi.buttons.black - colorScheme: root.colorScheme - width: 80 - - onClicked: root.renameFile() - enabled: treeView.selection.hasSelection - } - - HifiControls.Button { - id: deleteButton - - text: "Delete" - color: hifi.buttons.red - colorScheme: root.colorScheme - width: 80 - - onClicked: root.deleteFile() - enabled: treeView.selection.hasSelection - } - } - - Menu { - id: contextMenu - title: "Edit" - property var url: "" - property var currentIndex: null - - MenuItem { - text: "Copy URL" - onTriggered: { - copyURLToClipboard(contextMenu.currentIndex); - } - } - - MenuItem { - text: "Rename" - onTriggered: { - renameFile(contextMenu.currentIndex); - } - } - - MenuItem { - text: "Delete" - onTriggered: { - deleteFile(contextMenu.currentIndex); - } - } - } - - } - HifiControls.Tree { - id: treeView - height: 430 - anchors.leftMargin: hifi.dimensions.contentMargin.x + 2 // Extra for border - anchors.rightMargin: hifi.dimensions.contentMargin.x + 2 // Extra for border - anchors.left: parent.left - anchors.right: parent.right - - treeModel: assetProxyModel - canEdit: true - colorScheme: root.colorScheme - - modifyEl: renameEl - - MouseArea { - propagateComposedEvents: true - anchors.fill: parent - acceptedButtons: Qt.RightButton - onClicked: { - if (!HMD.active) { // Popup only displays properly on desktop - var index = treeView.indexAt(mouse.x, mouse.y); - treeView.selection.setCurrentIndex(index, 0x0002); - contextMenu.currentIndex = index; - contextMenu.popup(); - } - } - } - } - - - HifiControls.TabletContentSection { - id: uploadSection - name: "Upload A File" - spacing: hifi.dimensions.contentSpacing.y - //anchors.bottom: parent.bottom - height: 65 - anchors.left: parent.left - anchors.right: parent.right - - Item { - height: parent.height - width: parent.width - HifiControls.Button { - id: uploadButton - anchors.right: parent.right - - text: "Choose File" - color: hifi.buttons.blue - colorScheme: root.colorScheme - height: 30 - width: 155 - - onClicked: uploadClickedTimer.running = true - - // For some reason trigginer an API that enters - // an internal event loop directly from the button clicked - // trigger below causes the appliction to behave oddly. - // Most likely because the button onClicked handling is never - // completed until the function returns. - // FIXME find a better way of handling the input dialogs that - // doesn't trigger this. - Timer { - id: uploadClickedTimer - interval: 5 - repeat: false - running: false - onTriggered: uploadClicked(); - } - } - - Item { - id: uploadSpinner - visible: false - anchors.top: parent.top - anchors.left: parent.left - width: 40 - height: 32 - - Image { - id: image - width: 24 - height: 24 - source: "../../../images/Loading-Outer-Ring.png" - RotationAnimation on rotation { - loops: Animation.Infinite - from: 0 - to: 360 - duration: 2000 - } - } - Image { - width: 24 - height: 24 - source: "../../../images/Loading-Inner-H.png" - } - HifiControls.Label { - id: uploadProgressLabel - anchors.left: image.right - anchors.leftMargin: 10 - anchors.verticalCenter: image.verticalCenter - text: "In progress..." - colorScheme: root.colorScheme - } - } - } - } - } -} - diff --git a/interface/resources/qml/hifi/dialogs/TabletDCDialog.qml b/interface/resources/qml/hifi/dialogs/TabletDCDialog.qml deleted file mode 100644 index b33b957e15..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletDCDialog.qml +++ /dev/null @@ -1,160 +0,0 @@ -// -// TabletDCDialog.qml -// -// Created by Vlad Stelmahovsky on 3/15/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" - -Rectangle { - id: root - objectName: "DCConectionTiming" - - property var eventBridge; - signal sendToScript(var message); - property bool isHMD: false - - color: hifi.colors.baseGray - - property int colorScheme: hifi.colorSchemes.dark - - HifiConstants { id: hifi } - - Component.onCompleted: DCModel.refresh() - - Row { - id: header - anchors.top: parent.top - anchors.topMargin: hifi.dimensions.tabletMenuHeader - anchors.leftMargin: 5 - anchors.rightMargin: 5 - anchors.left: parent.left - anchors.right: parent.right - - HifiControls.Label { - id: nameButton - text: qsTr("Name") - size: 15 - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - height: 40 - width: 175 - } - HifiControls.Label { - id: tsButton - text: qsTr("Timestamp\n(ms)") - size: 15 - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - height: 40 - width: 125 - } - HifiControls.Label { - id: deltaButton - text: qsTr("Delta\n(ms)") - size: 15 - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - height: 40 - width: 80 - } - HifiControls.Label { - id: elapseButton - text: qsTr("Time elapsed\n(ms)") - size: 15 - color: "white" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter - height: 40 - width: 80 - } - } - - ListView { - anchors.leftMargin: 5 - anchors.rightMargin: 5 - anchors.left: parent.left - anchors.right: parent.right - anchors.top: header.bottom - anchors.topMargin: 5 - anchors.bottom: refreshButton.top - anchors.bottomMargin: 10 - clip: true - snapMode: ListView.SnapToItem - - model: DCModel - - delegate: Rectangle { - anchors.left: parent.left - anchors.right: parent.right - height: 30 - color: index % 2 === 0 ? hifi.colors.baseGray : hifi.colors.lightGray - Row { - anchors.fill: parent - spacing: 5 - HifiControls.Label { - size: 15 - text: name - color: "white" - anchors.verticalCenter: parent.verticalCenter - colorScheme: root.colorScheme - width: nameButton.width - } - HifiControls.Label { - size: 15 - text: timestamp - color: "white" - anchors.verticalCenter: parent.verticalCenter - colorScheme: root.colorScheme - horizontalAlignment: Text.AlignHCenter - width: tsButton.width - } - HifiControls.Label { - size: 15 - text: delta - color: "white" - anchors.verticalCenter: parent.verticalCenter - colorScheme: root.colorScheme - horizontalAlignment: Text.AlignHCenter - width: deltaButton.width - } - HifiControls.Label { - size: 15 - text: timeelapsed - color: "white" - anchors.verticalCenter: parent.verticalCenter - colorScheme: root.colorScheme - horizontalAlignment: Text.AlignHCenter - width: elapseButton.width - } - } - } - } - - HifiControls.Button { - id: refreshButton - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - text: qsTr("Refresh") - color: hifi.buttons.blue - colorScheme: root.colorScheme - height: 30 - onClicked: { - DCModel.refresh() - } - } -} diff --git a/interface/resources/qml/hifi/dialogs/TabletDebugWindow.qml b/interface/resources/qml/hifi/dialogs/TabletDebugWindow.qml deleted file mode 100644 index d4bbe0af04..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletDebugWindow.qml +++ /dev/null @@ -1,78 +0,0 @@ -// -// TabletDebugWindow.qml -// -// Vlad Stelmahovsky, created on 20/03/2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Hifi 1.0 as Hifi - -import "../../styles-uit" -import "../../controls-uit" as HifiControls - -Rectangle { - id: root - - objectName: "DebugWindow" - property var eventBridge; - - property var title: "Debug Window" - property bool isHMD: false - - color: hifi.colors.baseGray - - HifiConstants { id: hifi } - - signal sendToScript(var message); - property int colorScheme: hifi.colorSchemes.dark - - property var channel; - property var scripts: ScriptDiscoveryService; - - function fromScript(message) { - var MAX_LINE_COUNT = 2000; - var TRIM_LINES = 500; - if (textArea.lineCount > MAX_LINE_COUNT) { - var lines = textArea.text.split('\n'); - lines.splice(0, TRIM_LINES); - textArea.text = lines.join('\n'); - } - textArea.append(message); - } - - function getFormattedDate() { - var date = new Date(); - return date.getMonth() + "/" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); - } - - function sendToLogWindow(type, message, scriptFileName) { - var typeFormatted = ""; - if (type) { - typeFormatted = type + " - "; - } - fromScript("[" + getFormattedDate() + "] " + "[" + scriptFileName + "] " + typeFormatted + message); - } - - Connections { - target: ScriptDiscoveryService - onPrintedMessage: sendToLogWindow("", message, engineName); - onWarningMessage: sendToLogWindow("WARNING", message, engineName); - onErrorMessage: sendToLogWindow("ERROR", message, engineName); - onInfoMessage: sendToLogWindow("INFO", message, engineName); - } - - TextArea { - id: textArea - width: parent.width - height: parent.height - backgroundVisible: false - textColor: hifi.colors.white - text:"" - } - -} diff --git a/interface/resources/qml/hifi/dialogs/TabletEntityStatistics.qml b/interface/resources/qml/hifi/dialogs/TabletEntityStatistics.qml deleted file mode 100644 index 35ee58be0c..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletEntityStatistics.qml +++ /dev/null @@ -1,244 +0,0 @@ -// -// TabletEntityStatistics.qml -// -// Created by Vlad Stelmahovsky on 3/11/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" - -Rectangle { - id: root - objectName: "EntityStatistics" - - property var eventBridge; - signal sendToScript(var message); - property bool isHMD: false - - color: hifi.colors.baseGray - - property int colorScheme: hifi.colorSchemes.dark - - HifiConstants { id: hifi } - - Component.onCompleted: { - OctreeStats.startUpdates() - } - - Component.onDestruction: { - OctreeStats.stopUpdates() - } - - Flickable { - id: scrollView - width: parent.width - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.bottomMargin: hifi.dimensions.tabletMenuHeader - contentWidth: column.implicitWidth - contentHeight: column.implicitHeight - boundsBehavior: Flickable.StopAtBounds - - Column { - id: column - anchors.margins: 10 - anchors.left: parent.left - anchors.right: parent.right - y: hifi.dimensions.tabletMenuHeader //-bgNavBar - spacing: 20 - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Elements on Servers:") - text: OctreeStats.serverElements - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Local Elements:") - text: OctreeStats.localElements - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Elements Memory:") - text: OctreeStats.localElementsMemory - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Sending Mode:") - text: OctreeStats.sendingMode - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Incoming Entity Packets:") - text: OctreeStats.processedPackets - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Processed Packets Elements:") - text: OctreeStats.processedPacketsElements - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Processed Packets Entities:") - text: OctreeStats.processedPacketsEntities - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Processed Packets Timing:") - text: OctreeStats.processedPacketsTiming - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Outbound Entity Packets:") - text: OctreeStats.outboundEditPackets - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Entity Update Time:") - text: OctreeStats.entityUpdateTime - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - TabletEntityStatisticsItem { - anchors.left: parent.left - anchors.right: parent.right - titleText: qsTr("Entity Updates:") - text: OctreeStats.entityUpdates - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - Repeater { - model: OctreeStats.serversNum - - delegate: Column { - id: serverColumn - width: scrollView.width - 10 - x: 5 - spacing: 5 - - state: "less" - - TabletEntityStatisticsItem { - id: serverStats - width: parent.width - titleText: qsTr("Entity Server ") + (index+1) + ":" - colorScheme: root.colorScheme - color: OctreeStats.getColor() - } - - Row { - id: buttonsRow - width: parent.width - height: 30 - spacing: 10 - - HifiControls.Button { - id: moreButton - color: hifi.buttons.blue - colorScheme: root.colorScheme - width: parent.width / 2 - 10 - height: 30 - onClicked: { - if (serverColumn.state === "less") { - serverColumn.state = "more" - } else if (serverColumn.state === "more") { - serverColumn.state = "most" - } else { - serverColumn.state = "more" - } - } - } - HifiControls.Button { - id: mostButton - color: hifi.buttons.blue - colorScheme: root.colorScheme - height: 30 - width: parent.width / 2 - 10 - onClicked: { - if (serverColumn.state === "less") { - serverColumn.state = "most" - } else if (serverColumn.state === "more") { - serverColumn.state = "less" - } else { - serverColumn.state = "less" - } - } - - } - } - states: [ - State { - name: "less" - PropertyChanges { target: moreButton; text: qsTr("more..."); } - PropertyChanges { target: mostButton; text: qsTr("most..."); } - PropertyChanges { target: serverStats; text: OctreeStats.servers[index*3]; } - }, - State { - name: "more" - PropertyChanges { target: moreButton; text: qsTr("most..."); } - PropertyChanges { target: mostButton; text: qsTr("less..."); } - PropertyChanges { target: serverStats; text: OctreeStats.servers[index*3] + - OctreeStats.servers[index*3 + 1]; } - }, - State { - name: "most" - PropertyChanges { target: moreButton; text: qsTr("less..."); } - PropertyChanges { target: mostButton; text: qsTr("least..."); } - PropertyChanges { target: serverStats; text: OctreeStats.servers[index*3] + - OctreeStats.servers[index*3 + 1] + - OctreeStats.servers[index*3 + 2]; } - } - ] - } //servers column - } //repeater - } //column - } //flickable -} diff --git a/interface/resources/qml/hifi/dialogs/TabletEntityStatisticsItem.qml b/interface/resources/qml/hifi/dialogs/TabletEntityStatisticsItem.qml deleted file mode 100644 index 894a4c1813..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletEntityStatisticsItem.qml +++ /dev/null @@ -1,49 +0,0 @@ -// -// TabletEntityStatistics.qml -// -// Created by Vlad Stelmahovsky on 3/11/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls - -Column { - id: root - property int colorScheme: hifi.colorSchemes.dark - - property alias titleText: titleLabel.text - property alias text: valueLabel.text - property alias color: valueLabel.color - - HifiConstants { id: hifi } - - anchors.left: parent.left - anchors.right: parent.right - spacing: 10 - - HifiControls.Label { - id: titleLabel - size: 20 - anchors.left: parent.left - anchors.right: parent.right - colorScheme: root.colorScheme - } - - RalewaySemiBold { - id: valueLabel - anchors.left: parent.left - anchors.right: parent.right - wrapMode: Text.WordWrap - size: 16 - color: enabled ? (root.colorScheme == hifi.colorSchemes.light ? hifi.colors.lightGray : hifi.colors.lightGrayText) - : (root.colorScheme == hifi.colorSchemes.light ? hifi.colors.lightGrayText : hifi.colors.baseGrayHighlight); - } -} diff --git a/interface/resources/qml/hifi/dialogs/TabletLODTools.qml b/interface/resources/qml/hifi/dialogs/TabletLODTools.qml deleted file mode 100644 index 26e9759e0d..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletLODTools.qml +++ /dev/null @@ -1,119 +0,0 @@ -// -// TabletLODTools.qml -// -// Created by Vlad Stelmahovsky on 3/11/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" - -Rectangle { - id: root - objectName: "LODTools" - - property var eventBridge; - signal sendToScript(var message); - property bool isHMD: false - - color: hifi.colors.baseGray - - property int colorScheme: hifi.colorSchemes.dark - - HifiConstants { id: hifi } - - readonly property real treeScale: 32768; // ~20 miles.. This is the number of meters of the 0.0 to 1.0 voxel universe - readonly property real halfTreeScale: treeScale / 2; - - // This controls the LOD. Larger number will make smaller voxels visible at greater distance. - readonly property real defaultOctreeSizeScale: treeScale * 400.0 - - Column { - anchors.margins: 10 - anchors.left: parent.left - anchors.right: parent.right - y: hifi.dimensions.tabletMenuHeader //-bgNavBar - spacing: 20 - - HifiControls.Label { - size: 20 - anchors.left: parent.left - anchors.right: parent.right - text: qsTr("You can see...") - colorScheme: root.colorScheme - } - HifiControls.Label { - id: whatYouCanSeeLabel - color: "red" - size: 20 - anchors.left: parent.left - anchors.right: parent.right - colorScheme: root.colorScheme - } - Row { - anchors.left: parent.left - anchors.right: parent.right - spacing: 10 - - HifiControls.Label { - size: 20 - text: qsTr("Manually Adjust Level of Detail:") - anchors.verticalCenter: parent.verticalCenter - colorScheme: root.colorScheme - } - - HifiControls.CheckBox { - id: adjustCheckbox - boxSize: 20 - anchors.verticalCenter: parent.verticalCenter - onCheckedChanged: LODManager.setAutomaticLODAdjust(!checked); - } - } - - HifiControls.Label { - size: 20 - anchors.left: parent.left - anchors.right: parent.right - text: qsTr("Level of Detail:") - colorScheme: root.colorScheme - } - HifiControls.Slider { - id: slider - enabled: adjustCheckbox.checked - anchors.left: parent.left - anchors.right: parent.right - minimumValue: 5 - maximumValue: 2000 - value: LODManager.getOctreeSizeScale() / treeScale - tickmarksEnabled: false - onValueChanged: { - LODManager.setOctreeSizeScale(value * treeScale); - whatYouCanSeeLabel.text = LODManager.getLODFeedbackText() - } - } - - HifiControls.Button { - id: uploadButton - anchors.left: parent.left - anchors.right: parent.right - text: qsTr("Reset") - color: hifi.buttons.blue - colorScheme: root.colorScheme - height: 30 - onClicked: { - slider.value = defaultOctreeSizeScale/treeScale - adjustCheckbox.checked = false - LODManager.setAutomaticLODAdjust(adjustCheckbox.checked); - } - } - } -} - diff --git a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml b/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml deleted file mode 100644 index dee0d0e21f..0000000000 --- a/interface/resources/qml/hifi/dialogs/TabletRunningScripts.qml +++ /dev/null @@ -1,376 +0,0 @@ -// -// RunningScripts.qml -// -// Created by Bradley Austin Davis on 12 Jan 2016 -// Copyright 2016 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs -import Qt.labs.settings 1.0 - -import "../../styles-uit" -import "../../controls-uit" as HifiControls -import "../../windows" - -Rectangle { - id: root - objectName: "RunningScripts" - property var title: "Running Scripts" - HifiConstants { id: hifi } - signal sendToScript(var message); - property var eventBridge; - property var scripts: ScriptDiscoveryService; - property var scriptsModel: scripts.scriptsModelFilter - property var runningScriptsModel: ListModel { } - property bool isHMD: false - - color: hifi.colors.baseGray - - Connections { - target: ScriptDiscoveryService - onScriptCountChanged: updateRunningScripts(); - } - - Component.onCompleted: { - isHMD = HMD.active; - updateRunningScripts(); - } - - function updateRunningScripts() { - var runningScripts = ScriptDiscoveryService.getRunning(); - runningScriptsModel.clear() - for (var i = 0; i < runningScripts.length; ++i) { - runningScriptsModel.append(runningScripts[i]); - } - } - - function loadScript(script) { - console.log("Load script " + script); - scripts.loadOneScript(script); - } - - function reloadScript(script) { - console.log("Reload script " + script); - scripts.stopScript(script, true); - } - - function stopScript(script) { - console.log("Stop script " + script); - scripts.stopScript(script); - } - - function reloadAll() { - console.log("Reload all scripts"); - scripts.reloadAllScripts(); - } - - function loadDefaults() { - console.log("Load default scripts"); - scripts.loadOneScript(scripts.defaultScriptsPath + "/defaultScripts.js"); - } - - function stopAll() { - console.log("Stop all scripts"); - scripts.stopAllScripts(); - } - - Flickable { - id: flickable - width: parent.width - height: parent.height - (keyboard.raised ? keyboard.raisedHeight : 0) - contentWidth: parent.width - contentHeight: column.childrenRect.height - clip: true - - Column { - id: column - width: parent.width - HifiControls.TabletContentSection { - id: firstSection - name: "Currently Running" - isFirst: true - - HifiControls.VerticalSpacer {} - - Row { - spacing: hifi.dimensions.contentSpacing.x - - HifiControls.Button { - text: "Reload All" - color: hifi.buttons.black - onClicked: reloadAll() - } - - HifiControls.Button { - text: "Remove All" - color: hifi.buttons.red - onClicked: stopAll() - } - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight + 2 // Add space for border - } - - HifiControls.Table { - model: runningScriptsModel - id: table - height: 185 - colorScheme: hifi.colorSchemes.dark - anchors.left: parent.left - anchors.right: parent.right - expandSelectedRow: true - - itemDelegate: Item { - anchors { - left: parent ? parent.left : undefined - leftMargin: hifi.dimensions.tablePadding - right: parent ? parent.right : undefined - rightMargin: hifi.dimensions.tablePadding - } - - FiraSansSemiBold { - id: textItem - text: styleData.value - size: hifi.fontSizes.tableText - color: table.colorScheme == hifi.colorSchemes.light - ? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight) - : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - anchors { - left: parent.left - right: parent.right - top: parent.top - topMargin: 3 - } - - HiFiGlyphs { - id: reloadButton - text: hifi.glyphs.reloadSmall - color: reloadButtonArea.pressed ? hifi.colors.white : parent.color - anchors { - top: parent.top - right: stopButton.left - verticalCenter: parent.verticalCenter - } - MouseArea { - id: reloadButtonArea - anchors { fill: parent; margins: -2 } - onClicked: reloadScript(model.url) - } - } - - HiFiGlyphs { - id: stopButton - text: hifi.glyphs.closeSmall - color: stopButtonArea.pressed ? hifi.colors.white : parent.color - anchors { - top: parent.top - right: parent.right - verticalCenter: parent.verticalCenter - } - MouseArea { - id: stopButtonArea - anchors { fill: parent; margins: -2 } - onClicked: stopScript(model.url) - } - } - - } - - FiraSansSemiBold { - text: runningScriptsModel.get(styleData.row) ? runningScriptsModel.get(styleData.row).url : "" - elide: Text.ElideMiddle - size: hifi.fontSizes.tableText - color: table.colorScheme == hifi.colorSchemes.light - ? (styleData.selected ? hifi.colors.black : hifi.colors.lightGray) - : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - anchors { - top: textItem.bottom - left: parent.left - right: parent.right - } - visible: styleData.selected - } - } - - TableViewColumn { - role: "name" - } - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight + 2 // Add space for border - } - } - - HifiControls.TabletContentSection { - name: "Load Scripts" - - HifiControls.VerticalSpacer {} - - Row { - spacing: hifi.dimensions.contentSpacing.x - - HifiControls.Button { - text: "from URL" - color: hifi.buttons.black - height: 26 - onClicked: fromUrlTimer.running = true - - // For some reason trigginer an API that enters - // an internal event loop directly from the button clicked - // trigger below causes the appliction to behave oddly. - // Most likely because the button onClicked handling is never - // completed until the function returns. - // FIXME find a better way of handling the input dialogs that - // doesn't trigger this. - Timer { - id: fromUrlTimer - interval: 5 - repeat: false - running: false - onTriggered: ApplicationInterface.loadScriptURLDialog(); - } - } - - HifiControls.Button { - text: "from Disk" - color: hifi.buttons.black - height: 26 - onClicked: fromDiskTimer.running = true - - Timer { - id: fromDiskTimer - interval: 5 - repeat: false - running: false - onTriggered: ApplicationInterface.loadDialog(); - } - } - - HifiControls.Button { - text: "Load Defaults" - color: hifi.buttons.black - height: 26 - onClicked: loadDefaults() - } - } - - HifiControls.VerticalSpacer {} - - HifiControls.TextField { - id: filterEdit - isSearchField: true - anchors.left: parent.left - anchors.right: parent.right - colorScheme: hifi.colorSchemes.dark - placeholderText: "Filter" - onTextChanged: scriptsModel.filterRegExp = new RegExp("^.*" + text + ".*$", "i") - Component.onCompleted: scriptsModel.filterRegExp = new RegExp("^.*$", "i") - onActiveFocusChanged: { - // raise the keyboard - keyboard.raised = activeFocus; - - // scroll to the bottom of the content area. - if (activeFocus) { - flickable.contentY = (flickable.contentHeight - flickable.height); - } - } - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight + 2 // Add space for border - } - - HifiControls.Tree { - id: treeView - height: 155 - treeModel: scriptsModel - colorScheme: hifi.colorSchemes.dark - anchors.left: parent.left - anchors.right: parent.right - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight + 2 // Add space for border - } - - HifiControls.TextField { - id: selectedScript - anchors.left: parent.left - anchors.right: parent.right - anchors.rightMargin: loadButton.width + hifi.dimensions.contentSpacing.x - - colorScheme: hifi.colorSchemes.dark - readOnly: true - - Connections { - target: treeView - onCurrentIndexChanged: { - var path = scriptsModel.data(treeView.currentIndex, 0x100) - if (path) { - selectedScript.text = path - } else { - selectedScript.text = "" - } - } - } - } - - Item { - // Take the loadButton out of the column flow. - id: loadButtonContainer - anchors.top: selectedScript.top - anchors.right: parent.right - - HifiControls.Button { - id: loadButton - anchors.right: parent.right - - text: "Load" - color: hifi.buttons.blue - enabled: selectedScript.text != "" - onClicked: root.loadScript(selectedScript.text) - } - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight - (!isHMD ? 3 : 0) - } - - HifiControls.TextAction { - id: directoryButton - icon: hifi.glyphs.script - iconSize: 24 - text: "Reveal Scripts Folder" - onClicked: fileDialogHelper.openDirectory(scripts.defaultScriptsPath) - colorScheme: hifi.colorSchemes.dark - anchors.left: parent.left - visible: !isHMD - } - - HifiControls.VerticalSpacer { - height: hifi.dimensions.controlInterlineHeight - 3 - visible: !isHMD - } - } - } - } - - HifiControls.Keyboard { - id: keyboard - raised: false - numeric: false - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - } - } -} - diff --git a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml index 0e98f79216..6d371741ea 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Attachment.qml @@ -6,7 +6,6 @@ import Qt.labs.settings 1.0 import "." import ".." -import "../../tablet" import "../../../styles-uit" import "../../../controls-uit" as HifiControls import "../../../windows" @@ -18,24 +17,10 @@ Item { HifiConstants { id: hifi } - signal selectAttachment(); signal deleteAttachment(var attachment); signal updateAttachment(); property bool completed: false; - function doSelectAttachment(control, focus) { - if (focus) { - selectAttachment(); - - // Refocus control after possibly changing focus to attachment. - if (control.setControlFocus !== undefined) { - control.setControlFocus(); - } else { - control.focus = true; - } - } - } - Rectangle { color: hifi.colors.baseGray; anchors.fill: parent; radius: 4 } Component.onCompleted: { @@ -65,7 +50,6 @@ Item { updateAttachment(); } } - onFocusChanged: doSelectAttachment(this, focus); } HifiControls.Button { id: modelChooserButton; @@ -77,37 +61,17 @@ Item { id: modelBrowserBuilder; ModelBrowserDialog {} } - Component { - id: tabletModelBrowserBuilder; - TabletModelBrowserDialog {} - } onClicked: { - var browser; - if (typeof desktop !== "undefined") { - browser = modelBrowserBuilder.createObject(desktop); - browser.selected.connect(function(newModelUrl){ - modelUrl.text = newModelUrl; - }); - } else { - browser = tabletModelBrowserBuilder.createObject(tabletRoot); - browser.selected.connect(function(newModelUrl){ - modelUrl.text = newModelUrl; - tabletRoot.openModal = null; - }); - browser.canceled.connect(function() { - tabletRoot.openModal = null; - }); - - // Make dialog modal. - tabletRoot.openModal = browser; - } + var browser = modelBrowserBuilder.createObject(desktop); + browser.selected.connect(function(newModelUrl){ + modelUrl.text = newModelUrl; + }) } } } Item { - z: 1000 height: jointChooser.height + jointLabel.height + 4 anchors { left: parent.left; right: parent.right; } HifiControls.Label { @@ -118,7 +82,6 @@ Item { } HifiControls.ComboBox { id: jointChooser; - dropdownHeight: (typeof desktop !== "undefined") ? 480 : 206 anchors { bottom: parent.bottom; left: parent.left; right: parent.right } colorScheme: hifi.colorSchemes.dark currentIndex: attachment ? model.indexOf(attachment.jointName) : -1 @@ -128,7 +91,6 @@ Item { updateAttachment(); } } - onFocusChanged: doSelectAttachment(this, focus); } } @@ -146,7 +108,6 @@ Item { updateAttachment(); } } - onControlFocusChanged: doSelectAttachment(this, controlFocus); } } @@ -164,7 +125,6 @@ Item { updateAttachment(); } } - onControlFocusChanged: doSelectAttachment(this, controlFocus); } } @@ -193,7 +153,6 @@ Item { updateAttachment(); } } - onFocusChanged: doSelectAttachment(this, focus); } } @@ -219,7 +178,6 @@ Item { updateAttachment(); } } - onFocusChanged: doSelectAttachment(this, focus); } } } diff --git a/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml b/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml index 29f2c0ebf4..3d109cc2a5 100644 --- a/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml +++ b/interface/resources/qml/hifi/dialogs/attachments/Vector3.qml @@ -15,37 +15,9 @@ Item { property real stepSize: 1 property real maximumValue: 99 property real minimumValue: 0 - property bool controlFocus: false; // True if one of the ordinate controls has focus. - property var controlFocusControl: undefined signal valueChanged(); - function setControlFocus() { - if (controlFocusControl) { - controlFocusControl.focus = true; - // The controlFocus value is updated via onFocusChanged. - } - } - - function setFocus(control, focus) { - if (focus) { - controlFocusControl = control; - setControlFocusTrue.start(); // After any subsequent false from previous control. - } else { - controlFocus = false; - } - } - - Timer { - id: setControlFocusTrue - interval: 50 - repeat: false - running: false - onTriggered: { - controlFocus = true; - } - } - HifiConstants { id: hifi } HifiControls.SpinBox { @@ -66,7 +38,6 @@ Item { root.valueChanged(); } } - onFocusChanged: setFocus(this, focus); } HifiControls.SpinBox { @@ -87,7 +58,6 @@ Item { root.valueChanged(); } } - onFocusChanged: setFocus(this, focus); } HifiControls.SpinBox { @@ -108,6 +78,6 @@ Item { root.valueChanged(); } } - onFocusChanged: setFocus(this, focus); } } + diff --git a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml b/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml deleted file mode 100644 index 4adb485c2b..0000000000 --- a/interface/resources/qml/hifi/dialogs/content/AttachmentsContent.qml +++ /dev/null @@ -1,260 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs -import QtQuick.Controls.Styles 1.4 - -import "../../../styles-uit" -import "../../../controls-uit" as HifiControls -import "../../../windows" -import "../attachments" - -Item { - id: content - - readonly property var originalAttachments: MyAvatar.getAttachmentsVariant(); - property var attachments: []; - - Component.onCompleted: { - for (var i = 0; i < originalAttachments.length; ++i) { - var attachment = originalAttachments[i]; - content.attachments.push(attachment); - listView.model.append({}); - } - } - - Column { - width: pane.width - - Rectangle { - width: parent.width - height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) - color: hifi.colors.baseGray - - Rectangle { - id: attachmentsBackground - anchors { - left: parent.left; right: parent.right; top: parent.top; bottom: newAttachmentButton.top; - margins: hifi.dimensions.contentMargin.x - bottomMargin: hifi.dimensions.contentSpacing.y - } - color: hifi.colors.baseGrayShadow - radius: 4 - - ListView { - id: listView - anchors { - top: parent.top - left: parent.left - right: scrollBar.left - bottom: parent.bottom - margins: 4 - } - clip: true - snapMode: ListView.SnapToItem - - model: ListModel {} - delegate: Item { - id: attachmentDelegate - implicitHeight: attachmentView.height + 8; - implicitWidth: attachmentView.width - - MouseArea { - // User can click on whitespace to select item. - anchors.fill: parent - propagateComposedEvents: true - onClicked: { - listView.currentIndex = index; - attachmentsBackground.forceActiveFocus(); // Unfocus from any control. - mouse.accepted = false; - } - } - - Attachment { - id: attachmentView - width: listView.width - attachment: content.attachments[index] - onSelectAttachment: { - listView.currentIndex = index; - } - onDeleteAttachment: { - attachments.splice(index, 1); - listView.model.remove(index, 1); - } - onUpdateAttachment: MyAvatar.setAttachmentsVariant(attachments); - } - } - - onCountChanged: MyAvatar.setAttachmentsVariant(attachments); - - /* - // DEBUG - highlight: Rectangle { color: "#40ffff00" } - highlightFollowsCurrentItem: true - */ - - onHeightChanged: { - // Keyboard has been raised / lowered. - positionViewAtIndex(listView.currentIndex, ListView.SnapPosition); - } - - onCurrentIndexChanged: { - if (!yScrollTimer.running) { - scrollSlider.y = currentIndex * (scrollBar.height - scrollSlider.height) / (listView.count - 1); - } - } - - onContentYChanged: { - // User may have dragged content up/down. - yScrollTimer.restart(); - } - - Timer { - id: yScrollTimer - interval: 200 - repeat: false - running: false - onTriggered: { - var index = (listView.count - 1) * listView.contentY / (listView.contentHeight - scrollBar.height); - index = Math.round(index); - listView.currentIndex = index; - scrollSlider.y = index * (scrollBar.height - scrollSlider.height) / (listView.count - 1); - } - } - } - - Rectangle { - id: scrollBar - - property bool scrolling: listView.contentHeight > listView.height - - anchors { - top: parent.top - right: parent.right - bottom: parent.bottom - topMargin: 4 - bottomMargin: 4 - } - width: scrolling ? 18 : 0 - radius: attachmentsBackground.radius - color: hifi.colors.baseGrayShadow - - MouseArea { - anchors.fill: parent - - onClicked: { - var index = listView.currentIndex; - index = index + (mouse.y <= scrollSlider.y ? -1 : 1); - if (index < 0) { - index = 0; - } - if (index > listView.count - 1) { - index = listView.count - 1; - } - listView.currentIndex = index; - } - } - - Rectangle { - id: scrollSlider - anchors { - right: parent.right - rightMargin: 3 - } - width: 16 - height: (listView.height / listView.contentHeight) * listView.height - radius: width / 2 - color: hifi.colors.lightGray - - visible: scrollBar.scrolling; - - onYChanged: { - var index = y * (listView.count - 1) / (scrollBar.height - scrollSlider.height); - index = Math.round(index); - listView.currentIndex = index; - } - - MouseArea { - anchors.fill: parent - drag.target: scrollSlider - drag.axis: Drag.YAxis - drag.minimumY: 0 - drag.maximumY: scrollBar.height - scrollSlider.height - } - } - } - } - - HifiControls.Button { - id: newAttachmentButton - anchors { - left: parent.left - right: parent.right - bottom: buttonRow.top - margins: hifi.dimensions.contentMargin.x; - topMargin: hifi.dimensions.contentSpacing.y - bottomMargin: hifi.dimensions.contentSpacing.y - } - text: "New Attachment" - color: hifi.buttons.black - colorScheme: hifi.colorSchemes.dark - onClicked: { - var template = { - modelUrl: "", - translation: { x: 0, y: 0, z: 0 }, - rotation: { x: 0, y: 0, z: 0 }, - scale: 1, - jointName: MyAvatar.jointNames[0], - soft: false - }; - attachments.push(template); - listView.model.append({}); - MyAvatar.setAttachmentsVariant(attachments); - } - } - - Row { - id: buttonRow - spacing: 8 - anchors { - right: parent.right - bottom: parent.bottom - margins: hifi.dimensions.contentMargin.x - topMargin: hifi.dimensions.contentSpacing.y - bottomMargin: hifi.dimensions.contentSpacing.y - } - HifiControls.Button { - action: okAction - color: hifi.buttons.black - colorScheme: hifi.colorSchemes.dark - } - HifiControls.Button { - action: cancelAction - color: hifi.buttons.black - colorScheme: hifi.colorSchemes.dark - } - } - - Action { - id: cancelAction - text: "Cancel" - onTriggered: { - MyAvatar.setAttachmentsVariant(originalAttachments); - closeDialog(); - } - } - - Action { - id: okAction - text: "OK" - onTriggered: { - for (var i = 0; i < attachments.length; ++i) { - console.log("Attachment " + i + ": " + attachments[i]); - } - - MyAvatar.setAttachmentsVariant(attachments); - closeDialog(); - } - } - } - } -} diff --git a/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml b/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml deleted file mode 100644 index 50fca94ff1..0000000000 --- a/interface/resources/qml/hifi/dialogs/content/ModelBrowserContent.qml +++ /dev/null @@ -1,64 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../../../controls-uit" as HifiControls - -Column { - width: pane.contentWidth - - Rectangle { - width: parent.width - height: root.height - (keyboardEnabled && keyboardRaised ? 200 : 0) - color: hifi.colors.baseGray - - HifiControls.TextField { - id: filterEdit - anchors { left: parent.left; right: parent.right; top: parent.top ; margins: 8} - placeholderText: "filter" - onTextChanged: tableView.model.filter = text - colorScheme: hifi.colorSchemes.dark - } - - HifiControls.AttachmentsTable { - id: tableView - anchors { left: parent.left; right: parent.right; top: filterEdit.bottom; bottom: buttonRow.top; margins: 8; } - colorScheme: hifi.colorSchemes.dark - onCurrentRowChanged: { - if (currentRow == -1) { - root.result = null; - return; - } - result = model.baseUrl + "/" + model.get(tableView.currentRow).key; - } - } - - Row { - id: buttonRow - spacing: 8 - anchors { right: parent.right; rightMargin: 8; bottom: parent.bottom; bottomMargin: 8; } - HifiControls.Button { action: acceptAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } - HifiControls.Button { action: cancelAction ; color: hifi.buttons.black; colorScheme: hifi.colorSchemes.dark } - } - - Action { - id: acceptAction - text: qsTr("OK") - enabled: root.result ? true : false - shortcut: Qt.Key_Return - onTriggered: { - root.selected(root.result); - root.destroy(); - } - } - - Action { - id: cancelAction - text: qsTr("Cancel") - shortcut: Qt.Key_Escape - onTriggered: { - root.canceled(); - root.destroy(); - } - } - } -} diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml deleted file mode 100644 index 4abe698fbc..0000000000 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ /dev/null @@ -1,299 +0,0 @@ -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtWebEngine 1.1 -import QtWebChannel 1.0 -import QtQuick.Controls.Styles 1.4 -import "../../controls" -import "../toolbars" -import HFWebEngineProfile 1.0 -import QtGraphicalEffects 1.0 -import "../../controls-uit" as HifiControls -import "../../styles-uit" - -StackView { - id: editRoot - objectName: "stack" - initialItem: editBasePage - - property var eventBridge; - signal sendToScript(var message); - - HifiConstants { id: hifi } - - function pushSource(path) { - editRoot.push(Qt.resolvedUrl(path)); - editRoot.currentItem.eventBridge = editRoot.eventBridge; - editRoot.currentItem.sendToScript.connect(editRoot.sendToScript); - } - - function popSource() { - editRoot.pop(); - } - - - Component { - id: editBasePage - TabView { - id: editTabView - // anchors.fill: parent - height: 60 - - Tab { - title: "CREATE" - active: true - enabled: true - property string originalUrl: "" - - Rectangle { - color: "#404040" - - Text { - color: "#ffffff" - text: "Choose an Entity Type to Create:" - font.pixelSize: 14 - font.bold: true - anchors.top: parent.top - anchors.topMargin: 28 - anchors.left: parent.left - anchors.leftMargin: 28 - } - - Flow { - id: createEntitiesFlow - spacing: 35 - anchors.right: parent.right - anchors.rightMargin: 55 - anchors.left: parent.left - anchors.leftMargin: 55 - anchors.top: parent.top - anchors.topMargin: 70 - - - NewEntityButton { - icon: "icons/create-icons/94-model-01.svg" - text: "MODEL" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newModelButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/21-cube-01.svg" - text: "CUBE" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newCubeButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/22-sphere-01.svg" - text: "SPHERE" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newSphereButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/24-light-01.svg" - text: "LIGHT" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newLightButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/20-text-01.svg" - text: "TEXT" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newTextButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/25-web-1-01.svg" - text: "WEB" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newWebButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/23-zone-01.svg" - text: "ZONE" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newZoneButton" } - }); - editTabView.currentIndex = 2 - } - } - - NewEntityButton { - icon: "icons/create-icons/90-particles-01.svg" - text: "PARTICLE" - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "newParticleButton" } - }); - editTabView.currentIndex = 2 - } - } - } - - HifiControls.Button { - id: assetServerButton - text: "Open This Domain's Asset Server" - color: hifi.buttons.black - colorScheme: hifi.colorSchemes.dark - anchors.right: parent.right - anchors.rightMargin: 55 - anchors.left: parent.left - anchors.leftMargin: 55 - anchors.top: createEntitiesFlow.bottom - anchors.topMargin: 35 - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "openAssetBrowserButton" } - }); - } - } - - HifiControls.Button { - text: "Import Entities (.json)" - color: hifi.buttons.black - colorScheme: hifi.colorSchemes.dark - anchors.right: parent.right - anchors.rightMargin: 55 - anchors.left: parent.left - anchors.leftMargin: 55 - anchors.top: assetServerButton.bottom - anchors.topMargin: 20 - onClicked: { - editRoot.sendToScript({ - method: "newEntityButtonClicked", params: { buttonName: "importEntitiesButton" } - }); - } - } - } - } - - Tab { - title: "LIST" - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: entityListToolWebView - url: "../../../../../scripts/system/html/entityList.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent - enabled: true - } - } - - Tab { - title: "PROPERTIES" - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: entityPropertiesWebView - url: "../../../../../scripts/system/html/entityProperties.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent - enabled: true - } - } - - Tab { - title: "GRID" - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: gridControlsWebView - url: "../../../../../scripts/system/html/gridControls.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent - enabled: true - } - } - - Tab { - title: "P" - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: particleExplorerWebView - url: "../../../../../scripts/system/particle_explorer/particleExplorer.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent - enabled: true - } - } - - - style: TabViewStyle { - frameOverlap: 1 - tab: Rectangle { - color: styleData.selected ? "#404040" :"black" - implicitWidth: text.width + 42 - implicitHeight: 40 - Text { - id: text - anchors.centerIn: parent - text: styleData.title - font.pixelSize: 16 - font.bold: true - color: styleData.selected ? "white" : "white" - property string glyphtext: "" - HiFiGlyphs { - anchors.centerIn: parent - size: 30 - color: "#ffffff" - text: text.glyphtext - } - Component.onCompleted: if (styleData.title == "P") { - text.text = " "; - text.glyphtext = "\ue004"; - } - } - } - tabBar: Rectangle { - color: "black" - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - anchors.top: parent.top - anchors.topMargin: 0 - } - } - } - } -} diff --git a/interface/resources/qml/hifi/tablet/NewEntityButton.qml b/interface/resources/qml/hifi/tablet/NewEntityButton.qml deleted file mode 100644 index e5684fa791..0000000000 --- a/interface/resources/qml/hifi/tablet/NewEntityButton.qml +++ /dev/null @@ -1,160 +0,0 @@ -import QtQuick 2.0 -import QtGraphicalEffects 1.0 - -Item { - id: newEntityButton - property var uuid; - property string text: "ENTITY" - property string icon: "icons/edit-icon.svg" - property string activeText: newEntityButton.text - property string activeIcon: newEntityButton.icon - property bool isActive: false - property bool inDebugMode: false - property bool isEntered: false - property double sortOrder: 100 - property int stableOrder: 0 - property var tabletRoot; - width: 100 - height: 100 - - signal clicked() - - function changeProperty(key, value) { - tabletButton[key] = value; - } - - onIsActiveChanged: { - if (tabletButton.isEntered) { - tabletButton.state = (tabletButton.isActive) ? "hover active state" : "hover sate"; - } else { - tabletButton.state = (tabletButton.isActive) ? "active state" : "base sate"; - } - } - - Rectangle { - id: buttonBg - color: "#1c1c1c" - opacity: 1 - radius: 8 - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - anchors.top: parent.top - anchors.topMargin: 0 - } - - function urlHelper(src) { - if (src.match(/\bhttp/)) { - return src; - } else { - return "../../../" + src; - } - } - - Rectangle { - id: buttonOutline - color: "#00000000" - opacity: 0 - radius: 8 - z: 1 - border.width: 2 - border.color: "#ffffff" - anchors.right: parent.right - anchors.rightMargin: 0 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.bottom: parent.bottom - anchors.bottomMargin: 0 - anchors.top: parent.top - anchors.topMargin: 0 - } - - DropShadow { - id: glow - visible: false - anchors.fill: parent - horizontalOffset: 0 - verticalOffset: 0 - color: "#ffffff" - radius: 20 - z: -1 - samples: 41 - source: buttonOutline - } - - - Image { - id: icon - width: 50 - height: 50 - visible: false - anchors.bottom: text.top - anchors.bottomMargin: 5 - anchors.horizontalCenter: parent.horizontalCenter - fillMode: Image.Stretch - source: newEntityButton.urlHelper(newEntityButton.icon) - } - - ColorOverlay { - id: iconColorOverlay - anchors.fill: icon - source: icon - color: "#ffffff" - } - - Text { - id: text - color: "#ffffff" - text: newEntityButton.text - font.bold: true - font.pixelSize: 16 - anchors.bottom: parent.bottom - anchors.bottomMargin: 12 - anchors.horizontalCenter: parent.horizontalCenter - horizontalAlignment: Text.AlignHCenter - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - enabled: true - onClicked: { - newEntityButton.clicked(); - } - onEntered: { - newEntityButton.state = "hover state"; - } - onExited: { - newEntityButton.state = "base state"; - } - } - - states: [ - State { - name: "hover state" - - PropertyChanges { - target: buttonOutline - opacity: 1 - } - - PropertyChanges { - target: glow - visible: true - } - }, - State { - name: "base state" - - PropertyChanges { - target: glow - visible: false - } - } - ] -} - - diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml deleted file mode 100644 index 2fa48cac07..0000000000 --- a/interface/resources/qml/hifi/tablet/NewModelDialog.qml +++ /dev/null @@ -1,158 +0,0 @@ -// -// NewModelDialog.qml -// qml/hifi -// -// Created by Seth Alves on 2017-2-10 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "../../styles-uit" -import "../../controls-uit" - -Rectangle { - id: newModelDialog - // width: parent.width - // height: parent.height - HifiConstants { id: hifi } - color: hifi.colors.baseGray; - property var eventBridge; - signal sendToScript(var message); - - Column { - id: column1 - anchors.rightMargin: 10 - anchors.leftMargin: 10 - anchors.bottomMargin: 10 - anchors.topMargin: 10 - anchors.fill: parent - spacing: 5 - - Text { - id: text1 - text: qsTr("Model URL") - color: "#ffffff" - font.pixelSize: 12 - } - - TextInput { - id: modelURL - height: 20 - text: qsTr("") - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - font.pixelSize: 12 - } - - Row { - id: row1 - height: 400 - spacing: 30 - anchors.left: parent.left - anchors.leftMargin: 0 - anchors.right: parent.right - anchors.rightMargin: 0 - - Column { - id: column2 - width: 200 - height: 400 - spacing: 10 - - CheckBox { - id: dynamic - text: qsTr("Dynamic") - - } - - Row { - id: row2 - width: 200 - height: 400 - spacing: 20 - - Image { - id: image1 - width: 30 - height: 30 - source: "qrc:/qtquickplugin/images/template_image.png" - } - - Text { - id: text2 - width: 160 - color: "#ffffff" - text: qsTr("Models with automatic collisions set to 'Exact' cannot be dynamic") - wrapMode: Text.WordWrap - font.pixelSize: 12 - } - } - } - - Column { - id: column3 - height: 400 - spacing: 10 - - Text { - id: text3 - text: qsTr("Automatic Collisions") - color: "#ffffff" - font.pixelSize: 12 - } - - ComboBox { - id: collisionType - width: 200 - z: 100 - transformOrigin: Item.Center - model: ["No Collision", - "Basic - Whole model", - "Good - Sub-meshes", - "Exact - All polygons"] - } - - Row { - id: row3 - width: 200 - height: 400 - spacing: 5 - - anchors { - rightMargin: 15 - } - Button { - id: button1 - text: qsTr("Add") - z: -1 - onClicked: { - newModelDialog.sendToScript({ - method: "newModelDialogAdd", - params: { - textInput: modelURL.text, - checkBox: dynamic.checked, - comboBox: collisionType.currentIndex - } - }); - } - } - - Button { - id: button2 - z: -1 - text: qsTr("Cancel") - onClicked: { - newModelDialog.sendToScript({method: "newModelDialogCancel"}) - } - } - } - } - } - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml index 623054f233..952a1f7faa 100644 --- a/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml +++ b/interface/resources/qml/hifi/tablet/TabletAddressDialog.qml @@ -1,7 +1,7 @@ // // TabletAddressDialog.qml // -// Created by Dante Ruiz on 2017/03/16 +// Created by Dante Ruiz on 2016/07/16 // Copyright 2015 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -9,8 +9,7 @@ // import Hifi 1.0 -import QtQuick 2.5 -import QtQuick.Controls 1.4 +import QtQuick 2.4 import QtGraphicalEffects 1.0 import "../../controls" import "../../styles" @@ -20,23 +19,21 @@ import "../toolbars" import "../../styles-uit" as HifiStyles import "../../controls-uit" as HifiControls -StackView { +Item { id: root HifiConstants { id: hifi } HifiStyles.HifiConstants { id: hifiStyleConstants } - initialItem: addressBarDialog + width: parent.width height: parent.height property var allStories: []; - property int cardWidth: 460; + property int cardWidth: 370; property int cardHeight: 320; property string metaverseBase: addressBarDialog.metaverseServerUrl + "/api/v1/"; - Component { id: tabletStoryCard; TabletStoryCard {} } + Component.onCompleted: { - root.currentItem.focus = true; - root.currentItem.forceActiveFocus(); fillDestinations(); updateLocationText(); root.parentChanged.connect(center); @@ -57,9 +54,6 @@ StackView { } function goCard(targetString) { if (0 !== targetString.indexOf('hifi://')) { - var card = tabletStoryCard.createObject(); - card.setUrl(addressBarDialog.metaverseServerUrl + targetString); - root.push(card); return; } addressLine.text = targetString; @@ -88,156 +82,39 @@ StackView { } onMetaverseServerUrlChanged: updateLocationTextTimer.start(); - Rectangle { - id: navBar - width: 480 - height: 70 - color: hifiStyleConstants.colors.white - anchors { - top: parent.top - right: parent.right - rightMargin: 0 - left: parent.left - leftMargin: 0 - } - - ToolbarButton { - id: homeButton - imageURL: "../../../images/home.svg" - onClicked: { - addressBarDialog.loadHome(); - root.shown = false; - } - anchors { - left: parent.left - verticalCenter: parent.verticalCenter - } - } - ToolbarButton { - id: backArrow; - imageURL: "../../../images/backward.svg"; - onClicked: addressBarDialog.loadBack(); - anchors { - left: homeButton.right - verticalCenter: parent.verticalCenter - } - } - ToolbarButton { - id: forwardArrow; - imageURL: "../../../images/forward.svg"; - onClicked: addressBarDialog.loadForward(); - anchors { - left: backArrow.right - verticalCenter: parent.verticalCenter - } - } - } - - Rectangle { - id: addressBar - width: 480 - height: 70 - anchors { - top: navBar.bottom - right: parent.right - rightMargin: 16 - left: parent.left - leftMargin: 16 - } - - property int inputAreaHeight: 70 - property int inputAreaStep: (height - inputAreaHeight) / 2 - - HifiStyles.RalewayLight { - id: notice; - font.pixelSize: hifi.fonts.pixelSize * 0.50; - anchors { - top: parent.top - topMargin: parent.inputAreaStep + 12 - left: addressLine.left - right: addressLine.right - } - } - HifiStyles.FiraSansRegular { - id: location; - font.pixelSize: addressLine.font.pixelSize; - color: "gray"; - clip: true; - anchors.fill: addressLine; - visible: addressLine.text.length === 0 - } - - TextInput { - id: addressLine - focus: true - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - leftMargin: 0 - rightMargin: 0 - topMargin: parent.inputAreaStep + (2 * hifi.layout.spacing) - bottomMargin: parent.inputAreaStep - } - font.pixelSize: hifi.fonts.pixelSize * 0.75 - cursorVisible: false - onTextChanged: { - filterChoicesByText(); - updateLocationText(text.length > 0); - if (!isCursorVisible && text.length > 0) { - isCursorVisible = true; - cursorVisible = true; - } - } - onAccepted: { - addressBarDialog.keyboardEnabled = false; - } - onActiveFocusChanged: { - cursorVisible = isCursorVisible && focus; - } - MouseArea { - // If user clicks in address bar show cursor to indicate ability to enter address. - anchors.fill: parent - onClicked: { - isCursorVisible = true; - parent.cursorVisible = true; - parent.focus = true; - parent.forceActiveFocus(); - addressBarDialog.keyboardEnabled = HMD.active - tabletRoot.playButtonClickSound(); - } - } - } - - Rectangle { - anchors.fill: addressLine - color: hifiStyleConstants.colors.lightGray - opacity: 0.1 - } - } Rectangle { id: topBar - height: 37 - color: hifiStyleConstants.colors.white + height: 90 + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + + } + + GradientStop { + position: 1 + color: "#1e1e1e" + } + } anchors.right: parent.right anchors.rightMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 anchors.topMargin: 0 - anchors.top: addressBar.bottom + anchors.top: parent.top Row { id: thing - spacing: 5 * hifi.layout.spacing + spacing: 2 * hifi.layout.spacing anchors { top: parent.top; left: parent.left - leftMargin: 25 } - TabletTextButton { + TextButton { id: allTab; text: "ALL"; property string includeActions: 'snapshot, concurrency'; @@ -245,7 +122,7 @@ StackView { action: tabSelect; } - TabletTextButton { + TextButton { id: placeTab; text: "PLACES"; property string includeActions: 'concurrency'; @@ -254,7 +131,7 @@ StackView { } - TabletTextButton { + TextButton { id: snapTab; text: "SNAP"; property string includeActions: 'snapshot'; @@ -267,8 +144,21 @@ StackView { Rectangle { id: bgMain - color: hifiStyleConstants.colors.white - anchors.bottom: parent.keyboardEnabled ? keyboard.top : parent.bottom + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + + } + + GradientStop { + position: 1 + color: "#0f212e" + } + } + + + anchors.bottom: backgroundImage.top anchors.bottomMargin: 0 anchors.right: parent.right anchors.rightMargin: 0 @@ -282,7 +172,7 @@ StackView { ListView { id: scroll - property int stackedCardShadowHeight: 0; + property int stackedCardShadowHeight: 10; clip: true spacing: 14 anchors { @@ -290,9 +180,7 @@ StackView { top: parent.top left: parent.left right: parent.right - leftMargin: 10 - verticalCenter: parent.verticalCenter; - horizontalCenter: parent.horizontalCenter; + leftMargin: 50 } model: suggestions orientation: ListView.Vertical @@ -322,7 +210,109 @@ StackView { } } - Timer { + Rectangle { + id: backgroundImage + width: 480 + height: 70 + + gradient: Gradient { + GradientStop { + position: 0 + color: "#c2ced8" + + } + + GradientStop { + position: 1 + color: "#c2ced8" + } + } + + anchors { + bottom: parent.keyboardEnabled ? keyboard.top : parent.bottom + right: parent.right + left: parent.left + } + + + ToolbarButton { + id: homeButton + imageURL: "../../../images/home.svg" + onClicked: { + addressBarDialog.loadHome(); + root.shown = false; + } + anchors { + left: parent.left + leftMargin: homeButton.width / 2 + verticalCenter: parent.verticalCenter + } + } + property int inputAreaHeight: 70 + property int inputAreaStep: (height - inputAreaHeight) / 2 + + HifiStyles.RalewayLight { + id: notice; + font.pixelSize: hifi.fonts.pixelSize * 0.50; + anchors { + top: parent.top + topMargin: parent.inputAreaStep + 12 + left: addressLine.left + right: addressLine.right + } + } + HifiStyles.FiraSansRegular { + id: location; + font.pixelSize: addressLine.font.pixelSize; + color: "gray"; + clip: true; + anchors.fill: addressLine; + visible: addressLine.text.length === 0 + } + + TextInput { + id: addressLine + focus: true + anchors { + bottom: parent.bottom + left: homeButton.right + right: parent.right + leftMargin: homeButton.width + rightMargin: homeButton.width / 2 + topMargin: parent.inputAreaStep + (2 * hifi.layout.spacing) + bottomMargin: parent.inputAreaStep + } + font.pixelSize: hifi.fonts.pixelSize * 0.75 + cursorVisible: false + onTextChanged: { + filterChoicesByText(); + updateLocationText(text.length > 0); + if (!isCursorVisible && text.length > 0) { + isCursorVisible = true; + cursorVisible = true; + } + } + onAccepted: { + addressBarDialog.keyboardEnabled = false; + } + onActiveFocusChanged: { + cursorVisible = isCursorVisible && focus; + } + MouseArea { + // If user clicks in address bar show cursor to indicate ability to enter address. + anchors.fill: parent + onClicked: { + isCursorVisible = true; + //parent.cursorVisible = true; + parent.forceActiveFocus(); + addressBarDialog.keyboardEnabled = HMD.active + tabletRoot.playButtonClickSound(); + } + } + } + } + + Timer { // Delay updating location text a bit to avoid flicker of content and so that connection status is valid. id: updateLocationTextTimer running: false diff --git a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml b/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml deleted file mode 100644 index 634c9d41ec..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletAttachmentsDialog.qml +++ /dev/null @@ -1,105 +0,0 @@ -// -// TabletAttachmentsDialog.qml -// -// Created by David Rowe on 9 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../../controls-uit" as HifiControls -import "../../styles-uit" -import "../dialogs/content" - -Item { - id: root - objectName: "AttachmentsDialog" - - property string title: "Avatar Attachments" - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - property var eventBridge; - signal sendToScript(var message); - - anchors.fill: parent - - HifiConstants { id: hifi } - - Rectangle { - id: pane // Surrogate for ScrollingWindow's pane. - anchors.fill: parent - } - - function closeDialog() { - Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); - } - - anchors.topMargin: hifi.dimensions.tabletMenuHeader // Space for header. - - HifiControls.TabletHeader { - id: header - title: root.title - - anchors { - left: parent.left - right: parent.right - bottom: parent.top - } - } - - AttachmentsContent { - id: attachments - - anchors { - top: header.bottom - left: parent.left - right: parent.right - bottom: keyboard.top - } - - MouseArea { - // Defocuses any current control so that the keyboard gets hidden. - id: defocuser - anchors.fill: parent - propagateComposedEvents: true - acceptedButtons: Qt.AllButtons - onPressed: { - parent.forceActiveFocus(); - mouse.accepted = false; - } - } - } - - HifiControls.Keyboard { - id: keyboard - raised: parent.keyboardEnabled && parent.keyboardRaised - numeric: parent.punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - - MouseArea { - id: activator - anchors.fill: parent - propagateComposedEvents: true - enabled: true - acceptedButtons: Qt.AllButtons - onPressed: { - mouse.accepted = false; - } - } - - Component.onCompleted: { - keyboardEnabled = HMD.active; - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml b/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml deleted file mode 100644 index b21bc238ac..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletAudioPreferences.qml +++ /dev/null @@ -1,38 +0,0 @@ -// -// TabletAudioPreferences.qml -// -// Created by Davd Rowe on 7 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "tabletWindows" -import "../../dialogs" - -StackView { - id: profileRoot - initialItem: root - objectName: "stack" - property string title: "Audio Settings" - - property var eventBridge; - signal sendToScript(var message); - - function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); - } - - function popSource() { - profileRoot.pop(); - } - - TabletPreferencesDialog { - id: root - objectName: "TabletAudioPreferences" - showCategories: ["Audio"] - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml b/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml deleted file mode 100644 index 75973f32ae..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletAvatarPreferences.qml +++ /dev/null @@ -1,38 +0,0 @@ -// -// TabletAvatarPreferences.qml -// -// Created by Davd Rowe on 2 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "tabletWindows" -import "../../dialogs" - -StackView { - id: profileRoot - initialItem: root - objectName: "stack" - property string title: "Avatar Settings" - - property var eventBridge; - signal sendToScript(var message); - - function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); - } - - function popSource() { - profileRoot.pop(); - } - - TabletPreferencesDialog { - id: root - objectName: "TabletAvatarPreferences" - showCategories: ["Avatar Basics", "Avatar Tuning", "Avatar Camera"] - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGeneralSettings.qml similarity index 68% rename from interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml rename to interface/resources/qml/hifi/tablet/TabletGeneralSettings.qml index 6fc29ac920..b445e6a463 100644 --- a/interface/resources/qml/hifi/tablet/TabletGeneralPreferences.qml +++ b/interface/resources/qml/hifi/tablet/TabletGeneralSettings.qml @@ -1,38 +1,44 @@ // -// TabletGeneralPreferences.qml +// TabletGeneralSettings.qml +// scripts/system/ // // Created by Dante Ruiz on 9 Feb 2017 -// Copyright 2017 High Fidelity, Inc. +// Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // import QtQuick 2.5 -import QtQuick.Controls 1.4 import "tabletWindows" import "../../dialogs" +import QtQuick.Controls 1.4 +import QtQuick.Controls.Styles 1.4 +import QtGraphicalEffects 1.0 StackView { id: profileRoot initialItem: root objectName: "stack" - property string title: "General Settings" - + property var eventBridge; signal sendToScript(var message); function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); + editRoot.push(Qt.reslovedUrl(path)); } function popSource() { - profileRoot.pop(); + } - + TabletPreferencesDialog { id: root - objectName: "TabletGeneralPreferences" + objectName: "GeneralPreferencesDialog" + width: parent.width + height: parent.height showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Sixense Controllers", "Perception Neuron", "Kinect"] + } + } diff --git a/interface/resources/qml/hifi/tablet/TabletGraphicsPreferences.qml b/interface/resources/qml/hifi/tablet/TabletGraphicsPreferences.qml deleted file mode 100644 index 67c466f991..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletGraphicsPreferences.qml +++ /dev/null @@ -1,38 +0,0 @@ -// -// TabletGraphicsPreferences.qml -// -// Created by Vlad Stelmahovsky on 12 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "tabletWindows" -import "../../dialogs" - -StackView { - id: profileRoot - initialItem: root - objectName: "stack" - property string title: "Graphics Settings" - - property var eventBridge; - signal sendToScript(var message); - - function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); - } - - function popSource() { - profileRoot.pop(); - } - - TabletPreferencesDialog { - id: root - objectName: "TabletGraphicsPreferences" - showCategories: ["Graphics"] - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml b/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml deleted file mode 100644 index f61f6f8c4e..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletLodPreferences.qml +++ /dev/null @@ -1,38 +0,0 @@ -// -// TabletLodPreferences.qml -// -// Created by Vlad Stelmahovsky on 11 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "tabletWindows" -import "../../dialogs" - -StackView { - id: profileRoot - initialItem: root - objectName: "stack" - property string title: "LOD Settings" - - property var eventBridge; - signal sendToScript(var message); - - function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); - } - - function popSource() { - profileRoot.pop(); - } - - TabletPreferencesDialog { - id: root - objectName: "TabletLodPreferences" - showCategories: ["Level of Detail Tuning"] - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletMenu.qml b/interface/resources/qml/hifi/tablet/TabletMenu.qml index af36f72c82..e0deab64b6 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenu.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenu.qml @@ -2,14 +2,8 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import QtQuick.Controls 1.4 import QtQml 2.2 -import QtWebChannel 1.0 -import QtWebEngine 1.1 -import HFWebEngineProfile 1.0 - - import "." import "../../styles-uit" -import "../../controls" FocusScope { id: tabletMenu @@ -19,11 +13,10 @@ FocusScope { height: 720 property var rootMenu: Menu { objectName:"rootMenu" } - property var point: Qt.point(50, 50); - TabletMenuStack { id: menuPopperUpper } + property var point: Qt.point(50, 50) property string subMenu: "" - property var eventBridge; - signal sendToScript(var message); + + TabletMouseHandler { id: menuPopperUpper } Rectangle { id: bgNavBar @@ -60,11 +53,10 @@ FocusScope { anchors.fill: parent hoverEnabled: true onEntered: iconColorOverlay.color = "#1fc6a6"; - onExited: iconColorOverlay.color = "#34a2c7"; + onExited: iconColorOverlay.color = "#ffffff"; // navigate back to root level menu onClicked: { buildMenu(); - breadcrumbText.text = "Menu"; tabletRoot.playButtonClickSound(); } } @@ -105,7 +97,6 @@ FocusScope { menuPopperUpper.closeLastMenu(); } - function setRootMenu(rootMenu, subMenu) { tabletMenu.subMenu = subMenu; tabletMenu.rootMenu = rootMenu; @@ -125,12 +116,12 @@ FocusScope { } subMenu = ""; // Continue with full menu after initially displaying submenu. if (found) { - menuPopperUpper.popup(rootMenu.items[index].items); + menuPopperUpper.popup(tabletMenu, rootMenu.items[index].items); return; } } // Otherwise build whole menu. - menuPopperUpper.popup(rootMenu.items); + menuPopperUpper.popup(tabletMenu, rootMenu.items); } } diff --git a/interface/resources/qml/hifi/tablet/TabletMenuItem.qml b/interface/resources/qml/hifi/tablet/TabletMenuItem.qml index 25f672e7a9..c9223650f8 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuItem.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuItem.qml @@ -32,7 +32,8 @@ Item { anchors { left: parent.left leftMargin: hifi.dimensions.menuPadding.x + 15 - verticalCenter: label.verticalCenter + top: label.top + topMargin: 0 } width: 20 visible: source.visible && source.type === 1 && source.checkable @@ -50,8 +51,6 @@ Item { RalewaySemiBold { id: label size: 20 - //wrap will work only if width is set - width: parent.width - (check.width + check.anchors.leftMargin) - tail.width font.capitalization: isSubMenu ? Font.MixedCase : Font.AllUppercase anchors.left: check.right anchors.verticalCenter: parent.verticalCenter @@ -59,7 +58,6 @@ Item { color: source.enabled ? hifi.colors.baseGrayShadow : hifi.colors.baseGrayShadow50 enabled: source.visible && (source.type !== 0 ? source.enabled : false) visible: source.visible - wrapMode: Text.WordWrap } Item { diff --git a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml b/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml deleted file mode 100644 index 60bd7a88e0..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletModelBrowserDialog.qml +++ /dev/null @@ -1,87 +0,0 @@ -// -// TabletModelBrowserDialog.qml -// -// Created by David Rowe on 11 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 - -import "../../controls-uit" as HifiControls -import "../../styles-uit" -import "../dialogs/content" - -Item { - id: root - objectName: "ModelBrowserDialog" - - property string title: "Attachment Model" - - property var result - - signal selected(var modelUrl) - signal canceled() - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - anchors.fill: parent - - Rectangle { - id: pane // Surrogate for ScrollingWindow's pane. - anchors.fill: parent - } - - anchors.topMargin: hifi.dimensions.tabletMenuHeader // Space for header. - - HifiControls.TabletHeader { - id: header - title: parent.title - - anchors { - left: parent.left - right: parent.right - bottom: parent.top - } - } - - ModelBrowserContent { - anchors { - top: header.bottom - left: parent.left - right: parent.right - bottom: keyboard.top - } - } - - HifiControls.Keyboard { - id: keyboard - raised: parent.keyboardEnabled && parent.keyboardRaised - numeric: parent.punctuationMode - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - - MouseArea { - id: activator - anchors.fill: parent - propagateComposedEvents: true - enabled: true - acceptedButtons: Qt.AllButtons - onPressed: { - mouse.accepted = false; - } - } - - Component.onCompleted: { - keyboardEnabled = HMD.active; - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml similarity index 79% rename from interface/resources/qml/hifi/tablet/TabletMenuStack.qml rename to interface/resources/qml/hifi/tablet/TabletMouseHandler.qml index bacc11228e..17a00eccde 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml +++ b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml @@ -1,7 +1,7 @@ // // MessageDialog.qml // -// Created by Dante Ruiz on 13 Feb 2017 +// Created by Bradley Austin Davis on 18 Jan 2016 // Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -18,12 +18,18 @@ Item { anchors.fill: parent objectName: "tabletMenuHandlerItem" - StackView { + MouseArea { + id: menuRoot; + objectName: "tabletMenuHandlerMouseArea" anchors.fill: parent - id: d - objectName: "stack" - initialItem: topMenu + enabled: d.topMenu !== null + onClicked: { + d.clearMenus(); + } + } + QtObject { + id: d property var menuStack: [] property var topMenu: null; property var modelMaker: Component { ListModel { } } @@ -47,24 +53,6 @@ Item { } } - function pushSource(path) { - d.push(Qt.resolvedUrl(path)); - d.currentItem.eventBridge = tabletMenu.eventBridge - d.currentItem.sendToScript.connect(tabletMenu.sendToScript); - d.currentItem.focus = true; - d.currentItem.forceActiveFocus(); - breadcrumbText.text = d.currentItem.title; - if (typeof bgNavBar !== "undefined") { - d.currentItem.y = bgNavBar.height; - d.currentItem.height -= bgNavBar.height; - } - } - - function popSource() { - console.log("trying to pop page"); - d.pop(); - } - function toModel(items) { var result = modelMaker.createObject(tabletMenu); for (var i = 0; i < items.length; ++i) { @@ -88,18 +76,22 @@ Item { } function popMenu() { - if (d.depth) { - d.pop(); + if (menuStack.length) { + menuStack.pop().destroy(); } - if (d.depth) { - topMenu = d.currentItem; + if (menuStack.length) { + topMenu = menuStack[menuStack.length - 1]; topMenu.focus = true; topMenu.forceActiveFocus(); // show current menu level on nav bar - if (topMenu.objectName === "" || d.depth === 1) { + if (topMenu.objectName === "") { breadcrumbText.text = "Menu"; } else { - breadcrumbText.text = topMenu.objectName; + if (menuStack.length === 1) { + breadcrumbText.text = "Menu"; + } else { + breadcrumbText.text = topMenu.objectName; + } } } else { breadcrumbText.text = "Menu"; @@ -108,14 +100,16 @@ Item { } function pushMenu(newMenu) { - d.push({ item:newMenu, destroyOnPop: true}); + menuStack.push(newMenu); topMenu = newMenu; topMenu.focus = true; topMenu.forceActiveFocus(); } function clearMenus() { - d.clear() + while (menuStack.length) { + popMenu() + } } function clampMenuPosition(menu) { @@ -133,7 +127,7 @@ Item { } } - function buildMenu(items) { + function buildMenu(items, targetPosition) { var model = toModel(items); // Menus must be childed to desktop for Z-ordering var newMenu = menuViewMaker.createObject(tabletMenu, { model: model, isSubMenu: topMenu !== null }); @@ -164,13 +158,13 @@ Item { } - function popup(items) { + function popup(parent, items) { d.clearMenus(); - d.buildMenu(items); + d.buildMenu(items, point); } function closeLastMenu() { - if (d.depth > 1) { + if (d.menuStack.length > 1) { d.popMenu(); return true; } diff --git a/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml b/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml deleted file mode 100644 index db47c78c48..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletNetworkingPreferences.qml +++ /dev/null @@ -1,38 +0,0 @@ -// -// TabletNetworkingPreferences.qml -// -// Created by Davd Rowe on 7 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import "tabletWindows" -import "../../dialogs" - -StackView { - id: profileRoot - initialItem: root - objectName: "stack" - property var title: "Networking Settings" - - property var eventBridge; - signal sendToScript(var message); - - function pushSource(path) { - profileRoot.push(Qt.reslovedUrl(path)); - } - - function popSource() { - profileRoot.pop(); - } - - TabletPreferencesDialog { - id: root - objectName: "TabletNetworkingPreferences" - showCategories: ["Networking"] - } -} diff --git a/interface/resources/qml/hifi/tablet/TabletRoot.qml b/interface/resources/qml/hifi/tablet/TabletRoot.qml index 8037c1280e..1fb31e5619 100644 --- a/interface/resources/qml/hifi/tablet/TabletRoot.qml +++ b/interface/resources/qml/hifi/tablet/TabletRoot.qml @@ -1,59 +1,26 @@ import QtQuick 2.0 import Hifi 1.0 -import QtQuick.Controls 1.4 -import "../../dialogs" Item { id: tabletRoot objectName: "tabletRoot" property string username: "Unknown user" property var eventBridge; + property var rootMenu; - property var openModal: null; - property var openMessage: null; property string subMenu: "" + signal showDesktop(); function setOption(value) { option = value; } - Component { id: inputDialogBuilder; TabletQueryDialog { } } - function inputDialog(properties) { - openModal = inputDialogBuilder.createObject(tabletRoot, properties); - return openModal; - } - Component { id: messageBoxBuilder; TabletMessageBox { } } - function messageBox(properties) { - openMessage = messageBoxBuilder.createObject(tabletRoot, properties); - return openMessage; - } - - Component { id: customInputDialogBuilder; TabletCustomQueryDialog { } } - function customInputDialog(properties) { - openModal = customInputDialogBuilder.createObject(tabletRoot, properties); - return openModal; - } - - Component { id: fileDialogBuilder; TabletFileDialog { } } - function fileDialog(properties) { - openModal = fileDialogBuilder.createObject(tabletRoot, properties); - return openModal; - } - function setMenuProperties(rootMenu, subMenu) { tabletRoot.rootMenu = rootMenu; tabletRoot.subMenu = subMenu; } - function isDialogOpen() { - if (openMessage !== null || openModal !== null) { - return true; - } - - return false; - } - function loadSource(url) { loader.source = ""; // make sure we load the qml fresh each time. loader.source = url; @@ -101,7 +68,6 @@ Item { objectName: "loader" asynchronous: false - width: parent.width height: parent.height @@ -123,12 +89,6 @@ Item { loader.item.setRootMenu(tabletRoot.rootMenu, tabletRoot.subMenu); } loader.item.forceActiveFocus(); - - if (openModal) { - openModal.canceled(); - openModal.destroy(); - openModal = null; - } } } diff --git a/interface/resources/qml/hifi/tablet/TabletStoryCard.qml b/interface/resources/qml/hifi/tablet/TabletStoryCard.qml deleted file mode 100644 index ea6a23cb10..0000000000 --- a/interface/resources/qml/hifi/tablet/TabletStoryCard.qml +++ /dev/null @@ -1,132 +0,0 @@ -// -// TabletAddressDialog.qml -// -// Created by Dante Ruiz on 2017/04/24 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import Hifi 1.0 -import QtQuick 2.4 -import QtGraphicalEffects 1.0 -import "../../controls" -import "../../styles" -import "../../windows" -import "../" -import "../toolbars" -import "../../styles-uit" as HifiStyles -import "../../controls-uit" as HifiControls - - -Rectangle { - id: cardRoot - HifiStyles.HifiConstants { id: hifi } - width: parent.width - height: parent.height - property string address: "" - - function setUrl(url) { - cardRoot.address = url; - webview.url = url; - } - - function goBack() { - } - - function visit() { - } - - Rectangle { - id: header - anchors { - left: parent.left - right: parent.right - top: parent.top - } - - width: parent.width - height: 50 - color: hifi.colors.white - - Row { - anchors.fill: parent - spacing: 80 - - Item { - id: backButton - anchors { - top: parent.top - left: parent.left - leftMargin: 100 - } - height: parent.height - width: parent.height - - HifiStyles.FiraSansSemiBold { - text: "BACK" - elide: Text.ElideRight - anchors.fill: parent - size: 16 - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - - color: hifi.colors.lightGray - - MouseArea { - id: backButtonMouseArea - anchors.fill: parent - hoverEnabled: enabled - - onClicked: { - webview.goBack(); - } - } - } - } - - Item { - id: closeButton - anchors { - top: parent.top - right: parent.right - rightMargin: 100 - } - height: parent.height - width: parent.height - - HifiStyles.FiraSansSemiBold { - text: "CLOSE" - elide: Text.ElideRight - anchors.fill: parent - size: 16 - - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - - color: hifi.colors.lightGray - - MouseArea { - id: closeButtonMouseArea - anchors.fill: parent - hoverEnabled: enabled - - onClicked: root.pop(); - } - } - } - } - } - - HifiControls.WebView { - id: webview - anchors { - top: header.bottom - right: parent.right - left: parent.left - bottom: parent.bottom - } - } -} diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml index 26e35c4dcf..a3e94152b8 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletFileDialog.qml @@ -145,7 +145,7 @@ Item { } } - ComboBox { + TabletComboBox { id: pathSelector anchors { top: parent.top diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml index c96099a78a..7d214237a3 100644 --- a/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml +++ b/interface/resources/qml/hifi/tablet/tabletWindows/TabletPreferencesDialog.qml @@ -21,28 +21,18 @@ import "../../../controls-uit" as HifiControls Item { id: dialog - width: parent.width - height: parent.height + width: 480 + height: 720 HifiConstants { id: hifi } property var sections: [] property var showCategories: [] - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - property var tablet; function saveAll() { - dialog.forceActiveFocus(); // Accept any text box edits in progress. - for (var i = 0; i < sections.length; ++i) { var section = sections[i]; section.saveAll(); } - - closeDialog(); } function restoreAll() { @@ -50,25 +40,29 @@ Item { var section = sections[i]; section.restoreAll(); } - - closeDialog(); } - - function closeDialog() { - Tablet.getTablet("com.highfidelity.interface.tablet.system").gotoHomeScreen(); - } - + Rectangle { id: main + height: parent.height - 40 anchors { top: parent.top bottom: footer.top left: parent.left right: parent.right } - - color: hifi.colors.baseGray - + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + + } + + GradientStop { + position: 1 + color: "#0f212e" + } + } Flickable { id: scrollView width: parent.width @@ -116,7 +110,9 @@ Item { } scrollView.contentHeight = scrollView.getSectionsHeight(); + } + Column { id: prefControls @@ -135,39 +131,32 @@ Item { } } - MouseArea { - // Defocuses the current control so that the HMD keyboard gets hidden. - // Created under the footer so that the non-button part of the footer can defocus a control. - id: mouseArea - anchors { - top: parent.top - left: parent.left - right: parent.right - bottom: keyboard.top - } - propagateComposedEvents: true - acceptedButtons: Qt.AllButtons - onPressed: { - parent.forceActiveFocus(); - mouse.accepted = false; - } - } - Rectangle { id: footer height: 40 anchors { - bottom: keyboard.top + top: main.bottom + bottom: parent.bottom left: parent.left right: parent.right } + gradient: Gradient { + GradientStop { + position: 0 + color: "#2b2b2b" + + } - color: hifi.colors.baseGray + GradientStop { + position: 1 + color: "#0f212e" + } + } Row { anchors { - verticalCenter: parent.verticalCenter + top: parent,top right: parent.right rightMargin: hifi.dimensions.contentMargin.x } @@ -176,39 +165,15 @@ Item { HifiControls.Button { text: "Save changes" color: hifi.buttons.blue - onClicked: dialog.saveAll() + onClicked: root.saveAll() } HifiControls.Button { text: "Cancel" color: hifi.buttons.white - onClicked: dialog.restoreAll() - } - } - } - - HifiControls.Keyboard { - id: keyboard - raised: parent.keyboardEnabled && parent.keyboardRaised - numeric: parent.punctuationMode - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - } - } - - Component.onCompleted: { - tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - keyboardEnabled = HMD.active; - } - - onKeyboardRaisedChanged: { - if (keyboardEnabled && keyboardRaised) { - var delta = mouseArea.mouseY - (dialog.height - footer.height - keyboard.raisedHeight -hifi.dimensions.controlLineHeight); - if (delta > 0) { - scrollView.contentY += delta; + onClicked: root.restoreAll() } } } + } diff --git a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml b/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml deleted file mode 100644 index 029cf7d46b..0000000000 --- a/interface/resources/qml/hifi/tablet/tabletWindows/preferences/TabletAvatarBrowser.qml +++ /dev/null @@ -1,116 +0,0 @@ -// -// TabletAvatarBrowser.qml -// -// Created by David Rowe on 14 Mar 2017 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtWebChannel 1.0 -import QtWebEngine 1.2 - -import "../../../../windows" -import "../../../../controls-uit" -import "../../../../styles-uit" - -Item { - id: root - objectName: "ModelBrowserDialog" - - property string title: "Attachment Model" - - property bool keyboardEnabled: false - property bool keyboardRaised: false - property bool punctuationMode: false - - property alias eventBridge: eventBridgeWrapper.eventBridge - - anchors.fill: parent - - BaseWebView { - id: webview - url: "https://metaverse.highfidelity.com/marketplace?category=avatars" - focus: true - - anchors { - top: parent.top - left: parent.left - right: parent.right - bottom: footer.top - } - - QtObject { - id: eventBridgeWrapper - WebChannel.id: "eventBridgeWrapper" - property var eventBridge; - } - - webChannel.registeredObjects: [eventBridgeWrapper] - - // Create a global EventBridge object for raiseAndLowerKeyboard. - WebEngineScript { - id: createGlobalEventBridge - sourceCode: eventBridgeJavaScriptToInject - injectionPoint: WebEngineScript.DocumentCreation - worldId: WebEngineScript.MainWorld - } - - // Detect when may want to raise and lower keyboard. - WebEngineScript { - id: raiseAndLowerKeyboard - injectionPoint: WebEngineScript.Deferred - sourceUrl: resourceDirectoryUrl + "html/raiseAndLowerKeyboard.js" - worldId: WebEngineScript.MainWorld - } - - userScripts: [ createGlobalEventBridge, raiseAndLowerKeyboard ] - } - - Rectangle { - id: footer - height: 40 - - anchors { - left: parent.left - right: parent.right - bottom: keyboard.top - } - - color: hifi.colors.baseGray - - Row { - anchors { - verticalCenter: parent.verticalCenter - right: parent.right - rightMargin: hifi.dimensions.contentMargin.x - } - - Button { - text: "Cancel" - color: hifi.buttons.white - onClicked: root.destroy(); - } - } - } - - Keyboard { - id: keyboard - - raised: parent.keyboardEnabled && parent.keyboardRaised - numeric: parent.punctuationMode - - anchors { - left: parent.left - right: parent.right - bottom: parent.bottom - } - } - - Component.onCompleted: { - keyboardEnabled = HMD.active; - } -} diff --git a/interface/resources/qml/hifi/toolbars/Toolbar.qml b/interface/resources/qml/hifi/toolbars/Toolbar.qml index f80e0f8c14..c0d984e822 100644 --- a/interface/resources/qml/hifi/toolbars/Toolbar.qml +++ b/interface/resources/qml/hifi/toolbars/Toolbar.qml @@ -120,6 +120,8 @@ Window { function addButton(properties) { properties = properties || {} + unpinnedAlpha = 1; + // If a name is specified, then check if there's an existing button with that name // and return it if so. This will allow multiple clients to listen to a single button, // and allow scripts to be idempotent so they don't duplicate buttons if they're reloaded @@ -154,7 +156,7 @@ Window { updatePinned(); if (buttons.length === 0) { - fadeOut(function () {}); + unpinnedAlpha = 0; } } diff --git a/interface/resources/qml/styles-uit/FiraSansSemiBold.qml b/interface/resources/qml/styles-uit/FiraSansSemiBold.qml index b3f3324090..ddbeff7d90 100644 --- a/interface/resources/qml/styles-uit/FiraSansSemiBold.qml +++ b/interface/resources/qml/styles-uit/FiraSansSemiBold.qml @@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4 Text { id: root - FontLoader { id: firaSansSemiBold; source: pathToFonts + "fonts/FiraSans-SemiBold.ttf"; } + FontLoader { id: firaSansSemiBold; source: "../../fonts/FiraSans-SemiBold.ttf"; } property real size: 32 font.pixelSize: size verticalAlignment: Text.AlignVCenter diff --git a/interface/resources/qml/styles-uit/HiFiGlyphs.qml b/interface/resources/qml/styles-uit/HiFiGlyphs.qml index cbd6fa1d68..d0dae746be 100644 --- a/interface/resources/qml/styles-uit/HiFiGlyphs.qml +++ b/interface/resources/qml/styles-uit/HiFiGlyphs.qml @@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4 Text { id: root - FontLoader { id: hiFiGlyphs; source: pathToFonts + "fonts/hifi-glyphs.ttf"; } + FontLoader { id: hiFiGlyphs; source: "../../fonts/hifi-glyphs.ttf"; } property int size: 32 font.pixelSize: size width: size diff --git a/interface/resources/qml/styles-uit/HifiConstants.qml b/interface/resources/qml/styles-uit/HifiConstants.qml index a9d5a0ed2f..e00175d4e7 100644 --- a/interface/resources/qml/styles-uit/HifiConstants.qml +++ b/interface/resources/qml/styles-uit/HifiConstants.qml @@ -159,7 +159,6 @@ Item { readonly property vector2d menuPadding: Qt.vector2d(14, 102) readonly property real scrollbarBackgroundWidth: 18 readonly property real scrollbarHandleWidth: scrollbarBackgroundWidth - 2 - readonly property real tabletMenuHeader: 90 } Item { diff --git a/interface/resources/qml/styles-uit/RalewayBold.qml b/interface/resources/qml/styles-uit/RalewayBold.qml index 433fdb7ae6..97a6a4c208 100644 --- a/interface/resources/qml/styles-uit/RalewayBold.qml +++ b/interface/resources/qml/styles-uit/RalewayBold.qml @@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4 Text { id: root - FontLoader { id: ralewayBold; source: pathToFonts + "fonts/Raleway-Bold.ttf"; } + FontLoader { id: ralewayBold; source: "../../fonts/Raleway-Bold.ttf"; } property real size: 32 font.pixelSize: size verticalAlignment: Text.AlignVCenter diff --git a/interface/resources/qml/styles-uit/RalewayRegular.qml b/interface/resources/qml/styles-uit/RalewayRegular.qml index 2cffeeb59d..1ed5f122dc 100644 --- a/interface/resources/qml/styles-uit/RalewayRegular.qml +++ b/interface/resources/qml/styles-uit/RalewayRegular.qml @@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4 Text { id: root - FontLoader { id: ralewayRegular; source: pathToFonts + "fonts/Raleway-Regular.ttf"; } + FontLoader { id: ralewayRegular; source: "../../fonts/Raleway-Regular.ttf"; } property real size: 32 font.pixelSize: size verticalAlignment: Text.AlignVCenter diff --git a/interface/resources/qml/styles-uit/RalewaySemiBold.qml b/interface/resources/qml/styles-uit/RalewaySemiBold.qml index b6c79e02a4..3c36a872a4 100644 --- a/interface/resources/qml/styles-uit/RalewaySemiBold.qml +++ b/interface/resources/qml/styles-uit/RalewaySemiBold.qml @@ -14,7 +14,7 @@ import QtQuick.Controls.Styles 1.4 Text { id: root - FontLoader { id: ralewaySemiBold; source: pathToFonts + "fonts/Raleway-SemiBold.ttf"; } + FontLoader { id: ralewaySemiBold; source: "../../fonts/Raleway-SemiBold.ttf"; } property real size: 32 font.pixelSize: size verticalAlignment: Text.AlignVCenter diff --git a/interface/resources/qml/windows/TabletModalFrame.qml b/interface/resources/qml/windows/TabletModalFrame.qml deleted file mode 100644 index 550eec8357..0000000000 --- a/interface/resources/qml/windows/TabletModalFrame.qml +++ /dev/null @@ -1,89 +0,0 @@ -// -// ModalFrame.qml -// -// Created by Bradley Austin Davis on 15 Jan 2016 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -import QtQuick 2.5 - -import "." -import "../controls-uit" -import "../styles-uit" - - -Rectangle { - HifiConstants { id: hifi } - - id: frameContent - - readonly property bool hasTitle: root.title != "" - - readonly property int frameMarginLeft: hifi.dimensions.modalDialogMargin.x - readonly property int frameMarginRight: hifi.dimensions.modalDialogMargin.x - readonly property int frameMarginTop: hifi.dimensions.modalDialogMargin.y + (frameContent.hasTitle ? hifi.dimensions.modalDialogTitleHeight + 10 : 0) - readonly property int frameMarginBottom: hifi.dimensions.modalDialogMargin.y - - border { - width: hifi.dimensions.borderWidth - color: hifi.colors.lightGrayText80 - } - - radius: hifi.dimensions.borderRadius - color: hifi.colors.faintGray - Item { - id: frameTitle - visible: frameContent.hasTitle - - anchors { - horizontalCenter: parent.horizontalCenter - verticalCenter: parent.verticalCenter - fill: parent - topMargin: frameMarginTop - leftMargin: frameMarginLeft - rightMargin: frameMarginRight - //bottomMargin: frameMarginBottom - } - - Item { - width: title.width + (icon.text !== "" ? icon.width + hifi.dimensions.contentSpacing.x : 20) - - onWidthChanged: root.titleWidth = width - - HiFiGlyphs { - id: icon - text: root.iconText ? root.iconText : "" - size: root.iconSize ? root.iconSize : 30 - color: hifi.colors.lightGray - visible: true - anchors.verticalCenter: title.verticalCenter - anchors.leftMargin: 50 - anchors.left: parent.left - } - - RalewayRegular { - id: title - text: root.title - elide: Text.ElideRight - color: hifi.colors.baseGrayHighlight - size: hifi.fontSizes.overlayTitle - y: -hifi.dimensions.modalDialogTitleHeight - anchors.rightMargin: -50 - anchors.right: parent.right - //anchors.horizontalCenter: parent.horizontalCenter - } - } - - Rectangle { - anchors.left: parent.left - anchors.right: parent.right - height: 1 - color: hifi.colors.lightGray - } - - } - -} diff --git a/interface/resources/qml/windows/TabletModalWindow.qml b/interface/resources/qml/windows/TabletModalWindow.qml deleted file mode 100644 index 05f192f7a7..0000000000 --- a/interface/resources/qml/windows/TabletModalWindow.qml +++ /dev/null @@ -1,22 +0,0 @@ -// -// ModalWindow.qml -// -// Created by Bradley Austin Davis on 22 Jan 2016 -// Copyright 2015 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Dialogs 1.2 as OriginalDialogs -import "." - -Rectangle { - id: modalWindow - layer.enabled: true - property var title: "Modal" - width: tabletRoot.width - height: tabletRoot.height - color: "#80000000" -} diff --git a/interface/resources/qml/windows/Window.qml b/interface/resources/qml/windows/Window.qml index a0ef73290a..20216ed7ae 100644 --- a/interface/resources/qml/windows/Window.qml +++ b/interface/resources/qml/windows/Window.qml @@ -313,6 +313,6 @@ Fadable { } } - // onMouseEntered: console.log("Mouse entered " + window) - // onMouseExited: console.log("Mouse exited " + window) + onMouseEntered: console.log("Mouse entered " + window) + onMouseExited: console.log("Mouse exited " + window) } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 25a585ea34..78707ee635 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -171,10 +171,8 @@ #include "ui/Stats.h" #include "ui/UpdateDialog.h" #include "ui/overlays/Overlays.h" -#include "ui/DomainConnectionModel.h" #include "Util.h" #include "InterfaceParentFinder.h" -#include "ui/OctreeStatsProvider.h" #include "FrameTimingsScriptingInterface.h" #include @@ -222,7 +220,7 @@ static const float MIRROR_FULLSCREEN_DISTANCE = 0.389f; static const quint64 TOO_LONG_SINCE_LAST_SEND_DOWNSTREAM_AUDIO_STATS = 1 * USECS_PER_SECOND; static const QString INFO_EDIT_ENTITIES_PATH = "html/edit-commands.html"; -static const QString INFO_HELP_PATH = "../../../html/tabletHelp.html"; +static const QString INFO_HELP_PATH = "html/help.html"; static const unsigned int THROTTLED_SIM_FRAMERATE = 15; static const int THROTTLED_SIM_FRAME_PERIOD_MS = MSECS_PER_SECOND / THROTTLED_SIM_FRAMERATE; @@ -496,8 +494,6 @@ bool setupEssentials(int& argc, char** argv) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(); - DependencyManager::set(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) DependencyManager::set(); @@ -521,7 +517,6 @@ bool setupEssentials(int& argc, char** argv) { DependencyManager::set(); DependencyManager::set(); DependencyManager::set(); - DependencyManager::set(nullptr, qApp->getOcteeSceneStats()); return previousSessionCrashed; } @@ -549,7 +544,7 @@ const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f; const bool DEFAULT_DESKTOP_TABLET_BECOMES_TOOLBAR = true; const bool DEFAULT_HMD_TABLET_BECOMES_TOOLBAR = false; const bool DEFAULT_TABLET_VISIBLE_TO_OTHERS = false; -const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = true; +const bool DEFAULT_PREFER_AVATAR_FINGER_OVER_STYLUS = false; Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runServer, QString runServerPathOption) : QApplication(argc, argv), @@ -847,9 +842,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo connect(this, &QCoreApplication::aboutToQuit, addressManager.data(), &AddressManager::storeCurrentAddress); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateThreadPoolCount); - connect(this, &Application::activeDisplayPluginChanged, this, [](){ - qApp->setProperty(hifi::properties::HMD, qApp->isHMDMode()); - }); connect(this, &Application::activeDisplayPluginChanged, this, &Application::updateSystemTabletMode); // Save avatar location immediately after a teleport. @@ -1630,15 +1622,17 @@ QString Application::getUserAgent() { return userAgent; } +uint64_t lastTabletUIToggle { 0 }; +const uint64_t toggleTabletUILockout { 500000 }; void Application::toggleTabletUI() const { - auto tabletScriptingInterface = DependencyManager::get(); - auto hmd = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - bool messageOpen = tablet->isMessageDialogOpen(); - if (!messageOpen || (messageOpen && !hmd->getShouldShowTablet())) { - auto HMD = DependencyManager::get(); - HMD->toggleShouldShowTablet(); + uint64_t now = usecTimestampNow(); + if (now - lastTabletUIToggle < toggleTabletUILockout) { + return; } + lastTabletUIToggle = now; + + auto HMD = DependencyManager::get(); + HMD->toggleShouldShowTablet(); } void Application::checkChangeCursor() { @@ -1811,7 +1805,6 @@ Application::~Application() { DependencyManager::destroy(); DependencyManager::destroy(); DependencyManager::destroy(); - DependencyManager::destroy(); ResourceManager::cleanup(); @@ -1973,13 +1966,12 @@ void Application::initializeUi() { rootContext->setContextProperty("AddressManager", DependencyManager::get().data()); rootContext->setContextProperty("FrameTimings", &_frameTimingsScriptingInterface); rootContext->setContextProperty("Rates", new RatesScriptingInterface(this)); - rootContext->setContextProperty("pathToFonts", "../../"); rootContext->setContextProperty("TREE_SCALE", TREE_SCALE); rootContext->setContextProperty("Quat", new Quat()); rootContext->setContextProperty("Vec3", new Vec3()); rootContext->setContextProperty("Uuid", new ScriptUUID()); - rootContext->setContextProperty("Assets", DependencyManager::get().data()); + rootContext->setContextProperty("Assets", new AssetMappingsScriptingInterface()); rootContext->setContextProperty("AvatarList", DependencyManager::get().data()); rootContext->setContextProperty("Users", DependencyManager::get().data()); @@ -2397,10 +2389,8 @@ void Application::showHelp() { QUrlQuery queryString; queryString.addQueryItem("handControllerName", handControllerName); queryString.addQueryItem("defaultTab", defaultTab); - auto tabletScriptingInterface = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - tablet->gotoWebScreen(INFO_HELP_PATH + "?" + queryString.toString()); - //InfoView::show(INFO_HELP_PATH, false, queryString.toString()); + + InfoView::show(INFO_HELP_PATH, false, queryString.toString()); } void Application::resizeEvent(QResizeEvent* event) { @@ -3788,7 +3778,7 @@ void Application::loadSettings() { } getMyAvatar()->loadData(); - setTabletVisibleToOthersSetting(false); + _settingsLoaded = true; } @@ -5746,26 +5736,9 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) } } -void Application::toggleRunningScriptsWidget() const { - auto scriptEngines = DependencyManager::get(); - bool scriptsRunning = !scriptEngines->getRunningScripts().isEmpty(); - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - - if (tablet->getToolbarMode() || false == scriptsRunning) { - static const QUrl url("hifi/dialogs/RunningScripts.qml"); - DependencyManager::get()->show(url, "RunningScripts"); - } else { - auto hmd = DependencyManager::get(); - if (!hmd->getShouldShowTablet() && !isHMDMode()) { - static const QUrl url("hifi/dialogs/RunningScripts.qml"); - DependencyManager::get()->show(url, "RunningScripts"); - } else { - static const QUrl url("../../hifi/dialogs/TabletRunningScripts.qml"); - tablet->pushOntoStack(url); - } - } - //DependencyManager::get()->show(url, "RunningScripts"); +void Application::toggleRunningScriptsWidget() const { + static const QUrl url("hifi/dialogs/RunningScripts.qml"); + DependencyManager::get()->show(url, "RunningScripts"); //if (_runningScriptsWidget->isVisible()) { // if (_runningScriptsWidget->hasFocus()) { // _runningScriptsWidget->hide(); @@ -5780,24 +5753,6 @@ void Application::toggleRunningScriptsWidget() const { //} } -void Application::showScriptLogs() { - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - auto scriptEngines = DependencyManager::get(); - QUrl defaultScriptsLoc = defaultScriptsLocation(); - defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js"); - - if (tablet->getToolbarMode()) { - scriptEngines->loadScript(defaultScriptsLoc.toString()); - } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - if (!tabletRoot && !isHMDMode()) { - scriptEngines->loadScript(defaultScriptsLoc.toString()); - } else { - tablet->pushOntoStack("../../hifi/dialogs/TabletDebugWindow.qml"); - } - } -} void Application::showAssetServerWidget(QString filePath) { if (!DependencyManager::get()->getThisNodeCanWriteAssets()) { @@ -5810,20 +5765,7 @@ void Application::showAssetServerWidget(QString filePath) { emit uploadRequest(filePath); } }; - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - auto hmd = DependencyManager::get(); - if (tablet->getToolbarMode()) { - DependencyManager::get()->show(url, "AssetServer", startUpload); - } else { - if (!hmd->getShouldShowTablet() && !isHMDMode()) { - DependencyManager::get()->show(url, "AssetServer", startUpload); - } else { - static const QUrl url("../../hifi/dialogs/TabletAssetServer.qml"); - tablet->pushOntoStack(url); - } - } - + DependencyManager::get()->show(url, "AssetServer", startUpload); startUpload(nullptr, nullptr); } @@ -5846,21 +5788,6 @@ void Application::addAssetToWorldFromURL(QString url) { request->send(); } -void Application::showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const { - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - auto hmd = DependencyManager::get(); - if (tablet->getToolbarMode()) { - DependencyManager::get()->show(desktopURL, name); - } else { - tablet->pushOntoStack(tabletURL); - if (!hmd->getShouldShowTablet() && !isHMDMode()) { - hmd->openTablet(); - } - - } -} - void Application::addAssetToWorldFromURLRequestFinished() { auto request = qobject_cast(sender()); auto url = request->getUrl().toString(); @@ -6342,41 +6269,6 @@ void Application::loadScriptURLDialog() const { } } -void Application::loadLODToolsDialog() { - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { - auto dialogsManager = DependencyManager::get(); - dialogsManager->lodTools(); - } else { - tablet->pushOntoStack("../../hifi/dialogs/TabletLODTools.qml"); - } - -} - - -void Application::loadEntityStatisticsDialog() { - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { - auto dialogsManager = DependencyManager::get(); - dialogsManager->octreeStatsDetails(); - } else { - tablet->pushOntoStack("../../hifi/dialogs/TabletEntityStatistics.qml"); - } -} - -void Application::loadDomainConnectionDialog() { - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode() || (!tablet->getTabletRoot() && !isHMDMode())) { - auto dialogsManager = DependencyManager::get(); - dialogsManager->showDomainConnectionDialog(); - } else { - tablet->pushOntoStack("../../hifi/dialogs/TabletDCDialog.qml"); - } -} - void Application::toggleLogDialog() { if (! _logDialog) { _logDialog = new LogDialog(nullptr, getLogger()); @@ -6963,7 +6855,6 @@ void Application::updateThreadPoolCount() const { } void Application::updateSystemTabletMode() { - qApp->setProperty(hifi::properties::HMD, isHMDMode()); if (isHMDMode()) { DependencyManager::get()->setToolbarMode(getHmdTabletBecomesToolbarSetting()); } else { diff --git a/interface/src/Application.h b/interface/src/Application.h index 0a5fcd78f1..7ae4160f8b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -333,8 +333,6 @@ public slots: void toggleRunningScriptsWidget() const; Q_INVOKABLE void showAssetServerWidget(QString filePath = ""); - void showDialog(const QString& desktopURL, const QString& tabletURL, const QString& name) const; - // FIXME: Move addAssetToWorld* methods to own class? void addAssetToWorldFromURL(QString url); void addAssetToWorldFromURLRequestFinished(); @@ -402,10 +400,6 @@ public slots: void addAssetToWorldMessageClose(); Q_INVOKABLE void toggleMuteAudio(); - void loadLODToolsDialog(); - void loadEntityStatisticsDialog(); - void loadDomainConnectionDialog(); - void showScriptLogs(); private slots: void showDesktop(); diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 23d689e339..a48ee4e7db 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -163,10 +163,10 @@ Menu::Menu() { // Avatar > Attachments... auto action = addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/AttachmentsDialog.qml"), - QString("../../hifi/tablet/TabletAttachmentsDialog.qml"), "AttachmentsDialog"); + DependencyManager::get()->show(QString("hifi/dialogs/AttachmentsDialog.qml"), "AttachmentsDialog"); }); + // Avatar > Size MenuWrapper* avatarSizeMenu = avatarMenu->addMenu("Size"); @@ -283,22 +283,19 @@ Menu::Menu() { // Settings > General... action = addActionToQMenuAndActionHash(settingsMenu, MenuOption::Preferences, Qt::CTRL | Qt::Key_Comma, nullptr, nullptr, QAction::PreferencesRole); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletGeneralPreferences.qml"), "GeneralPreferencesDialog"); + DependencyManager::get()->toggle(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), "GeneralPreferencesDialog"); }); // Settings > Avatar... action = addActionToQMenuAndActionHash(settingsMenu, "Avatar..."); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/AvatarPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletAvatarPreferences.qml"), "AvatarPreferencesDialog"); + DependencyManager::get()->toggle(QString("hifi/dialogs/AvatarPreferencesDialog.qml"), "AvatarPreferencesDialog"); }); // Settings > LOD... action = addActionToQMenuAndActionHash(settingsMenu, "LOD..."); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/LodPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletLodPreferences.qml"), "LodPreferencesDialog"); + DependencyManager::get()->toggle(QString("hifi/dialogs/LodPreferencesDialog.qml"), "LodPreferencesDialog"); }); // Settings > Control with Speech [advanced] @@ -319,8 +316,7 @@ Menu::Menu() { // Developer > Graphics... action = addActionToQMenuAndActionHash(developerMenu, "Graphics..."); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/GraphicsPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletGraphicsPreferences.qml"), "GraphicsPreferencesDialog"); + DependencyManager::get()->toggle(QString("hifi/dialogs/GraphicsPreferencesDialog.qml"), "GraphicsPreferencesDialog"); }); // Developer > Render >>> @@ -399,8 +395,7 @@ Menu::Menu() { // Developer > Render > LOD Tools - addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, - qApp, SLOT(loadLODToolsDialog())); + addActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::LodTools, 0, dialogsManager.data(), SLOT(lodTools())); // HACK enable texture decimation { @@ -515,8 +510,6 @@ Menu::Menu() { avatar.get(), SLOT(setEnableInverseKinematics(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderSensorToWorldMatrix, 0, false, avatar.get(), SLOT(setEnableDebugDrawSensorToWorldMatrix(bool))); - addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::RenderIKTargets, 0, false, - avatar.get(), SLOT(setEnableDebugDrawIKTargets(bool))); addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ActionMotorControl, Qt::CTRL | Qt::SHIFT | Qt::Key_K, true, avatar.get(), SLOT(updateMotionBehaviorFromMenu()), @@ -542,18 +535,16 @@ Menu::Menu() { // Developer > Entities >>> MenuWrapper* entitiesOptionsMenu = developerMenu->addMenu("Entities"); - addActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::OctreeStats, 0, - qApp, SLOT(loadEntityStatisticsDialog())); - + dialogsManager.data(), SLOT(octreeStatsDetails())); addCheckableActionToQMenuAndActionHash(entitiesOptionsMenu, MenuOption::ShowRealtimeEntityStats); // Developer > Network >>> MenuWrapper* networkMenu = developerMenu->addMenu("Network"); action = addActionToQMenuAndActionHash(networkMenu, MenuOption::Networking); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/NetworkingPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletNetworkingPreferences.qml"), "NetworkingPreferencesDialog"); + DependencyManager::get()->toggle(QUrl("hifi/dialogs/NetworkingPreferencesDialog.qml"), + "NetworkingPreferencesDialog"); }); addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches())); addActionToQMenuAndActionHash(networkMenu, MenuOption::ClearDiskCache, 0, @@ -565,7 +556,7 @@ Menu::Menu() { &UserActivityLogger::getInstance(), SLOT(disable(bool))); addActionToQMenuAndActionHash(networkMenu, MenuOption::ShowDSConnectTable, 0, - qApp, SLOT(loadDomainConnectionDialog())); + dialogsManager.data(), SLOT(showDomainConnectionDialog())); #if (PR_BUILD || DEV_BUILD) addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::SendWrongProtocolVersion, 0, false, @@ -612,8 +603,7 @@ Menu::Menu() { action = addActionToQMenuAndActionHash(audioDebugMenu, "Buffers..."); connect(action, &QAction::triggered, [] { - qApp->showDialog(QString("hifi/dialogs/AudioPreferencesDialog.qml"), - QString("../../hifi/tablet/TabletAudioPreferences.qml"), "AudioPreferencesDialog"); + DependencyManager::get()->toggle(QString("hifi/dialogs/AudioPreferencesDialog.qml"), "AudioPreferencesDialog"); }); addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction, 0, true, @@ -710,8 +700,14 @@ Menu::Menu() { }); essLogAction->setEnabled(nodeList->getThisNodeCanRez()); - action = addActionToQMenuAndActionHash(developerMenu, "Script Log (HMD friendly)...", Qt::NoButton, - qApp, SLOT(showScriptLogs())); + action = addActionToQMenuAndActionHash(developerMenu, "Script Log (HMD friendly)..."); + connect(action, &QAction::triggered, [] { + auto scriptEngines = DependencyManager::get(); + QUrl defaultScriptsLoc = defaultScriptsLocation(); + defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js"); + scriptEngines->loadScript(defaultScriptsLoc.toString()); + }); + // Developer > Stats addCheckableActionToQMenuAndActionHash(developerMenu, MenuOption::Stats); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 14b2f4aeaa..b4eaf56758 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -161,7 +161,6 @@ namespace MenuOption { const QString RenderResolutionThird = "1/3"; const QString RenderResolutionQuarter = "1/4"; const QString RenderSensorToWorldMatrix = "Show SensorToWorld Matrix"; - const QString RenderIKTargets = "Show IK Targets"; const QString ResetAvatarSize = "Reset Avatar Size"; const QString ResetSensors = "Reset Sensors"; const QString RunningScripts = "Running Scripts..."; diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 0d0390a365..e0f4b55393 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -491,11 +491,6 @@ void MyAvatar::simulate(float deltaTime) { { PerformanceTimer perfTimer("skeleton"); - - if (_rig) { - _rig->setEnableDebugDrawIKTargets(_enableDebugDrawIKTargets); - } - _skeletonModel->simulate(deltaTime); } @@ -921,10 +916,6 @@ void MyAvatar::setEnableDebugDrawSensorToWorldMatrix(bool isEnabled) { } } -void MyAvatar::setEnableDebugDrawIKTargets(bool isEnabled) { - _enableDebugDrawIKTargets = isEnabled; -} - void MyAvatar::setEnableMeshVisible(bool isEnabled) { render::ScenePointer scene = qApp->getMain3DScene(); _skeletonModel->setVisibleInScene(isEnabled, scene); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index add57cf5be..9f93fa1bd2 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -482,7 +482,6 @@ public slots: void setEnableDebugDrawPosition(bool isEnabled); void setEnableDebugDrawHandControllers(bool isEnabled); void setEnableDebugDrawSensorToWorldMatrix(bool isEnabled); - void setEnableDebugDrawIKTargets(bool isEnabled); bool getEnableMeshVisible() const { return _skeletonModel->isVisible(); } void setEnableMeshVisible(bool isEnabled); void setUseAnimPreAndPostRotations(bool isEnabled); @@ -669,7 +668,6 @@ private: bool _enableDebugDrawAnimPose { false }; bool _enableDebugDrawHandControllers { false }; bool _enableDebugDrawSensorToWorldMatrix { false }; - bool _enableDebugDrawIKTargets { false }; AudioListenerMode _audioListenerMode; glm::vec3 _customListenPosition; diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.h b/interface/src/scripting/AssetMappingsScriptingInterface.h index b7fcea2491..459f01b512 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.h +++ b/interface/src/scripting/AssetMappingsScriptingInterface.h @@ -20,8 +20,6 @@ #include #include -#include "DependencyManager.h" - class AssetMappingModel : public QStandardItemModel { Q_OBJECT @@ -41,12 +39,10 @@ private: QHash _pathToItemMap; }; -Q_DECLARE_METATYPE(AssetMappingModel*) +Q_DECLARE_METATYPE(AssetMappingModel*); -class AssetMappingsScriptingInterface : public QObject, public Dependency { +class AssetMappingsScriptingInterface : public QObject { Q_OBJECT - SINGLETON_DEPENDENCY - Q_PROPERTY(AssetMappingModel* mappingModel READ getAssetMappingModel CONSTANT) Q_PROPERTY(QAbstractProxyModel* proxyModel READ getProxyModel CONSTANT) public: diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.cpp b/interface/src/scripting/AudioDeviceScriptingInterface.cpp index cbb08c0af0..c4dc58f16b 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.cpp +++ b/interface/src/scripting/AudioDeviceScriptingInterface.cpp @@ -18,21 +18,6 @@ AudioDeviceScriptingInterface* AudioDeviceScriptingInterface::getInstance() { return &sharedInstance; } -QStringList AudioDeviceScriptingInterface::inputAudioDevices() const -{ - return DependencyManager::get()->getDeviceNames(QAudio::AudioInput).toList();; -} - -QStringList AudioDeviceScriptingInterface::outputAudioDevices() const -{ - return DependencyManager::get()->getDeviceNames(QAudio::AudioOutput).toList();; -} - -bool AudioDeviceScriptingInterface::muted() -{ - return getMuted(); -} - AudioDeviceScriptingInterface::AudioDeviceScriptingInterface() { connect(DependencyManager::get().data(), &AudioClient::muteToggled, this, &AudioDeviceScriptingInterface::muteToggled); @@ -46,6 +31,7 @@ bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) { Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, result), Q_ARG(const QString&, deviceName)); + return result; } @@ -55,6 +41,7 @@ bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) { Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, result), Q_ARG(const QString&, deviceName)); + return result; } @@ -82,6 +69,7 @@ QVector AudioDeviceScriptingInterface::getOutputDevices() { return DependencyManager::get()->getDeviceNames(QAudio::AudioOutput); } + float AudioDeviceScriptingInterface::getInputVolume() { return DependencyManager::get()->getInputVolume(); } @@ -102,17 +90,6 @@ void AudioDeviceScriptingInterface::toggleMute() { DependencyManager::get()->toggleMute(); } -void AudioDeviceScriptingInterface::setMuted(bool muted) -{ - bool lMuted = getMuted(); - if (lMuted == muted) - return; - - toggleMute(); - lMuted = getMuted(); - emit mutedChanged(lMuted); -} - bool AudioDeviceScriptingInterface::getMuted() { return DependencyManager::get()->isMuted(); } diff --git a/interface/src/scripting/AudioDeviceScriptingInterface.h b/interface/src/scripting/AudioDeviceScriptingInterface.h index 4d1d47dcba..149de9bf56 100644 --- a/interface/src/scripting/AudioDeviceScriptingInterface.h +++ b/interface/src/scripting/AudioDeviceScriptingInterface.h @@ -20,18 +20,9 @@ class AudioEffectOptions; class AudioDeviceScriptingInterface : public QObject { Q_OBJECT - - Q_PROPERTY(QStringList inputAudioDevices READ inputAudioDevices NOTIFY inputAudioDevicesChanged) - Q_PROPERTY(QStringList outputAudioDevices READ outputAudioDevices NOTIFY outputAudioDevicesChanged) - Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged) - public: static AudioDeviceScriptingInterface* getInstance(); - QStringList inputAudioDevices() const; - QStringList outputAudioDevices() const; - bool muted(); - public slots: bool setInputDevice(const QString& deviceName); bool setOutputDevice(const QString& deviceName); @@ -53,17 +44,12 @@ public slots: bool getMuted(); void toggleMute(); - void setMuted(bool muted); - private: AudioDeviceScriptingInterface(); signals: void muteToggled(); void deviceChanged(); - void mutedChanged(bool muted); - void inputAudioDevicesChanged(QStringList inputAudioDevices); - void outputAudioDevicesChanged(QStringList outputAudioDevices); }; #endif // hifi_AudioDeviceScriptingInterface_h diff --git a/interface/src/scripting/HMDScriptingInterface.cpp b/interface/src/scripting/HMDScriptingInterface.cpp index e2fed40a6d..65ac506a88 100644 --- a/interface/src/scripting/HMDScriptingInterface.cpp +++ b/interface/src/scripting/HMDScriptingInterface.cpp @@ -135,7 +135,7 @@ glm::quat HMDScriptingInterface::getOrientation() const { return glm::quat(); } -bool HMDScriptingInterface::isMounted() const { +bool HMDScriptingInterface::isMounted() const{ auto displayPlugin = qApp->getActiveDisplayPlugin(); return (displayPlugin->isHmd() && displayPlugin->isDisplayVisible()); } diff --git a/interface/src/ui/AvatarInputs.cpp b/interface/src/ui/AvatarInputs.cpp index 7d63a85a27..944be4bf9e 100644 --- a/interface/src/ui/AvatarInputs.cpp +++ b/interface/src/ui/AvatarInputs.cpp @@ -43,20 +43,10 @@ AvatarInputs::AvatarInputs(QQuickItem* parent) : QQuickItem(parent) { } \ } -#define AI_UPDATE_WRITABLE(name, src) \ - { \ - auto val = src; \ - if (_##name != val) { \ - _##name = val; \ - qDebug() << "AvatarInputs" << val; \ - emit name##Changed(val); \ - } \ - } - #define AI_UPDATE_FLOAT(name, src, epsilon) \ { \ float val = src; \ - if (fabsf(_##name - val) >= epsilon) { \ + if (fabs(_##name - val) >= epsilon) { \ _##name = val; \ emit name##Changed(); \ } \ @@ -69,8 +59,7 @@ void AvatarInputs::update() { AI_UPDATE(cameraEnabled, !Menu::getInstance()->isOptionChecked(MenuOption::NoFaceTracking)); AI_UPDATE(cameraMuted, Menu::getInstance()->isOptionChecked(MenuOption::MuteFaceTracking)); AI_UPDATE(isHMD, qApp->isHMDMode()); - - AI_UPDATE_WRITABLE(showAudioTools, Menu::getInstance()->isOptionChecked(MenuOption::AudioTools)); + AI_UPDATE(showAudioTools, Menu::getInstance()->isOptionChecked(MenuOption::AudioTools)); auto audioIO = DependencyManager::get(); const float AUDIO_METER_AVERAGING = 0.5; @@ -93,7 +82,7 @@ void AvatarInputs::update() { if (audioLevel > 1.0f) { audioLevel = 1.0; } - AI_UPDATE_FLOAT(audioLevel, audioLevel, 0.01f); + AI_UPDATE_FLOAT(audioLevel, audioLevel, 0.01); AI_UPDATE(audioClipping, ((audioIO->getTimeSinceLastClip() > 0.0f) && (audioIO->getTimeSinceLastClip() < 1.0f))); AI_UPDATE(audioMuted, audioIO->isMuted()); @@ -111,14 +100,6 @@ void AvatarInputs::update() { //iconColor = PULSE_MIN + (PULSE_MAX - PULSE_MIN) * pulseFactor; } -void AvatarInputs::setShowAudioTools(bool showAudioTools) { - if (_showAudioTools == showAudioTools) - return; - - Menu::getInstance()->setIsOptionChecked(MenuOption::AudioTools, showAudioTools); - update(); -} - void AvatarInputs::toggleCameraMute() { FaceTracker* faceTracker = qApp->getSelectedFaceTracker(); if (faceTracker) { diff --git a/interface/src/ui/AvatarInputs.h b/interface/src/ui/AvatarInputs.h index 0c4fc0f23c..5535469445 100644 --- a/interface/src/ui/AvatarInputs.h +++ b/interface/src/ui/AvatarInputs.h @@ -29,17 +29,12 @@ class AvatarInputs : public QQuickItem { AI_PROPERTY(bool, audioClipping, false) AI_PROPERTY(float, audioLevel, 0) AI_PROPERTY(bool, isHMD, false) - - Q_PROPERTY(bool showAudioTools READ showAudioTools WRITE setShowAudioTools NOTIFY showAudioToolsChanged) + AI_PROPERTY(bool, showAudioTools, true) public: static AvatarInputs* getInstance(); AvatarInputs(QQuickItem* parent = nullptr); void update(); - bool showAudioTools() const { return _showAudioTools; } - -public slots: - void setShowAudioTools(bool showAudioTools); signals: void cameraEnabledChanged(); @@ -48,7 +43,7 @@ signals: void audioClippingChanged(); void audioLevelChanged(); void isHMDChanged(); - void showAudioToolsChanged(bool showAudioTools); + void showAudioToolsChanged(); protected: Q_INVOKABLE void resetSensors(); @@ -57,7 +52,6 @@ protected: private: float _trailingAudioLoudness{ 0 }; - bool _showAudioTools { false }; }; #endif // hifi_AvatarInputs_h diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 0f7acc7c64..f1d6f585d7 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -28,9 +28,6 @@ #include "PreferencesDialog.h" #include "UpdateDialog.h" -#include "TabletScriptingInterface.h" -#include "scripting/HMDScriptingInterface.h" - template void DialogsManager::maybeCreateDialog(QPointer& member) { if (!member) { @@ -72,7 +69,7 @@ void DialogsManager::toggleLoginDialog() { } void DialogsManager::showLoginDialog() { - LoginDialog::showWithSelection(); + LoginDialog::show(); } void DialogsManager::showUpdateDialog() { diff --git a/interface/src/ui/DomainConnectionModel.cpp b/interface/src/ui/DomainConnectionModel.cpp deleted file mode 100644 index b9e4c1348e..0000000000 --- a/interface/src/ui/DomainConnectionModel.cpp +++ /dev/null @@ -1,101 +0,0 @@ -// -// DomainConnectionModel.cpp -// -// Created by Vlad Stelmahovsky -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "DomainConnectionModel.h" -#include - -#include -#include - -Q_LOGGING_CATEGORY(dcmodel, "hifi.dcmodel") - -DomainConnectionModel::DomainConnectionModel(QAbstractItemModel* parent) : - QAbstractItemModel(parent) -{} - -DomainConnectionModel::~DomainConnectionModel() { -} - -QVariant DomainConnectionModel::data(const QModelIndex& index, int role) const { - //sanity - const QMap × = - DependencyManager::get()->getLastConnectionTimes(); - - if (!index.isValid() || index.row() >= times.size()) - return QVariant(); - - // setup our data with the values from the NodeList - quint64 firstStepTime = times.firstKey() / USECS_PER_MSEC; - quint64 timestamp = times.keys().at(index.row()); - - quint64 stepTime = timestamp / USECS_PER_MSEC; - quint64 delta = 0;//(stepTime - lastStepTime); - quint64 elapsed = 0;//stepTime - firstStepTime; - - if (index.row() > 0) { - quint64 prevstepTime = times.keys().at(index.row() - 1) / USECS_PER_MSEC; - delta = (stepTime - prevstepTime); - elapsed = stepTime - firstStepTime; - } - - if (role == Qt::DisplayRole || role == DisplayNameRole) { - const QMetaObject &nodeListMeta = NodeList::staticMetaObject; - QMetaEnum stepEnum = nodeListMeta.enumerator(nodeListMeta.indexOfEnumerator("ConnectionStep")); - int stepIndex = (int) times.value(timestamp); - return stepEnum.valueToKey(stepIndex); - } else if (role == DeltaRole) { - return delta; - } else if (role == TimestampRole) { - return stepTime; - } else if (role == TimeElapsedRole) { - return elapsed; - } - return QVariant(); -} - -int DomainConnectionModel::rowCount(const QModelIndex& parent) const { - Q_UNUSED(parent) - const QMap × = - DependencyManager::get()->getLastConnectionTimes(); - return times.size(); -} - -QHash DomainConnectionModel::roleNames() const { - QHash roles; - roles.insert(DisplayNameRole, "name"); - roles.insert(TimestampRole, "timestamp"); - roles.insert(DeltaRole, "delta"); - roles.insert(TimeElapsedRole, "timeelapsed"); - return roles; -} - -QModelIndex DomainConnectionModel::index(int row, int column, const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return createIndex(row, column); -} - -QModelIndex DomainConnectionModel::parent(const QModelIndex &child) const -{ - Q_UNUSED(child) - return QModelIndex(); -} - -int DomainConnectionModel::columnCount(const QModelIndex &parent) const -{ - Q_UNUSED(parent) - return 1; -} - -void DomainConnectionModel::refresh() { - //inform view that we want refresh data - beginResetModel(); - endResetModel(); -} \ No newline at end of file diff --git a/interface/src/ui/DomainConnectionModel.h b/interface/src/ui/DomainConnectionModel.h deleted file mode 100644 index 11ecb23bd2..0000000000 --- a/interface/src/ui/DomainConnectionModel.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// DomainConnectionModel.h -// -// Created by Vlad Stelmahovsky -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// -#pragma once - -#ifndef hifi_DomainConnectionModel_h -#define hifi_DomainConnectionModel_h - -#include -#include - -class DomainConnectionModel : public QAbstractItemModel, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY -public: - DomainConnectionModel(QAbstractItemModel* parent = nullptr); - ~DomainConnectionModel(); - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QHash roleNames() const override; - - QModelIndex index(int row, int column, const QModelIndex& parent) const override; - QModelIndex parent(const QModelIndex& child) const override; - int columnCount(const QModelIndex& parent = QModelIndex()) const override; - - enum Roles { - DisplayNameRole = Qt::UserRole, - TimestampRole, - DeltaRole, - TimeElapsedRole - }; - -public slots: - void refresh(); - -protected: - -private: -}; - -#endif // hifi_DomainConnectionModel_h diff --git a/interface/src/ui/LoginDialog.cpp b/interface/src/ui/LoginDialog.cpp index 10783afd23..e333bb1b88 100644 --- a/interface/src/ui/LoginDialog.cpp +++ b/interface/src/ui/LoginDialog.cpp @@ -24,10 +24,6 @@ #include "DependencyManager.h" #include "Menu.h" -#include "Application.h" -#include "TabletScriptingInterface.h" -#include "scripting/HMDScriptingInterface.h" - HIFI_QML_DEF(LoginDialog) LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { @@ -35,24 +31,7 @@ LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) { connect(accountManager.data(), &AccountManager::loginComplete, this, &LoginDialog::handleLoginCompleted); connect(accountManager.data(), &AccountManager::loginFailed, - this, &LoginDialog::handleLoginFailed); -} - -void LoginDialog::showWithSelection() -{ - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - auto hmd = DependencyManager::get(); - - if (tablet->getToolbarMode()) { - LoginDialog::show(); - } else { - static const QUrl url("../../dialogs/TabletLoginDialog.qml"); - tablet->initialScreen(url); - if (!hmd->getShouldShowTablet()) { - hmd->openTablet(); - } - } + this, &LoginDialog::handleLoginFailed); } void LoginDialog::toggleAction() { @@ -72,7 +51,7 @@ void LoginDialog::toggleAction() { // change the menu item to login loginAction->setText("Login / Sign Up"); connection = connect(loginAction, &QAction::triggered, [] { - LoginDialog::showWithSelection(); + LoginDialog::show(); }); } } @@ -162,23 +141,9 @@ void LoginDialog::createAccountFromStream(QString username) { } void LoginDialog::openUrl(const QString& url) const { - - auto tabletScriptingInterface = DependencyManager::get(); - auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - auto hmd = DependencyManager::get(); auto offscreenUi = DependencyManager::get(); - - if (tablet->getToolbarMode()) { - auto browser = offscreenUi->load("Browser.qml"); - browser->setProperty("url", url); - } else { - if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { - auto browser = offscreenUi->load("Browser.qml"); - browser->setProperty("url", url); - } else { - tablet->gotoWebScreen(url); - } - } + auto browser = offscreenUi->load("Browser.qml"); + browser->setProperty("url", url); } void LoginDialog::linkCompleted(QNetworkReply& reply) { diff --git a/interface/src/ui/LoginDialog.h b/interface/src/ui/LoginDialog.h index 5ebf866fbd..ce6075793b 100644 --- a/interface/src/ui/LoginDialog.h +++ b/interface/src/ui/LoginDialog.h @@ -27,7 +27,6 @@ public: LoginDialog(QQuickItem* parent = nullptr); - static void showWithSelection(); signals: void handleLoginCompleted(); void handleLoginFailed(); diff --git a/interface/src/ui/OctreeStatsProvider.cpp b/interface/src/ui/OctreeStatsProvider.cpp deleted file mode 100644 index 5f40b9916d..0000000000 --- a/interface/src/ui/OctreeStatsProvider.cpp +++ /dev/null @@ -1,377 +0,0 @@ -// -// OctreeStatsProvider.cpp -// interface/src/ui -// -// Created by Vlad Stelmahovsky on 3/12/17. -// Copyright 2013 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "Application.h" - -#include "../octree/OctreePacketProcessor.h" -#include "ui/OctreeStatsProvider.h" - -OctreeStatsProvider::OctreeStatsProvider(QObject* parent, NodeToOctreeSceneStats* model) : - QObject(parent), - _model(model) - , _statCount(0) - , _averageUpdatesPerSecond(SAMPLES_PER_SECOND) -{ - //schedule updates - connect(&_updateTimer, &QTimer::timeout, this, &OctreeStatsProvider::updateOctreeStatsData); - _updateTimer.setInterval(100); - //timer will be rescheduled on each new timeout - _updateTimer.setSingleShot(true); -} - -/* - * Start updates statistics -*/ -void OctreeStatsProvider::startUpdates() { - _updateTimer.start(); -} - -/* - * Stop updates statistics -*/ -void OctreeStatsProvider::stopUpdates() { - _updateTimer.stop(); -} - -QColor OctreeStatsProvider::getColor() const { - static int statIndex = 1; - static quint32 rotatingColors[] = { GREENISH, YELLOWISH, GREYISH }; - quint32 colorRGBA = rotatingColors[statIndex % (sizeof(rotatingColors)/sizeof(rotatingColors[0]))]; - quint32 rgb = colorRGBA >> 8; - const quint32 colorpart1 = 0xfefefeu; - const quint32 colorpart2 = 0xf8f8f8; - rgb = ((rgb & colorpart1) >> 1) + ((rgb & colorpart2) >> 3); - statIndex++; - return QColor::fromRgb(rgb); -} - -OctreeStatsProvider::~OctreeStatsProvider() { - _updateTimer.stop(); -} - -int OctreeStatsProvider::serversNum() const { - return m_serversNum; -} - -void OctreeStatsProvider::updateOctreeStatsData() { - - // Processed Entities Related stats - auto entities = qApp->getEntities(); - auto entitiesTree = entities->getTree(); - - // Do this ever paint event... even if we don't update - auto totalTrackedEdits = entitiesTree->getTotalTrackedEdits(); - - const quint64 SAMPLING_WINDOW = USECS_PER_SECOND / SAMPLES_PER_SECOND; - quint64 now = usecTimestampNow(); - quint64 sinceLastWindow = now - _lastWindowAt; - auto editsInLastWindow = totalTrackedEdits - _lastKnownTrackedEdits; - float sinceLastWindowInSeconds = (float)sinceLastWindow / (float)USECS_PER_SECOND; - float recentUpdatesPerSecond = (float)editsInLastWindow / sinceLastWindowInSeconds; - if (sinceLastWindow > SAMPLING_WINDOW) { - _averageUpdatesPerSecond.updateAverage(recentUpdatesPerSecond); - _lastWindowAt = now; - _lastKnownTrackedEdits = totalTrackedEdits; - } - - // Only refresh our stats every once in a while, unless asked for realtime - quint64 REFRESH_AFTER = Menu::getInstance()->isOptionChecked(MenuOption::ShowRealtimeEntityStats) ? 0 : USECS_PER_SECOND; - quint64 sinceLastRefresh = now - _lastRefresh; - if (sinceLastRefresh < REFRESH_AFTER) { - _updateTimer.start((REFRESH_AFTER - sinceLastRefresh)/1000); - return; - } - // Only refresh our stats every once in a while, unless asked for realtime - //if no realtime, then update once per second. Otherwise consider 60FPS update, ie 16ms interval - //int updateinterval = Menu::getInstance()->isOptionChecked(MenuOption::ShowRealtimeEntityStats) ? 16 : 1000; - _updateTimer.start(REFRESH_AFTER/1000); - - const int FLOATING_POINT_PRECISION = 3; - - m_localElementsMemory = QString("Elements RAM: %1MB").arg(OctreeElement::getTotalMemoryUsage() / 1000000.0f, 5, 'f', 4); - emit localElementsMemoryChanged(m_localElementsMemory); - - // Local Elements - m_localElements = QString("Total: %1 / Internal: %2 / Leaves: %3"). - arg(OctreeElement::getNodeCount()). - arg(OctreeElement::getInternalNodeCount()). - arg(OctreeElement::getLeafNodeCount()); - emit localElementsChanged(m_localElements); - - // iterate all the current octree stats, and list their sending modes, total their octree elements, etc... - int serverCount = 0; - int movingServerCount = 0; - unsigned long totalNodes = 0; - unsigned long totalInternal = 0; - unsigned long totalLeaves = 0; - - m_sendingMode.clear(); - NodeToOctreeSceneStats* sceneStats = qApp->getOcteeSceneStats(); - sceneStats->withReadLock([&] { - for (NodeToOctreeSceneStatsIterator i = sceneStats->begin(); i != sceneStats->end(); i++) { - //const QUuid& uuid = i->first; - OctreeSceneStats& stats = i->second; - serverCount++; - - // calculate server node totals - totalNodes += stats.getTotalElements(); - totalInternal += stats.getTotalInternal(); - totalLeaves += stats.getTotalLeaves(); - - // Sending mode - if (serverCount > 1) { - m_sendingMode += ","; - } - if (stats.isMoving()) { - m_sendingMode += "M"; - movingServerCount++; - } else { - m_sendingMode += "S"; - } - if (stats.isFullScene()) { - m_sendingMode += "F"; - } else { - m_sendingMode += "p"; - } - } - }); - m_sendingMode += QString(" - %1 servers").arg(serverCount); - if (movingServerCount > 0) { - m_sendingMode += " "; - } else { - m_sendingMode += " "; - } - - emit sendingModeChanged(m_sendingMode); - - // Server Elements - m_serverElements = QString("Total: %1 / Internal: %2 / Leaves: %3"). - arg(totalNodes).arg(totalInternal).arg(totalLeaves); - emit serverElementsChanged(m_serverElements); - - - // Processed Packets Elements - auto averageElementsPerPacket = entities->getAverageElementsPerPacket(); - auto averageEntitiesPerPacket = entities->getAverageEntitiesPerPacket(); - - auto averageElementsPerSecond = entities->getAverageElementsPerSecond(); - auto averageEntitiesPerSecond = entities->getAverageEntitiesPerSecond(); - - auto averageWaitLockPerPacket = entities->getAverageWaitLockPerPacket(); - auto averageUncompressPerPacket = entities->getAverageUncompressPerPacket(); - auto averageReadBitstreamPerPacket = entities->getAverageReadBitstreamPerPacket(); - - const OctreePacketProcessor& entitiesPacketProcessor = qApp->getOctreePacketProcessor(); - - auto incomingPacketsDepth = entitiesPacketProcessor.packetsToProcessCount(); - auto incomingPPS = entitiesPacketProcessor.getIncomingPPS(); - auto processedPPS = entitiesPacketProcessor.getProcessedPPS(); - auto treeProcessedPPS = entities->getAveragePacketsPerSecond(); - - m_processedPackets = QString("Queue Size: %1 Packets / Network IN: %2 PPS / Queue OUT: %3 PPS / Tree IN: %4 PPS") - .arg(incomingPacketsDepth) - .arg(incomingPPS, 5, 'f', FLOATING_POINT_PRECISION) - .arg(processedPPS, 5, 'f', FLOATING_POINT_PRECISION) - .arg(treeProcessedPPS, 5, 'f', FLOATING_POINT_PRECISION); - emit processedPacketsChanged(m_processedPackets); - - m_processedPacketsElements = QString("%1 per packet / %2 per second") - .arg(averageElementsPerPacket, 5, 'f', FLOATING_POINT_PRECISION) - .arg(averageElementsPerSecond, 5, 'f', FLOATING_POINT_PRECISION); - emit processedPacketsElementsChanged(m_processedPacketsElements); - - m_processedPacketsEntities = QString("%1 per packet / %2 per second") - .arg(averageEntitiesPerPacket, 5, 'f', FLOATING_POINT_PRECISION) - .arg(averageEntitiesPerSecond, 5, 'f', FLOATING_POINT_PRECISION); - emit processedPacketsEntitiesChanged(m_processedPacketsEntities); - - m_processedPacketsTiming = QString("Lock Wait: %1 (usecs) / Uncompress: %2 (usecs) / Process: %3 (usecs)") - .arg(averageWaitLockPerPacket) - .arg(averageUncompressPerPacket) - .arg(averageReadBitstreamPerPacket); - emit processedPacketsTimingChanged(m_processedPacketsTiming); - - auto entitiesEditPacketSender = qApp->getEntityEditPacketSender(); - auto outboundPacketsDepth = entitiesEditPacketSender->packetsToSendCount(); - auto outboundQueuedPPS = entitiesEditPacketSender->getLifetimePPSQueued(); - auto outboundSentPPS = entitiesEditPacketSender->getLifetimePPS(); - - m_outboundEditPackets = QString("Queue Size: %1 packets / Queued IN: %2 PPS / Sent OUT: %3 PPS") - .arg(outboundPacketsDepth) - .arg(outboundQueuedPPS, 5, 'f', FLOATING_POINT_PRECISION) - .arg(outboundSentPPS, 5, 'f', FLOATING_POINT_PRECISION); - emit outboundEditPacketsChanged(m_outboundEditPackets); - - // Entity Edits update time - auto averageEditDelta = entitiesTree->getAverageEditDeltas(); - auto maxEditDelta = entitiesTree->getMaxEditDelta(); - - m_entityUpdateTime = QString("Average: %1 (usecs) / Max: %2 (usecs)") - .arg(averageEditDelta) - .arg(maxEditDelta); - emit entityUpdateTimeChanged(m_entityUpdateTime); - - // Entity Edits - auto bytesPerEdit = entitiesTree->getAverageEditBytes(); - - auto updatesPerSecond = _averageUpdatesPerSecond.getAverage(); - if (updatesPerSecond < 1) { - updatesPerSecond = 0; // we don't really care about small updates per second so suppress those - } - - m_entityUpdates = QString("%1 updates per second / %2 total updates / Average Size: %3 bytes") - .arg(updatesPerSecond, 5, 'f', FLOATING_POINT_PRECISION) - .arg(totalTrackedEdits) - .arg(bytesPerEdit); - emit entityUpdatesChanged(m_entityUpdates); - - updateOctreeServers(); -} - -void OctreeStatsProvider::updateOctreeServers() { - int serverCount = 0; - - showOctreeServersOfType(serverCount, NodeType::EntityServer, "Entity", - qApp->getEntityServerJurisdictions()); - if (m_serversNum != serverCount) { - m_serversNum = serverCount; - emit serversNumChanged(m_serversNum); - } -} - -void OctreeStatsProvider::showOctreeServersOfType(int& serverCount, NodeType_t serverType, const char* serverTypeName, - NodeToJurisdictionMap& serverJurisdictions) { - - m_servers.clear(); - - auto nodeList = DependencyManager::get(); - nodeList->eachNode([&](const SharedNodePointer& node) { - - // only send to the NodeTypes that are NodeType_t_VOXEL_SERVER - if (node->getType() == serverType) { - serverCount++; - - QString lesserDetails; - QString moreDetails; - QString mostDetails; - - if (node->getActiveSocket()) { - lesserDetails += "active "; - } else { - lesserDetails += "inactive "; - } - - QUuid nodeUUID = node->getUUID(); - - // lookup our nodeUUID in the jurisdiction map, if it's missing then we're - // missing at least one jurisdiction - serverJurisdictions.withReadLock([&] { - if (serverJurisdictions.find(nodeUUID) == serverJurisdictions.end()) { - lesserDetails += " unknown jurisdiction "; - return; - } - const JurisdictionMap& map = serverJurisdictions[nodeUUID]; - - auto rootCode = map.getRootOctalCode(); - - if (rootCode) { - QString rootCodeHex = octalCodeToHexString(rootCode.get()); - - VoxelPositionSize rootDetails; - voxelDetailsForCode(rootCode.get(), rootDetails); - AACube serverBounds(glm::vec3(rootDetails.x, rootDetails.y, rootDetails.z), rootDetails.s); - lesserDetails += QString(" jurisdiction: %1 [%2, %3, %4: %5]") - .arg(rootCodeHex) - .arg(rootDetails.x) - .arg(rootDetails.y) - .arg(rootDetails.z) - .arg(rootDetails.s); - } else { - lesserDetails += " jurisdiction has no rootCode"; - } // root code - }); - - // now lookup stats details for this server... - NodeToOctreeSceneStats* sceneStats = qApp->getOcteeSceneStats(); - sceneStats->withReadLock([&] { - if (sceneStats->find(nodeUUID) != sceneStats->end()) { - OctreeSceneStats& stats = sceneStats->at(nodeUUID); - - float lastFullEncode = stats.getLastFullTotalEncodeTime() / USECS_PER_MSEC; - float lastFullSend = stats.getLastFullElapsedTime() / USECS_PER_MSEC; - float lastFullSendInSeconds = stats.getLastFullElapsedTime() / USECS_PER_SECOND; - float lastFullPackets = stats.getLastFullTotalPackets(); - float lastFullPPS = lastFullPackets; - if (lastFullSendInSeconds > 0) { - lastFullPPS = lastFullPackets / lastFullSendInSeconds; - } - - mostDetails += QString("

Last Full Scene... Encode: %1 ms Send: %2 ms Packets: %3 Bytes: %4 Rate: %5 PPS") - .arg(lastFullEncode) - .arg(lastFullSend) - .arg(lastFullPackets) - .arg(stats.getLastFullTotalBytes()) - .arg(lastFullPPS); - - for (int i = 0; i < OctreeSceneStats::ITEM_COUNT; i++) { - OctreeSceneStats::Item item = (OctreeSceneStats::Item)(i); - OctreeSceneStats::ItemInfo& itemInfo = stats.getItemInfo(item); - mostDetails += QString("
%1 %2") - .arg(itemInfo.caption).arg(stats.getItemValue(item)); - } - - moreDetails += "
Node UUID: " +nodeUUID.toString() + " "; - - moreDetails += QString("
Elements: %1 total %2 internal %3 leaves ") - .arg(stats.getTotalElements()) - .arg(stats.getTotalInternal()) - .arg(stats.getTotalLeaves()); - - const SequenceNumberStats& seqStats = stats.getIncomingOctreeSequenceNumberStats(); - qint64 clockSkewInUsecs = node->getClockSkewUsec(); - qint64 clockSkewInMS = clockSkewInUsecs / (qint64)USECS_PER_MSEC; - - moreDetails += QString("
Incoming Packets: %1/ Lost: %2/ Recovered: %3") - .arg(stats.getIncomingPackets()) - .arg(seqStats.getLost()) - .arg(seqStats.getRecovered()); - - moreDetails += QString("
Out of Order: %1/ Early: %2/ Late: %3/ Unreasonable: %4") - .arg(seqStats.getOutOfOrder()) - .arg(seqStats.getEarly()) - .arg(seqStats.getLate()) - .arg(seqStats.getUnreasonable()); - - moreDetails += QString("
Average Flight Time: %1 msecs") - .arg(stats.getIncomingFlightTimeAverage()); - - moreDetails += QString("
Average Ping Time: %1 msecs") - .arg(node->getPingMs()); - - moreDetails += QString("
Average Clock Skew: %1 msecs [%2]") - .arg(clockSkewInMS) - .arg(formatUsecTime(clockSkewInUsecs)); - - - moreDetails += QString("
Incoming Bytes: %1 Wasted Bytes: %2") - .arg(stats.getIncomingBytes()) - .arg(stats.getIncomingWastedBytes()); - } - }); - m_servers.append(lesserDetails); - m_servers.append(moreDetails); - m_servers.append(mostDetails); - } // is VOXEL_SERVER - }); - emit serversChanged(m_servers); -} - - diff --git a/interface/src/ui/OctreeStatsProvider.h b/interface/src/ui/OctreeStatsProvider.h deleted file mode 100644 index c919ca102f..0000000000 --- a/interface/src/ui/OctreeStatsProvider.h +++ /dev/null @@ -1,154 +0,0 @@ -// -// OctreeStatsProvider.h -// interface/src/ui -// -// Created by Vlad Stelmahovsky on 3/12/17. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_OctreeStatsProvider_h -#define hifi_OctreeStatsProvider_h - -#include -#include -#include - -#include "DependencyManager.h" - -#define MAX_STATS 100 -#define MAX_VOXEL_SERVERS 50 -#define DEFAULT_COLOR 0 - -class OctreeStatsProvider : public QObject, public Dependency { - Q_OBJECT - SINGLETON_DEPENDENCY - - Q_PROPERTY(int serversNum READ serversNum NOTIFY serversNumChanged) - Q_PROPERTY(QString serverElements READ serverElements NOTIFY serverElementsChanged) - Q_PROPERTY(QString localElements READ localElements NOTIFY localElementsChanged) - Q_PROPERTY(QString localElementsMemory READ localElementsMemory NOTIFY localElementsMemoryChanged) - Q_PROPERTY(QString sendingMode READ sendingMode NOTIFY sendingModeChanged) - Q_PROPERTY(QString processedPackets READ processedPackets NOTIFY processedPacketsChanged) - Q_PROPERTY(QString processedPacketsElements READ processedPacketsElements NOTIFY processedPacketsElementsChanged) - Q_PROPERTY(QString processedPacketsEntities READ processedPacketsEntities NOTIFY processedPacketsEntitiesChanged) - Q_PROPERTY(QString processedPacketsTiming READ processedPacketsTiming NOTIFY processedPacketsTimingChanged) - Q_PROPERTY(QString outboundEditPackets READ outboundEditPackets NOTIFY outboundEditPacketsChanged) - Q_PROPERTY(QString entityUpdateTime READ entityUpdateTime NOTIFY entityUpdateTimeChanged) - Q_PROPERTY(QString entityUpdates READ entityUpdates NOTIFY entityUpdatesChanged) - - Q_PROPERTY(QStringList servers READ servers NOTIFY serversChanged) - -public: - OctreeStatsProvider(QObject* parent, NodeToOctreeSceneStats* model); - ~OctreeStatsProvider(); - - int serversNum() const; - - QString serverElements() const { - return m_serverElements; - } - - QString localElements() const { - return m_localElements; - } - - QString localElementsMemory() const { - return m_localElementsMemory; - } - - QString sendingMode() const { - return m_sendingMode; - } - - QString processedPackets() const { - return m_processedPackets; - } - - QString processedPacketsElements() const { - return m_processedPacketsElements; - } - - QString processedPacketsEntities() const { - return m_processedPacketsEntities; - } - - QString processedPacketsTiming() const { - return m_processedPacketsTiming; - } - - QString outboundEditPackets() const { - return m_outboundEditPackets; - } - - QString entityUpdateTime() const { - return m_entityUpdateTime; - } - - QString entityUpdates() const { - return m_entityUpdates; - } - - QStringList servers() const { - return m_servers; - } - -signals: - - void serversNumChanged(int serversNum); - void serverElementsChanged(const QString &serverElements); - void localElementsChanged(const QString &localElements); - void sendingModeChanged(const QString &sendingMode); - void processedPacketsChanged(const QString &processedPackets); - void localElementsMemoryChanged(const QString &localElementsMemory); - void processedPacketsElementsChanged(const QString &processedPacketsElements); - void processedPacketsEntitiesChanged(const QString &processedPacketsEntities); - void processedPacketsTimingChanged(const QString &processedPacketsTiming); - void outboundEditPacketsChanged(const QString &outboundEditPackets); - void entityUpdateTimeChanged(const QString &entityUpdateTime); - void entityUpdatesChanged(const QString &entityUpdates); - - void serversChanged(const QStringList &servers); - -public slots: - void startUpdates(); - void stopUpdates(); - QColor getColor() const; - -private slots: - void updateOctreeStatsData(); -protected: - void updateOctreeServers(); - void showOctreeServersOfType(int& serverNumber, NodeType_t serverType, - const char* serverTypeName, NodeToJurisdictionMap& serverJurisdictions); - -private: - NodeToOctreeSceneStats* _model; - int _statCount; - - const int SAMPLES_PER_SECOND = 10; - SimpleMovingAverage _averageUpdatesPerSecond; - quint64 _lastWindowAt = usecTimestampNow(); - quint64 _lastKnownTrackedEdits = 0; - - quint64 _lastRefresh = 0; - - QTimer _updateTimer; - int m_serversNum {0}; - QString m_serverElements; - QString m_localElements; - QString m_localElementsMemory; - QString m_sendingMode; - QString m_processedPackets; - QString m_processedPacketsElements; - QString m_processedPacketsEntities; - QString m_processedPacketsTiming; - QString m_outboundEditPackets; - QString m_entityUpdateTime; - QString m_entityUpdates; - QStringList m_servers; -}; - -#endif // hifi_OctreeStatsProvider_h diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 5983d7cc25..c2caf91045 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -102,13 +102,11 @@ void setupPreferences() { auto setter = [](bool value) { qApp->setHmdTabletBecomesToolbarSetting(value); }; preferences->addPreference(new CheckPreference(UI_CATEGORY, "HMD Tablet Becomes Toolbar", getter, setter)); } - // TODO - // Note: If this code is added back, you must remove the line "setTabletVisibleToOthersSetting(false)" from Application::loadSettings() - /*{ + { auto getter = []()->bool { return qApp->getTabletVisibleToOthersSetting(); }; auto setter = [](bool value) { qApp->setTabletVisibleToOthersSetting(value); }; preferences->addPreference(new CheckPreference(UI_CATEGORY, "Tablet Is Visible To Others", getter, setter)); - }*/ + } { auto getter = []()->bool { return qApp->getPreferAvatarFingerOverStylus(); }; auto setter = [](bool value) { qApp->setPreferAvatarFingerOverStylus(value); }; diff --git a/interface/src/ui/overlays/Overlay.cpp b/interface/src/ui/overlays/Overlay.cpp index 764422019e..0ad2c94241 100644 --- a/interface/src/ui/overlays/Overlay.cpp +++ b/interface/src/ui/overlays/Overlay.cpp @@ -100,9 +100,6 @@ void Overlay::setProperties(const QVariantMap& properties) { } QVariant Overlay::getProperty(const QString& property) { - if (property == "type") { - return QVariant(getType()); - } if (property == "color") { return xColorToVariant(_color); } diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 712342087d..6514052d26 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -713,9 +713,10 @@ PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay r auto dimensions = thisOverlay->getSize(); glm::vec2 pos2D = projectOntoOverlayXYPlane(position, rotation, dimensions, ray, rayPickResult); - - PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, - ray.direction, toPointerButton(*event), toPointerButtons(*event), event->modifiers()); + PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID, + pos2D, rayPickResult.intersection, + rayPickResult.surfaceNormal, ray.direction, + toPointerButton(*event), toPointerButtons(*event)); return pointerEvent; } diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index 9cc95b84b8..97e5344062 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include @@ -38,17 +37,9 @@ #include #include "scripting/AccountScriptingInterface.h" #include "scripting/HMDScriptingInterface.h" -#include "scripting/AssetMappingsScriptingInterface.h" #include -#include #include "FileDialogHelper.h" -#include "avatar/AvatarManager.h" -#include "AudioClient.h" -#include "LODManager.h" -#include "ui/OctreeStatsProvider.h" -#include "ui/DomainConnectionModel.h" -#include "scripting/AudioDeviceScriptingInterface.h" -#include "ui/AvatarInputs.h" +#include #include "avatar/AvatarManager.h" #include "scripting/GlobalServicesScriptingInterface.h" @@ -173,10 +164,6 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("UserActivityLogger", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Preferences", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Vec3", new Vec3()); - _webSurface->getRootContext()->setContextProperty("Quat", new Quat()); - _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); - _webSurface->getRootContext()->setContextProperty("Entities", DependencyManager::get().data()); if (_webSurface->getRootItem() && _webSurface->getRootItem()->objectName() == "tabletRoot") { auto tabletScriptingInterface = DependencyManager::get(); @@ -184,41 +171,22 @@ void Web3DOverlay::loadSourceURL() { _webSurface->getRootContext()->setContextProperty("offscreenFlags", flags); _webSurface->getRootContext()->setContextProperty("AddressManager", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("Account", AccountScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AudioStats", DependencyManager::get()->getStats().data()); _webSurface->getRootContext()->setContextProperty("HMD", DependencyManager::get().data()); _webSurface->getRootContext()->setContextProperty("fileDialogHelper", new FileDialogHelper()); _webSurface->getRootContext()->setContextProperty("MyAvatar", DependencyManager::get()->getMyAvatar().get()); - _webSurface->getRootContext()->setContextProperty("ScriptDiscoveryService", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Tablet", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("Assets", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("LODManager", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("OctreeStats", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("DCModel", DependencyManager::get().data()); - _webSurface->getRootContext()->setContextProperty("AudioDevice", AudioDeviceScriptingInterface::getInstance()); - _webSurface->getRootContext()->setContextProperty("AvatarInputs", AvatarInputs::getInstance()); _webSurface->getRootContext()->setContextProperty("GlobalServices", GlobalServicesScriptingInterface::getInstance()); _webSurface->getRootContext()->setContextProperty("AvatarList", DependencyManager::get().data()); - - _webSurface->getRootContext()->setContextProperty("pathToFonts", "../../"); + _webSurface->getRootContext()->setContextProperty("Vec3", new Vec3()); + _webSurface->getRootContext()->setContextProperty("Quat", new Quat()); tabletScriptingInterface->setQmlTabletRoot("com.highfidelity.interface.tablet.system", _webSurface->getRootItem(), _webSurface.data()); - // mark the TabletProxy object as cpp ownership. - QObject* tablet = tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"); - _webSurface->getRootContext()->engine()->setObjectOwnership(tablet, QQmlEngine::CppOwnership); - // Override min fps for tablet UI, for silky smooth scrolling - setMaxFPS(90); + _webSurface->setMaxFps(90); } } _webSurface->getRootContext()->setContextProperty("globalPosition", vec3toVariant(getPosition())); -} - -void Web3DOverlay::setMaxFPS(uint8_t maxFPS) { - _desiredMaxFPS = maxFPS; - if (_webSurface) { - _webSurface->setMaxFps(_desiredMaxFPS); - _currentMaxFPS = _desiredMaxFPS; - } + auto offscreenUi = DependencyManager::get(); + _webSurface->getRootContext()->setContextProperty("desktop", offscreenUi->getDesktop()); } void Web3DOverlay::render(RenderArgs* args) { @@ -230,11 +198,9 @@ void Web3DOverlay::render(RenderArgs* args) { QSurface * currentSurface = currentContext->surface(); if (!_webSurface) { _webSurface = DependencyManager::get()->acquire(pickURL()); + _webSurface->setMaxFps(10); // FIXME, the max FPS could be better managed by being dynamic (based on the number of current surfaces // and the current rendering load) - if (_currentMaxFPS != _desiredMaxFPS) { - setMaxFPS(_desiredMaxFPS); - } loadSourceURL(); _webSurface->resume(); _webSurface->resize(QSize(_resolution.x, _resolution.y)); @@ -246,7 +212,10 @@ void Web3DOverlay::render(RenderArgs* args) { std::weak_ptr weakSelf = std::dynamic_pointer_cast(qApp->getOverlays().getOverlay(selfOverlayID)); auto forwardPointerEvent = [=](OverlayID overlayID, const PointerEvent& event) { auto self = weakSelf.lock(); - if (self && overlayID == selfOverlayID) { + if (!self) { + return; + } + if (overlayID == selfOverlayID) { self->handlePointerEvent(event); } }; @@ -260,18 +229,27 @@ void Web3DOverlay::render(RenderArgs* args) { return; } if (self->_pressed && overlayID == selfOverlayID) { - PointerEvent endEvent(PointerEvent::Release, event.getID(), event.getPos2D(), event.getPos3D(), event.getNormal(), event.getDirection(), - event.getButton(), event.getButtons(), event.getKeyboardModifiers()); - forwardPointerEvent(overlayID, event); + // If the user mouses off the overlay while the button is down, simulate a touch end. + QTouchEvent::TouchPoint point; + point.setId(event.getID()); + point.setState(Qt::TouchPointReleased); + glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi); + QPointF windowPoint(windowPos.x, windowPos.y); + point.setScenePos(windowPoint); + point.setPos(windowPoint); + QList touchPoints; + touchPoints.push_back(point); + QTouchEvent* touchEvent = new QTouchEvent(QEvent::TouchEnd, nullptr, Qt::NoModifier, Qt::TouchPointReleased, + touchPoints); + touchEvent->setWindow(self->_webSurface->getWindow()); + touchEvent->setDevice(&_touchDevice); + touchEvent->setTarget(self->_webSurface->getRootItem()); + QCoreApplication::postEvent(self->_webSurface->getWindow(), touchEvent); } }, Qt::DirectConnection); _emitScriptEventConnection = connect(this, &Web3DOverlay::scriptEventReceived, _webSurface.data(), &OffscreenQmlSurface::emitScriptEvent); _webEventReceivedConnection = connect(_webSurface.data(), &OffscreenQmlSurface::webEventReceived, this, &Web3DOverlay::webEventReceived); - } else { - if (_currentMaxFPS != _desiredMaxFPS) { - setMaxFPS(_desiredMaxFPS); - } } vec2 halfSize = getSize() / 2.0f; @@ -339,14 +317,6 @@ void Web3DOverlay::setProxyWindow(QWindow* proxyWindow) { } void Web3DOverlay::handlePointerEvent(const PointerEvent& event) { - if (_inputMode == Touch) { - handlePointerEventAsTouch(event); - } else { - handlePointerEventAsMouse(event); - } -} - -void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { if (!_webSurface) { return; } @@ -354,16 +324,16 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi); QPointF windowPoint(windowPos.x, windowPos.y); - if (event.getButtons() == PointerEvent::NoButtons && event.getType() == PointerEvent::Move) { + if (event.getType() == PointerEvent::Move) { // Forward a mouse move event to the Web surface. - QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseMove, windowPoint, windowPoint, windowPoint, Qt::NoButton, Qt::NoButton, Qt::NoModifier); + QMouseEvent* mouseEvent = new QMouseEvent(QEvent::MouseMove, windowPoint, windowPoint, windowPoint, Qt::NoButton, + Qt::NoButton, Qt::NoModifier); QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); - return; } - if (event.getType() == PointerEvent::Press && event.getButton() == PointerEvent::PrimaryButton) { + if (event.getType() == PointerEvent::Press) { this->_pressed = true; - } else if (event.getType() == PointerEvent::Release && event.getButton() == PointerEvent::PrimaryButton) { + } else if (event.getType() == PointerEvent::Release) { this->_pressed = false; } @@ -393,8 +363,9 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { QList touchPoints; touchPoints.push_back(point); - QTouchEvent* touchEvent = new QTouchEvent(type, &_touchDevice, event.getKeyboardModifiers()); + QTouchEvent* touchEvent = new QTouchEvent(type); touchEvent->setWindow(_webSurface->getWindow()); + touchEvent->setDevice(&_touchDevice); touchEvent->setTarget(_webSurface->getRootItem()); touchEvent->setTouchPoints(touchPoints); touchEvent->setTouchPointStates(touchPointState); @@ -402,47 +373,6 @@ void Web3DOverlay::handlePointerEventAsTouch(const PointerEvent& event) { QCoreApplication::postEvent(_webSurface->getWindow(), touchEvent); } -void Web3DOverlay::handlePointerEventAsMouse(const PointerEvent& event) { - if (!_webSurface) { - return; - } - - glm::vec2 windowPos = event.getPos2D() * (METERS_TO_INCHES * _dpi); - QPointF windowPoint(windowPos.x, windowPos.y); - - if (event.getType() == PointerEvent::Press) { - this->_pressed = true; - } else if (event.getType() == PointerEvent::Release) { - this->_pressed = false; - } - - Qt::MouseButtons buttons = Qt::NoButton; - if (event.getButtons() & PointerEvent::PrimaryButton) { - buttons |= Qt::LeftButton; - } - - QEvent::Type type; - Qt::MouseButton button = Qt::NoButton; - if (event.getButton() == PointerEvent::PrimaryButton) { - button = Qt::LeftButton; - } - switch (event.getType()) { - case PointerEvent::Press: - type = QEvent::MouseButtonPress; - break; - case PointerEvent::Release: - type = QEvent::MouseButtonRelease; - break; - case PointerEvent::Move: - default: - type = QEvent::MouseMove; - break; - } - - QMouseEvent* mouseEvent = new QMouseEvent(type, windowPoint, windowPoint, windowPoint, button, buttons, Qt::NoModifier); - QCoreApplication::postEvent(_webSurface->getWindow(), mouseEvent); -} - void Web3DOverlay::setProperties(const QVariantMap& properties) { Billboard3DOverlay::setProperties(properties); @@ -476,25 +406,10 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) { _dpi = dpi.toFloat(); } - auto maxFPS = properties["maxFPS"]; - if (maxFPS.isValid()) { - _desiredMaxFPS = maxFPS.toInt(); - } - auto showKeyboardFocusHighlight = properties["showKeyboardFocusHighlight"]; if (showKeyboardFocusHighlight.isValid()) { _showKeyboardFocusHighlight = showKeyboardFocusHighlight.toBool(); } - - auto inputModeValue = properties["inputMode"]; - if (inputModeValue.isValid()) { - QString inputModeStr = inputModeValue.toString(); - if (inputModeStr == "Mouse") { - _inputMode = Mouse; - } else { - _inputMode = Touch; - } - } } QVariant Web3DOverlay::getProperty(const QString& property) { @@ -510,20 +425,9 @@ QVariant Web3DOverlay::getProperty(const QString& property) { if (property == "dpi") { return _dpi; } - if (property == "maxFPS") { - return _desiredMaxFPS; - } if (property == "showKeyboardFocusHighlight") { return _showKeyboardFocusHighlight; } - - if (property == "inputMode") { - if (_inputMode == Mouse) { - return QVariant("Mouse"); - } else { - return QVariant("Touch"); - } - } return Billboard3DOverlay::getProperty(property); } diff --git a/interface/src/ui/overlays/Web3DOverlay.h b/interface/src/ui/overlays/Web3DOverlay.h index 6a35dec96d..2b9686919d 100644 --- a/interface/src/ui/overlays/Web3DOverlay.h +++ b/interface/src/ui/overlays/Web3DOverlay.h @@ -31,7 +31,6 @@ public: QString pickURL(); void loadSourceURL(); - void setMaxFPS(uint8_t maxFPS); virtual void render(RenderArgs* args) override; virtual const render::ShapeKey getShapeKey() override; @@ -40,8 +39,6 @@ public: QObject* getEventHandler(); void setProxyWindow(QWindow* proxyWindow); void handlePointerEvent(const PointerEvent& event); - void handlePointerEventAsTouch(const PointerEvent& event); - void handlePointerEventAsMouse(const PointerEvent& event); // setters void setURL(const QString& url); @@ -57,11 +54,6 @@ public: virtual Web3DOverlay* createClone() const override; - enum InputMode { - Touch, - Mouse - }; - public slots: void emitScriptEvent(const QVariant& scriptMessage); @@ -70,7 +62,6 @@ signals: void webEventReceived(const QVariant& message); private: - InputMode _inputMode { Touch }; QSharedPointer _webSurface; QMetaObject::Connection _connection; gpu::TexturePointer _texture; @@ -84,9 +75,6 @@ private: bool _pressed{ false }; QTouchDevice _touchDevice; - uint8_t _desiredMaxFPS { 10 }; - uint8_t _currentMaxFPS { 0 }; - QMetaObject::Connection _mousePressConnection; QMetaObject::Connection _mouseReleaseConnection; QMetaObject::Connection _mouseMoveConnection; diff --git a/libraries/animation/src/AnimBlendLinear.cpp b/libraries/animation/src/AnimBlendLinear.cpp index 936126bf52..52c440a14e 100644 --- a/libraries/animation/src/AnimBlendLinear.cpp +++ b/libraries/animation/src/AnimBlendLinear.cpp @@ -24,7 +24,7 @@ AnimBlendLinear::~AnimBlendLinear() { } -const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { +const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { _alpha = animVars.lookup(_alphaVar, _alpha); @@ -33,7 +33,7 @@ const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, con pose = AnimPose::identity; } } else if (_children.size() == 1) { - _poses = _children[0]->evaluate(animVars, context, dt, triggersOut); + _poses = _children[0]->evaluate(animVars, dt, triggersOut); } else { float clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1)); @@ -41,7 +41,7 @@ const AnimPoseVec& AnimBlendLinear::evaluate(const AnimVariantMap& animVars, con size_t nextPoseIndex = glm::ceil(clampedAlpha); float alpha = glm::fract(clampedAlpha); - evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, dt); + evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, dt); } return _poses; } @@ -51,15 +51,15 @@ const AnimPoseVec& AnimBlendLinear::getPosesInternal() const { return _poses; } -void AnimBlendLinear::evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha, +void AnimBlendLinear::evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha, size_t prevPoseIndex, size_t nextPoseIndex, float dt) { if (prevPoseIndex == nextPoseIndex) { // this can happen if alpha is on an integer boundary - _poses = _children[prevPoseIndex]->evaluate(animVars, context, dt, triggersOut); + _poses = _children[prevPoseIndex]->evaluate(animVars, dt, triggersOut); } else { // need to eval and blend between two children. - auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, context, dt, triggersOut); - auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, context, dt, triggersOut); + auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, dt, triggersOut); + auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, dt, triggersOut); if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) { _poses.resize(prevPoses.size()); diff --git a/libraries/animation/src/AnimBlendLinear.h b/libraries/animation/src/AnimBlendLinear.h index 0dae6aabdb..2478f9b473 100644 --- a/libraries/animation/src/AnimBlendLinear.h +++ b/libraries/animation/src/AnimBlendLinear.h @@ -30,7 +30,7 @@ public: AnimBlendLinear(const QString& id, float alpha); virtual ~AnimBlendLinear() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; } @@ -38,7 +38,7 @@ protected: // for AnimDebugDraw rendering virtual const AnimPoseVec& getPosesInternal() const override; - void evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha, + void evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha, size_t prevPoseIndex, size_t nextPoseIndex, float dt); AnimPoseVec _poses; diff --git a/libraries/animation/src/AnimBlendLinearMove.cpp b/libraries/animation/src/AnimBlendLinearMove.cpp index 40fbb5a6f7..609b464512 100644 --- a/libraries/animation/src/AnimBlendLinearMove.cpp +++ b/libraries/animation/src/AnimBlendLinearMove.cpp @@ -26,7 +26,7 @@ AnimBlendLinearMove::~AnimBlendLinearMove() { } -const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { +const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { assert(_children.size() == _characteristicSpeeds.size()); @@ -43,7 +43,7 @@ const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, const int nextPoseIndex = 0; float prevDeltaTime, nextDeltaTime; setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut); - evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime); + evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime); } else { auto clampedAlpha = glm::clamp(_alpha, 0.0f, (float)(_children.size() - 1)); @@ -52,7 +52,7 @@ const AnimPoseVec& AnimBlendLinearMove::evaluate(const AnimVariantMap& animVars, auto alpha = glm::fract(clampedAlpha); float prevDeltaTime, nextDeltaTime; setFrameAndPhase(dt, alpha, prevPoseIndex, nextPoseIndex, &prevDeltaTime, &nextDeltaTime, triggersOut); - evaluateAndBlendChildren(animVars, context, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime); + evaluateAndBlendChildren(animVars, triggersOut, alpha, prevPoseIndex, nextPoseIndex, prevDeltaTime, nextDeltaTime); } return _poses; } @@ -62,16 +62,16 @@ const AnimPoseVec& AnimBlendLinearMove::getPosesInternal() const { return _poses; } -void AnimBlendLinearMove::evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha, +void AnimBlendLinearMove::evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha, size_t prevPoseIndex, size_t nextPoseIndex, float prevDeltaTime, float nextDeltaTime) { if (prevPoseIndex == nextPoseIndex) { // this can happen if alpha is on an integer boundary - _poses = _children[prevPoseIndex]->evaluate(animVars, context, prevDeltaTime, triggersOut); + _poses = _children[prevPoseIndex]->evaluate(animVars, prevDeltaTime, triggersOut); } else { // need to eval and blend between two children. - auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, context, prevDeltaTime, triggersOut); - auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, context, nextDeltaTime, triggersOut); + auto prevPoses = _children[prevPoseIndex]->evaluate(animVars, prevDeltaTime, triggersOut); + auto nextPoses = _children[nextPoseIndex]->evaluate(animVars, nextDeltaTime, triggersOut); if (prevPoses.size() > 0 && prevPoses.size() == nextPoses.size()) { _poses.resize(prevPoses.size()); diff --git a/libraries/animation/src/AnimBlendLinearMove.h b/libraries/animation/src/AnimBlendLinearMove.h index 083858f873..4e04ce29cb 100644 --- a/libraries/animation/src/AnimBlendLinearMove.h +++ b/libraries/animation/src/AnimBlendLinearMove.h @@ -39,7 +39,7 @@ public: AnimBlendLinearMove(const QString& id, float alpha, float desiredSpeed, const std::vector& characteristicSpeeds); virtual ~AnimBlendLinearMove() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; } void setDesiredSpeedVar(const QString& desiredSpeedVar) { _desiredSpeedVar = desiredSpeedVar; } @@ -48,7 +48,7 @@ protected: // for AnimDebugDraw rendering virtual const AnimPoseVec& getPosesInternal() const override; - void evaluateAndBlendChildren(const AnimVariantMap& animVars, const AnimContext& context, Triggers& triggersOut, float alpha, + void evaluateAndBlendChildren(const AnimVariantMap& animVars, Triggers& triggersOut, float alpha, size_t prevPoseIndex, size_t nextPoseIndex, float prevDeltaTime, float nextDeltaTime); diff --git a/libraries/animation/src/AnimClip.cpp b/libraries/animation/src/AnimClip.cpp index 1118e21c91..cb1d058576 100644 --- a/libraries/animation/src/AnimClip.cpp +++ b/libraries/animation/src/AnimClip.cpp @@ -31,7 +31,7 @@ AnimClip::~AnimClip() { } -const AnimPoseVec& AnimClip::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { +const AnimPoseVec& AnimClip::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { // lookup parameters from animVars, using current instance variables as defaults. _startFrame = animVars.lookup(_startFrameVar, _startFrame); diff --git a/libraries/animation/src/AnimClip.h b/libraries/animation/src/AnimClip.h index c7e7ebf3ee..7989f6d172 100644 --- a/libraries/animation/src/AnimClip.h +++ b/libraries/animation/src/AnimClip.h @@ -30,7 +30,7 @@ public: AnimClip(const QString& id, const QString& url, float startFrame, float endFrame, float timeScale, bool loopFlag, bool mirrorFlag); virtual ~AnimClip() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; void setStartFrameVar(const QString& startFrameVar) { _startFrameVar = startFrameVar; } void setEndFrameVar(const QString& endFrameVar) { _endFrameVar = endFrameVar; } diff --git a/libraries/animation/src/AnimContext.cpp b/libraries/animation/src/AnimContext.cpp deleted file mode 100644 index c8d3e7bcda..0000000000 --- a/libraries/animation/src/AnimContext.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// -// AnimContext.cpp -// -// Created by Anthony J. Thibault on 9/19/16. -// Copyright (c) 2016 High Fidelity, Inc. All rights reserved. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "AnimContext.h" - -AnimContext::AnimContext(bool enableDebugDrawIKTargets, const glm::mat4& geometryToRigMatrix) : - _enableDebugDrawIKTargets(enableDebugDrawIKTargets), - _geometryToRigMatrix(geometryToRigMatrix) { -} diff --git a/libraries/animation/src/AnimContext.h b/libraries/animation/src/AnimContext.h deleted file mode 100644 index 3170911e14..0000000000 --- a/libraries/animation/src/AnimContext.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// AnimContext.h -// -// Created by Anthony J. Thibault on 9/19/16. -// Copyright (c) 2016 High Fidelity, Inc. All rights reserved. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_AnimContext_h -#define hifi_AnimContext_h - -#include -#include - -class AnimContext { -public: - AnimContext(bool enableDebugDrawIKTargets, const glm::mat4& geometryToRigMatrix); - - bool getEnableDebugDrawIKTargets() const { return _enableDebugDrawIKTargets; } - const glm::mat4& getGeometryToRigMatrix() const { return _geometryToRigMatrix; } - -protected: - - bool _enableDebugDrawIKTargets { false }; - glm::mat4 _geometryToRigMatrix; -}; - -#endif // hifi_AnimContext_h diff --git a/libraries/animation/src/AnimInverseKinematics.cpp b/libraries/animation/src/AnimInverseKinematics.cpp index 2c9376d591..fa8e4654f6 100644 --- a/libraries/animation/src/AnimInverseKinematics.cpp +++ b/libraries/animation/src/AnimInverseKinematics.cpp @@ -14,8 +14,6 @@ #include #include #include -#include -#include "Rig.h" #include "ElbowConstraint.h" #include "SwingTwistConstraint.h" @@ -380,14 +378,14 @@ int AnimInverseKinematics::solveTargetWithCCD(const IKTarget& target, AnimPoseVe } //virtual -const AnimPoseVec& AnimInverseKinematics::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimNode::Triggers& triggersOut) { +const AnimPoseVec& AnimInverseKinematics::evaluate(const AnimVariantMap& animVars, float dt, AnimNode::Triggers& triggersOut) { // don't call this function, call overlay() instead assert(false); return _relativePoses; } //virtual -const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) { +const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) { const float MAX_OVERLAY_DT = 1.0f / 30.0f; // what to clamp delta-time to in AnimInverseKinematics::overlay if (dt > MAX_OVERLAY_DT) { @@ -441,28 +439,6 @@ const AnimPoseVec& AnimInverseKinematics::overlay(const AnimVariantMap& animVars computeTargets(animVars, targets, underPoses); } - // debug render ik targets - if (context.getEnableDebugDrawIKTargets()) { - const vec4 WHITE(1.0f); - glm::mat4 rigToAvatarMat = createMatFromQuatAndPos(Quaternions::Y_180, glm::vec3()); - - for (auto& target : targets) { - glm::mat4 geomTargetMat = createMatFromQuatAndPos(target.getRotation(), target.getTranslation()); - glm::mat4 avatarTargetMat = rigToAvatarMat * context.getGeometryToRigMatrix() * geomTargetMat; - - QString name = QString("ikTarget%1").arg(target.getIndex()); - DebugDraw::getInstance().addMyAvatarMarker(name, glmExtractRotation(avatarTargetMat), extractTranslation(avatarTargetMat), WHITE); - } - } else if (context.getEnableDebugDrawIKTargets() != _previousEnableDebugIKTargets) { - // remove markers if they were added last frame. - for (auto& target : targets) { - QString name = QString("ikTarget%1").arg(target.getIndex()); - DebugDraw::getInstance().removeMyAvatarMarker(name); - } - } - - _previousEnableDebugIKTargets = context.getEnableDebugDrawIKTargets(); - if (targets.empty()) { // no IK targets but still need to enforce constraints std::map::iterator constraintItr = _constraints.begin(); diff --git a/libraries/animation/src/AnimInverseKinematics.h b/libraries/animation/src/AnimInverseKinematics.h index 366e5f765e..892a5616b2 100644 --- a/libraries/animation/src/AnimInverseKinematics.h +++ b/libraries/animation/src/AnimInverseKinematics.h @@ -34,8 +34,8 @@ public: void setTargetVars(const QString& jointName, const QString& positionVar, const QString& rotationVar, const QString& typeVar); - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, AnimNode::Triggers& triggersOut) override; - virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, AnimNode::Triggers& triggersOut) override; + virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override; void clearIKJointLimitHistory(); @@ -97,7 +97,6 @@ protected: int _maxTargetIndex { 0 }; float _maxErrorOnLastSolve { FLT_MAX }; - bool _previousEnableDebugIKTargets { false }; }; #endif // hifi_AnimInverseKinematics_h diff --git a/libraries/animation/src/AnimManipulator.cpp b/libraries/animation/src/AnimManipulator.cpp index 111501898a..f2bd2d983a 100644 --- a/libraries/animation/src/AnimManipulator.cpp +++ b/libraries/animation/src/AnimManipulator.cpp @@ -22,11 +22,11 @@ AnimManipulator::~AnimManipulator() { } -const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { - return overlay(animVars, context, dt, triggersOut, _skeleton->getRelativeBindPoses()); +const AnimPoseVec& AnimManipulator::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { + return overlay(animVars, dt, triggersOut, _skeleton->getRelativeBindPoses()); } -const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) { +const AnimPoseVec& AnimManipulator::overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) { _alpha = animVars.lookup(_alphaVar, _alpha); _poses = underPoses; diff --git a/libraries/animation/src/AnimManipulator.h b/libraries/animation/src/AnimManipulator.h index 26f50a7dd9..8534b9c269 100644 --- a/libraries/animation/src/AnimManipulator.h +++ b/libraries/animation/src/AnimManipulator.h @@ -22,8 +22,8 @@ public: AnimManipulator(const QString& id, float alpha); virtual ~AnimManipulator() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; - virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) override; void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; } diff --git a/libraries/animation/src/AnimNode.h b/libraries/animation/src/AnimNode.h index 10db38f42e..23f2e1c7b3 100644 --- a/libraries/animation/src/AnimNode.h +++ b/libraries/animation/src/AnimNode.h @@ -20,7 +20,6 @@ #include "AnimSkeleton.h" #include "AnimVariant.h" -#include "AnimContext.h" class QJsonObject; @@ -73,10 +72,9 @@ public: AnimSkeleton::ConstPointer getSkeleton() const { return _skeleton; } - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) = 0; - virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut, - const AnimPoseVec& underPoses) { - return evaluate(animVars, context, dt, triggersOut); + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) = 0; + virtual const AnimPoseVec& overlay(const AnimVariantMap& animVars, float dt, Triggers& triggersOut, const AnimPoseVec& underPoses) { + return evaluate(animVars, dt, triggersOut); } void setCurrentFrame(float frame); diff --git a/libraries/animation/src/AnimOverlay.cpp b/libraries/animation/src/AnimOverlay.cpp index dbc635af66..8f60b972ce 100644 --- a/libraries/animation/src/AnimOverlay.cpp +++ b/libraries/animation/src/AnimOverlay.cpp @@ -39,7 +39,7 @@ void AnimOverlay::buildBoneSet(BoneSet boneSet) { } } -const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { +const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { // lookup parameters from animVars, using current instance variables as defaults. // NOTE: switching bonesets can be an expensive operation, let's try to avoid it. @@ -51,8 +51,8 @@ const AnimPoseVec& AnimOverlay::evaluate(const AnimVariantMap& animVars, const A _alpha = animVars.lookup(_alphaVar, _alpha); if (_children.size() >= 2) { - auto& underPoses = _children[1]->evaluate(animVars, context, dt, triggersOut); - auto& overPoses = _children[0]->overlay(animVars, context, dt, triggersOut, underPoses); + auto& underPoses = _children[1]->evaluate(animVars, dt, triggersOut); + auto& overPoses = _children[0]->overlay(animVars, dt, triggersOut, underPoses); if (underPoses.size() > 0 && underPoses.size() == overPoses.size()) { _poses.resize(underPoses.size()); diff --git a/libraries/animation/src/AnimOverlay.h b/libraries/animation/src/AnimOverlay.h index 2f34c07309..eda8847d40 100644 --- a/libraries/animation/src/AnimOverlay.h +++ b/libraries/animation/src/AnimOverlay.h @@ -43,7 +43,7 @@ public: AnimOverlay(const QString& id, BoneSet boneSet, float alpha); virtual ~AnimOverlay() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; void setBoneSetVar(const QString& boneSetVar) { _boneSetVar = boneSetVar; } void setAlphaVar(const QString& alphaVar) { _alphaVar = alphaVar; } diff --git a/libraries/animation/src/AnimStateMachine.cpp b/libraries/animation/src/AnimStateMachine.cpp index 4e86b92c0b..41d8a94b0a 100644 --- a/libraries/animation/src/AnimStateMachine.cpp +++ b/libraries/animation/src/AnimStateMachine.cpp @@ -21,7 +21,7 @@ AnimStateMachine::~AnimStateMachine() { } -const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) { +const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) { QString desiredStateID = animVars.lookup(_currentStateVar, _currentState->getID()); if (_currentState->getID() != desiredStateID) { @@ -29,7 +29,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, co bool foundState = false; for (auto& state : _states) { if (state->getID() == desiredStateID) { - switchState(animVars, context, state); + switchState(animVars, state); foundState = true; break; } @@ -42,7 +42,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, co // evaluate currentState transitions auto desiredState = evaluateTransitions(animVars); if (desiredState != _currentState) { - switchState(animVars, context, desiredState); + switchState(animVars, desiredState); } assert(_currentState); @@ -62,7 +62,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, co } else if (_interpType == InterpType::SnapshotPrev) { // interp between the prev snapshot and evaluated next target. // this is useful for interping into a blend - localNextPoses = currentStateNode->evaluate(animVars, context, dt, triggersOut); + localNextPoses = currentStateNode->evaluate(animVars, dt, triggersOut); prevPoses = &_prevPoses; nextPoses = &localNextPoses; } else { @@ -79,7 +79,7 @@ const AnimPoseVec& AnimStateMachine::evaluate(const AnimVariantMap& animVars, co } } if (!_duringInterp) { - _poses = currentStateNode->evaluate(animVars, context, dt, triggersOut); + _poses = currentStateNode->evaluate(animVars, dt, triggersOut); } return _poses; } @@ -92,7 +92,7 @@ void AnimStateMachine::addState(State::Pointer state) { _states.push_back(state); } -void AnimStateMachine::switchState(const AnimVariantMap& animVars, const AnimContext& context, State::Pointer desiredState) { +void AnimStateMachine::switchState(const AnimVariantMap& animVars, State::Pointer desiredState) { const float FRAMES_PER_SECOND = 30.0f; @@ -114,7 +114,7 @@ void AnimStateMachine::switchState(const AnimVariantMap& animVars, const AnimCon _prevPoses = _poses; // snapshot next pose at the target frame. nextStateNode->setCurrentFrame(desiredState->_interpTarget); - _nextPoses = nextStateNode->evaluate(animVars, context, dt, triggers); + _nextPoses = nextStateNode->evaluate(animVars, dt, triggers); } else if (_interpType == InterpType::SnapshotPrev) { // snapshot previoius pose _prevPoses = _poses; diff --git a/libraries/animation/src/AnimStateMachine.h b/libraries/animation/src/AnimStateMachine.h index 711326a9ae..d92b94d1b5 100644 --- a/libraries/animation/src/AnimStateMachine.h +++ b/libraries/animation/src/AnimStateMachine.h @@ -113,7 +113,7 @@ public: explicit AnimStateMachine(const QString& id); virtual ~AnimStateMachine() override; - virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, const AnimContext& context, float dt, Triggers& triggersOut) override; + virtual const AnimPoseVec& evaluate(const AnimVariantMap& animVars, float dt, Triggers& triggersOut) override; void setCurrentStateVar(QString& currentStateVar) { _currentStateVar = currentStateVar; } @@ -123,7 +123,7 @@ protected: void addState(State::Pointer state); - void switchState(const AnimVariantMap& animVars, const AnimContext& context, State::Pointer desiredState); + void switchState(const AnimVariantMap& animVars, State::Pointer desiredState); State::Pointer evaluateTransitions(const AnimVariantMap& animVars) const; // for AnimDebugDraw rendering diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 8b54f0ee92..0520e5c5a1 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -950,11 +950,9 @@ void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform) { updateAnimationStateHandlers(); _animVars.setRigToGeometryTransform(_rigToGeometryTransform); - AnimContext context(_enableDebugDrawIKTargets, getGeometryToRigTransform()); - // evaluate the animation AnimNode::Triggers triggersOut; - _internalPoseSet._relativePoses = _animNode->evaluate(_animVars, context, deltaTime, triggersOut); + _internalPoseSet._relativePoses = _animNode->evaluate(_animVars, deltaTime, triggersOut); if ((int)_internalPoseSet._relativePoses.size() != _animSkeleton->getNumJoints()) { // animations haven't fully loaded yet. _internalPoseSet._relativePoses = _animSkeleton->getRelativeDefaultPoses(); @@ -1429,10 +1427,9 @@ void Rig::computeAvatarBoundingCapsule( // call overlay twice: once to verify AnimPoseVec joints and again to do the IK AnimNode::Triggers triggersOut; - AnimContext context(false, glm::mat4()); float dt = 1.0f; // the value of this does not matter - ikNode.overlay(animVars, context, dt, triggersOut, _animSkeleton->getRelativeBindPoses()); - AnimPoseVec finalPoses = ikNode.overlay(animVars, context, dt, triggersOut, _animSkeleton->getRelativeBindPoses()); + ikNode.overlay(animVars, dt, triggersOut, _animSkeleton->getRelativeBindPoses()); + AnimPoseVec finalPoses = ikNode.overlay(animVars, dt, triggersOut, _animSkeleton->getRelativeBindPoses()); // convert relative poses to absolute _animSkeleton->convertRelativePosesToAbsolute(finalPoses); diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index ea498e6a69..41cc5cabc6 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -219,8 +219,6 @@ public: const glm::mat4& getGeometryToRigTransform() const { return _geometryToRigTransform; } - void setEnableDebugDrawIKTargets(bool enableDebugDrawIKTargets) { _enableDebugDrawIKTargets = enableDebugDrawIKTargets; } - signals: void onLoadComplete(); @@ -326,8 +324,7 @@ protected: mutable uint32_t _jointNameWarningCount { 0 }; float _maxHipsOffsetLength { 1.0f }; - - bool _enableDebugDrawIKTargets { false }; + float _maxErrorOnLastSolve { 0.0f }; private: QMap _stateHandlers; diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 4843afd5b1..fb6054a514 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -608,6 +608,7 @@ RayToEntityIntersectionResult EntityTreeRenderer::findRayIntersectionWorker(cons (void**)&intersectedEntity, lockType, &result.accurate); if (result.intersects && intersectedEntity) { result.entityID = intersectedEntity->getEntityItemID(); + result.properties = intersectedEntity->getProperties(); result.intersection = ray.origin + (ray.direction * result.distance); result.entity = intersectedEntity; } @@ -703,9 +704,7 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) { if (rayPickResult.intersects) { //qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID; - auto entity = getTree()->findEntityByEntityItemID(rayPickResult.entityID); - auto properties = entity->getProperties(); - QString urlString = properties.getHref(); + QString urlString = rayPickResult.properties.getHref(); QUrl url = QUrl(urlString, QUrl::StrictMode); if (url.isValid() && !url.isEmpty()){ DependencyManager::get()->handleLookupString(urlString); @@ -715,8 +714,7 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit mousePressOnEntity(rayPickResult.entityID, pointerEvent); @@ -752,11 +750,17 @@ void EntityTreeRenderer::mouseDoublePressEvent(QMouseEvent* event) { if (rayPickResult.intersects) { //qCDebug(entitiesrenderer) << "mouseDoublePressEvent over entity:" << rayPickResult.entityID; + QString urlString = rayPickResult.properties.getHref(); + QUrl url = QUrl(urlString, QUrl::StrictMode); + if (url.isValid() && !url.isEmpty()){ + DependencyManager::get()->handleLookupString(urlString); + } + glm::vec2 pos2D = projectOntoEntityXYPlane(rayPickResult.entity, ray, rayPickResult); PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), Qt::NoModifier); + toPointerButton(*event), toPointerButtons(*event)); emit mouseDoublePressOnEntity(rayPickResult.entityID, pointerEvent); @@ -796,8 +800,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit mouseReleaseOnEntity(rayPickResult.entityID, pointerEvent); if (_entitiesScriptEngine) { @@ -817,8 +820,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit clickReleaseOnEntity(_currentClickingOnEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -848,8 +850,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit mouseMoveOnEntity(rayPickResult.entityID, pointerEvent); @@ -869,8 +870,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -911,8 +911,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -931,8 +930,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event), - Qt::NoModifier); // TODO -- check for modifier keys? + toPointerButton(*event), toPointerButtons(*event)); emit holdingClickOnEntity(_currentClickingOnEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -1045,7 +1043,7 @@ void EntityTreeRenderer::playEntityCollisionSound(EntityItemPointer entity, cons // Shift the pitch down by ln(1 + (size / COLLISION_SIZE_FOR_STANDARD_PITCH)) / ln(2) const float COLLISION_SIZE_FOR_STANDARD_PITCH = 0.2f; - const float stretchFactor = logf(1.0f + (minAACube.getLargestDimension() / COLLISION_SIZE_FOR_STANDARD_PITCH)) / logf(2.0f); + const float stretchFactor = log(1.0f + (minAACube.getLargestDimension() / COLLISION_SIZE_FOR_STANDARD_PITCH)) / log(2); AudioInjector::playSound(collisionSound, volume, stretchFactor, collision.contactPoint); } diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 487a3e1e56..e94e5df9cb 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -812,7 +812,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) { auto& meshes = _model->getGeometry()->getMeshes(); int32_t numMeshes = (int32_t)(meshes.size()); - const int MAX_ALLOWED_MESH_COUNT = 1000; + const int MAX_ALLOWED_MESH_COUNT = 500; if (numMeshes > MAX_ALLOWED_MESH_COUNT) { // too many will cause the deadlock timer to throw... shapeInfo.setParams(SHAPE_TYPE_BOX, 0.5f * dimensions); diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp index 419f32f897..1d58527427 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.cpp @@ -404,9 +404,6 @@ bool RenderablePolyVoxEntityItem::setSphere(glm::vec3 centerWorldCoords, float r float smallestDimensionSize = voxelSize.x; smallestDimensionSize = glm::min(smallestDimensionSize, voxelSize.y); smallestDimensionSize = glm::min(smallestDimensionSize, voxelSize.z); - if (smallestDimensionSize <= 0.0f) { - return false; - } glm::vec3 maxRadiusInVoxelCoords = glm::vec3(radiusWorldCoords / smallestDimensionSize); glm::vec3 centerInVoxelCoords = wtvMatrix * glm::vec4(centerWorldCoords, 1.0f); @@ -417,33 +414,21 @@ bool RenderablePolyVoxEntityItem::setSphere(glm::vec3 centerWorldCoords, float r glm::ivec3 lowI = glm::clamp(low, glm::vec3(0.0f), _voxelVolumeSize); glm::ivec3 highI = glm::clamp(high, glm::vec3(0.0f), _voxelVolumeSize); - glm::vec3 radials(radiusWorldCoords / voxelSize.x, - radiusWorldCoords / voxelSize.y, - radiusWorldCoords / voxelSize.z); - // This three-level for loop iterates over every voxel in the volume that might be in the sphere withWriteLock([&] { for (int z = lowI.z; z < highI.z; z++) { for (int y = lowI.y; y < highI.y; y++) { for (int x = lowI.x; x < highI.x; x++) { - - // set voxels whose bounding-box touches the sphere - AABox voxelBox(glm::vec3(x - 0.5f, y - 0.5f, z - 0.5f), glm::vec3(1.0f, 1.0f, 1.0f)); - if (voxelBox.touchesAAEllipsoid(centerInVoxelCoords, radials)) { + // Store our current position as a vector... + glm::vec4 pos(x + 0.5f, y + 0.5f, z + 0.5f, 1.0); // consider voxels cenetered on their coordinates + // convert to world coordinates + glm::vec3 worldPos = glm::vec3(vtwMatrix * pos); + // compute how far the current position is from the center of the volume + float fDistToCenter = glm::distance(worldPos, centerWorldCoords); + // If the current voxel is less than 'radius' units from the center then we set its value + if (fDistToCenter <= radiusWorldCoords) { result |= setVoxelInternal(x, y, z, toValue); } - - // TODO -- this version only sets voxels which have centers inside the sphere. which is best? - // // Store our current position as a vector... - // glm::vec4 pos(x + 0.5f, y + 0.5f, z + 0.5f, 1.0); // consider voxels cenetered on their coordinates - // // convert to world coordinates - // glm::vec3 worldPos = glm::vec3(vtwMatrix * pos); - // // compute how far the current position is from the center of the volume - // float fDistToCenter = glm::distance(worldPos, centerWorldCoords); - // // If the current voxel is less than 'radius' units from the center then we set its value - // if (fDistToCenter <= radiusWorldCoords) { - // result |= setVoxelInternal(x, y, z, toValue); - // } } } } @@ -692,8 +677,6 @@ bool RenderablePolyVoxEntityItem::updateDependents() { _voxelDataDirty = false; } else if (_volDataDirty) { _volDataDirty = false; - } else { - _meshReady = true; } }); if (voxelDataDirty) { @@ -711,9 +694,7 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) { assert(getType() == EntityTypes::PolyVox); Q_ASSERT(args->_batch); - if (_voxelDataDirty || _volDataDirty) { - updateDependents(); - } + updateDependents(); model::MeshPointer mesh; glm::vec3 voxelVolumeSize; @@ -775,12 +756,6 @@ void RenderablePolyVoxEntityItem::render(RenderArgs* args) { 0, sizeof(PolyVox::PositionMaterialNormal)); - // TODO -- should we be setting this? - // batch.setInputBuffer(gpu::Stream::NORMAL, mesh->getVertexBuffer()._buffer, - // 12, - // sizeof(PolyVox::PositionMaterialNormal)); - - batch.setIndexBuffer(gpu::UINT32, mesh->getIndexBuffer()._buffer, 0); if (!_xTextureURL.isEmpty() && !_xTexture) { @@ -1299,27 +1274,23 @@ void RenderablePolyVoxEntityItem::recomputeMesh() { auto indexBuffer = std::make_shared(vecIndices.size() * sizeof(uint32_t), (gpu::Byte*)vecIndices.data()); auto indexBufferPtr = gpu::BufferPointer(indexBuffer); - gpu::BufferView indexBufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::INDEX)); + gpu::BufferView indexBufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::RAW)); mesh->setIndexBuffer(indexBufferView); - const std::vector& vecVertices = polyVoxMesh.getRawVertexData(); + const std::vector& vecVertices = polyVoxMesh.getVertices(); auto vertexBuffer = std::make_shared(vecVertices.size() * sizeof(PolyVox::PositionMaterialNormal), (gpu::Byte*)vecVertices.data()); auto vertexBufferPtr = gpu::BufferPointer(vertexBuffer); gpu::BufferView vertexBufferView(vertexBufferPtr, 0, vertexBufferPtr->getSize(), sizeof(PolyVox::PositionMaterialNormal), - gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); + gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW)); mesh->setVertexBuffer(vertexBufferView); - - - // TODO -- use 3-byte normals rather than 3-float normals mesh->addAttribute(gpu::Stream::NORMAL, - gpu::BufferView(vertexBufferPtr, - sizeof(float) * 3, // polyvox mesh is packed: position, normal, material - vertexBufferPtr->getSize(), + gpu::BufferView(vertexBufferPtr, sizeof(float) * 3, + vertexBufferPtr->getSize() , sizeof(PolyVox::PositionMaterialNormal), - gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ))); + gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::RAW))); std::vector parts; parts.emplace_back(model::Mesh::Part((model::Index)0, // startIndex @@ -1341,7 +1312,7 @@ void RenderablePolyVoxEntityItem::setMesh(model::MeshPointer mesh) { } _mesh = mesh; _meshDirty = true; - _meshReady = true; + _meshInitialized = true; neighborsNeedUpdate = _neighborsNeedUpdate; _neighborsNeedUpdate = false; }); @@ -1353,7 +1324,7 @@ void RenderablePolyVoxEntityItem::setMesh(model::MeshPointer mesh) { void RenderablePolyVoxEntityItem::computeShapeInfoWorker() { // this creates a collision-shape for the physics engine. The shape comes from // _volData for cubic extractors and from _mesh for marching-cube extractors - if (!_meshReady) { + if (!_meshInitialized) { return; } @@ -1621,7 +1592,7 @@ void RenderablePolyVoxEntityItem::locationChanged(bool tellPhysics) { scene->enqueuePendingChanges(pendingChanges); } -bool RenderablePolyVoxEntityItem::getMeshes(MeshProxyList& result) { +bool RenderablePolyVoxEntityItem::getMeshAsScriptValue(QScriptEngine *engine, QScriptValue& result) { if (!updateDependents()) { return false; } @@ -1630,22 +1601,15 @@ bool RenderablePolyVoxEntityItem::getMeshes(MeshProxyList& result) { MeshProxy* meshProxy = nullptr; glm::mat4 transform = voxelToLocalMatrix(); withReadLock([&] { - gpu::BufferView::Index numVertices = (gpu::BufferView::Index)_mesh->getNumVertices(); - if (!_meshReady) { - // we aren't ready to return a mesh. the caller will have to try again later. - success = false; - } else if (numVertices == 0) { - // we are ready, but there are no triangles in the mesh. - success = true; - } else { + if (_meshInitialized) { success = true; // the mesh will be in voxel-space. transform it into object-space meshProxy = new MeshProxy( _mesh->map([=](glm::vec3 position){ return glm::vec3(transform * glm::vec4(position, 1.0f)); }, - [=](glm::vec3 normal){ return glm::normalize(glm::vec3(transform * glm::vec4(normal, 0.0f))); }, - [&](uint32_t index){ return index; })); - result << meshProxy; + [=](glm::vec3 normal){ return glm::vec3(transform * glm::vec4(normal, 0.0f)); }, + [](uint32_t index){ return index; })); } }); + result = meshToScriptValue(engine, meshProxy); return success; } diff --git a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h index cdfe2e38fe..cf4672f068 100644 --- a/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyVoxEntityItem.h @@ -66,7 +66,7 @@ public: void render(RenderArgs* args) override; virtual bool supportsDetailedRayIntersection() const override { return true; } virtual bool findDetailedRayIntersection(const glm::vec3& origin, const glm::vec3& direction, - bool& keepSearching, OctreeElementPointer& element, float& distance, + bool& keepSearching, OctreeElementPointer& element, float& distance, BoxFace& face, glm::vec3& surfaceNormal, void** intersectedObject, bool precisionPicking) const override; @@ -135,19 +135,18 @@ public: QByteArray volDataToArray(quint16 voxelXSize, quint16 voxelYSize, quint16 voxelZSize) const; void setMesh(model::MeshPointer mesh); + bool getMeshAsScriptValue(QScriptEngine *engine, QScriptValue& result) override; void setCollisionPoints(ShapeInfo::PointCollection points, AABox box); PolyVox::SimpleVolume* getVolData() { return _volData; } uint8_t getVoxelInternal(int x, int y, int z) const; bool setVoxelInternal(int x, int y, int z, uint8_t toValue); - void setVolDataDirty() { withWriteLock([&] { _volDataDirty = true; _meshReady = false; }); } + void setVolDataDirty() { withWriteLock([&] { _volDataDirty = true; }); } // Transparent polyvox didn't seem to be working so disable for now bool isTransparent() override { return false; } - bool getMeshes(MeshProxyList& result) override; - protected: virtual void locationChanged(bool tellPhysics = true) override; @@ -158,7 +157,7 @@ private: model::MeshPointer _mesh; gpu::Stream::FormatPointer _vertexFormat; bool _meshDirty { true }; // does collision-shape need to be recomputed? - bool _meshReady { false }; + bool _meshInitialized { false }; NetworkTexturePointer _xTexture; NetworkTexturePointer _yTexture; diff --git a/libraries/entities/CMakeLists.txt b/libraries/entities/CMakeLists.txt index b2ae0f0ab7..1230fe8146 100644 --- a/libraries/entities/CMakeLists.txt +++ b/libraries/entities/CMakeLists.txt @@ -1,6 +1,6 @@ set(TARGET_NAME entities) setup_hifi_library(Network Script) -link_hifi_libraries(avatars shared audio octree model model-networking fbx networking animation) +link_hifi_libraries(avatars shared audio octree model fbx networking animation) target_bullet() diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index b973d916e6..163b4d9e45 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -63,8 +63,6 @@ namespace render { #define debugTimeOnly(T) qPrintable(QString("%1").arg(T, 16, 10)) #define debugTreeVector(V) V << "[" << V << " in meters ]" -class MeshProxyList; - /// EntityItem class this is the base class for all entity types. It handles the basic properties and functionality available /// to all other entity types. In particular: postion, size, rotation, age, lifetime, velocity, gravity. You can not instantiate @@ -472,11 +470,9 @@ public: QUuid getLastEditedBy() const { return _lastEditedBy; } void setLastEditedBy(QUuid value) { _lastEditedBy = value; } - + bool matchesJSONFilters(const QJsonObject& jsonFilters) const; - virtual bool getMeshes(MeshProxyList& result) { return true; } - protected: void setSimulated(bool simulated) { _simulated = simulated; } diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 2c332e8d05..1ab5438e53 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include "EntitiesLogging.h" #include "EntityActionFactoryInterface.h" @@ -674,6 +673,7 @@ RayToEntityIntersectionResult EntityScriptingInterface::findRayIntersectionWorke (void**)&intersectedEntity, lockType, &result.accurate); if (result.intersects && intersectedEntity) { result.entityID = intersectedEntity->getEntityItemID(); + result.properties = intersectedEntity->getProperties(); result.intersection = ray.origin + (ray.direction * result.distance); } } @@ -838,6 +838,7 @@ RayToEntityIntersectionResult::RayToEntityIntersectionResult() : intersects(false), accurate(true), // assume it's accurate entityID(), + properties(), distance(0), face(), entity(NULL) @@ -853,6 +854,9 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID); obj.setProperty("entityID", entityItemValue); + QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties); + obj.setProperty("properties", propertiesValue); + obj.setProperty("distance", value.distance); QString faceName = ""; @@ -898,6 +902,10 @@ void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, Ra QScriptValue entityIDValue = object.property("entityID"); // EntityItemIDfromScriptValue(entityIDValue, value.entityID); quuidFromScriptValue(entityIDValue, value.entityID); + QScriptValue entityPropertiesValue = object.property("properties"); + if (entityPropertiesValue.isValid()) { + EntityItemPropertiesFromScriptValueHonorReadOnly(entityPropertiesValue, value.properties); + } value.distance = object.property("distance").toVariant().toFloat(); QString faceName = object.property("face").toVariant().toString(); @@ -1032,6 +1040,25 @@ bool EntityScriptingInterface::setVoxelsInCuboid(QUuid entityID, const glm::vec3 }); } +void EntityScriptingInterface::voxelsToMesh(QUuid entityID, QScriptValue callback) { + PROFILE_RANGE(script_entities, __FUNCTION__); + + bool success { false }; + QScriptValue mesh { false }; + + polyVoxWorker(entityID, [&](PolyVoxEntityItem& polyVoxEntity) mutable { + if (polyVoxEntity.getOnCount() == 0) { + success = true; + } else { + success = polyVoxEntity.getMeshAsScriptValue(callback.engine(), mesh); + } + return true; + }); + + QScriptValueList args { mesh, success }; + callback.call(QScriptValue(), args); +} + bool EntityScriptingInterface::setAllPoints(QUuid entityID, const QVector& points) { PROFILE_RANGE(script_entities, __FUNCTION__); @@ -1648,30 +1675,6 @@ bool EntityScriptingInterface::AABoxIntersectsCapsule(const glm::vec3& low, cons return aaBox.findCapsulePenetration(start, end, radius, penetration); } -void EntityScriptingInterface::getMeshes(QUuid entityID, QScriptValue callback) { - PROFILE_RANGE(script_entities, __FUNCTION__); - - EntityItemPointer entity = static_cast(_entityTree->findEntityByEntityItemID(entityID)); - if (!entity) { - qCDebug(entities) << "EntityScriptingInterface::getMeshes no entity with ID" << entityID; - QScriptValueList args { callback.engine()->undefinedValue(), false }; - callback.call(QScriptValue(), args); - return; - } - - MeshProxyList result; - bool success = entity->getMeshes(result); - - if (success) { - QScriptValue resultAsScriptValue = meshesToScriptValue(callback.engine(), result); - QScriptValueList args { resultAsScriptValue, true }; - callback.call(QScriptValue(), args); - } else { - QScriptValueList args { callback.engine()->undefinedValue(), false }; - callback.call(QScriptValue(), args); - } -} - glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) { glm::mat4 result; if (_entityTree) { @@ -1688,20 +1691,3 @@ glm::mat4 EntityScriptingInterface::getEntityTransform(const QUuid& entityID) { } return result; } - -glm::mat4 EntityScriptingInterface::getEntityLocalTransform(const QUuid& entityID) { - glm::mat4 result; - if (_entityTree) { - _entityTree->withReadLock([&] { - EntityItemPointer entity = _entityTree->findEntityByEntityItemID(EntityItemID(entityID)); - if (entity) { - glm::mat4 translation = glm::translate(entity->getLocalPosition()); - glm::mat4 rotation = glm::mat4_cast(entity->getLocalOrientation()); - glm::mat4 registration = glm::translate(ENTITY_ITEM_DEFAULT_REGISTRATION_POINT - - entity->getRegistrationPoint()); - result = translation * rotation * registration; - } - }); - } - return result; -} diff --git a/libraries/entities/src/EntityScriptingInterface.h b/libraries/entities/src/EntityScriptingInterface.h index b25764790e..63b5771e60 100644 --- a/libraries/entities/src/EntityScriptingInterface.h +++ b/libraries/entities/src/EntityScriptingInterface.h @@ -58,6 +58,7 @@ public: bool intersects; bool accurate; QUuid entityID; + EntityItemProperties properties; float distance; BoxFace face; glm::vec3 intersection; @@ -265,6 +266,7 @@ public slots: Q_INVOKABLE bool setAllVoxels(QUuid entityID, int value); Q_INVOKABLE bool setVoxelsInCuboid(QUuid entityID, const glm::vec3& lowPosition, const glm::vec3& cuboidSize, int value); + Q_INVOKABLE void voxelsToMesh(QUuid entityID, QScriptValue callback); Q_INVOKABLE bool setAllPoints(QUuid entityID, const QVector& points); Q_INVOKABLE bool appendPoint(QUuid entityID, const glm::vec3& point); @@ -329,8 +331,6 @@ public slots: const glm::vec3& start, const glm::vec3& end, float radius); - Q_INVOKABLE void getMeshes(QUuid entityID, QScriptValue callback); - /**jsdoc * Returns object to world transform, excluding scale * @@ -340,16 +340,6 @@ public slots: */ Q_INVOKABLE glm::mat4 getEntityTransform(const QUuid& entityID); - - /**jsdoc - * Returns object to world transform, excluding scale - * - * @function Entities.getEntityLocalTransform - * @param {EntityID} entityID The ID of the entity whose local transform is to be returned - * @return {Mat4} Entity's object to parent transform, excluding scale - */ - Q_INVOKABLE glm::mat4 getEntityLocalTransform(const QUuid& entityID); - signals: void collisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision); diff --git a/libraries/entities/src/PolyVoxEntityItem.cpp b/libraries/entities/src/PolyVoxEntityItem.cpp index 2a374c1d17..90344d6c4b 100644 --- a/libraries/entities/src/PolyVoxEntityItem.cpp +++ b/libraries/entities/src/PolyVoxEntityItem.cpp @@ -242,3 +242,7 @@ const QByteArray PolyVoxEntityItem::getVoxelData() const { }); return voxelDataCopy; } + +bool PolyVoxEntityItem::getMeshAsScriptValue(QScriptEngine *engine, QScriptValue& result) { + return false; +} diff --git a/libraries/entities/src/PolyVoxEntityItem.h b/libraries/entities/src/PolyVoxEntityItem.h index cf7531fc9e..311a002a4a 100644 --- a/libraries/entities/src/PolyVoxEntityItem.h +++ b/libraries/entities/src/PolyVoxEntityItem.h @@ -135,6 +135,8 @@ class PolyVoxEntityItem : public EntityItem { void setVoxelDataDirty(bool value) { withWriteLock([&] { _voxelDataDirty = value; }); } virtual void recomputeMesh() {}; + virtual bool getMeshAsScriptValue(QScriptEngine *engine, QScriptValue& result); + protected: glm::vec3 _voxelVolumeSize; // this is always 3 bytes diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index 64ee0bc869..718793fefa 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -1631,15 +1631,13 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS // whether we're skinned depends on how many clusters are attached const FBXCluster& firstFBXCluster = extracted.mesh.clusters.at(0); + int maxJointIndex = firstFBXCluster.jointIndex; glm::mat4 inverseModelTransform = glm::inverse(modelTransform); if (clusterIDs.size() > 1) { // this is a multi-mesh joint - const int WEIGHTS_PER_VERTEX = 4; - int numClusterIndices = extracted.mesh.vertices.size() * WEIGHTS_PER_VERTEX; - extracted.mesh.clusterIndices.fill(0, numClusterIndices); - QVector weightAccumulators; - weightAccumulators.fill(0.0f, numClusterIndices); - + extracted.mesh.clusterIndices.resize(extracted.mesh.vertices.size()); + extracted.mesh.clusterWeights.resize(extracted.mesh.vertices.size()); + float maxWeight = 0.0f; for (int i = 0; i < clusterIDs.size(); i++) { QString clusterID = clusterIDs.at(i); const Cluster& cluster = clusters[clusterID]; @@ -1664,69 +1662,61 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS glm::mat4 meshToJoint = glm::inverse(joint.bindTransform) * modelTransform; ShapeVertices& points = shapeVertices.at(jointIndex); + float totalWeight = 0.0f; for (int j = 0; j < cluster.indices.size(); j++) { int oldIndex = cluster.indices.at(j); float weight = cluster.weights.at(j); + totalWeight += weight; for (QMultiHash::const_iterator it = extracted.newIndices.constFind(oldIndex); it != extracted.newIndices.end() && it.key() == oldIndex; it++) { - int newIndex = it.value(); // remember vertices with at least 1/4 weight const float EXPANSION_WEIGHT_THRESHOLD = 0.99f; if (weight > EXPANSION_WEIGHT_THRESHOLD) { // transform to joint-frame and save for later - const glm::mat4 vertexTransform = meshToJoint * glm::translate(extracted.mesh.vertices.at(newIndex)); + const glm::mat4 vertexTransform = meshToJoint * glm::translate(extracted.mesh.vertices.at(it.value())); points.push_back(extractTranslation(vertexTransform) * clusterScale); } // look for an unused slot in the weights vector - int weightIndex = newIndex * WEIGHTS_PER_VERTEX; + glm::vec4& weights = extracted.mesh.clusterWeights[it.value()]; int lowestIndex = -1; float lowestWeight = FLT_MAX; int k = 0; - for (; k < WEIGHTS_PER_VERTEX; k++) { - if (weightAccumulators[weightIndex + k] == 0.0f) { - extracted.mesh.clusterIndices[weightIndex + k] = i; - weightAccumulators[weightIndex + k] = weight; + for (; k < 4; k++) { + if (weights[k] == 0.0f) { + extracted.mesh.clusterIndices[it.value()][k] = i; + weights[k] = weight; break; } - if (weightAccumulators[weightIndex + k] < lowestWeight) { + if (weights[k] < lowestWeight) { lowestIndex = k; - lowestWeight = weightAccumulators[weightIndex + k]; + lowestWeight = weights[k]; } } - if (k == WEIGHTS_PER_VERTEX && weight > lowestWeight) { + if (k == 4 && weight > lowestWeight) { // no space for an additional weight; we must replace the lowest - weightAccumulators[weightIndex + lowestIndex] = weight; - extracted.mesh.clusterIndices[weightIndex + lowestIndex] = i; + weights[lowestIndex] = weight; + extracted.mesh.clusterIndices[it.value()][lowestIndex] = i; } } } - } - - // now that we've accumulated the most relevant weights for each vertex - // normalize and compress to 8-bits - extracted.mesh.clusterWeights.fill(0, numClusterIndices); - int numVertices = extracted.mesh.vertices.size(); - for (int i = 0; i < numVertices; ++i) { - int j = i * WEIGHTS_PER_VERTEX; - - // normalize weights into uint8_t - float totalWeight = weightAccumulators[j]; - for (int k = j + 1; k < j + WEIGHTS_PER_VERTEX; ++k) { - totalWeight += weightAccumulators[k]; + if (totalWeight > maxWeight) { + maxWeight = totalWeight; + maxJointIndex = jointIndex; } - if (totalWeight > 0.0f) { - const float ALMOST_HALF = 0.499f; - float weightScalingFactor = (float)(UINT8_MAX) / totalWeight; - for (int k = j; k < j + WEIGHTS_PER_VERTEX; ++k) { - extracted.mesh.clusterWeights[k] = (uint8_t)(weightScalingFactor * weightAccumulators[k] + ALMOST_HALF); - } + } + // normalize the weights if they don't add up to one + for (int i = 0; i < extracted.mesh.clusterWeights.size(); i++) { + glm::vec4& weights = extracted.mesh.clusterWeights[i]; + float total = weights.x + weights.y + weights.z + weights.w; + if (total != 1.0f && total != 0.0f) { + weights /= total; } } } else { // this is a single-mesh joint - int jointIndex = firstFBXCluster.jointIndex; + int jointIndex = maxJointIndex; FBXJoint& joint = geometry.joints[jointIndex]; // transform cluster vertices to joint-frame and save for later @@ -1746,8 +1736,18 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS } } } + extracted.mesh.isEye = (maxJointIndex == geometry.leftEyeJointIndex || maxJointIndex == geometry.rightEyeJointIndex); + buildModelMesh(extracted.mesh, url); + if (extracted.mesh.isEye) { + if (maxJointIndex == geometry.leftEyeJointIndex) { + geometry.leftEyeSize = extracted.mesh.meshExtents.largestDimension() * offsetScale; + } else { + geometry.rightEyeSize = extracted.mesh.meshExtents.largestDimension() * offsetScale; + } + } + geometry.meshes.append(extracted.mesh); int meshIndex = geometry.meshes.size() - 1; meshIDsToMeshIndices.insert(it.key(), meshIndex); diff --git a/libraries/fbx/src/FBXReader.h b/libraries/fbx/src/FBXReader.h index f73088e7a1..fa047e512f 100644 --- a/libraries/fbx/src/FBXReader.h +++ b/libraries/fbx/src/FBXReader.h @@ -202,7 +202,7 @@ public: /// A single mesh (with optional blendshapes) extracted from an FBX document. class FBXMesh { public: - + QVector parts; QVector vertices; @@ -211,14 +211,16 @@ public: QVector colors; QVector texCoords; QVector texCoords1; - QVector clusterIndices; - QVector clusterWeights; - + QVector clusterIndices; + QVector clusterWeights; + QVector clusters; Extents meshExtents; glm::mat4 modelTransform; + bool isEye; + QVector blendshapes; unsigned int meshIndex; // the order the meshes appeared in the object file diff --git a/libraries/fbx/src/FBXReader_Mesh.cpp b/libraries/fbx/src/FBXReader_Mesh.cpp index 4e153dfe3a..8eb31b0731 100644 --- a/libraries/fbx/src/FBXReader_Mesh.cpp +++ b/libraries/fbx/src/FBXReader_Mesh.cpp @@ -422,13 +422,8 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) { int colorsSize = fbxMesh.colors.size() * sizeof(glm::vec3); int texCoordsSize = fbxMesh.texCoords.size() * sizeof(glm::vec2); int texCoords1Size = fbxMesh.texCoords1.size() * sizeof(glm::vec2); - - int clusterIndicesSize = fbxMesh.clusterIndices.size() * sizeof(uint8_t); - if (fbxMesh.clusters.size() > UINT8_MAX) { - // we need 16 bits instead of just 8 for clusterIndices - clusterIndicesSize *= 2; - } - int clusterWeightsSize = fbxMesh.clusterWeights.size() * sizeof(uint8_t); + int clusterIndicesSize = fbxMesh.clusterIndices.size() * sizeof(glm::vec4); + int clusterWeightsSize = fbxMesh.clusterWeights.size() * sizeof(glm::vec4); int normalsOffset = 0; int tangentsOffset = normalsOffset + normalsSize; @@ -447,20 +442,7 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) { attribBuffer->setSubData(colorsOffset, colorsSize, (gpu::Byte*) fbxMesh.colors.constData()); attribBuffer->setSubData(texCoordsOffset, texCoordsSize, (gpu::Byte*) fbxMesh.texCoords.constData()); attribBuffer->setSubData(texCoords1Offset, texCoords1Size, (gpu::Byte*) fbxMesh.texCoords1.constData()); - - if (fbxMesh.clusters.size() < UINT8_MAX) { - // yay! we can fit the clusterIndices within 8-bits - int32_t numIndices = fbxMesh.clusterIndices.size(); - QVector clusterIndices; - clusterIndices.resize(numIndices); - for (int32_t i = 0; i < numIndices; ++i) { - assert(fbxMesh.clusterIndices[i] <= UINT8_MAX); - clusterIndices[i] = (uint8_t)(fbxMesh.clusterIndices[i]); - } - attribBuffer->setSubData(clusterIndicesOffset, clusterIndicesSize, (gpu::Byte*) clusterIndices.constData()); - } else { - attribBuffer->setSubData(clusterIndicesOffset, clusterIndicesSize, (gpu::Byte*) fbxMesh.clusterIndices.constData()); - } + attribBuffer->setSubData(clusterIndicesOffset, clusterIndicesSize, (gpu::Byte*) fbxMesh.clusterIndices.constData()); attribBuffer->setSubData(clusterWeightsOffset, clusterWeightsSize, (gpu::Byte*) fbxMesh.clusterWeights.constData()); if (normalsSize) { @@ -494,20 +476,14 @@ void FBXReader::buildModelMesh(FBXMesh& extractedMesh, const QString& url) { } if (clusterIndicesSize) { - if (fbxMesh.clusters.size() < UINT8_MAX) { - mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, - model::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize, - gpu::Element(gpu::VEC4, gpu::UINT8, gpu::XYZW))); - } else { - mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, - model::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize, - gpu::Element(gpu::VEC4, gpu::UINT16, gpu::XYZW))); - } + mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_INDEX, + model::BufferView(attribBuffer, clusterIndicesOffset, clusterIndicesSize, + gpu::Element(gpu::VEC4, gpu::FLOAT, gpu::XYZW))); } if (clusterWeightsSize) { mesh->addAttribute(gpu::Stream::SKIN_CLUSTER_WEIGHT, model::BufferView(attribBuffer, clusterWeightsOffset, clusterWeightsSize, - gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::XYZW))); + gpu::Element(gpu::VEC4, gpu::FLOAT, gpu::XYZW))); } diff --git a/libraries/fbx/src/OBJWriter.cpp b/libraries/fbx/src/OBJWriter.cpp index 034263eb53..5ee04c5718 100644 --- a/libraries/fbx/src/OBJWriter.cpp +++ b/libraries/fbx/src/OBJWriter.cpp @@ -40,16 +40,12 @@ static QString formatFloat(double n) { } bool writeOBJToTextStream(QTextStream& out, QList meshes) { - int attributeTypeNormal = gpu::Stream::InputSlot::NORMAL; // libraries/gpu/src/gpu/Stream.h - // each mesh's vertices are numbered from zero. We're combining all their vertices into one list here, // so keep track of the start index for each mesh. QList meshVertexStartOffset; - QList meshNormalStartOffset; int currentVertexStartOffset = 0; - int currentNormalStartOffset = 0; - // write out vertices + // write out all vertices foreach (const MeshPointer& mesh, meshes) { meshVertexStartOffset.append(currentVertexStartOffset); const gpu::BufferView& vertexBuffer = mesh->getVertexBuffer(); @@ -68,28 +64,10 @@ bool writeOBJToTextStream(QTextStream& out, QList meshes) { } out << "\n"; - // write out normals - bool haveNormals = true; - foreach (const MeshPointer& mesh, meshes) { - meshNormalStartOffset.append(currentNormalStartOffset); - const gpu::BufferView& normalsBufferView = mesh->getAttributeBuffer(attributeTypeNormal); - gpu::BufferView::Index numNormals = (gpu::BufferView::Index)normalsBufferView.getNumElements(); - for (gpu::BufferView::Index i = 0; i < numNormals; i++) { - glm::vec3 normal = normalsBufferView.get(i); - out << "vn "; - out << formatFloat(normal[0]) << " "; - out << formatFloat(normal[1]) << " "; - out << formatFloat(normal[2]) << "\n"; - } - currentNormalStartOffset += numNormals; - } - out << "\n"; - // write out faces int nth = 0; foreach (const MeshPointer& mesh, meshes) { currentVertexStartOffset = meshVertexStartOffset.takeFirst(); - currentNormalStartOffset = meshNormalStartOffset.takeFirst(); const gpu::BufferView& partBuffer = mesh->getPartBuffer(); const gpu::BufferView& indexBuffer = mesh->getIndexBuffer(); @@ -126,15 +104,9 @@ bool writeOBJToTextStream(QTextStream& out, QList meshes) { indexCount++; out << "f "; - if (haveNormals) { - out << currentVertexStartOffset + index0 + 1 << "//" << currentVertexStartOffset + index0 + 1 << " "; - out << currentVertexStartOffset + index1 + 1 << "//" << currentVertexStartOffset + index1 + 1 << " "; - out << currentVertexStartOffset + index2 + 1 << "//" << currentVertexStartOffset + index2 + 1 << "\n"; - } else { - out << currentVertexStartOffset + index0 + 1 << " "; - out << currentVertexStartOffset + index1 + 1 << " "; - out << currentVertexStartOffset + index2 + 1 << "\n"; - } + out << currentVertexStartOffset + index0 + 1 << " "; + out << currentVertexStartOffset + index1 + 1 << " "; + out << currentVertexStartOffset + index2 + 1 << "\n"; } out << "\n"; } diff --git a/libraries/gl/src/gl/OffscreenQmlSurface.cpp b/libraries/gl/src/gl/OffscreenQmlSurface.cpp index de0caf56a9..447b9d56aa 100644 --- a/libraries/gl/src/gl/OffscreenQmlSurface.cpp +++ b/libraries/gl/src/gl/OffscreenQmlSurface.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include "OffscreenGLCanvas.h" #include "GLHelpers.h" @@ -434,7 +433,6 @@ void OffscreenQmlSurface::create(QOpenGLContext* shareContext) { auto rootContext = getRootContext(); rootContext->setContextProperty("urlHandler", new UrlHandler()); rootContext->setContextProperty("resourceDirectoryUrl", QUrl::fromLocalFile(PathUtils::resourcesPath())); - rootContext->setContextProperty("pathToFonts", "../../"); } static uvec2 clampSize(const uvec2& size, uint32_t maxDimension) { @@ -913,23 +911,20 @@ void OffscreenQmlSurface::setKeyboardRaised(QObject* object, bool raised, bool n return; } - // if HMD is being worn, allow keyboard to open. allow it to close, HMD or not. - if (!raised || qApp->property(hifi::properties::HMD).toBool()) { - QQuickItem* item = dynamic_cast(object); - while (item) { - // Numeric value may be set in parameter from HTML UI; for QML UI, detect numeric fields here. - numeric = numeric || QString(item->metaObject()->className()).left(7) == "SpinBox"; + QQuickItem* item = dynamic_cast(object); + while (item) { + // Numeric value may be set in parameter from HTML UI; for QML UI, detect numeric fields here. + numeric = numeric || QString(item->metaObject()->className()).left(7) == "SpinBox"; - if (item->property("keyboardRaised").isValid()) { - // FIXME - HMD only: Possibly set value of "keyboardEnabled" per isHMDMode() for use in WebView.qml. - if (item->property("punctuationMode").isValid()) { - item->setProperty("punctuationMode", QVariant(numeric)); - } - item->setProperty("keyboardRaised", QVariant(raised)); - return; + if (item->property("keyboardRaised").isValid()) { + // FIXME - HMD only: Possibly set value of "keyboardEnabled" per isHMDMode() for use in WebView.qml. + if (item->property("punctuationMode").isValid()) { + item->setProperty("punctuationMode", QVariant(numeric)); } - item = dynamic_cast(item->parentItem()); + item->setProperty("keyboardRaised", QVariant(raised)); + return; } + item = dynamic_cast(item->parentItem()); } } diff --git a/libraries/gpu-gl/CMakeLists.txt b/libraries/gpu-gl/CMakeLists.txt index 3e3853532a..65df5ed9dc 100644 --- a/libraries/gpu-gl/CMakeLists.txt +++ b/libraries/gpu-gl/CMakeLists.txt @@ -1,9 +1,6 @@ set(TARGET_NAME gpu-gl) setup_hifi_library() link_hifi_libraries(shared gl gpu) -if (UNIX) - target_link_libraries(${TARGET_NAME} pthread) -endif(UNIX) GroupSources("src") target_opengl() diff --git a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp index 65c5788227..1de820e1df 100644 --- a/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl/GLTexture.cpp @@ -8,6 +8,8 @@ #include "GLTexture.h" +#include + #include "GLBackend.h" using namespace gpu; diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp index 51a24563f3..638841b170 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendInput.cpp @@ -99,13 +99,8 @@ void GL41Backend::updateInput() { GLboolean isNormalized = attrib._element.isNormalized(); for (size_t locNum = 0; locNum < locationCount; ++locNum) { - if (attrib._element.isInteger()) { - glVertexAttribIPointer(slot + (GLuint)locNum, count, type, stride, - reinterpret_cast(pointer + perLocationStride * (GLuint)locNum)); - } else { - glVertexAttribPointer(slot + (GLuint)locNum, count, type, isNormalized, stride, - reinterpret_cast(pointer + perLocationStride * (GLuint)locNum)); - } + glVertexAttribPointer(slot + (GLuint)locNum, count, type, isNormalized, stride, + reinterpret_cast(pointer + perLocationStride * (GLuint)locNum)); #ifdef GPU_STEREO_DRAWCALL_INSTANCED glVertexAttribDivisor(slot + (GLuint)locNum, attrib._frequency * (isStereo() ? 2 : 1)); #else diff --git a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp index 46672b3b65..8dbef09f06 100644 --- a/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl41/GL41BackendTexture.cpp @@ -72,7 +72,7 @@ GL41Texture::GL41Texture(const std::weak_ptr& backend, const Texture& incrementTextureGPUCount(); withPreservedTexture([&] { GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), _gpuObject.getStoredMipFormat()); - auto numMips = _gpuObject.getNumMipLevels(); + auto numMips = _gpuObject.evalNumMips(); for (uint16_t mipLevel = 0; mipLevel < numMips; ++mipLevel) { // Get the mip level dimensions, accounting for the downgrade level Vec3u dimensions = _gpuObject.evalMipDimensions(mipLevel); diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp index ece62e15f1..01bd2d7bce 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendInput.cpp @@ -61,11 +61,8 @@ void GL45Backend::updateInput() { _input._attributeActivation.set(attriNum); glEnableVertexAttribArray(attriNum); } - if (attrib._element.isInteger()) { - glVertexAttribIFormat(attriNum, count, type, offset + locNum * perLocationSize); - } else { - glVertexAttribFormat(attriNum, count, type, isNormalized, offset + locNum * perLocationSize); - } + glVertexAttribFormat(attriNum, count, type, isNormalized, offset + locNum * perLocationSize); + // TODO: Support properly the IAttrib version glVertexAttribBinding(attriNum, attrib._channel); } diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp index c82c13c57c..36aaf75e81 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendTexture.cpp @@ -186,10 +186,8 @@ GL45FixedAllocationTexture::~GL45FixedAllocationTexture() { void GL45FixedAllocationTexture::allocateStorage() const { const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto dimensions = _gpuObject.getDimensions(); - const auto mips = _gpuObject.getNumMipLevels(); - + const auto mips = _gpuObject.evalNumMips(); glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); - glTextureParameteri(_id, GL_TEXTURE_BASE_LEVEL, 0); } void GL45FixedAllocationTexture::syncSampler() const { @@ -216,7 +214,7 @@ GL45AttachmentTexture::~GL45AttachmentTexture() { using GL45StrictResourceTexture = GL45Backend::GL45StrictResourceTexture; GL45StrictResourceTexture::GL45StrictResourceTexture(const std::weak_ptr& backend, const Texture& texture) : GL45FixedAllocationTexture(backend, texture) { - auto mipLevels = _gpuObject.getNumMipLevels(); + auto mipLevels = _gpuObject.evalNumMips(); for (uint16_t sourceMip = 0; sourceMip < mipLevels; ++sourceMip) { uint16_t targetMip = sourceMip; size_t maxFace = GLTexture::getFaceCount(_target); diff --git a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp index 188fff9979..d54ad1ea4b 100644 --- a/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp +++ b/libraries/gpu-gl/src/gpu/gl45/GL45BackendVariableTexture.cpp @@ -461,10 +461,10 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) { _allocatedMip = allocatedMip; const GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat()); const auto dimensions = _gpuObject.evalMipDimensions(_allocatedMip); - const auto totalMips = _gpuObject.getNumMipLevels(); + const auto totalMips = _gpuObject.evalNumMips(); const auto mips = totalMips - _allocatedMip; glTextureStorage2D(_id, mips, texelFormat.internalFormat, dimensions.x, dimensions.y); - auto mipLevels = _gpuObject.getNumMipLevels(); + auto mipLevels = _gpuObject.evalNumMips(); _size = 0; for (uint16_t mip = _allocatedMip; mip < mipLevels; ++mip) { _size += _gpuObject.evalMipSize(mip); @@ -474,7 +474,7 @@ void GL45ResourceTexture::allocateStorage(uint16 allocatedMip) { } void GL45ResourceTexture::copyMipsFromTexture() { - auto mipLevels = _gpuObject.getNumMipLevels(); + auto mipLevels = _gpuObject.evalNumMips(); size_t maxFace = GLTexture::getFaceCount(_target); for (uint16_t sourceMip = _populatedMip; sourceMip < mipLevels; ++sourceMip) { uint16_t targetMip = sourceMip - _allocatedMip; @@ -499,7 +499,7 @@ void GL45ResourceTexture::promote() { uint16_t oldAllocatedMip = _allocatedMip; // allocate storage for new level allocateStorage(_allocatedMip - std::min(_allocatedMip, 2)); - uint16_t mips = _gpuObject.getNumMipLevels(); + uint16_t mips = _gpuObject.evalNumMips(); // copy pre-existing mips for (uint16_t mip = _populatedMip; mip < mips; ++mip) { auto mipDimensions = _gpuObject.evalMipDimensions(mip); @@ -532,7 +532,7 @@ void GL45ResourceTexture::demote() { const_cast(_id) = allocate(_gpuObject); allocateStorage(_allocatedMip + 1); _populatedMip = std::max(_populatedMip, _allocatedMip); - uint16_t mips = _gpuObject.getNumMipLevels(); + uint16_t mips = _gpuObject.evalNumMips(); // copy pre-existing mips for (uint16_t mip = _populatedMip; mip < mips; ++mip) { auto mipDimensions = _gpuObject.evalMipDimensions(mip); diff --git a/libraries/gpu/src/gpu/Format.h b/libraries/gpu/src/gpu/Format.h index 4114ccb15c..493a2de3c2 100644 --- a/libraries/gpu/src/gpu/Format.h +++ b/libraries/gpu/src/gpu/Format.h @@ -75,12 +75,12 @@ static const bool TYPE_IS_INTEGER[NUM_TYPES] = { true, // Normalized values - false, - false, - false, - false, - false, - false + true, + true, + true, + true, + true, + true }; // Dimension of an Element diff --git a/libraries/gpu/src/gpu/Inputs.slh b/libraries/gpu/src/gpu/Inputs.slh index 843d1059f2..ce5e4227eb 100644 --- a/libraries/gpu/src/gpu/Inputs.slh +++ b/libraries/gpu/src/gpu/Inputs.slh @@ -15,7 +15,7 @@ layout(location = 1) in vec4 inNormal; layout(location = 2) in vec4 inColor; layout(location = 3) in vec4 inTexCoord0; layout(location = 4) in vec4 inTangent; -layout(location = 5) in ivec4 inSkinClusterIndex; +layout(location = 5) in vec4 inSkinClusterIndex; layout(location = 6) in vec4 inSkinClusterWeight; layout(location = 7) in vec4 inTexCoord1; <@endif@> diff --git a/libraries/gpu/src/gpu/Texture.h b/libraries/gpu/src/gpu/Texture.h index ce71b41b77..f7297b3280 100755 --- a/libraries/gpu/src/gpu/Texture.h +++ b/libraries/gpu/src/gpu/Texture.h @@ -418,8 +418,8 @@ public: uint32 evalTotalSize(uint16 startingMip = 0) const { uint32 size = 0; - uint16 minMipLevel = std::max(getMinMip(), startingMip); - uint16 maxMipLevel = getMaxMip(); + uint16 minMipLevel = std::max(minMip(), startingMip); + uint16 maxMipLevel = maxMip(); for (uint16 l = minMipLevel; l <= maxMipLevel; l++) { size += evalMipSize(l); } @@ -429,9 +429,12 @@ public: // max mip is in the range [ 0 if no sub mips, log2(max(width, height, depth))] // if autoGenerateMip is on => will provide the maxMIp level specified // else provide the deepest mip level provided through assignMip - uint16 getMaxMip() const { return _maxMip; } - uint16 getMinMip() const { return _minMip; } - uint16 getNumMipLevels() const { return _maxMip + 1; } + uint16 maxMip() const { return _maxMip; } + + uint16 minMip() const { return _minMip; } + + uint16 mipLevels() const { return _maxMip + 1; } + uint16 usedMipLevels() const { return (_maxMip - _minMip) + 1; } const std::string& source() const { return _source; } diff --git a/libraries/gpu/src/gpu/Texture_ktx.cpp b/libraries/gpu/src/gpu/Texture_ktx.cpp index ab5be7475a..5f0ededee7 100644 --- a/libraries/gpu/src/gpu/Texture_ktx.cpp +++ b/libraries/gpu/src/gpu/Texture_ktx.cpp @@ -121,7 +121,7 @@ ktx::KTXUniquePointer Texture::serialize(const Texture& texture) { } // Number level of mips coming - header.numberOfMipmapLevels = texture.getNumMipLevels(); + header.numberOfMipmapLevels = texture.maxMip() + 1; ktx::Images images; for (uint32_t level = 0; level < header.numberOfMipmapLevels; level++) { diff --git a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp index b5a2fc6b3c..ddb2f482a1 100755 --- a/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp +++ b/libraries/input-plugins/src/input-plugins/KeyboardMouseDevice.cpp @@ -25,7 +25,6 @@ void KeyboardMouseDevice::pluginUpdate(float deltaTime, const controller::InputC auto userInputMapper = DependencyManager::get(); userInputMapper->withLock([&, this]() { _inputDevice->update(deltaTime, inputCalibrationData); - eraseMouseClicked(); _inputDevice->_axisStateMap[MOUSE_AXIS_X] = _lastCursor.x(); _inputDevice->_axisStateMap[MOUSE_AXIS_Y] = _lastCursor.y(); @@ -79,6 +78,8 @@ void KeyboardMouseDevice::mousePressEvent(QMouseEvent* event) { _mousePressPos = event->pos(); _clickDeadspotActive = true; + + eraseMouseClicked(); } void KeyboardMouseDevice::mouseReleaseEvent(QMouseEvent* event) { @@ -121,6 +122,7 @@ void KeyboardMouseDevice::mouseMoveEvent(QMouseEvent* event) { const int CLICK_EVENT_DEADSPOT = 6; // pixels if (_clickDeadspotActive && (_mousePressPos - currentPos).manhattanLength() > CLICK_EVENT_DEADSPOT) { + eraseMouseClicked(); _clickDeadspotActive = false; } } diff --git a/libraries/model-networking/src/model-networking/MeshFace.cpp b/libraries/model-networking/src/model-networking/MeshFace.cpp deleted file mode 100644 index 8092d36aa3..0000000000 --- a/libraries/model-networking/src/model-networking/MeshFace.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// -// MeshFace.cpp -// libraries/model/src/model/ -// -// Created by Seth Alves on 2017-3-23 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include - -#include "MeshFace.h" - - -QScriptValue meshFaceToScriptValue(QScriptEngine* engine, const MeshFace &meshFace) { - QScriptValue obj = engine->newObject(); - obj.setProperty("vertices", qVectorIntToScriptValue(engine, meshFace.vertexIndices)); - return obj; -} - -void meshFaceFromScriptValue(const QScriptValue &object, MeshFace& meshFaceResult) { - qVectorIntFromScriptValue(object.property("vertices"), meshFaceResult.vertexIndices); -} - -QScriptValue qVectorMeshFaceToScriptValue(QScriptEngine* engine, const QVector& vector) { - QScriptValue array = engine->newArray(); - for (int i = 0; i < vector.size(); i++) { - array.setProperty(i, meshFaceToScriptValue(engine, vector.at(i))); - } - return array; -} - -void qVectorMeshFaceFromScriptValue(const QScriptValue& array, QVector& result) { - int length = array.property("length").toInteger(); - result.clear(); - - for (int i = 0; i < length; i++) { - MeshFace meshFace = MeshFace(); - meshFaceFromScriptValue(array.property(i), meshFace); - result << meshFace; - } -} diff --git a/libraries/model-networking/src/model-networking/MeshFace.h b/libraries/model-networking/src/model-networking/MeshFace.h deleted file mode 100644 index 3b81b372c3..0000000000 --- a/libraries/model-networking/src/model-networking/MeshFace.h +++ /dev/null @@ -1,43 +0,0 @@ -// -// MeshFace.h -// libraries/model/src/model/ -// -// Created by Seth Alves on 2017-3-23 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_MeshFace_h -#define hifi_MeshFace_h - -#include -#include -#include - -#include - -using MeshPointer = std::shared_ptr; - -class MeshFace { - -public: - MeshFace() {} - ~MeshFace() {} - - QVector vertexIndices; - // TODO -- material... -}; - -Q_DECLARE_METATYPE(MeshFace) -Q_DECLARE_METATYPE(QVector) - -QScriptValue meshFaceToScriptValue(QScriptEngine* engine, const MeshFace &meshFace); -void meshFaceFromScriptValue(const QScriptValue &object, MeshFace& meshFaceResult); -QScriptValue qVectorMeshFaceToScriptValue(QScriptEngine* engine, const QVector& vector); -void qVectorMeshFaceFromScriptValue(const QScriptValue& array, QVector& result); - - - -#endif // hifi_MeshFace_h diff --git a/libraries/model-networking/src/model-networking/MeshProxy.cpp b/libraries/model-networking/src/model-networking/MeshProxy.cpp deleted file mode 100644 index 1b6fa43c82..0000000000 --- a/libraries/model-networking/src/model-networking/MeshProxy.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -// MeshProxy.cpp -// libraries/model/src/model/ -// -// Created by Seth Alves on 2017-3-22. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include "MeshProxy.h" - - -QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in) { - return engine->newQObject(in, QScriptEngine::QtOwnership, - QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects); -} - -void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) { - out = qobject_cast(value.toQObject()); -} - -QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) { - // QScriptValueList result; - QScriptValue result = engine->newArray(); - int i = 0; - foreach (MeshProxy* const meshProxy, in) { - result.setProperty(i++, meshToScriptValue(engine, meshProxy)); - } - return result; -} - -void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out) { - QScriptValueIterator itr(value); - - qDebug() << "in meshesFromScriptValue, value.length =" << value.property("length").toInt32(); - - while(itr.hasNext()) { - itr.next(); - MeshProxy* meshProxy = qscriptvalue_cast(itr.value()); - if (meshProxy) { - out.append(meshProxy); - } else { - qDebug() << "null meshProxy"; - } - } -} diff --git a/libraries/model/src/model/Geometry.cpp b/libraries/model/src/model/Geometry.cpp index 16608ab63e..04b0db92d3 100755 --- a/libraries/model/src/model/Geometry.cpp +++ b/libraries/model/src/model/Geometry.cpp @@ -145,7 +145,7 @@ model::MeshPointer Mesh::map(std::function vertexFunc, unsigned char* resultVertexData = new unsigned char[vertexSize]; unsigned char* vertexDataCursor = resultVertexData; - for (gpu::BufferView::Index i = 0; i < numVertices; i++) { + for (gpu::BufferView::Index i = 0; i < numVertices; i ++) { glm::vec3 pos = vertexFunc(vertexBufferView.get(i)); memcpy(vertexDataCursor, &pos, sizeof(pos)); vertexDataCursor += sizeof(pos); @@ -159,7 +159,7 @@ model::MeshPointer Mesh::map(std::function vertexFunc, unsigned char* resultNormalData = new unsigned char[normalSize]; unsigned char* normalDataCursor = resultNormalData; - for (gpu::BufferView::Index i = 0; i < numNormals; i++) { + for (gpu::BufferView::Index i = 0; i < numNormals; i ++) { glm::vec3 normal = normalFunc(normalsBufferView.get(i)); memcpy(normalDataCursor, &normal, sizeof(normal)); normalDataCursor += sizeof(normal); @@ -173,7 +173,7 @@ model::MeshPointer Mesh::map(std::function vertexFunc, unsigned char* resultIndexData = new unsigned char[indexSize]; unsigned char* indexDataCursor = resultIndexData; - for (gpu::BufferView::Index i = 0; i < numIndexes; i++) { + for (gpu::BufferView::Index i = 0; i < numIndexes; i ++) { uint32_t index = indexFunc(indexBufferView.get(i)); memcpy(indexDataCursor, &index, sizeof(index)); indexDataCursor += sizeof(index); @@ -217,18 +217,19 @@ model::MeshPointer Mesh::map(std::function vertexFunc, void Mesh::forEach(std::function vertexFunc, std::function normalFunc, std::function indexFunc) { + int attributeTypeNormal = gpu::Stream::InputSlot::NORMAL; // libraries/gpu/src/gpu/Stream.h + // vertex data const gpu::BufferView& vertexBufferView = getVertexBuffer(); gpu::BufferView::Index numVertices = (gpu::BufferView::Index)getNumVertices(); - for (gpu::BufferView::Index i = 0; i < numVertices; i++) { + for (gpu::BufferView::Index i = 0; i < numVertices; i ++) { vertexFunc(vertexBufferView.get(i)); } // normal data - int attributeTypeNormal = gpu::Stream::InputSlot::NORMAL; // libraries/gpu/src/gpu/Stream.h const gpu::BufferView& normalsBufferView = getAttributeBuffer(attributeTypeNormal); - gpu::BufferView::Index numNormals = (gpu::BufferView::Index)normalsBufferView.getNumElements(); - for (gpu::BufferView::Index i = 0; i < numNormals; i++) { + gpu::BufferView::Index numNormals = (gpu::BufferView::Index) normalsBufferView.getNumElements(); + for (gpu::BufferView::Index i = 0; i < numNormals; i ++) { normalFunc(normalsBufferView.get(i)); } // TODO -- other attributes @@ -236,7 +237,7 @@ void Mesh::forEach(std::function vertexFunc, // face data const gpu::BufferView& indexBufferView = getIndexBuffer(); gpu::BufferView::Index numIndexes = (gpu::BufferView::Index)getNumIndices(); - for (gpu::BufferView::Index i = 0; i < numIndexes; i++) { + for (gpu::BufferView::Index i = 0; i < numIndexes; i ++) { indexFunc(indexBufferView.get(i)); } } diff --git a/libraries/render-utils/src/AmbientOcclusionEffect.cpp b/libraries/render-utils/src/AmbientOcclusionEffect.cpp index 3bacf85273..4a8f4d1dbc 100644 --- a/libraries/render-utils/src/AmbientOcclusionEffect.cpp +++ b/libraries/render-utils/src/AmbientOcclusionEffect.cpp @@ -73,12 +73,12 @@ void AmbientOcclusionFramebuffer::allocate() { auto width = _frameSize.x; auto height = _frameSize.y; - - _occlusionTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); + + _occlusionTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); _occlusionFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusion")); _occlusionFramebuffer->setRenderBuffer(0, _occlusionTexture); - - _occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); + + _occlusionBlurredTexture = gpu::TexturePointer(gpu::Texture::create2D(gpu::Element::COLOR_RGBA_32, width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); _occlusionBlurredFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("occlusionBlurred")); _occlusionBlurredFramebuffer->setRenderBuffer(0, _occlusionBlurredTexture); } diff --git a/libraries/render-utils/src/DebugDeferredBuffer.cpp b/libraries/render-utils/src/DebugDeferredBuffer.cpp index 9ffd94af38..d0e2859e90 100644 --- a/libraries/render-utils/src/DebugDeferredBuffer.cpp +++ b/libraries/render-utils/src/DebugDeferredBuffer.cpp @@ -76,7 +76,6 @@ static const std::string DEFAULT_ROUGHNESS_SHADER { "vec4 getFragmentColor() {" " DeferredFragment frag = unpackDeferredFragmentNoPosition(uv);" " return vec4(vec3(pow(frag.roughness, 1.0 / 2.2)), 1.0);" - // " return vec4(vec3(pow(colorRamp(frag.roughness), vec3(1.0 / 2.2))), 1.0);" " }" }; static const std::string DEFAULT_NORMAL_SHADER { diff --git a/libraries/render-utils/src/LightAmbient.slh b/libraries/render-utils/src/LightAmbient.slh index b919108115..e343d8c239 100644 --- a/libraries/render-utils/src/LightAmbient.slh +++ b/libraries/render-utils/src/LightAmbient.slh @@ -39,7 +39,7 @@ vec3 evalAmbientSpecularIrradiance(LightAmbient ambient, vec3 fragEyeDir, vec3 f <@if supportAmbientMap@> { float levels = getLightAmbientMapNumMips(ambient); - float lod = min(((roughness)* levels), levels); + float lod = min(floor((roughness)* levels), levels); specularLight = evalSkyboxLight(direction, lod).xyz; } <@endif@> diff --git a/libraries/render-utils/src/Skinning.slh b/libraries/render-utils/src/Skinning.slh index 2d1f010029..687dab536b 100644 --- a/libraries/render-utils/src/Skinning.slh +++ b/libraries/render-utils/src/Skinning.slh @@ -18,11 +18,11 @@ layout(std140) uniform skinClusterBuffer { mat4 clusterMatrices[MAX_CLUSTERS]; }; -void skinPosition(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, out vec4 skinnedPosition) { +void skinPosition(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, out vec4 skinnedPosition) { vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[(skinClusterIndex[i])]; + mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])]; float clusterWeight = skinClusterWeight[i]; newPosition += clusterMatrix * inPosition * clusterWeight; } @@ -30,13 +30,13 @@ void skinPosition(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPositio skinnedPosition = newPosition; } -void skinPositionNormal(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, +void skinPositionNormal(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, out vec4 skinnedPosition, out vec3 skinnedNormal) { vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[(skinClusterIndex[i])]; + mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])]; float clusterWeight = skinClusterWeight[i]; newPosition += clusterMatrix * inPosition * clusterWeight; newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; @@ -46,14 +46,14 @@ void skinPositionNormal(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inP skinnedNormal = newNormal.xyz; } -void skinPositionNormalTangent(ivec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, vec3 inTangent, +void skinPositionNormalTangent(vec4 skinClusterIndex, vec4 skinClusterWeight, vec4 inPosition, vec3 inNormal, vec3 inTangent, out vec4 skinnedPosition, out vec3 skinnedNormal, out vec3 skinnedTangent) { vec4 newPosition = vec4(0.0, 0.0, 0.0, 0.0); vec4 newNormal = vec4(0.0, 0.0, 0.0, 0.0); vec4 newTangent = vec4(0.0, 0.0, 0.0, 0.0); for (int i = 0; i < INDICES_PER_VERTEX; i++) { - mat4 clusterMatrix = clusterMatrices[(skinClusterIndex[i])]; + mat4 clusterMatrix = clusterMatrices[int(skinClusterIndex[i])]; float clusterWeight = skinClusterWeight[i]; newPosition += clusterMatrix * inPosition * clusterWeight; newNormal += clusterMatrix * vec4(inNormal.xyz, 0.0) * clusterWeight; diff --git a/libraries/render-utils/src/SurfaceGeometryPass.cpp b/libraries/render-utils/src/SurfaceGeometryPass.cpp index f713e3ce75..3a23e70664 100644 --- a/libraries/render-utils/src/SurfaceGeometryPass.cpp +++ b/libraries/render-utils/src/SurfaceGeometryPass.cpp @@ -72,18 +72,18 @@ void LinearDepthFramebuffer::allocate() { auto height = _frameSize.y; // For Linear Depth: - _linearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RED), width, height, + _linearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RGB), width, height, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); _linearDepthFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("linearDepth")); _linearDepthFramebuffer->setRenderBuffer(0, _linearDepthTexture); _linearDepthFramebuffer->setDepthStencilBuffer(_primaryDepthTexture, _primaryDepthTexture->getTexelFormat()); // For Downsampling: - _halfLinearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RED), _halfFrameSize.x, _halfFrameSize.y, + _halfLinearDepthTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::SCALAR, gpu::FLOAT, gpu::RGB), _halfFrameSize.x, _halfFrameSize.y, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); _halfLinearDepthTexture->autoGenerateMips(5); - _halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element::COLOR_RGBA_32, _halfFrameSize.x, _halfFrameSize.y, + _halfNormalTexture = gpu::TexturePointer(gpu::Texture::createRenderBuffer(gpu::Element(gpu::VEC3, gpu::NUINT8, gpu::RGB), _halfFrameSize.x, _halfFrameSize.y, gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_LINEAR_MIP_POINT))); _downsampleFramebuffer = gpu::FramebufferPointer(gpu::Framebuffer::create("halfLinearDepth")); diff --git a/libraries/render-utils/src/debug_deferred_buffer.slf b/libraries/render-utils/src/debug_deferred_buffer.slf index c018e5e526..079f79c06e 100644 --- a/libraries/render-utils/src/debug_deferred_buffer.slf +++ b/libraries/render-utils/src/debug_deferred_buffer.slf @@ -13,8 +13,6 @@ // <@include DeferredBufferRead.slh@> -<@include gpu/Color.slh@> -<$declareColorWheel()$> uniform sampler2D linearDepthMap; uniform sampler2D halfLinearDepthMap; diff --git a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf index 46554dd7f8..533073b224 100644 --- a/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf +++ b/libraries/render-utils/src/surfaceGeometry_downsampleDepthNormal.slf @@ -24,8 +24,8 @@ void main(void) { // Gather 2 by 2 quads from texture // Try different filters for Z - //vec4 Zeyes = textureGather(linearDepthMap, varTexCoord0, 0); - //float Zeye = min(min(Zeyes.x, Zeyes.y), min(Zeyes.z, Zeyes.w)); +// vec4 Zeyes = textureGather(linearDepthMap, varTexCoord0, 0); + // float Zeye = min(min(Zeyes.x, Zeyes.y), min(Zeyes.z, Zeyes.w)); float Zeye = texture(linearDepthMap, varTexCoord0).x; vec4 rawNormalsX = textureGather(normalMap, varTexCoord0, 0); diff --git a/libraries/model-networking/src/model-networking/MeshProxy.h b/libraries/script-engine/src/MeshProxy.h similarity index 69% rename from libraries/model-networking/src/model-networking/MeshProxy.h rename to libraries/script-engine/src/MeshProxy.h index c5b25b7895..82f5038348 100644 --- a/libraries/model-networking/src/model-networking/MeshProxy.h +++ b/libraries/script-engine/src/MeshProxy.h @@ -1,6 +1,6 @@ // // MeshProxy.h -// libraries/model/src/model/ +// libraries/script-engine/src // // Created by Seth Alves on 2017-1-27. // Copyright 2017 High Fidelity, Inc. @@ -12,10 +12,6 @@ #ifndef hifi_MeshProxy_h #define hifi_MeshProxy_h -#include -#include -#include - #include using MeshPointer = std::shared_ptr; @@ -42,11 +38,4 @@ Q_DECLARE_METATYPE(MeshProxy*); class MeshProxyList : public QList {}; // typedef and using fight with the Qt macros/templates, do this instead Q_DECLARE_METATYPE(MeshProxyList); - -QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in); -void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out); - -QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in); -void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out); - #endif // hifi_MeshProxy_h diff --git a/libraries/script-engine/src/ModelScriptingInterface.cpp b/libraries/script-engine/src/ModelScriptingInterface.cpp index f56312568e..833ac5b64d 100644 --- a/libraries/script-engine/src/ModelScriptingInterface.cpp +++ b/libraries/script-engine/src/ModelScriptingInterface.cpp @@ -12,18 +12,36 @@ #include #include #include -#include #include "ScriptEngine.h" -#include "ScriptEngineLogging.h" #include "ModelScriptingInterface.h" #include "OBJWriter.h" ModelScriptingInterface::ModelScriptingInterface(QObject* parent) : QObject(parent) { _modelScriptEngine = qobject_cast(parent); +} - qScriptRegisterSequenceMetaType>(_modelScriptEngine); - qScriptRegisterMetaType(_modelScriptEngine, meshFaceToScriptValue, meshFaceFromScriptValue); - qScriptRegisterMetaType(_modelScriptEngine, qVectorMeshFaceToScriptValue, qVectorMeshFaceFromScriptValue); +QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in) { + return engine->newQObject(in, QScriptEngine::QtOwnership, + QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects); +} + +void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) { + out = qobject_cast(value.toQObject()); +} + +QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) { + return engine->toScriptValue(in); +} + +void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out) { + QScriptValueIterator itr(value); + while(itr.hasNext()) { + itr.next(); + MeshProxy* meshProxy = qscriptvalue_cast(itr.value()); + if (meshProxy) { + out.append(meshProxy); + } + } } QString ModelScriptingInterface::meshToOBJ(MeshProxyList in) { @@ -122,6 +140,8 @@ QScriptValue ModelScriptingInterface::appendMeshes(MeshProxyList in) { return meshToScriptValue(_modelScriptEngine, resultProxy); } + + QScriptValue ModelScriptingInterface::transformMesh(glm::mat4 transform, MeshProxy* meshProxy) { if (!meshProxy) { return QScriptValue(false); @@ -137,57 +157,3 @@ QScriptValue ModelScriptingInterface::transformMesh(glm::mat4 transform, MeshPro MeshProxy* resultProxy = new MeshProxy(result); return meshToScriptValue(_modelScriptEngine, resultProxy); } - -QScriptValue ModelScriptingInterface::newMesh(const QVector& vertices, - const QVector& normals, - const QVector& faces) { - model::MeshPointer mesh(new model::Mesh()); - - // vertices - auto vertexBuffer = std::make_shared(vertices.size() * sizeof(glm::vec3), (gpu::Byte*)vertices.data()); - auto vertexBufferPtr = gpu::BufferPointer(vertexBuffer); - gpu::BufferView vertexBufferView(vertexBufferPtr, 0, vertexBufferPtr->getSize(), - sizeof(glm::vec3), gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); - mesh->setVertexBuffer(vertexBufferView); - - if (vertices.size() == normals.size()) { - // normals - auto normalBuffer = std::make_shared(normals.size() * sizeof(glm::vec3), (gpu::Byte*)normals.data()); - auto normalBufferPtr = gpu::BufferPointer(normalBuffer); - gpu::BufferView normalBufferView(normalBufferPtr, 0, normalBufferPtr->getSize(), - sizeof(glm::vec3), gpu::Element(gpu::VEC3, gpu::FLOAT, gpu::XYZ)); - mesh->addAttribute(gpu::Stream::NORMAL, normalBufferView); - } else { - qCDebug(scriptengine) << "ModelScriptingInterface::newMesh normals must be same length as vertices"; - } - - // indices (faces) - int VERTICES_PER_TRIANGLE = 3; - int indexBufferSize = faces.size() * sizeof(uint32_t) * VERTICES_PER_TRIANGLE; - unsigned char* indexData = new unsigned char[indexBufferSize]; - unsigned char* indexDataCursor = indexData; - foreach(const MeshFace& meshFace, faces) { - for (int i = 0; i < VERTICES_PER_TRIANGLE; i++) { - memcpy(indexDataCursor, &meshFace.vertexIndices[i], sizeof(uint32_t)); - indexDataCursor += sizeof(uint32_t); - } - } - auto indexBuffer = std::make_shared(indexBufferSize, (gpu::Byte*)indexData); - auto indexBufferPtr = gpu::BufferPointer(indexBuffer); - gpu::BufferView indexBufferView(indexBufferPtr, gpu::Element(gpu::SCALAR, gpu::UINT32, gpu::RAW)); - mesh->setIndexBuffer(indexBufferView); - - // parts - std::vector parts; - parts.emplace_back(model::Mesh::Part((model::Index)0, // startIndex - (model::Index)faces.size() * 3, // numIndices - (model::Index)0, // baseVertex - model::Mesh::TRIANGLES)); // topology - mesh->setPartBuffer(gpu::BufferView(new gpu::Buffer(parts.size() * sizeof(model::Mesh::Part), - (gpu::Byte*) parts.data()), gpu::Element::PART_DRAWCALL)); - - - - MeshProxy* meshProxy = new MeshProxy(mesh); - return meshToScriptValue(_modelScriptEngine, meshProxy); -} diff --git a/libraries/script-engine/src/ModelScriptingInterface.h b/libraries/script-engine/src/ModelScriptingInterface.h index d899f532d8..14789943e3 100644 --- a/libraries/script-engine/src/ModelScriptingInterface.h +++ b/libraries/script-engine/src/ModelScriptingInterface.h @@ -17,8 +17,7 @@ #include #include #include -#include -#include +#include "MeshProxy.h" using MeshPointer = std::shared_ptr; class ScriptEngine; @@ -32,12 +31,15 @@ public: Q_INVOKABLE QString meshToOBJ(MeshProxyList in); Q_INVOKABLE QScriptValue appendMeshes(MeshProxyList in); Q_INVOKABLE QScriptValue transformMesh(glm::mat4 transform, MeshProxy* meshProxy); - Q_INVOKABLE QScriptValue newMesh(const QVector& vertices, - const QVector& normals, - const QVector& faces); private: ScriptEngine* _modelScriptEngine { nullptr }; }; +QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in); +void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out); + +QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in); +void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out); + #endif // hifi_ModelScriptingInterface_h diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index c287fbcfe7..32bd7f422e 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -250,27 +250,6 @@ static QString getUsername() { } } -void TabletProxy::initialScreen(const QVariant& url) { - if (getQmlTablet()) { - pushOntoStack(url); - } else { - _initialScreen = true; - _initialPath = url; - } -} - -bool TabletProxy::isMessageDialogOpen() { - if (_qmlTabletRoot) { - QVariant result; - QMetaObject::invokeMethod(_qmlTabletRoot, "isDialogOpen",Qt::DirectConnection, - Q_RETURN_ARG(QVariant, result)); - - return result.toBool(); - } - - return false; -} - void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscreenSurface) { std::lock_guard guard(_mutex); _qmlOffscreenSurface = qmlOffscreenSurface; @@ -296,8 +275,7 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, QVariant(TABLET_SOURCE_URL))); } - // force to the tablet to go to the homescreen - loadHomeScreen(true); + gotoHomeScreen(); QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername()))); @@ -308,11 +286,6 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr QMetaObject::invokeMethod(_qmlTabletRoot, "setUsername", Q_ARG(const QVariant&, QVariant(getUsername()))); } }); - - if (_initialScreen) { - pushOntoStack(_initialPath); - _initialScreen = false; - } } else { removeButtonsFromHomeScreen(); _state = State::Uninitialized; @@ -320,9 +293,6 @@ void TabletProxy::setQmlTabletRoot(QQuickItem* qmlTabletRoot, QObject* qmlOffscr } } -void TabletProxy::gotoHomeScreen() { - loadHomeScreen(false); -} void TabletProxy::gotoMenuScreen(const QString& submenu) { QObject* root = nullptr; @@ -361,53 +331,11 @@ void TabletProxy::loadQMLSource(const QVariant& path) { emit screenChanged(QVariant("QML"), path); QMetaObject::invokeMethod(root, "setShown", Q_ARG(const QVariant&, QVariant(true))); } - } else { - qCDebug(scriptengine) << "tablet cannot load QML because _qmlTabletRoot is null"; } } -void TabletProxy::pushOntoStack(const QVariant& path) { - if (_qmlTabletRoot) { - auto stack = _qmlTabletRoot->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); - } else { - loadQMLSource(path); - } - } else if (_desktopWindow) { - auto stack = _desktopWindow->asQuickItem()->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); - } else { - qCDebug(scriptengine) << "tablet cannot push QML because _desktopWindow doesn't have child stack"; - } - } else { - qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot or _desktopWindow is null"; - } -} - -void TabletProxy::popFromStack() { - if (_qmlTabletRoot) { - auto stack = _qmlTabletRoot->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "popSource"); - } else { - qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack"; - } - } else if (_desktopWindow) { - auto stack = _desktopWindow->asQuickItem()->findChild("stack"); - if (stack) { - QMetaObject::invokeMethod(stack, "popSource"); - } else { - qCDebug(scriptengine) << "tablet cannot pop QML because _desktopWindow doesn't have child stack"; - } - } else { - qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot or _desktopWindow is null"; - } -} - -void TabletProxy::loadHomeScreen(bool forceOntoHomeScreen) { - if ((_state != State::Home && _state != State::Uninitialized) || forceOntoHomeScreen) { +void TabletProxy::gotoHomeScreen() { + if (_state != State::Home) { if (!_toolbarMode && _qmlTabletRoot) { auto loader = _qmlTabletRoot->findChild("loader"); QObject::connect(loader, SIGNAL(loaded()), this, SLOT(addButtonsToHomeScreen()), Qt::DirectConnection); @@ -632,7 +560,7 @@ QQuickItem* TabletProxy::getQmlTablet() const { } QQuickItem* TabletProxy::getQmlMenu() const { - if (!_qmlTabletRoot) { + if (!_qmlTabletRoot) { return nullptr; } diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index 2e7b91fa4c..e450923758 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -56,14 +56,7 @@ public: QQuickWindow* getTabletWindow(); QObject* getFlags(); -signals: - /** jsdoc - * Signaled when a tablet message or dialog is created - * @function TabletProxy#tabletNotification - * @returns {Signal} - */ - void tabletNotification(); - + private: void processMenuEvents(QObject* object, const QKeyEvent* event); void processTabletEvents(QObject* object, const QKeyEvent* event); @@ -97,8 +90,6 @@ public: bool getToolbarMode() const { return _toolbarMode; } void setToolbarMode(bool toolbarMode); - void initialScreen(const QVariant& url); - /**jsdoc * transition to the home screen * @function TabletProxy#gotoHomeScreen @@ -115,14 +106,6 @@ public: Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl); Q_INVOKABLE void loadQMLSource(const QVariant& path); - Q_INVOKABLE void pushOntoStack(const QVariant& path); - Q_INVOKABLE void popFromStack(); - - /** jsdoc - * Check if the tablet has a message dialog open - * @function TabletProxy#isMessageDialogOpen - */ - Q_INVOKABLE bool isMessageDialogOpen(); /**jsdoc * Creates a new button, adds it to this and returns it. @@ -167,14 +150,8 @@ public: */ Q_INVOKABLE void sendToQml(QVariant msg); - /**jsdoc - * Check if the tablet is on the homescreen - * @function TabletProxy#onHomeScreen() - */ Q_INVOKABLE bool onHomeScreen(); - QQuickItem* getTabletRoot() const { return _qmlTabletRoot; } - QObject* getTabletSurface(); QQuickItem* getQmlTablet() const; @@ -211,12 +188,9 @@ protected slots: void desktopWindowClosed(); protected: void removeButtonsFromHomeScreen(); - void loadHomeScreen(bool forceOntoHomeScreen); void addButtonsToToolbar(); void removeButtonsFromToolbar(); - bool _initialScreen { false }; - QVariant _initialPath { "" }; QString _name; std::mutex _mutex; std::vector> _tabletButtonProxies; diff --git a/libraries/shared/src/AABox.cpp b/libraries/shared/src/AABox.cpp index 3f3146cc04..89d5ce709d 100644 --- a/libraries/shared/src/AABox.cpp +++ b/libraries/shared/src/AABox.cpp @@ -436,38 +436,6 @@ glm::vec3 AABox::getClosestPointOnFace(const glm::vec4& origin, const glm::vec4& return getClosestPointOnFace(glm::vec3(origin), face); } -bool AABox::touchesAAEllipsoid(const glm::vec3& center, const glm::vec3& radials) const { - // handle case where ellipsoid's alix-aligned box doesn't touch this AABox - if (_corner.x - radials.x > center.x || - _corner.y - radials.y > center.y || - _corner.z - radials.z > center.z || - _corner.x + _scale.x + radials.x < center.x || - _corner.y + _scale.y + radials.y < center.y || - _corner.z + _scale.z + radials.z < center.z) { - return false; - } - - // handle case where ellipsoid is entirely inside this AABox - if (contains(center)) { - return true; - } - - for (int i = 0; i < FACE_COUNT; i++) { - glm::vec3 closest = getClosestPointOnFace(center, (BoxFace)i) - center; - float x = closest.x; - float y = closest.y; - float z = closest.z; - float a = radials.x; - float b = radials.y; - float c = radials.z; - if (x*x/(a*a) + y*y/(b*b) + z*z/(c*c) < 1.0f) { - return true; - } - } - return false; -} - - glm::vec4 AABox::getPlane(BoxFace face) const { switch (face) { case MIN_X_FACE: return glm::vec4(-1.0f, 0.0f, 0.0f, _corner.x); diff --git a/libraries/shared/src/AABox.h b/libraries/shared/src/AABox.h index a53cc26163..ccc7b6e302 100644 --- a/libraries/shared/src/AABox.h +++ b/libraries/shared/src/AABox.h @@ -70,7 +70,6 @@ public: bool findRayIntersection(const glm::vec3& origin, const glm::vec3& direction, float& distance, BoxFace& face, glm::vec3& surfaceNormal) const; bool touchesSphere(const glm::vec3& center, float radius) const; // fast but may generate false positives - bool touchesAAEllipsoid(const glm::vec3& center, const glm::vec3& radials) const; bool findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration) const; bool findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) const; diff --git a/libraries/shared/src/PointerEvent.cpp b/libraries/shared/src/PointerEvent.cpp index 7ec5e78b9f..e429204e94 100644 --- a/libraries/shared/src/PointerEvent.cpp +++ b/libraries/shared/src/PointerEvent.cpp @@ -25,9 +25,9 @@ PointerEvent::PointerEvent() { } PointerEvent::PointerEvent(EventType type, uint32_t id, - const glm::vec2& pos2D, const glm::vec3& pos3D, - const glm::vec3& normal, const glm::vec3& direction, - Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers) : + const glm::vec2& pos2D, const glm::vec3& pos3D, + const glm::vec3& normal, const glm::vec3& direction, + Button button, uint32_t buttons) : _type(type), _id(id), _pos2D(pos2D), @@ -35,8 +35,7 @@ PointerEvent::PointerEvent(EventType type, uint32_t id, _normal(normal), _direction(direction), _button(button), - _buttons(buttons), - _keyboardModifiers(keyboardModifiers) + _buttons(buttons) { ; } @@ -123,8 +122,6 @@ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEve obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton)); obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton)); - obj.setProperty("keyboardModifiers", QScriptValue(event.getKeyboardModifiers())); - return obj; } @@ -143,7 +140,7 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve } QScriptValue id = object.property("id"); - event._id = id.isNumber() ? (uint32_t)id.toNumber() : 0; + event._id = type.isNumber() ? (uint32_t)type.toNumber() : 0; glm::vec2 pos2D; vec2FromScriptValue(object.property("pos2D"), event._pos2D); @@ -158,8 +155,7 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve vec3FromScriptValue(object.property("direction"), event._direction); QScriptValue button = object.property("button"); - QString buttonStr = type.isString() ? button.toString() : "NoButtons"; - + QString buttonStr = type.isString() ? type.toString() : "NoButtons"; if (buttonStr == "Primary") { event._button = PrimaryButton; } else if (buttonStr == "Secondary") { @@ -183,30 +179,5 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve if (tertiary) { event._buttons |= TertiaryButton; } - - event._keyboardModifiers = (Qt::KeyboardModifiers)(object.property("keyboardModifiers").toUInt32()); } } - -static const char* typeToStringMap[PointerEvent::NumEventTypes] = { "Press", "DoublePress", "Release", "Move" }; -static const char* buttonsToStringMap[8] = { - "NoButtons", - "PrimaryButton", - "SecondaryButton", - "PrimaryButton | SecondaryButton", - "TertiaryButton", - "PrimaryButton | TertiaryButton", - "SecondaryButton | TertiaryButton", - "PrimaryButton | SecondaryButton | TertiaryButton", -}; - -QDebug& operator<<(QDebug& dbg, const PointerEvent& p) { - dbg.nospace() << "PointerEvent, type = " << typeToStringMap[p.getType()] << ", id = " << p.getID(); - dbg.nospace() << ", pos2D = (" << p.getPos2D().x << ", " << p.getPos2D().y; - dbg.nospace() << "), pos3D = (" << p.getPos3D().x << ", " << p.getPos3D().y << ", " << p.getPos3D().z; - dbg.nospace() << "), normal = (" << p.getNormal().x << ", " << p.getNormal().y << ", " << p.getNormal().z; - dbg.nospace() << "), dir = (" << p.getDirection().x << ", " << p.getDirection().y << ", " << p.getDirection().z; - dbg.nospace() << "), button = " << buttonsToStringMap[p.getButton()] << " " << (int)p.getButton(); - dbg.nospace() << ", buttons = " << buttonsToStringMap[p.getButtons()]; - return dbg; -} diff --git a/libraries/shared/src/PointerEvent.h b/libraries/shared/src/PointerEvent.h index cdea0aa3ed..166c4be592 100644 --- a/libraries/shared/src/PointerEvent.h +++ b/libraries/shared/src/PointerEvent.h @@ -12,8 +12,6 @@ #ifndef hifi_PointerEvent_h #define hifi_PointerEvent_h -#include - #include #include #include @@ -31,15 +29,14 @@ public: Press, // A button has just been pressed DoublePress, // A button has just been double pressed Release, // A button has just been released - Move, // The pointer has just moved - NumEventTypes + Move // The pointer has just moved }; PointerEvent(); PointerEvent(EventType type, uint32_t id, const glm::vec2& pos2D, const glm::vec3& pos3D, const glm::vec3& normal, const glm::vec3& direction, - Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers); + Button button, uint32_t buttons); static QScriptValue toScriptValue(QScriptEngine* engine, const PointerEvent& event); static void fromScriptValue(const QScriptValue& object, PointerEvent& event); @@ -54,7 +51,6 @@ public: const glm::vec3& getDirection() const { return _direction; } Button getButton() const { return _button; } uint32_t getButtons() const { return _buttons; } - Qt::KeyboardModifiers getKeyboardModifiers() const { return _keyboardModifiers; } private: EventType _type; @@ -66,11 +62,8 @@ private: Button _button { NoButtons }; // button assosiated with this event, (if type is Press, this will be the button that is pressed) uint32_t _buttons { NoButtons }; // the current state of all the buttons. - Qt::KeyboardModifiers _keyboardModifiers; // set of keys held when event was generated }; -QDebug& operator<<(QDebug& dbg, const PointerEvent& p); - Q_DECLARE_METATYPE(PointerEvent) #endif // hifi_PointerEvent_h diff --git a/libraries/shared/src/RegisteredMetaTypes.cpp b/libraries/shared/src/RegisteredMetaTypes.cpp index 70067b93f3..7f12d6cc00 100644 --- a/libraries/shared/src/RegisteredMetaTypes.cpp +++ b/libraries/shared/src/RegisteredMetaTypes.cpp @@ -43,7 +43,6 @@ void registerMetaTypes(QScriptEngine* engine) { qScriptRegisterMetaType(engine, qVectorQuatToScriptValue, qVectorQuatFromScriptValue); qScriptRegisterMetaType(engine, qVectorBoolToScriptValue, qVectorBoolFromScriptValue); qScriptRegisterMetaType(engine, qVectorFloatToScriptValue, qVectorFloatFromScriptValue); - qScriptRegisterMetaType(engine, qVectorIntToScriptValue, qVectorIntFromScriptValue); qScriptRegisterMetaType(engine, vec2toScriptValue, vec2FromScriptValue); qScriptRegisterMetaType(engine, quatToScriptValue, quatFromScriptValue); qScriptRegisterMetaType(engine, qRectToScriptValue, qRectFromScriptValue); @@ -387,15 +386,6 @@ QScriptValue qVectorFloatToScriptValue(QScriptEngine* engine, const QVector& vector) { - QScriptValue array = engine->newArray(); - for (int i = 0; i < vector.size(); i++) { - int num = vector.at(i); - array.setProperty(i, QScriptValue(num)); - } - return array; -} - void qVectorFloatFromScriptValue(const QScriptValue& array, QVector& vector) { int length = array.property("length").toInteger(); @@ -403,15 +393,6 @@ void qVectorFloatFromScriptValue(const QScriptValue& array, QVector& vect vector << array.property(i).toVariant().toFloat(); } } - -void qVectorIntFromScriptValue(const QScriptValue& array, QVector& vector) { - int length = array.property("length").toInteger(); - - for (int i = 0; i < length; i++) { - vector << array.property(i).toVariant().toInt(); - } -} - // QVector qVectorVec3FromScriptValue(const QScriptValue& array){ QVector newVector; diff --git a/libraries/shared/src/RegisteredMetaTypes.h b/libraries/shared/src/RegisteredMetaTypes.h index 8a15f62eed..498a8b3b3a 100644 --- a/libraries/shared/src/RegisteredMetaTypes.h +++ b/libraries/shared/src/RegisteredMetaTypes.h @@ -113,10 +113,6 @@ QScriptValue qVectorFloatToScriptValue(QScriptEngine* engine, const QVector& vector); QVector qVectorFloatFromScriptValue(const QScriptValue& array); -// vector -QScriptValue qVectorIntToScriptValue(QScriptEngine* engine, const QVector& vector); -void qVectorIntFromScriptValue(const QScriptValue& array, QVector& vector); - QVector qVectorQUuidFromScriptValue(const QScriptValue& array); QScriptValue aaCubeToScriptValue(QScriptEngine* engine, const AACube& aaCube); diff --git a/libraries/shared/src/shared/GlobalAppProperties.cpp b/libraries/shared/src/shared/GlobalAppProperties.cpp index b0ba0bf83d..f2d8990708 100644 --- a/libraries/shared/src/shared/GlobalAppProperties.cpp +++ b/libraries/shared/src/shared/GlobalAppProperties.cpp @@ -16,7 +16,6 @@ namespace hifi { namespace properties { const char* OCULUS_STORE = "com.highfidelity.oculusStore"; const char* TEST = "com.highfidelity.test"; const char* TRACING = "com.highfidelity.tracing"; - const char* HMD = "com.highfidelity.hmd"; namespace gl { const char* BACKEND = "com.highfidelity.gl.backend"; diff --git a/libraries/shared/src/shared/GlobalAppProperties.h b/libraries/shared/src/shared/GlobalAppProperties.h index b1811586ba..609f2afd94 100644 --- a/libraries/shared/src/shared/GlobalAppProperties.h +++ b/libraries/shared/src/shared/GlobalAppProperties.h @@ -18,7 +18,6 @@ namespace hifi { namespace properties { extern const char* OCULUS_STORE; extern const char* TEST; extern const char* TRACING; - extern const char* HMD; namespace gl { extern const char* BACKEND; diff --git a/libraries/ui/CMakeLists.txt b/libraries/ui/CMakeLists.txt index f2b48446fe..cc2382926f 100644 --- a/libraries/ui/CMakeLists.txt +++ b/libraries/ui/CMakeLists.txt @@ -1,3 +1,3 @@ set(TARGET_NAME ui) setup_hifi_library(OpenGL Network Qml Quick Script WebChannel WebSockets XmlPatterns) -link_hifi_libraries(shared networking gl script-engine) +link_hifi_libraries(shared networking gl) diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 1cb9045e79..7724a409f0 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -19,8 +19,7 @@ #include #include -#include -#include + #include "FileDialogHelper.h" #include "VrMenu.h" @@ -211,20 +210,9 @@ QQuickItem* OffscreenUi::createMessageBox(Icon icon, const QString& title, const map.insert("buttons", buttons.operator int()); map.insert("defaultButton", defaultButton); QVariant result; - bool invokeResult; - auto tabletScriptingInterface = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode()) { - invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - invokeResult = QMetaObject::invokeMethod(tabletRoot, "messageBox", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - emit tabletScriptingInterface->tabletNotification(); - } + bool invokeResult = QMetaObject::invokeMethod(_desktop, "messageBox", + Q_RETURN_ARG(QVariant, result), + Q_ARG(QVariant, QVariant::fromValue(map))); if (!invokeResult) { qWarning() << "Failed to create message box"; @@ -417,22 +405,10 @@ QQuickItem* OffscreenUi::createInputDialog(const Icon icon, const QString& title map.insert("label", label); map.insert("current", current); QVariant result; + bool invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog", + Q_RETURN_ARG(QVariant, result), + Q_ARG(QVariant, QVariant::fromValue(map))); - auto tabletScriptingInterface = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - - bool invokeResult; - if (tablet->getToolbarMode()) { - invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - emit tabletScriptingInterface->tabletNotification(); - } if (!invokeResult) { qWarning() << "Failed to create message box"; return nullptr; @@ -446,22 +422,10 @@ QQuickItem* OffscreenUi::createCustomInputDialog(const Icon icon, const QString& map.insert("title", title); map.insert("icon", icon); QVariant result; - auto tabletScriptingInterface = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + bool invokeResult = QMetaObject::invokeMethod(_desktop, "customInputDialog", + Q_RETURN_ARG(QVariant, result), + Q_ARG(QVariant, QVariant::fromValue(map))); - bool invokeResult; - if (tablet->getToolbarMode()) { - invokeResult = QMetaObject::invokeMethod(_desktop, "inputDialog", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - invokeResult = QMetaObject::invokeMethod(tabletRoot, "inputDialog", - Q_RETURN_ARG(QVariant, result), - Q_ARG(QVariant, QVariant::fromValue(map))); - emit tabletScriptingInterface->tabletNotification(); - } - if (!invokeResult) { qWarning() << "Failed to create custom message box"; return nullptr; @@ -605,20 +569,9 @@ private slots: QString OffscreenUi::fileDialog(const QVariantMap& properties) { QVariant buildDialogResult; - bool invokeResult; - auto tabletScriptingInterface = DependencyManager::get(); - TabletProxy* tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); - if (tablet->getToolbarMode()) { - invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog", - Q_RETURN_ARG(QVariant, buildDialogResult), - Q_ARG(QVariant, QVariant::fromValue(properties))); - } else { - QQuickItem* tabletRoot = tablet->getTabletRoot(); - invokeResult = QMetaObject::invokeMethod(tabletRoot, "fileDialog", - Q_RETURN_ARG(QVariant, buildDialogResult), - Q_ARG(QVariant, QVariant::fromValue(properties))); - emit tabletScriptingInterface->tabletNotification(); - } + bool invokeResult = QMetaObject::invokeMethod(_desktop, "fileDialog", + Q_RETURN_ARG(QVariant, buildDialogResult), + Q_ARG(QVariant, QVariant::fromValue(properties))); if (!invokeResult) { qWarning() << "Failed to create file open dialog"; diff --git a/libraries/ui/src/ui/Menu.cpp b/libraries/ui/src/ui/Menu.cpp index 50833e90fc..a793942056 100644 --- a/libraries/ui/src/ui/Menu.cpp +++ b/libraries/ui/src/ui/Menu.cpp @@ -471,10 +471,10 @@ void Menu::removeSeparator(const QString& menuName, const QString& separatorName int textAt = findPositionOfMenuItem(menu, separatorName); QList menuActions = menu->actions(); if (textAt > 0 && textAt < menuActions.size()) { + QAction* separatorText = menuActions[textAt]; QAction* separatorLine = menuActions[textAt - 1]; if (separatorLine) { if (separatorLine->isSeparator()) { - QAction* separatorText = menuActions[textAt]; menu->removeAction(separatorText); menu->removeAction(separatorLine); separatorRemoved = true; diff --git a/script-archive/example/games/grabHockey.js b/script-archive/example/games/grabHockey.js index 3f2a2fcf91..961a8af6ad 100644 --- a/script-archive/example/games/grabHockey.js +++ b/script-archive/example/games/grabHockey.js @@ -142,8 +142,7 @@ function mousePressEvent(event) { if (!pickResults.intersects) { return; } - var isDynamic = Entites.getEntityProperties(pickResults.entityID, "dynamic").dynamic; - if (isDynamic) { + if (pickResults.properties.dynamic) { grabbedEntity = pickResults.entityID; var props = Entities.getEntityProperties(grabbedEntity) originalGravity = props.gravity; diff --git a/script-archive/example/games/hydraGrabHockey.js b/script-archive/example/games/hydraGrabHockey.js index e357735fe5..e7d6746309 100644 --- a/script-archive/example/games/hydraGrabHockey.js +++ b/script-archive/example/games/hydraGrabHockey.js @@ -190,10 +190,7 @@ function controller(side) { direction: Vec3.normalize(Vec3.subtract(this.tipPosition, this.palmPosition)) }; var intersection = getRayIntersection(pickRay, true); - - var isDynamic = Entites.getEntityProperties(intersection.entityID, "dynamic").dynamic; - - if (intersection.intersects && isDynamic) { + if (intersection.intersects && intersection.properties.dynamic) { this.laserWasHovered = true; if (this.triggerHeld && !this.grabbing) { this.grab(intersection.entityID); diff --git a/script-archive/example/scripts/rayPickExample.js b/script-archive/example/scripts/rayPickExample.js index 3687176af1..d85138211e 100644 --- a/script-archive/example/scripts/rayPickExample.js +++ b/script-archive/example/scripts/rayPickExample.js @@ -38,6 +38,7 @@ function mouseMoveEvent(event) { if (intersection.intersects) { print("intersection entityID=" + intersection.entityID); + print("intersection properties.modelURL=" + intersection.properties.modelURL); print("intersection face=" + intersection.face); print("intersection distance=" + intersection.distance); print("intersection intersection.x/y/z=" + intersection.intersection.x + ", " diff --git a/script-archive/painting/whiteboard/whiteboardEntityScript.js b/script-archive/painting/whiteboard/whiteboardEntityScript.js index 01497b406d..181932c7cb 100644 --- a/script-archive/painting/whiteboard/whiteboardEntityScript.js +++ b/script-archive/painting/whiteboard/whiteboardEntityScript.js @@ -77,8 +77,6 @@ //Comment out above line and uncomment below line to see difference in performance between using a whitelist, and not using one // this.intersection = Entities.findRayIntersection(pickRay, true); - var type = Entites.getEntityProperties(this.intersection.entityID, "type").type; - if (this.intersection.intersects) { var distance = Vec3.distance(handPosition, this.intersection.intersection); if (distance < MAX_DISTANCE) { @@ -100,7 +98,7 @@ this.oldPosition = null; } } - } else if (type !== "Unknown") { + } else if (this.intersection.properties.type !== "Unknown") { //Sometimes ray will pick against an invisible object with type unkown... so if type is unknown, ignore this.stopPainting(); } diff --git a/script-archive/vrShop/item/shopItemGrab.js b/script-archive/vrShop/item/shopItemGrab.js index 2b63ca1b53..a7226675eb 100644 --- a/script-archive/vrShop/item/shopItemGrab.js +++ b/script-archive/vrShop/item/shopItemGrab.js @@ -382,10 +382,7 @@ function MyController(hand) { var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA); - var properties = Entites.getEntityProperties(intersection.entityID, ["locked", "name"]); - - - if (properties.name == "Grab Debug Entity") { + if (intersection.properties.name == "Grab Debug Entity") { continue; } @@ -402,7 +399,7 @@ function MyController(hand) { this.grabbedEntity = intersection.entityID; this.setState(STATE_NEAR_TRIGGER); return; - } else if (!properties.locked) { + } else if (!intersection.properties.locked) { var ownerObj = getEntityCustomData('ownerKey', intersection.entityID, null); if (ownerObj == null || ownerObj.ownerID === MyAvatar.sessionUUID) { //I can only grab new or already mine items diff --git a/scripts/defaultScripts.js b/scripts/defaultScripts.js index d557083cf2..240c1de4c3 100644 --- a/scripts/defaultScripts.js +++ b/scripts/defaultScripts.js @@ -11,7 +11,7 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -var DEFAULT_SCRIPTS_COMBINED = [ +var DEFAULT_SCRIPTS = [ "system/progress.js", "system/away.js", "system/audio.js", @@ -22,19 +22,22 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/help.js", "system/pal.js", // "system/mod.js", // older UX, if you prefer "system/makeUserConnection.js", - "system/tablet-goto.js", + "system/goto.js", "system/marketplaces/marketplaces.js", "system/edit.js", - "system/tablet-users.js", "system/selectAudioDevice.js", "system/notifications.js", + "system/controllers/controllerDisplayManager.js", + "system/controllers/handControllerGrab.js", + "system/controllers/handControllerPointer.js", + "system/controllers/squeezeHands.js", + "system/controllers/grab.js", + "system/controllers/teleport.js", + "system/controllers/toggleAdvancedMovementForHandControllers.js", "system/dialTone.js", "system/firstPersonHMD.js", "system/tablet-ui/tabletUI.js" ]; -var DEFAULT_SCRIPTS_SEPARATE = [ - "system/controllers/controllerScripts.js" -]; // add a menu item for debugging var MENU_CATEGORY = "Developer"; @@ -61,24 +64,16 @@ if (Menu.menuExists(MENU_CATEGORY) && !Menu.menuItemExists(MENU_CATEGORY, MENU_I }); } -function loadSeparateDefaults() { - for (var i in DEFAULT_SCRIPTS_SEPARATE) { - Script.load(DEFAULT_SCRIPTS_SEPARATE[i]); - } -} - function runDefaultsTogether() { - for (var i in DEFAULT_SCRIPTS_COMBINED) { - Script.include(DEFAULT_SCRIPTS_COMBINED[i]); + for (var j in DEFAULT_SCRIPTS) { + Script.include(DEFAULT_SCRIPTS[j]); } - loadSeparateDefaults(); } function runDefaultsSeparately() { - for (var i in DEFAULT_SCRIPTS_COMBINED) { - Script.load(DEFAULT_SCRIPTS_COMBINED[i]); + for (var i in DEFAULT_SCRIPTS) { + Script.load(DEFAULT_SCRIPTS[i]); } - loadSeparateDefaults(); } // start all scripts diff --git a/scripts/developer/tests/sliderTest.html b/scripts/developer/tests/sliderTest.html deleted file mode 100644 index a672cfeaf8..0000000000 --- a/scripts/developer/tests/sliderTest.html +++ /dev/null @@ -1,157 +0,0 @@ - - - - Slider Test - - - - - - - - - -
-

Slider Test

-
-
-

Native Input Range Slider

-

- -

-

Bootstrap Slider

-

- -

-
- - - - - - - \ No newline at end of file diff --git a/scripts/developer/tests/sliderTestMain.js b/scripts/developer/tests/sliderTestMain.js deleted file mode 100644 index 22bf4fa911..0000000000 --- a/scripts/developer/tests/sliderTestMain.js +++ /dev/null @@ -1,35 +0,0 @@ -(function () { - var HTML_URL = Script.resolvePath("sliderTest.html"); - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - var button = tablet.addButton({ - text: "SLIDER" - }); - - function onClicked() { - tablet.gotoWebScreen(HTML_URL); - } - - button.clicked.connect(onClicked); - - var onSliderTestScreen = false; - function onScreenChanged(type, url) { - if (type === "Web" && url === HTML_URL) { - // when switching to the slider page, change inputMode to "Mouse", this should make the sliders work. - onSliderTestScreen = true; - Overlays.editOverlay(HMD.tabletScreenID, { inputMode: "Mouse" }); - } else if (onSliderTestScreen) { - // when switching off of the slider page, change inputMode to back to "Touch". - onSliderTestScreen = false; - Overlays.editOverlay(HMD.tabletScreenID, { inputMode: "Touch" }); - } - } - - tablet.screenChanged.connect(onScreenChanged); - - function cleanup() { - tablet.removeButton(button); - tablet.screenChanged.disconnect(onScreenChanged); - } - Script.scriptEnding.connect(cleanup); - -}()); diff --git a/scripts/developer/utilities/audio/TabletStats.qml b/scripts/developer/utilities/audio/TabletStats.qml deleted file mode 100644 index 130b90f032..0000000000 --- a/scripts/developer/utilities/audio/TabletStats.qml +++ /dev/null @@ -1,89 +0,0 @@ -// -// TabletStats.qml -// scripts/developer/utilities/audio -// -// Created by David Rowe on 3 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html -// -import QtQuick 2.5 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 - -import "../../../../resources/qml/styles-uit" - -Item { - id: dialog - width: 480 - height: 720 - - HifiConstants { id: hifi } - - Rectangle { - id: header - height: 90 - anchors { - top: parent.top - left: parent.left - right: parent.right - } - z: 100 - - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#1e1e1e" - } - } - - RalewayBold { - text: "Audio Interface Statistics" - size: 26 - color: "#34a2c7" - anchors.verticalCenter: parent.verticalCenter - anchors.left: parent.left - anchors.leftMargin: hifi.dimensions.contentMargin.x // ####### hifi is not defined - } - } - - Rectangle { - id: main - anchors { - top: header.bottom - bottom: parent.bottom - left: parent.left - right: parent.right - } - - gradient: Gradient { - GradientStop { - position: 0 - color: "#2b2b2b" - } - - GradientStop { - position: 1 - color: "#0f212e" - } - } - - Flickable { - id: scrollView - width: parent.width - height: parent.height - contentWidth: parent.width - contentHeight: stats.height - - Stats { - id: stats - } - } - } -} diff --git a/scripts/developer/utilities/audio/stats.js b/scripts/developer/utilities/audio/stats.js index 382e14df5f..493271ac99 100644 --- a/scripts/developer/utilities/audio/stats.js +++ b/scripts/developer/utilities/audio/stats.js @@ -9,23 +9,17 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -if (HMD.active && !Settings.getValue("HUDUIEnabled")) { - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - var qml = Script.resolvePath("TabletStats.qml"); - tablet.loadQMLSource(qml); - Script.stop(); +var INITIAL_WIDTH = 400; +var INITIAL_OFFSET = 50; -} else { - var INITIAL_WIDTH = 400; - var INITIAL_OFFSET = 50; +// Set up the qml ui +var qml = Script.resolvePath('stats.qml'); +var window = new OverlayWindow({ + title: 'Audio Interface Statistics', + source: qml, + width: 500, height: 520 // stats.qml may be too large for some screens +}); +window.setPosition(INITIAL_OFFSET, INITIAL_OFFSET); - var qml = Script.resolvePath("Stats.qml"); - var window = new OverlayWindow({ - title: "Audio Interface Statistics", - source: qml, - width: 500, height: 520 // stats.qml may be too large for some screens - }); - window.setPosition(INITIAL_OFFSET, INITIAL_OFFSET); +window.closed.connect(function() { Script.stop(); }); - window.closed.connect(function () { Script.stop(); }); -} diff --git a/scripts/developer/utilities/audio/Stats.qml b/scripts/developer/utilities/audio/stats.qml similarity index 93% rename from scripts/developer/utilities/audio/Stats.qml rename to scripts/developer/utilities/audio/stats.qml index 7f559ea664..346e5e3544 100644 --- a/scripts/developer/utilities/audio/Stats.qml +++ b/scripts/developer/utilities/audio/stats.qml @@ -1,5 +1,5 @@ // -// Stats.qml +// stats.qml // scripts/developer/utilities/audio // // Created by Zach Pomerantz on 9/22/2016 @@ -12,21 +12,22 @@ import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 -import "../../../../resources/qml/controls-uit" as HifiControls - Column { id: stats width: parent.width + height: parent.height property bool showGraphs: toggleGraphs.checked - Item { + RowLayout { width: parent.width height: 30 - HifiControls.Button { + Button { id: toggleGraphs property bool checked: false - anchors.horizontalCenter: parent.horizontalCenter + + Layout.alignment: Qt.AlignCenter + text: checked ? "Hide graphs" : "Show graphs" onClicked: function() { checked = !checked; } } @@ -34,9 +35,11 @@ Column { Grid { width: parent.width + height: parent.height - 30 Column { width: parent.width / 2 + height: parent.height Section { label: "Latency" @@ -73,6 +76,7 @@ Column { Column { width: parent.width / 2 + height: parent.height Section { label: "Mixer (upstream)" @@ -88,3 +92,4 @@ Column { } } } + diff --git a/scripts/system/audio.js b/scripts/system/audio.js index 7bc8676a2e..beeb8609d8 100644 --- a/scripts/system/audio.js +++ b/scripts/system/audio.js @@ -45,8 +45,7 @@ function onClicked() { var entity = HMD.tabletID; Entities.editEntity(entity, { textures: JSON.stringify({ "tex.close": HOME_BUTTON_TEXTURE }) }); shouldActivateButton = true; - shouldActivateButton = true; - tablet.loadQMLSource("../Audio.qml"); + tablet.gotoMenuScreen("Audio"); onAudioScreen = true; } } diff --git a/scripts/system/controllers/controllerScripts.js b/scripts/system/controllers/controllerScripts.js deleted file mode 100644 index df11a1e5be..0000000000 --- a/scripts/system/controllers/controllerScripts.js +++ /dev/null @@ -1,41 +0,0 @@ -"use strict"; - -// controllerScripts.js -// -// Created by David Rowe on 15 Mar 2017. -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -var CONTOLLER_SCRIPTS = [ - "squeezeHands.js", - "controllerDisplayManager.js", - "handControllerGrab.js", - "handControllerPointer.js", - "grab.js", - "teleport.js", - "toggleAdvancedMovementForHandControllers.js", -]; - -var DEBUG_MENU_ITEM = "Debug defaultScripts.js"; - - -function runDefaultsTogether() { - for (var j in CONTOLLER_SCRIPTS) { - Script.include(CONTOLLER_SCRIPTS[j]); - } -} - -function runDefaultsSeparately() { - for (var i in CONTOLLER_SCRIPTS) { - Script.load(CONTOLLER_SCRIPTS[i]); - } -} - -if (Menu.isOptionChecked(DEBUG_MENU_ITEM)) { - runDefaultsSeparately(); -} else { - runDefaultsTogether(); -} diff --git a/scripts/system/controllers/grab.js b/scripts/system/controllers/grab.js index 10f477b3af..05b2eefeb5 100644 --- a/scripts/system/controllers/grab.js +++ b/scripts/system/controllers/grab.js @@ -343,8 +343,7 @@ Grabber.prototype.pressEvent = function(event) { return; } - var isDynamic = Entities.getEntityProperties(pickResults.entityID, "dynamic").dynamic; - if (!isDynamic) { + if (!pickResults.properties.dynamic) { // only grab dynamic objects return; } diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 9a6760a37b..e83e31aaa5 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -13,8 +13,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, - Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, - setGrabCommunications, Menu, HMD, isInEditMode */ + Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, setGrabCommunications, + Menu, HMD, isInEditMode */ /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ (function() { // BEGIN LOCAL_SCOPE @@ -71,6 +71,12 @@ var EQUIP_SPHERE_SCALE_FACTOR = 0.65; var WEB_DISPLAY_STYLUS_DISTANCE = 0.5; var WEB_STYLUS_LENGTH = 0.2; var WEB_TOUCH_Y_OFFSET = 0.05; // how far forward (or back with a negative number) to slide stylus in hand +var WEB_TOUCH_TOO_CLOSE = 0.03; // if the stylus is pushed far though the web surface, don't consider it touching +var WEB_TOUCH_Y_TOUCH_DEADZONE_SIZE = 0.01; + +var FINGER_TOUCH_Y_OFFSET = -0.02; +var FINGER_TOUCH_MIN = -0.01 - FINGER_TOUCH_Y_OFFSET; +var FINGER_TOUCH_MAX = 0.01 - FINGER_TOUCH_Y_OFFSET; // // distant manipulation @@ -131,6 +137,7 @@ var GRAB_POINT_SPHERE_ALPHA = 0.85; // // other constants // + var RIGHT_HAND = 1; var LEFT_HAND = 0; @@ -207,9 +214,10 @@ var STATE_NEAR_GRABBING = 4; var STATE_NEAR_TRIGGER = 5; var STATE_FAR_TRIGGER = 6; var STATE_HOLD = 7; -var STATE_ENTITY_LASER_TOUCHING = 8; -var STATE_OVERLAY_LASER_TOUCHING = 9; -var STATE_STYLUS_TOUCHING = 10; +var STATE_ENTITY_STYLUS_TOUCHING = 8; +var STATE_ENTITY_LASER_TOUCHING = 9; +var STATE_OVERLAY_STYLUS_TOUCHING = 10; +var STATE_OVERLAY_LASER_TOUCHING = 11; var CONTROLLER_STATE_MACHINE = {}; @@ -253,30 +261,30 @@ CONTROLLER_STATE_MACHINE[STATE_FAR_TRIGGER] = { enterMethod: "farTriggerEnter", updateMethod: "farTrigger" }; +CONTROLLER_STATE_MACHINE[STATE_ENTITY_STYLUS_TOUCHING] = { + name: "entityStylusTouching", + enterMethod: "entityTouchingEnter", + exitMethod: "entityTouchingExit", + updateMethod: "entityTouching" +}; CONTROLLER_STATE_MACHINE[STATE_ENTITY_LASER_TOUCHING] = { name: "entityLaserTouching", - enterMethod: "entityLaserTouchingEnter", - exitMethod: "entityLaserTouchingExit", - updateMethod: "entityLaserTouching" + enterMethod: "entityTouchingEnter", + exitMethod: "entityTouchingExit", + updateMethod: "entityTouching" +}; +CONTROLLER_STATE_MACHINE[STATE_OVERLAY_STYLUS_TOUCHING] = { + name: "overlayStylusTouching", + enterMethod: "overlayTouchingEnter", + exitMethod: "overlayTouchingExit", + updateMethod: "overlayTouching" }; CONTROLLER_STATE_MACHINE[STATE_OVERLAY_LASER_TOUCHING] = { name: "overlayLaserTouching", - enterMethod: "overlayLaserTouchingEnter", - exitMethod: "overlayLaserTouchingExit", - updateMethod: "overlayLaserTouching" + enterMethod: "overlayTouchingEnter", + exitMethod: "overlayTouchingExit", + updateMethod: "overlayTouching" }; -CONTROLLER_STATE_MACHINE[STATE_STYLUS_TOUCHING] = { - name: "stylusTouching", - enterMethod: "stylusTouchingEnter", - exitMethod: "stylusTouchingExit", - updateMethod: "stylusTouching" -}; - -function distance2D(a, b) { - var dx = (a.x - b.x); - var dy = (a.y - b.y); - return Math.sqrt(dx * dx + dy * dy); -} function getFingerWorldLocation(hand) { var fingerJointName = (hand === RIGHT_HAND) ? "RightHandIndex4" : "LeftHandIndex4"; @@ -287,8 +295,13 @@ function getFingerWorldLocation(hand) { var worldFingerRotation = Quat.multiply(MyAvatar.orientation, fingerRotation); var worldFingerPosition = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, fingerPosition)); + // local y offset. + var localYOffset = Vec3.multiplyQbyV(worldFingerRotation, {x: 0, y: FINGER_TOUCH_Y_OFFSET, z: 0}); + + var offsetWorldFingerPosition = Vec3.sum(worldFingerPosition, localYOffset); + return { - position: worldFingerPosition, + position: offsetWorldFingerPosition, orientation: worldFingerRotation, rotation: worldFingerRotation, valid: true @@ -554,253 +567,6 @@ function restore2DMode() { } } -function stylusTargetHasKeyboardFocus(stylusTarget) { - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - return Entities.keyboardFocusEntity === stylusTarget.entityID; - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - return Overlays.keyboardFocusOverlay === stylusTarget.overlayID; - } -} - -function setKeyboardFocusOnStylusTarget(stylusTarget) { - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID && Entities.wantsHandControllerPointerEvents(stylusTarget.entityID)) { - Overlays.keyboardFocusOverlay = NULL_UUID; - Entities.keyboardFocusEntity = stylusTarget.entityID; - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.keyboardFocusOverlay = stylusTarget.overlayID; - Entities.keyboardFocusEntity = NULL_UUID; - } -} - -function sendHoverEnterEventToStylusTarget(hand, stylusTarget) { - var pointerEvent = { - type: "Move", - id: hand + 1, // 0 is reserved for hardware mouse - pos2D: stylusTarget.position2D, - pos3D: stylusTarget.position, - normal: stylusTarget.normal, - direction: Vec3.subtract(ZERO_VEC, stylusTarget.normal), - button: "None" - }; - - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - Entities.sendHoverEnterEntity(stylusTarget.entityID, pointerEvent); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.sendHoverEnterOverlay(stylusTarget.overlayID, pointerEvent); - } -} - -function sendHoverOverEventToStylusTarget(hand, stylusTarget) { - var pointerEvent = { - type: "Move", - id: hand + 1, // 0 is reserved for hardware mouse - pos2D: stylusTarget.position2D, - pos3D: stylusTarget.position, - normal: stylusTarget.normal, - direction: Vec3.subtract(ZERO_VEC, stylusTarget.normal), - button: "None" - }; - - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - Entities.sendMouseMoveOnEntity(stylusTarget.entityID, pointerEvent); - Entities.sendHoverOverEntity(stylusTarget.entityID, pointerEvent); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.sendMouseMoveOnOverlay(stylusTarget.overlayID, pointerEvent); - Overlays.sendHoverOverOverlay(stylusTarget.overlayID, pointerEvent); - } -} - -function sendTouchStartEventToStylusTarget(hand, stylusTarget) { - var pointerEvent = { - type: "Press", - id: hand + 1, // 0 is reserved for hardware mouse - pos2D: stylusTarget.position2D, - pos3D: stylusTarget.position, - normal: stylusTarget.normal, - direction: Vec3.subtract(ZERO_VEC, stylusTarget.normal), - button: "Primary", - isPrimaryHeld: true - }; - - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - Entities.sendMousePressOnEntity(stylusTarget.entityID, pointerEvent); - Entities.sendClickDownOnEntity(stylusTarget.entityID, pointerEvent); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.sendMousePressOnOverlay(stylusTarget.overlayID, pointerEvent); - } -} - -function sendTouchEndEventToStylusTarget(hand, stylusTarget) { - var pointerEvent = { - type: "Release", - id: hand + 1, // 0 is reserved for hardware mouse - pos2D: stylusTarget.position2D, - pos3D: stylusTarget.position, - normal: stylusTarget.normal, - direction: Vec3.subtract(ZERO_VEC, stylusTarget.normal), - button: "Primary" - }; - - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - Entities.sendMouseReleaseOnEntity(stylusTarget.entityID, pointerEvent); - Entities.sendClickReleaseOnEntity(stylusTarget.entityID, pointerEvent); - Entities.sendHoverLeaveEntity(stylusTarget.entityID, pointerEvent); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.sendMouseReleaseOnOverlay(stylusTarget.overlayID, pointerEvent); - } -} - -function sendTouchMoveEventToStylusTarget(hand, stylusTarget) { - var pointerEvent = { - type: "Move", - id: hand + 1, // 0 is reserved for hardware mouse - pos2D: stylusTarget.position2D, - pos3D: stylusTarget.position, - normal: stylusTarget.normal, - direction: Vec3.subtract(ZERO_VEC, stylusTarget.normal), - button: "Primary", - isPrimaryHeld: true - }; - - if (stylusTarget.entityID && stylusTarget.entityID !== NULL_UUID) { - Entities.sendMouseMoveOnEntity(stylusTarget.entityID, pointerEvent); - Entities.sendHoldingClickOnEntity(stylusTarget.entityID, pointerEvent); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== NULL_UUID) { - Overlays.sendMouseMoveOnOverlay(stylusTarget.overlayID, pointerEvent); - } -} - -// will return undefined if entity does not exist. -function calculateStylusTargetFromEntity(stylusTip, entityID) { - var props = entityPropertiesCache.getProps(entityID); - if (props.rotation === undefined) { - // if rotation is missing from props object, then this entity has probably been deleted. - return; - } - - // project stylus tip onto entity plane. - var normal = Vec3.multiplyQbyV(props.rotation, {x: 0, y: 0, z: 1}); - Vec3.multiplyQbyV(props.rotation, {x: 0, y: 1, z: 0}); - var distance = Vec3.dot(Vec3.subtract(stylusTip.position, props.position), normal); - var position = Vec3.subtract(stylusTip.position, Vec3.multiply(normal, distance)); - - // generate normalized coordinates - var invRot = Quat.inverse(props.rotation); - var localPos = Vec3.multiplyQbyV(invRot, Vec3.subtract(position, props.position)); - var invDimensions = { x: 1 / props.dimensions.x, y: 1 / props.dimensions.y, z: 1 / props.dimensions.z }; - var normalizedPosition = Vec3.sum(Vec3.multiplyVbyV(localPos, invDimensions), props.registrationPoint); - - // 2D position on entity plane in meters, relative to the bounding box upper-left hand corner. - var position2D = { x: normalizedPosition.x * props.dimensions.x, y: (1 - normalizedPosition.y) * props.dimensions.y }; // flip y-axis - - return { - entityID: entityID, - overlayID: null, - distance: distance, - position: position, - position2D: position2D, - normal: normal, - normalizedPosition: normalizedPosition, - dimensions: props.dimensions, - valid: true - }; -} - -// will return undefined if overlayID does not exist. -function calculateStylusTargetFromOverlay(stylusTip, overlayID) { - var overlayPosition = Overlays.getProperty(overlayID, "position"); - if (overlayPosition === undefined) { - return; - } - - // project stylusTip onto overlay plane. - var overlayRotation = Overlays.getProperty(overlayID, "rotation"); - if (overlayRotation === undefined) { - return; - } - var normal = Vec3.multiplyQbyV(overlayRotation, {x: 0, y: 0, z: 1}); - var distance = Vec3.dot(Vec3.subtract(stylusTip.position, overlayPosition), normal); - var position = Vec3.subtract(stylusTip.position, Vec3.multiply(normal, distance)); - - // calclulate normalized position - var invRot = Quat.inverse(overlayRotation); - var localPos = Vec3.multiplyQbyV(invRot, Vec3.subtract(position, overlayPosition)); - var dpi = Overlays.getProperty(overlayID, "dpi"); - - var dimensions; - if (dpi) { - // Calculate physical dimensions for web3d overlay from resolution and dpi; "dimensions" property is used as a scale. - var resolution = Overlays.getProperty(overlayID, "resolution"); - if (resolution === undefined) { - return; - } - resolution.z = 1; // Circumvent divide-by-zero. - var scale = Overlays.getProperty(overlayID, "dimensions"); - if (scale === undefined) { - return; - } - scale.z = 0.01; // overlay dimensions are 2D, not 3D. - dimensions = Vec3.multiplyVbyV(Vec3.multiply(resolution, INCHES_TO_METERS / dpi), scale); - } else { - dimensions = Overlays.getProperty(overlayID, "dimensions"); - if (dimensions === undefined) { - return; - } - if (!dimensions.z) { - dimensions.z = 0.01; // sometimes overlay dimensions are 2D, not 3D. - } - } - var invDimensions = { x: 1 / dimensions.x, y: 1 / dimensions.y, z: 1 / dimensions.z }; - var normalizedPosition = Vec3.sum(Vec3.multiplyVbyV(localPos, invDimensions), DEFAULT_REGISTRATION_POINT); - - // 2D position on overlay plane in meters, relative to the bounding box upper-left hand corner. - var position2D = { x: normalizedPosition.x * dimensions.x, y: (1 - normalizedPosition.y) * dimensions.y }; // flip y-axis - - return { - entityID: null, - overlayID: overlayID, - distance: distance, - position: position, - position2D: position2D, - normal: normal, - normalizedPosition: normalizedPosition, - dimensions: dimensions, - valid: true - }; -} - -function isNearStylusTarget(stylusTargets, edgeBorder, minNormalDistance, maxNormalDistance) { - for (var i = 0; i < stylusTargets.length; i++) { - var stylusTarget = stylusTargets[i]; - - // check to see if the projected stylusTip is within within the 2d border - var borderMin = {x: -edgeBorder, y: -edgeBorder}; - var borderMax = {x: stylusTarget.dimensions.x + edgeBorder, y: stylusTarget.dimensions.y + edgeBorder}; - if (stylusTarget.distance >= minNormalDistance && stylusTarget.distance <= maxNormalDistance && - stylusTarget.position2D.x >= borderMin.x && stylusTarget.position2D.y >= borderMin.y && - stylusTarget.position2D.x <= borderMax.x && stylusTarget.position2D.y <= borderMax.y) { - return true; - } - } - return false; -} - -function calculateNearestStylusTarget(stylusTargets) { - var nearestStylusTarget; - - for (var i = 0; i < stylusTargets.length; i++) { - var stylusTarget = stylusTargets[i]; - - if ((!nearestStylusTarget || stylusTarget.distance < nearestStylusTarget.distance) && - stylusTarget.normalizedPosition.x >= 0 && stylusTarget.normalizedPosition.y >= 0 && - stylusTarget.normalizedPosition.x <= 1 && stylusTarget.normalizedPosition.y <= 1) { - nearestStylusTarget = stylusTarget; - } - } - - return nearestStylusTarget; -}; - // EntityPropertiesCache is a helper class that contains a cache of entity properties. // the hope is to prevent excess calls to Entity.getEntityProperties() // @@ -1030,16 +796,6 @@ EquipHotspotBuddy.prototype.update = function(deltaTime, timestamp) { } }; -function getControllerJointIndex(hand) { - if (HMD.isHandControllerAvailable()) { - return MyAvatar.getJointIndex(hand === RIGHT_HAND ? - "_CONTROLLER_RIGHTHAND" : - "_CONTROLLER_LEFTHAND"); - } - - return MyAvatar.getJointIndex("Head"); -} - // global EquipHotspotBuddy instance var equipHotspotBuddy = new EquipHotspotBuddy(); @@ -1049,9 +805,10 @@ function MyController(hand) { this.grabPointIntersectsEntity = false; this.stylus = null; this.homeButtonTouched = false; - this.editTriggered = false; - this.controllerJointIndex = getControllerJointIndex(this.hand); + this.controllerJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? + "_CONTROLLER_RIGHTHAND" : + "_CONTROLLER_LEFTHAND"); // Until there is some reliable way to keep track of a "stack" of parentIDs, we'll have problems // when more than one avatar does parenting grabs on things. This script tries to work @@ -1130,17 +887,6 @@ function MyController(hand) { this.tabletStabbedPos3D = null; this.useFingerInsteadOfStylus = false; - this.fingerPointing = false; - - // initialize stylus tip - var DEFAULT_STYLUS_TIP = { - position: {x: 0, y: 0, z: 0}, - orientation: {x: 0, y: 0, z: 0, w: 0}, - rotation: {x: 0, y: 0, z: 0, w: 0}, - velocity: {x: 0, y: 0, z: 0}, - valid: false - }; - this.stylusTip = DEFAULT_STYLUS_TIP; var _this = this; @@ -1151,37 +897,11 @@ function MyController(hand) { return (-1 !== suppressedIn2D.indexOf(this.state)) && isIn2DMode(); }; - this.updateStylusTip = function() { - if (this.useFingerInsteadOfStylus) { - this.stylusTip = getFingerWorldLocation(this.hand); - } else { - this.stylusTip = getControllerWorldLocation(this.handToController(), true); - - // translate tip forward according to constant. - var TIP_OFFSET = {x: 0, y: WEB_STYLUS_LENGTH - WEB_TOUCH_Y_OFFSET, z: 0}; - this.stylusTip.position = Vec3.sum(this.stylusTip.position, Vec3.multiplyQbyV(this.stylusTip.orientation, TIP_OFFSET)); - } - - // compute tip velocity from hand controller motion, it is more accurate then computing it from previous positions. - var pose = Controller.getPoseValue(this.handToController()); - if (pose.valid) { - var worldControllerPos = Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, pose.translation)); - var worldControllerLinearVel = Vec3.multiplyQbyV(MyAvatar.orientation, pose.velocity); - var worldControllerAngularVel = Vec3.multiplyQbyV(MyAvatar.orientation, pose.angularVelocity); - var tipVelocity = Vec3.sum(worldControllerLinearVel, Vec3.cross(worldControllerAngularVel, Vec3.subtract(this.stylusTip.position, worldControllerPos))); - this.stylusTip.velocity = tipVelocity; - } else { - this.stylusTip.velocity = {x: 0, y: 0, z: 0}; - } - }; - this.update = function(deltaTime, timestamp) { this.updateSmoothedTrigger(); this.maybeScaleMyAvatar(); - this.updateStylusTip(); - - var DEFAULT_USE_FINGER_AS_STYLUS = true; + var DEFAULT_USE_FINGER_AS_STYLUS = false; var USE_FINGER_AS_STYLUS = Settings.getValue("preferAvatarFingerOverStylus"); if (USE_FINGER_AS_STYLUS === "") { USE_FINGER_AS_STYLUS = DEFAULT_USE_FINGER_AS_STYLUS; @@ -1196,7 +916,10 @@ function MyController(hand) { // Most hand input is disabled, because we are interacting with the 2d hud. // However, we still should check for collisions of the stylus with the web overlay. - this.processStylus(); + + var controllerLocation = getControllerWorldLocation(this.handToController(), true); + this.processStylus(controllerLocation.position); + this.turnOffVisualizations(); return; } @@ -1226,7 +949,7 @@ function MyController(hand) { if ((isInEditMode() && this.grabbedThingID !== HMD.tabletID) && (newState !== STATE_OFF && newState !== STATE_SEARCHING && - newState !== STATE_STYLUS_TOUCHING && + newState !== STATE_OVERLAY_STYLUS_TOUCHING && newState !== STATE_OVERLAY_LASER_TOUCHING)) { return; } @@ -1361,6 +1084,10 @@ function MyController(hand) { } Overlays.deleteOverlay(this.stylus); this.stylus = null; + if (this.stylusTip) { + Overlays.deleteOverlay(this.stylusTip); + this.stylusTip = null; + } }; this.overlayLineOn = function(closePoint, farPoint, color, farParentID) { @@ -1410,7 +1137,7 @@ function MyController(hand) { } var searchSphereLocation = Vec3.sum(distantPickRay.origin, - Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); + Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, (this.triggerSmoothedGrab() || this.secondarySqueezed()) ? COLORS_GRAB_SEARCHING_FULL_SQUEEZE : @@ -1564,185 +1291,72 @@ function MyController(hand) { return _this.rawThumbValue < THUMB_ON_VALUE; }; - this.stealTouchFocus = function(stylusTarget) { - // send hover events to target - // record the entity or overlay we are hovering over. - if ((stylusTarget.entityID === this.getOtherHandController().hoverEntity) || - (stylusTarget.overlayID === this.getOtherHandController().hoverOverlay)) { - this.getOtherHandController().relinquishTouchFocus(); - } - this.requestTouchFocus(stylusTarget); - }; - - this.requestTouchFocus = function(stylusTarget) { - - // send hover events to target if we can. - // record the entity or overlay we are hovering over. - if (stylusTarget.entityID && stylusTarget.entityID !== this.hoverEntity && stylusTarget.entityID !== this.getOtherHandController().hoverEntity) { - this.hoverEntity = stylusTarget.entityID; - sendHoverEnterEventToStylusTarget(this.hand, stylusTarget); - } else if (stylusTarget.overlayID && stylusTarget.overlayID !== this.hoverOverlay && stylusTarget.overlayID !== this.getOtherHandController().hoverOverlay) { - this.hoverOverlay = stylusTarget.overlayID; - sendHoverEnterEventToStylusTarget(this.hand, stylusTarget); - } - }; - - this.hasTouchFocus = function(stylusTarget) { - return ((stylusTarget.entityID && stylusTarget.entityID === this.hoverEntity) || - (stylusTarget.overlayID && stylusTarget.overlayID === this.hoverOverlay)); - }; - - this.relinquishTouchFocus = function() { - - // send hover leave event. - var pointerEvent = { type: "Move", id: this.hand + 1 }; - if (this.hoverEntity) { - Entities.sendHoverLeaveEntity(this.hoverEntity, pointerEvent); - this.hoverEntity = null; - } else if (this.hoverOverlay) { - Overlays.sendMouseMoveOnOverlay(this.hoverOverlay, pointerEvent); - Overlays.sendHoverOverOverlay(this.hoverOverlay, pointerEvent); - Overlays.sendHoverLeaveOverlay(this.hoverOverlay, pointerEvent); - this.hoverOverlay = null; - } - }; - - this.pointFinger = function(value) { - var HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index"; - if (this.fingerPointing !== value) { - var message; - if (this.hand === RIGHT_HAND) { - message = { pointRightIndex: value }; - } else { - message = { pointLeftIndex: value }; - } - Messages.sendMessage(HIFI_POINT_INDEX_MESSAGE_CHANNEL, JSON.stringify(message), true); - this.fingerPointing = value; - } - }; - - this.processStylus = function() { - if (!this.stylusTip.valid) { - this.pointFinger(false); - this.hideStylus(); - return; - } + this.processStylus = function(worldHandPosition) { + var performRayTest = false; if (this.useFingerInsteadOfStylus) { this.hideStylus(); - } + performRayTest = true; + } else { + var i; - var tipPosition = this.stylusTip.position; - - var candidates = { - entities: [], - overlays: [] - }; - - // build list of stylus targets, near the stylusTip - var stylusTargets = []; - var candidateEntities = Entities.findEntities(tipPosition, WEB_DISPLAY_STYLUS_DISTANCE); - entityPropertiesCache.addEntities(candidateEntities); - var i, props, stylusTarget; - for (i = 0; i < candidateEntities.length; i++) { - props = entityPropertiesCache.getProps(candidateEntities[i]); - if (props && (props.type === "Web" || this.isTablet(candidateEntities[i]))) { - stylusTarget = calculateStylusTargetFromEntity(this.stylusTip, candidateEntities[i]); - if (stylusTarget) { - stylusTargets.push(stylusTarget); + // see if the hand is near a tablet or web-entity + var candidateEntities = Entities.findEntities(worldHandPosition, WEB_DISPLAY_STYLUS_DISTANCE); + entityPropertiesCache.addEntities(candidateEntities); + for (i = 0; i < candidateEntities.length; i++) { + var props = entityPropertiesCache.getProps(candidateEntities[i]); + if (props && (props.type == "Web" || this.isTablet(candidateEntities[i]))) { + performRayTest = true; + break; } } - } - // add the tabletScreen, if it is valid - if (HMD.tabletScreenID && HMD.tabletScreenID !== NULL_UUID && Overlays.getProperty(HMD.tabletScreenID, "visible")) { - stylusTarget = calculateStylusTargetFromOverlay(this.stylusTip, HMD.tabletScreenID); - if (stylusTarget) { - stylusTargets.push(stylusTarget); + if (!performRayTest) { + var candidateOverlays = Overlays.findOverlays(worldHandPosition, WEB_DISPLAY_STYLUS_DISTANCE); + for (i = 0; i < candidateOverlays.length; i++) { + if (this.isTablet(candidateOverlays[i])) { + performRayTest = true; + break; + } + } } - } - // add the tablet home button. - if (HMD.homeButtonID && HMD.homeButtonID !== NULL_UUID && Overlays.getProperty(HMD.homeButtonID, "visible")) { - stylusTarget = calculateStylusTargetFromOverlay(this.stylusTip, HMD.homeButtonID); - if (stylusTarget) { - stylusTargets.push(stylusTarget); - } - } - - var TABLET_MIN_HOVER_DISTANCE = 0.01; - var TABLET_MAX_HOVER_DISTANCE = 0.1; - var TABLET_MIN_TOUCH_DISTANCE = -0.05; - var TABLET_MAX_TOUCH_DISTANCE = TABLET_MIN_HOVER_DISTANCE; - var EDGE_BORDER = 0.075; - - var hysteresisOffset = 0.0; - if (this.isNearStylusTarget) { - hysteresisOffset = 0.05; - } - - this.isNearStylusTarget = isNearStylusTarget(stylusTargets, EDGE_BORDER + hysteresisOffset, - TABLET_MIN_TOUCH_DISTANCE - hysteresisOffset, WEB_DISPLAY_STYLUS_DISTANCE + hysteresisOffset); - - if (this.isNearStylusTarget) { - if (!this.useFingerInsteadOfStylus) { + if (performRayTest) { this.showStylus(); } else { - this.pointFinger(true); + this.hideStylus(); } - } else { - this.hideStylus(); - this.pointFinger(false); } - var nearestStylusTarget = calculateNearestStylusTarget(stylusTargets); - - if (nearestStylusTarget && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE && - nearestStylusTarget.distance < TABLET_MAX_HOVER_DISTANCE) { - - this.requestTouchFocus(nearestStylusTarget); - - if (!stylusTargetHasKeyboardFocus(nearestStylusTarget)) { - setKeyboardFocusOnStylusTarget(nearestStylusTarget); + if (performRayTest) { + var rayPickInfo = this.calcRayPickInfo(this.hand, this.useFingerInsteadOfStylus); + var max, min; + if (this.useFingerInsteadOfStylus) { + max = FINGER_TOUCH_MAX; + min = FINGER_TOUCH_MIN; + } else { + max = WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET; + min = WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_TOO_CLOSE; } - if (this.hasTouchFocus(nearestStylusTarget)) { - sendHoverOverEventToStylusTarget(this.hand, nearestStylusTarget); - } - - // filter out presses when tip is moving away from tablet. - // ensure that stylus is within bounding box by checking normalizedPosition - if (nearestStylusTarget.valid && nearestStylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE && - nearestStylusTarget.distance < TABLET_MAX_TOUCH_DISTANCE && Vec3.dot(this.stylusTip.velocity, nearestStylusTarget.normal) < 0 && - nearestStylusTarget.normalizedPosition.x >= 0 && nearestStylusTarget.normalizedPosition.x <= 1 && - nearestStylusTarget.normalizedPosition.y >= 0 && nearestStylusTarget.normalizedPosition.y <= 1) { - - var name; - if (nearestStylusTarget.entityID) { - name = entityPropertiesCache.getProps(nearestStylusTarget.entityID).name; - this.stylusTarget = nearestStylusTarget; - this.setState(STATE_STYLUS_TOUCHING, "begin touching entity '" + name + "'"); - } else if (nearestStylusTarget.overlayID) { - name = Overlays.getProperty(nearestStylusTarget.overlayID, "name"); - this.stylusTarget = nearestStylusTarget; - this.setState(STATE_STYLUS_TOUCHING, "begin touching overlay '" + name + "'"); + if (rayPickInfo.distance < max && rayPickInfo.distance > min) { + this.handleStylusOnHomeButton(rayPickInfo); + if (this.handleStylusOnWebEntity(rayPickInfo)) { + return; } + if (this.handleStylusOnWebOverlay(rayPickInfo)) { + return; + } + } else { + this.homeButtonTouched = false; } - } else { - this.relinquishTouchFocus(); } - - this.homeButtonTouched = false; }; this.off = function(deltaTime, timestamp) { this.checkForUnexpectedChildren(); - if (this.editTriggered) { - this.editTriggered = false; - } - if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.waitForTriggerRelease = false; } @@ -1792,7 +1406,25 @@ function MyController(hand) { this.grabPointSphereOff(); } - this.processStylus(); + this.processStylus(worldHandPosition); + }; + + this.handleStylusOnHomeButton = function(rayPickInfo) { + if (rayPickInfo.overlayID) { + var homeButton = rayPickInfo.overlayID; + var hmdHomeButton = HMD.homeButtonID; + if (homeButton === hmdHomeButton) { + if (this.homeButtonTouched === false) { + this.homeButtonTouched = true; + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); + Messages.sendLocalMessage("home", homeButton); + } + } else { + this.homeButtonTouched = false; + } + } else { + this.homeButtonTouched = false; + } }; this.handleLaserOnHomeButton = function(rayPickInfo) { @@ -1832,27 +1464,27 @@ function MyController(hand) { // Performs ray pick test from the hand controller into the world // @param {number} which hand to use, RIGHT_HAND or LEFT_HAND - // @param {object} if set, use this as as the pick ray, expects origin, direction, and length fields. + // @param {bool} if true use the world position/orientation of the index finger to cast the ray from. // @returns {object} returns object with two keys entityID and distance // - this.calcRayPickInfo = function(hand, pickRayOverride) { + this.calcRayPickInfo = function(hand, useFingerInsteadOfController) { - var pickRay; - if (pickRayOverride) { - pickRay = pickRayOverride; + var controllerLocation; + if (useFingerInsteadOfController) { + controllerLocation = getFingerWorldLocation(hand); } else { - var controllerLocation = getControllerWorldLocation(this.handToController(), true); - var worldHandPosition = controllerLocation.position; - var worldHandRotation = controllerLocation.orientation; - - pickRay = { - origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position, - direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation), - Quat.getFront(Camera.orientation), - HAND_HEAD_MIX_RATIO), - length: PICK_MAX_DISTANCE - }; + controllerLocation = getControllerWorldLocation(this.handToController(), true); } + var worldHandPosition = controllerLocation.position; + var worldHandRotation = controllerLocation.orientation; + + var pickRay = { + origin: PICK_WITH_HAND_RAY ? worldHandPosition : Camera.position, + direction: PICK_WITH_HAND_RAY ? Quat.getUp(worldHandRotation) : Vec3.mix(Quat.getUp(worldHandRotation), + Quat.getForward(Camera.orientation), + HAND_HEAD_MIX_RATIO), + length: PICK_MAX_DISTANCE + }; var result = { entityID: null, @@ -2211,21 +1843,23 @@ function MyController(hand) { return aDistance - bDistance; }); entity = grabbableEntities[0]; - if (!isInEditMode() || entity == HMD.tabletID) { // tablet is grabbable, even when editing - name = entityPropertiesCache.getProps(entity).name; - this.grabbedThingID = entity; - this.grabbedIsOverlay = false; - if (this.entityWantsTrigger(entity)) { - if (this.triggerSmoothedGrab()) { - this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'"); - return; - } + name = entityPropertiesCache.getProps(entity).name; + this.grabbedThingID = entity; + this.grabbedIsOverlay = false; + if (this.entityWantsTrigger(entity)) { + if (this.triggerSmoothedGrab()) { + this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'"); + return; } else { - // If near something grabbable, grab it! - if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { - this.setState(STATE_NEAR_GRABBING, "near grab entity '" + name + "'"); - return; - } + // potentialNearTriggerEntity = entity; + } + } else { + // If near something grabbable, grab it! + if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { + this.setState(STATE_NEAR_GRABBING, "near grab entity '" + name + "'"); + return; + } else { + // potentialNearGrabEntity = entity; } } } @@ -2240,21 +1874,6 @@ function MyController(hand) { } } - if (isInEditMode()) { - this.searchIndicatorOn(rayPickInfo.searchRay); - if (this.triggerSmoothedGrab()) { - if (!this.editTriggered && rayPickInfo.entityID) { - Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "selectEntity", - entityID: rayPickInfo.entityID - })); - } - this.editTriggered = true; - } - Reticle.setVisible(false); - return; - } - if (rayPickInfo.entityID) { entity = rayPickInfo.entityID; name = entityPropertiesCache.getProps(entity).name; @@ -2324,7 +1943,7 @@ function MyController(hand) { return false; }; - this.handleLaserOnWebEntity = function (rayPickInfo) { + this.handleStylusOnWebEntity = function (rayPickInfo) { var pointerEvent; if (rayPickInfo.entityID && Entities.wantsHandControllerPointerEvents(rayPickInfo.entityID)) { @@ -2353,8 +1972,9 @@ function MyController(hand) { if (this.hand == mostRecentSearchingHand || (this.hand !== mostRecentSearchingHand && this.getOtherHandController().state !== STATE_SEARCHING && - this.getOtherHandController().state !== STATE_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_ENTITY_STYLUS_TOUCHING && this.getOtherHandController().state !== STATE_ENTITY_LASER_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_STYLUS_TOUCHING && this.getOtherHandController().state !== STATE_OVERLAY_LASER_TOUCHING)) { // most recently searching hand has priority over other hand, for the purposes of button highlighting. @@ -2372,12 +1992,10 @@ function MyController(hand) { Entities.sendHoverOverEntity(entity, pointerEvent); } - if (this.triggerSmoothedGrab()) { - this.grabbedThingID = entity; - this.grabbedIsOverlay = false; - this.setState(STATE_ENTITY_LASER_TOUCHING, "begin touching entity '" + name + "'"); - return true; - } + this.grabbedThingID = entity; + this.grabbedIsOverlay = false; + this.setState(STATE_ENTITY_STYLUS_TOUCHING, "begin touching entity '" + name + "'"); + return true; } else if (this.hoverEntity) { pointerEvent = { @@ -2391,13 +2009,10 @@ function MyController(hand) { return false; }; - this.handleLaserOnWebOverlay = function (rayPickInfo) { + this.handleStylusOnWebOverlay = function (rayPickInfo) { var pointerEvent; if (rayPickInfo.overlayID) { var overlay = rayPickInfo.overlayID; - if (Overlays.getProperty(overlay, "type") != "web3d") { - return false; - } if (Overlays.keyboardFocusOverlay != overlay) { Entities.keyboardFocusEntity = null; Overlays.keyboardFocusOverlay = overlay; @@ -2420,8 +2035,141 @@ function MyController(hand) { if (this.hand == mostRecentSearchingHand || (this.hand !== mostRecentSearchingHand && this.getOtherHandController().state !== STATE_SEARCHING && - this.getOtherHandController().state !== STATE_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_ENTITY_STYLUS_TOUCHING && this.getOtherHandController().state !== STATE_ENTITY_LASER_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_LASER_TOUCHING)) { + + // most recently searching hand has priority over other hand, for the purposes of button highlighting. + pointerEvent = { + type: "Move", + id: HARDWARE_MOUSE_ID, + pos2D: projectOntoOverlayXYPlane(overlay, rayPickInfo.intersection), + pos3D: rayPickInfo.intersection, + normal: rayPickInfo.normal, + direction: rayPickInfo.searchRay.direction, + button: "None" + }; + + Overlays.sendMouseMoveOnOverlay(overlay, pointerEvent); + Overlays.sendHoverOverOverlay(overlay, pointerEvent); + } + + this.grabbedOverlay = overlay; + this.setState(STATE_OVERLAY_STYLUS_TOUCHING, "begin touching overlay '" + overlay + "'"); + return true; + + } else if (this.hoverOverlay) { + pointerEvent = { + type: "Move", + id: HARDWARE_MOUSE_ID + }; + Overlays.sendHoverLeaveOverlay(this.hoverOverlay, pointerEvent); + this.hoverOverlay = null; + } + + return false; + }; + + this.handleLaserOnWebEntity = function(rayPickInfo) { + var pointerEvent; + if (rayPickInfo.entityID && Entities.wantsHandControllerPointerEvents(rayPickInfo.entityID)) { + var entity = rayPickInfo.entityID; + var props = entityPropertiesCache.getProps(entity); + var name = props.name; + + if (Entities.keyboardFocusEntity != entity) { + Overlays.keyboardFocusOverlay = 0; + Entities.keyboardFocusEntity = entity; + + pointerEvent = { + type: "Move", + id: this.hand + 1, // 0 is reserved for hardware mouse + pos2D: projectOntoEntityXYPlane(entity, rayPickInfo.intersection), + pos3D: rayPickInfo.intersection, + normal: rayPickInfo.normal, + direction: rayPickInfo.searchRay.direction, + button: "None" + }; + + this.hoverEntity = entity; + Entities.sendHoverEnterEntity(entity, pointerEvent); + } + + // send mouse events for button highlights and tooltips. + if (this.hand == mostRecentSearchingHand || + (this.hand !== mostRecentSearchingHand && + this.getOtherHandController().state !== STATE_SEARCHING && + this.getOtherHandController().state !== STATE_ENTITY_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_ENTITY_LASER_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_LASER_TOUCHING)) { + + // most recently searching hand has priority over other hand, for the purposes of button highlighting. + pointerEvent = { + type: "Move", + id: this.hand + 1, // 0 is reserved for hardware mouse + pos2D: projectOntoEntityXYPlane(entity, rayPickInfo.intersection), + pos3D: rayPickInfo.intersection, + normal: rayPickInfo.normal, + direction: rayPickInfo.searchRay.direction, + button: "None" + }; + + Entities.sendMouseMoveOnEntity(entity, pointerEvent); + Entities.sendHoverOverEntity(entity, pointerEvent); + } + + if (this.triggerSmoothedGrab() && (!isEditing() || this.isTablet(entity))) { + this.grabbedThingID = entity; + this.grabbedIsOverlay = false; + this.setState(STATE_ENTITY_LASER_TOUCHING, "begin touching entity '" + name + "'"); + return true; + } + } else if (this.hoverEntity) { + pointerEvent = { + type: "Move", + id: this.hand + 1 + }; + Entities.sendHoverLeaveEntity(this.hoverEntity, pointerEvent); + this.hoverEntity = null; + } + + return false; + }; + + this.handleLaserOnWebOverlay = function(rayPickInfo) { + var pointerEvent; + var overlay; + + if (rayPickInfo.overlayID) { + overlay = rayPickInfo.overlayID; + + if (Overlays.keyboardFocusOverlay != overlay) { + Entities.keyboardFocusEntity = null; + Overlays.keyboardFocusOverlay = overlay; + + pointerEvent = { + type: "Move", + id: HARDWARE_MOUSE_ID, + pos2D: projectOntoOverlayXYPlane(overlay, rayPickInfo.intersection), + pos3D: rayPickInfo.intersection, + normal: rayPickInfo.normal, + direction: rayPickInfo.searchRay.direction, + button: "None" + }; + + this.hoverOverlay = overlay; + Overlays.sendHoverEnterOverlay(overlay, pointerEvent); + } + + // Send mouse events for button highlights and tooltips. + if (this.hand == mostRecentSearchingHand || + (this.hand !== mostRecentSearchingHand && + this.getOtherHandController().state !== STATE_SEARCHING && + this.getOtherHandController().state !== STATE_ENTITY_STYLUS_TOUCHING && + this.getOtherHandController().state !== STATE_ENTITY_LASER_TOUCHING && + this.getOtherHandController().state !== STATE_OVERLAY_STYLUS_TOUCHING && this.getOtherHandController().state !== STATE_OVERLAY_LASER_TOUCHING)) { // most recently searching hand has priority over other hand, for the purposes of button highlighting. @@ -3346,9 +3094,14 @@ function MyController(hand) { this.release(); }; - this.entityLaserTouchingEnter = function() { + this.entityTouchingEnter = function() { // test for intersection between controller laser and web entity plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_ENTITY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectEntity(this.grabbedThingID, controllerLocation); if (intersectInfo) { var pointerEvent = { @@ -3371,15 +3124,26 @@ function MyController(hand) { this.deadspotExpired = false; var LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.026; // radians ~ 1.2 degrees - this.deadspotRadius = Math.tan(LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE) * intersectInfo.distance; // dead spot radius in meters + var STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.314; // radians ~ 18 degrees + var theta = this.state === STATE_ENTITY_STYLUS_TOUCHING ? STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE : LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE; + this.deadspotRadius = Math.tan(theta) * intersectInfo.distance; // dead spot radius in meters } - Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + if (this.state == STATE_ENTITY_STYLUS_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); + } else if (this.state == STATE_ENTITY_LASER_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + } }; - this.entityLaserTouchingExit = function() { + this.entityTouchingExit = function() { // test for intersection between controller laser and web entity plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_ENTITY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectEntity(this.grabbedThingID, controllerLocation); if (intersectInfo) { var pointerEvent; @@ -3408,22 +3172,40 @@ function MyController(hand) { this.grabbedOverlay = null; }; - this.entityLaserTouching = function(dt) { + this.entityTouching = function(dt) { this.touchingEnterTimer += dt; entityPropertiesCache.addEntity(this.grabbedThingID); - if (this.state == STATE_ENTITY_LASER_TOUCHING && !this.triggerSmoothedGrab()) { // AJT: + if (this.state == STATE_ENTITY_LASER_TOUCHING && !this.triggerSmoothedGrab()) { this.setState(STATE_OFF, "released trigger"); return; } // test for intersection between controller laser and web entity plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_ENTITY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectEntity(this.grabbedThingID, controllerLocation); if (intersectInfo) { + var max; + if (this.useFingerInsteadOfStylus && this.state === STATE_ENTITY_STYLUS_TOUCHING) { + max = FINGER_TOUCH_MAX; + } else { + max = WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET; + } + + if (this.state == STATE_ENTITY_STYLUS_TOUCHING && + intersectInfo.distance > max) { + this.setState(STATE_OFF, "pulled away from web entity"); + return; + } + if (Entities.keyboardFocusEntity != this.grabbedThingID) { Overlays.keyboardFocusOverlay = 0; Entities.keyboardFocusEntity = this.grabbedThingID; @@ -3460,14 +3242,19 @@ function MyController(hand) { } }; - this.overlayLaserTouchingEnter = function () { + this.overlayTouchingEnter = function () { // Test for intersection between controller laser and Web overlay plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_OVERLAY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectOverlay(this.grabbedOverlay, controllerLocation); if (intersectInfo) { var pointerEvent = { type: "Press", - id: this.hand + 1, + id: HARDWARE_MOUSE_ID, pos2D: projectOntoOverlayXYPlane(this.grabbedOverlay, intersectInfo.point), pos3D: intersectInfo.point, normal: intersectInfo.normal, @@ -3484,15 +3271,26 @@ function MyController(hand) { this.deadspotExpired = false; var LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.026; // radians ~ 1.2 degrees - this.deadspotRadius = Math.tan(LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE) * intersectInfo.distance; // dead spot radius in meters + var STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE = 0.314; // radians ~ 18 degrees + var theta = this.state === STATE_OVERLAY_STYLUS_TOUCHING ? STYLUS_PRESS_TO_MOVE_DEADSPOT_ANGLE : LASER_PRESS_TO_MOVE_DEADSPOT_ANGLE; + this.deadspotRadius = Math.tan(theta) * intersectInfo.distance; // dead spot radius in meters } - Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); + } else if (this.state == STATE_OVERLAY_LASER_TOUCHING) { + Controller.triggerHapticPulse(HAPTIC_LASER_UI_STRENGTH, HAPTIC_LASER_UI_DURATION, this.hand); + } }; - this.overlayLaserTouchingExit = function () { + this.overlayTouchingExit = function () { // Test for intersection between controller laser and Web overlay plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_OVERLAY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectOverlay(this.grabbedOverlay, controllerLocation); if (intersectInfo) { var pointerEvent; @@ -3516,7 +3314,7 @@ function MyController(hand) { if (this.deadspotExpired) { pointerEvent = { type: "Release", - id: this.hand + 1, + id: HARDWARE_MOUSE_ID, pos2D: pos2D, pos3D: pos3D, normal: intersectInfo.normal, @@ -3537,22 +3335,66 @@ function MyController(hand) { this.grabbedOverlay = null; }; - this.overlayLaserTouching = function (dt) { + this.overlayTouching = function (dt) { this.touchingEnterTimer += dt; + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && this.triggerSmoothedSqueezed()) { + return; + } + if (this.state == STATE_OVERLAY_LASER_TOUCHING && !this.triggerSmoothedGrab()) { this.setState(STATE_OFF, "released trigger"); return; } // Test for intersection between controller laser and Web overlay plane. - var controllerLocation = getControllerWorldLocation(this.handToController(), true); + var controllerLocation; + if (this.useFingerInsteadOfStylus && this.state === STATE_OVERLAY_STYLUS_TOUCHING) { + controllerLocation = getFingerWorldLocation(this.hand); + } else { + controllerLocation = getControllerWorldLocation(this.handToController(), true); + } var intersectInfo = handLaserIntersectOverlay(this.grabbedOverlay, controllerLocation); if (intersectInfo) { + var max, min; + if (this.useFingerInsteadOfStylus && this.state === STATE_OVERLAY_STYLUS_TOUCHING) { + max = FINGER_TOUCH_MAX; + min = FINGER_TOUCH_MIN; + } else { + max = WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_Y_OFFSET + WEB_TOUCH_Y_TOUCH_DEADZONE_SIZE; + min = WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_TOO_CLOSE; + } + + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && intersectInfo.distance > max) { + this.grabbedThingID = null; + this.setState(STATE_OFF, "pulled away from overlay"); + return; + } + var pos2D = projectOntoOverlayXYPlane(this.grabbedOverlay, intersectInfo.point); var pos3D = intersectInfo.point; + if (this.state == STATE_OVERLAY_STYLUS_TOUCHING && + !this.tabletStabbed && + intersectInfo.distance < min) { + // they've stabbed the tablet, don't send events until they pull back + this.tabletStabbed = true; + this.tabletStabbedPos2D = pos2D; + this.tabletStabbedPos3D = pos3D; + return; + } + + if (this.tabletStabbed) { + var origin = {x: this.tabletStabbedPos2D.x, y: this.tabletStabbedPos2D.y, z: 0}; + var point = {x: pos2D.x, y: pos2D.y, z: 0}; + var offset = Vec3.distance(origin, point); + var radius = 0.05; + if (offset < radius) { + return; + } + } + if (Overlays.keyboardFocusOverlay != this.grabbedOverlay) { Entities.keyboardFocusEntity = null; Overlays.keyboardFocusOverlay = this.grabbedOverlay; @@ -3560,7 +3402,7 @@ function MyController(hand) { var pointerEvent = { type: "Move", - id: this.hand + 1, + id: HARDWARE_MOUSE_ID, pos2D: pos2D, pos3D: pos3D, normal: intersectInfo.normal, @@ -3588,68 +3430,6 @@ function MyController(hand) { } }; - this.stylusTouchingEnter = function () { - this.stealTouchFocus(this.stylusTarget); - sendTouchStartEventToStylusTarget(this.hand, this.stylusTarget); - Controller.triggerHapticPulse(HAPTIC_STYLUS_STRENGTH, HAPTIC_STYLUS_DURATION, this.hand); - - this.touchingEnterTimer = 0; - this.touchingEnterStylusTarget = this.stylusTarget; - this.deadspotExpired = false; - - var TOUCH_PRESS_TO_MOVE_DEADSPOT = 0.0381; - this.deadspotRadius = TOUCH_PRESS_TO_MOVE_DEADSPOT; - }; - - this.stylusTouchingExit = function () { - - if (this.stylusTarget === undefined) { - return; - } - - // special case to handle home button. - if (this.stylusTarget.overlayID === HMD.homeButtonID) { - Messages.sendLocalMessage("home", this.stylusTarget.overlayID); - } - - // send press event - if (this.deadspotExpired) { - sendTouchEndEventToStylusTarget(this.hand, this.stylusTarget); - } else { - sendTouchEndEventToStylusTarget(this.hand, this.touchingEnterStylusTarget); - } - }; - - this.stylusTouching = function (dt) { - - this.touchingEnterTimer += dt; - - if (this.stylusTarget.entityID) { - entityPropertiesCache.addEntity(this.stylusTarget.entityID); - this.stylusTarget = calculateStylusTargetFromEntity(this.stylusTip, this.stylusTarget.entityID); - } else if (this.stylusTarget.overlayID) { - this.stylusTarget = calculateStylusTargetFromOverlay(this.stylusTip, this.stylusTarget.overlayID); - } - - var TABLET_MIN_TOUCH_DISTANCE = -0.1; - var TABLET_MAX_TOUCH_DISTANCE = 0.01; - - if (this.stylusTarget) { - if (this.stylusTarget.distance > TABLET_MIN_TOUCH_DISTANCE && this.stylusTarget.distance < TABLET_MAX_TOUCH_DISTANCE) { - var POINTER_PRESS_TO_MOVE_DELAY = 0.33; // seconds - if (this.deadspotExpired || this.touchingEnterTimer > POINTER_PRESS_TO_MOVE_DELAY || - distance2D(this.stylusTarget.position2D, this.touchingEnterStylusTarget.position2D) > this.deadspotRadius) { - sendTouchMoveEventToStylusTarget(this.hand, this.stylusTarget); - this.deadspotExpired = true; - } - } else { - this.setState(STATE_OFF, "hand moved away from touch surface"); - } - } else { - this.setState(STATE_OFF, "touch surface was destroyed"); - } - }; - this.release = function() { this.turnOffVisualizations(); @@ -3715,8 +3495,6 @@ function MyController(hand) { this.cleanup = function() { this.release(); this.grabPointSphereOff(); - this.hideStylus(); - this.overlayLineOff(); }; this.thisHandIsParent = function(props) { diff --git a/scripts/system/controllers/squeezeHands.js b/scripts/system/controllers/squeezeHands.js index c9de473e28..75e6249dd6 100644 --- a/scripts/system/controllers/squeezeHands.js +++ b/scripts/system/controllers/squeezeHands.js @@ -11,7 +11,6 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ (function() { // BEGIN LOCAL_SCOPE @@ -26,11 +25,7 @@ var OVERLAY_RAMP_RATE = 8.0; var animStateHandlerID; -var leftIndexPointingOverride = 0; -var rightIndexPointingOverride = 0; -var leftThumbRaisedOverride = 0; -var rightThumbRaisedOverride = 0; - +var isBothIndexesPointing = false; var HIFI_POINT_INDEX_MESSAGE_CHANNEL = "Hifi-Point-Index"; var isLeftIndexPointing = false; @@ -58,7 +53,7 @@ function init() { "leftHandOverlayAlpha", "leftHandGraspAlpha", "rightHandOverlayAlpha", "rightHandGraspAlpha", "isLeftHandGrasp", "isLeftIndexPoint", "isLeftThumbRaise", "isLeftIndexPointAndThumbRaise", - "isRightHandGrasp", "isRightIndexPoint", "isRightThumbRaise", "isRightIndexPointAndThumbRaise" + "isRightHandGrasp", "isRightIndexPoint", "isRightThumbRaise", "isRightIndexPointAndThumbRaise", ] ); Messages.subscribe(HIFI_POINT_INDEX_MESSAGE_CHANNEL); @@ -71,23 +66,21 @@ function animStateHandler(props) { leftHandGraspAlpha: lastLeftTrigger, rightHandOverlayAlpha: rightHandOverlayAlpha, rightHandGraspAlpha: lastRightTrigger, - - isLeftHandGrasp: !isLeftIndexPointing && !isLeftThumbRaised, - isLeftIndexPoint: isLeftIndexPointing && !isLeftThumbRaised, - isLeftThumbRaise: !isLeftIndexPointing && isLeftThumbRaised, - isLeftIndexPointAndThumbRaise: isLeftIndexPointing && isLeftThumbRaised, - - isRightHandGrasp: !isRightIndexPointing && !isRightThumbRaised, - isRightIndexPoint: isRightIndexPointing && !isRightThumbRaised, - isRightThumbRaise: !isRightIndexPointing && isRightThumbRaised, - isRightIndexPointAndThumbRaise: isRightIndexPointing && isRightThumbRaised + isLeftHandGrasp: !isBothIndexesPointing && !isLeftIndexPointing && !isLeftThumbRaised, + isLeftIndexPoint: (isBothIndexesPointing || isLeftIndexPointing) && !isLeftThumbRaised, + isLeftThumbRaise: !isBothIndexesPointing && !isLeftIndexPointing && isLeftThumbRaised, + isLeftIndexPointAndThumbRaise: (isBothIndexesPointing || isLeftIndexPointing) && isLeftThumbRaised, + isRightHandGrasp: !isBothIndexesPointing && !isRightIndexPointing && !isRightThumbRaised, + isRightIndexPoint: (isBothIndexesPointing || isRightIndexPointing) && !isRightThumbRaised, + isRightThumbRaise: !isBothIndexesPointing && !isRightIndexPointing && isRightThumbRaised, + isRightIndexPointAndThumbRaise: (isBothIndexesPointing || isRightIndexPointing) && isRightThumbRaised }; } function update(dt) { var leftTrigger = clamp(Controller.getValue(Controller.Standard.LT) + Controller.getValue(Controller.Standard.LeftGrip), 0, 1); var rightTrigger = clamp(Controller.getValue(Controller.Standard.RT) + Controller.getValue(Controller.Standard.RightGrip), 0, 1); - + // Average last few trigger values together for a bit of smoothing var tau = clamp(dt / TRIGGER_SMOOTH_TIMESCALE, 0, 1); lastLeftTrigger = lerp(leftTrigger, lastLeftTrigger, tau); @@ -110,61 +103,18 @@ function update(dt) { } // Pointing index fingers and raising thumbs - isLeftIndexPointing = (leftIndexPointingOverride > 0) || (leftHandPose.valid && Controller.getValue(Controller.Standard.LeftIndexPoint) === 1); - isRightIndexPointing = (rightIndexPointingOverride > 0) || (rightHandPose.valid && Controller.getValue(Controller.Standard.RightIndexPoint) === 1); - isLeftThumbRaised = (leftThumbRaisedOverride > 0) || (leftHandPose.valid && Controller.getValue(Controller.Standard.LeftThumbUp) === 1); - isRightThumbRaised = (rightThumbRaisedOverride > 0) || (rightHandPose.valid && Controller.getValue(Controller.Standard.RightThumbUp) === 1); + isLeftIndexPointing = leftHandPose.valid && Controller.getValue(Controller.Standard.LeftIndexPoint) === 1; + isRightIndexPointing = rightHandPose.valid && Controller.getValue(Controller.Standard.RightIndexPoint) === 1; + isLeftThumbRaised = leftHandPose.valid && Controller.getValue(Controller.Standard.LeftThumbUp) === 1; + isRightThumbRaised = rightHandPose.valid && Controller.getValue(Controller.Standard.RightThumbUp) === 1; } function handleMessages(channel, message, sender) { if (sender === MyAvatar.sessionUUID && channel === HIFI_POINT_INDEX_MESSAGE_CHANNEL) { var data = JSON.parse(message); - if (data.pointIndex !== undefined) { - if (data.pointIndex) { - leftIndexPointingOverride++; - rightIndexPointingOverride++; - } else { - leftIndexPointingOverride--; - rightIndexPointingOverride--; - } - } - if (data.pointLeftIndex !== undefined) { - if (data.pointLeftIndex) { - leftIndexPointingOverride++; - } else { - leftIndexPointingOverride--; - } - } - if (data.pointRightIndex !== undefined) { - if (data.pointRightIndex) { - rightIndexPointingOverride++; - } else { - rightIndexPointingOverride--; - } - } - if (data.raiseThumbs !== undefined) { - if (data.raiseThumbs) { - leftThumbRaisedOverride++; - rightThumbRaisedOverride++; - } else { - leftThumbRaisedOverride--; - rightThumbRaisedOverride--; - } - } - if (data.raiseLeftThumb !== undefined) { - if (data.raiseLeftThumb) { - leftThumbRaisedOverride++; - } else { - leftThumbRaisedOverride--; - } - } - if (data.raiseRightThumb !== undefined) { - if (data.raiseRightThumb) { - rightThumbRaisedOverride++; - } else { - rightThumbRaisedOverride--; - } + print("pointIndex: " + data.pointIndex); + isBothIndexesPointing = data.pointIndex; } } } diff --git a/scripts/system/controllers/teleport.js b/scripts/system/controllers/teleport.js index 90f8ccb368..1c6c9af272 100644 --- a/scripts/system/controllers/teleport.js +++ b/scripts/system/controllers/teleport.js @@ -441,12 +441,7 @@ function getTeleportTargetType(intersection) { var props = Entities.getEntityProperties(intersection.entityID, ['userData', 'visible']); var data = parseJSON(props.userData); if (data !== undefined && data.seat !== undefined) { - var avatarUuid = Uuid.fromString(data.seat.user); - if (Uuid.isNull(avatarUuid) || !AvatarList.getAvatar(avatarUuid)) { - return TARGET.SEAT; - } else { - return TARGET.INVALID; - } + return TARGET.SEAT; } if (!props.visible) { diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 770ebecba2..8b02eb1550 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1,6 +1,7 @@ "use strict"; -// edit.js +// newEditEntities.js +// examples // // Created by Brad Hefta-Gaub on 10/2/14. // Persist toolbar by HRS 6/11/15. @@ -12,8 +13,6 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EntityListTool, Vec3, SelectionManager, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, ParticleExplorerTool */ - (function() { // BEGIN LOCAL_SCOPE var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; @@ -112,13 +111,18 @@ selectionManager.addEventListener(function () { const KEY_P = 80; //Key code for letter p used for Parenting hotkey. var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; +var epsilon = 0.001; var MIN_ANGULAR_SIZE = 2; var MAX_ANGULAR_SIZE = 45; var allowLargeModels = true; var allowSmallModels = true; +var SPAWN_DISTANCE = 1; var DEFAULT_DIMENSION = 0.20; +var DEFAULT_TEXT_DIMENSION_X = 1.0; +var DEFAULT_TEXT_DIMENSION_Y = 1.0; +var DEFAULT_TEXT_DIMENSION_Z = 0.01; var DEFAULT_DIMENSIONS = { x: DEFAULT_DIMENSION, @@ -133,6 +137,7 @@ var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; var MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "Show Lights and Particle Systems in Edit Mode"; var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Edit Mode"; +var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled"; var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var SETTING_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE = "showLightsAndParticlesInEditMode"; @@ -204,13 +209,13 @@ function hideMarketplace() { marketplaceWindow.setURL("about:blank"); } -// function toggleMarketplace() { -// if (marketplaceWindow.visible) { -// hideMarketplace(); -// } else { -// showMarketplace(); -// } -// } +function toggleMarketplace() { + if (marketplaceWindow.visible) { + hideMarketplace(); + } else { + showMarketplace(); + } +} var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); @@ -223,6 +228,8 @@ var toolBar = (function () { tablet = null; function createNewEntity(properties) { + Settings.setValue(EDIT_SETTING, false); + var dimensions = properties.dimensions ? properties.dimensions : DEFAULT_DIMENSIONS; var position = getPositionToCreateEntity(); var entityID = null; @@ -230,12 +237,8 @@ var toolBar = (function () { position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions), properties.position = position; entityID = Entities.addEntity(properties); - if (properties.type == "ParticleEffect") { - selectParticleEntity(entityID); - } } else { - Window.notifyEditError("Can't create " + properties.type + ": " + - properties.type + " would be out of bounds."); + Window.notifyEditError("Can't create " + properties.type + ": " + properties.type + " would be out of bounds."); } selectionManager.clearSelections(); @@ -255,63 +258,24 @@ var toolBar = (function () { } } - var buttonHandlers = {}; // only used to tablet mode - function addButton(name, image, handler) { - buttonHandlers[name] = handler; - } - - var SHAPE_TYPE_NONE = 0; - var SHAPE_TYPE_SIMPLE_HULL = 1; - var SHAPE_TYPE_SIMPLE_COMPOUND = 2; - var SHAPE_TYPE_STATIC_MESH = 3; - var DYNAMIC_DEFAULT = false; - - function handleNewModelDialogResult(result) { - if (result) { - var url = result.textInput; - var shapeType; - switch (result.comboBox) { - case SHAPE_TYPE_SIMPLE_HULL: - shapeType = "simple-hull"; - break; - case SHAPE_TYPE_SIMPLE_COMPOUND: - shapeType = "simple-compound"; - break; - case SHAPE_TYPE_STATIC_MESH: - shapeType = "static-mesh"; - break; - default: - shapeType = "none"; - } - - var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; - if (shapeType === "static-mesh" && dynamic) { - // The prompt should prevent this case - print("Error: model cannot be both static mesh and dynamic. This should never happen."); - } else if (url) { - createNewEntity({ - type: "Model", - modelURL: url, - shapeType: shapeType, - dynamic: dynamic, - gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } - }); - } - } - } - - function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.popFromStack(); - switch (message.method) { - case "newModelDialogAdd": - handleNewModelDialogResult(message.params); - break; - case "newEntityButtonClicked": - buttonHandlers[message.params.buttonName](); - break; + var imageUrl = TOOLS_PATH + image; + var button = toolBar.addButton({ + objectName: name, + imageURL: imageUrl, + imageOffOut: 1, + imageOffIn: 2, + imageOnOut: 0, + imageOnIn: 2, + alpha: 0.9, + visible: true + }); + if (handler) { + button.clicked.connect(function () { + Script.setTimeout(handler, 100); + }); } + return button; } function initialize() { @@ -328,54 +292,101 @@ var toolBar = (function () { } }); - tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - activeButton = tablet.addButton({ - icon: "icons/tablet-icons/edit-i.svg", - activeIcon: "icons/tablet-icons/edit-a.svg", - text: "EDIT", - sortOrder: 10 - }); - tablet.screenChanged.connect(function (type, url) { - if (isActive && (type !== "QML" || url !== "Edit.qml")) { - that.toggle(); - } - }); - tablet.fromQml.connect(fromQml); + + if (Settings.getValue("HUDUIEnabled")) { + systemToolbar = Toolbars.getToolbar(SYSTEM_TOOLBAR); + activeButton = systemToolbar.addButton({ + objectName: EDIT_TOGGLE_BUTTON, + imageURL: TOOLS_PATH + "edit.svg", + visible: true, + alpha: 0.9, + defaultState: 1 + }); + } else { + tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + activeButton = tablet.addButton({ + icon: "icons/tablet-icons/edit-i.svg", + activeIcon: "icons/tablet-icons/edit-a.svg", + text: "EDIT", + sortOrder: 10 + }); + } activeButton.clicked.connect(function() { that.toggle(); }); - addButton("importEntitiesButton", "assets-01.svg", function() { - var importURL = null; - var fullPath = Window.browse("Select Model to Import", "", "*.json"); - if (fullPath) { - importURL = "file:///" + fullPath; - } - if (importURL) { - if (!isActive && (Entities.canRez() && Entities.canRezTmp())) { - toolBar.toggle(); - } - importSVO(importURL); - } - }); - - addButton("openAssetBrowserButton", "assets-01.svg", function() { + toolBar = Toolbars.getToolbar(EDIT_TOOLBAR); + toolBar.writeProperty("shown", false); + addButton("openAssetBrowserButton","assets-01.svg",function(){ Window.showAssetServer(); - }); + }) addButton("newModelButton", "model-01.svg", function () { + var SHAPE_TYPE_NONE = 0; + var SHAPE_TYPE_SIMPLE_HULL = 1; + var SHAPE_TYPE_SIMPLE_COMPOUND = 2; + var SHAPE_TYPE_STATIC_MESH = 3; var SHAPE_TYPES = []; SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_COMPOUND] = "Good - Sub-meshes"; SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; - var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; - // tablet version of new-model dialog - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.pushOntoStack("NewModelDialog.qml"); + var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; + var DYNAMIC_DEFAULT = false; + var result = Window.customPrompt({ + textInput: { + label: "Model URL" + }, + comboBox: { + label: "Automatic Collisions", + index: SHAPE_TYPE_DEFAULT, + items: SHAPE_TYPES + }, + checkBox: { + label: "Dynamic", + checked: DYNAMIC_DEFAULT, + disableForItems: [ + SHAPE_TYPE_STATIC_MESH + ], + checkStateOnDisable: false, + warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic" + } + }); + + if (result) { + var url = result.textInput; + var shapeType; + switch (result.comboBox) { + case SHAPE_TYPE_SIMPLE_HULL: + shapeType = "simple-hull"; + break; + case SHAPE_TYPE_SIMPLE_COMPOUND: + shapeType = "simple-compound"; + break; + case SHAPE_TYPE_STATIC_MESH: + shapeType = "static-mesh"; + break; + default: + shapeType = "none"; + } + + var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; + if (shapeType === "static-mesh" && dynamic) { + // The prompt should prevent this case + print("Error: model cannot be both static mesh and dynamic. This should never happen."); + } else if (url) { + createNewEntity({ + type: "Model", + modelURL: url, + shapeType: shapeType, + dynamic: dynamic, + gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } + }); + } + } }); addButton("newCubeButton", "cube-01.svg", function () { @@ -497,12 +508,10 @@ var toolBar = (function () { entityListTool.clearEntityList(); }; + that.toggle = function () { that.setActive(!isActive); activeButton.editProperties({isActive: isActive}); - if (!isActive) { - tablet.gotoHomeScreen(); - } }; that.setActive = function (active) { @@ -532,8 +541,6 @@ var toolBar = (function () { cameraManager.disable(); selectionDisplay.triggerMapping.disable(); } else { - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.loadQMLSource("Edit.qml"); UserActivityLogger.enabledEdit(); entityListTool.setVisible(true); gridTool.setVisible(true); @@ -544,6 +551,13 @@ var toolBar = (function () { // everybody else to think that Interface has lost focus overall. fogbugzid:558 // Window.setFocus(); } + // Sets visibility of tool buttons, excluding the power button + toolBar.writeProperty("shown", active); + var visible = toolBar.readProperty("visible"); + if (active && !visible) { + toolBar.writeProperty("shown", false); + toolBar.writeProperty("shown", true); + } entityIconOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_AND_PARTICLES_IN_EDIT_MODE)); Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE)); }; @@ -674,6 +688,7 @@ var idleMouseTimerId = null; var CLICK_TIME_THRESHOLD = 500 * 1000; // 500 ms var CLICK_MOVE_DISTANCE_THRESHOLD = 20; var IDLE_MOUSE_TIMEOUT = 200; +var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0; var lastMouseMoveEvent = null; @@ -747,22 +762,11 @@ function mouseReleaseEvent(event) { } } -function wasTabletClicked(event) { - var rayPick = Camera.computePickRay(event.x, event.y); - var result = Overlays.findRayIntersection(rayPick, true, [HMD.tabletID, HMD.tabletScreenID, HMD.homeButtonID]); - return result.intersects; -} - function mouseClickEvent(event) { var wantDebug = false; - var result, properties, tabletClicked; + var result, properties; if (isActive && event.isLeftButton) { result = findClickedEntity(event); - tabletClicked = wasTabletClicked(event); - if (tabletClicked) { - return; - } - if (result === null || result === undefined) { if (!event.isShifted) { selectionManager.clearSelections(); @@ -814,12 +818,6 @@ function mouseClickEvent(event) { orientation = MyAvatar.orientation; intersection = rayPlaneIntersection(pickRay, P, Quat.getForward(orientation)); - if (event.isShifted) { - particleExplorerTool.destroyWebView(); - } - if (properties.type !== "ParticleEffect") { - particleExplorerTool.destroyWebView(); - } if (!event.isShifted) { selectionManager.setSelections([foundEntity]); @@ -1345,11 +1343,11 @@ function getPositionToCreateEntity() { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), distance)); + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), distance)) } position.y += 0.5; if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { - return null; + return null } return position; } @@ -1363,11 +1361,11 @@ function getPositionToImportEntity() { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, longest)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), longest)); + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getForward(Camera.orientation), longest)) } if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { - return null; + return null } return position; @@ -1575,11 +1573,11 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) { Entities.getServerScriptStatus(entityID, onStatusReceived); } }, 1000); - } + }; }; self.stop = function() { self.active = false; - }; + } Entities.getServerScriptStatus(entityID, onStatusReceived); }; @@ -1587,9 +1585,11 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) { var PropertiesTool = function (opts) { var that = {}; - var webView = null; - webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - webView.setVisible = function(value) {}; + var webView = new OverlayWebWindow({ + title: 'Entity Properties', + source: ENTITY_PROPERTIES_URL, + toolWindow: true + }); var visible = false; @@ -1608,7 +1608,7 @@ var PropertiesTool = function (opts) { function updateScriptStatus(info) { info.type = "server_script_status"; webView.emitScriptEvent(JSON.stringify(info)); - } + }; function resetScriptStatus() { updateScriptStatus({ @@ -1619,7 +1619,7 @@ var PropertiesTool = function (opts) { }); } - function updateSelections(selectionUpdated) { + selectionManager.addEventListener(function (selectionUpdated) { var data = { type: 'update' }; @@ -1660,15 +1660,14 @@ var PropertiesTool = function (opts) { } data.selections = selections; webView.emitScriptEvent(JSON.stringify(data)); - } - selectionManager.addEventListener(updateSelections); + }); webView.webEventReceived.connect(function (data) { try { data = JSON.parse(data); } catch(e) { - print('Edit.js received web event that was not valid json.'); + print('Edit.js received web event that was not valid json.') return; } var i, properties, dY, diff, newPosition; @@ -1686,15 +1685,15 @@ var PropertiesTool = function (opts) { for (i = 0; i < selectionManager.selections.length; i++) { Entities.editEntity(selectionManager.selections[i], properties); } - } else if (data.properties) { + } else { if (data.properties.dynamic === false) { // this object is leaving dynamic, so we zero its velocities - data.properties.velocity = { + data.properties["velocity"] = { x: 0, y: 0, z: 0 }; - data.properties.angularVelocity = { + data.properties["angularVelocity"] = { x: 0, y: 0, z: 0 @@ -1823,8 +1822,6 @@ var PropertiesTool = function (opts) { } } } - } else if (data.type === "propertiesPageReady") { - updateSelections(true); } }); @@ -2008,45 +2005,13 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace"); var propertiesTool = new PropertiesTool(); var particleExplorerTool = new ParticleExplorerTool(); -var selectedParticleEntity = 0; var selectedParticleEntityID = null; - - -function selectParticleEntity(entityID) { - var properties = Entities.getEntityProperties(entityID); - var particleData = { - messageType: "particle_settings", - currentProperties: properties - }; - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); - - selectedParticleEntity = entityID; - particleExplorerTool.setActiveParticleEntity(entityID); - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); -} - entityListTool.webView.webEventReceived.connect(function (data) { data = JSON.parse(data); if (data.type === 'parent') { parentSelectedEntities(); } else if(data.type === 'unparent') { unparentSelectedEntities(); - } else if (data.type === "selectionUpdate") { - var ids = data.entityIds; - if (ids.length === 1) { - if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { - if (JSON.stringify(selectedParticleEntity) === JSON.stringify(ids[0])) { - // This particle entity is already selected, so return - return; - } - // Destroy the old particles web view first - selectParticleEntity(ids[0]); - } else { - selectedParticleEntity = 0; - particleExplorerTool.destroyWebView(); - } - } } }); diff --git a/scripts/system/fingerPaint.js b/scripts/system/fingerPaint.js index 27206ef9fa..959f594212 100644 --- a/scripts/system/fingerPaint.js +++ b/scripts/system/fingerPaint.js @@ -13,7 +13,6 @@ button, BUTTON_NAME = "PAINT", isFingerPainting = false, - shouldPointFingers = false, leftHand = null, rightHand = null, leftBrush = null, @@ -309,14 +308,9 @@ Messages.sendMessage(HIFI_POINTER_DISABLE_MESSAGE_CHANNEL, JSON.stringify({ pointerEnabled: enabled }), true); - - var newShouldPointFingers = !enabled; - if (newShouldPointFingers !== shouldPointFingers) { - Messages.sendMessage(HIFI_POINT_INDEX_MESSAGE_CHANNEL, JSON.stringify({ - pointIndex: newShouldPointFingers - }), true); - shouldPointFingers = newShouldPointFingers; - } + Messages.sendMessage(HIFI_POINT_INDEX_MESSAGE_CHANNEL, JSON.stringify({ + pointIndex: !enabled + }), true); } function enableProcessing() { @@ -436,4 +430,4 @@ setUp(); Script.scriptEnding.connect(tearDown); -}()); +}()); \ No newline at end of file diff --git a/scripts/system/generalSettings.js b/scripts/system/generalSettings.js index 7d97f13757..0a9fc823ae 100644 --- a/scripts/system/generalSettings.js +++ b/scripts/system/generalSettings.js @@ -18,7 +18,7 @@ var buttonName = "Settings"; var toolBar = null; var tablet = null; - var settings = "TabletGeneralPreferences.qml" + var settings = "TabletGeneralSettings.qml" function onClicked(){ if (tablet) { tablet.loadQMLSource(settings); diff --git a/scripts/system/help.js b/scripts/system/help.js index a335b2ef9c..3923b922fc 100644 --- a/scripts/system/help.js +++ b/scripts/system/help.js @@ -13,10 +13,8 @@ /* globals Tablet, Script, HMD, Controller, Menu */ (function() { // BEGIN LOCAL_SCOPE - - var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png"; + var buttonName = "HELP"; - var onHelpScreen = false; var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ icon: "icons/tablet-icons/help-i.svg", @@ -27,24 +25,18 @@ var enabled = false; function onClicked() { - if (onHelpScreen) { - tablet.gotoHomeScreen(); + if (enabled) { + Menu.closeInfoView('InfoView_html/help.html'); + enabled = !enabled; + button.editProperties({isActive: enabled}); } else { - var tabletEntity = HMD.tabletID; - if (tabletEntity) { - Entities.editEntity(tabletEntity, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})}); - } Menu.triggerOption('Help...'); - onHelpScreen = true; + enabled = !enabled; + button.editProperties({isActive: enabled}); } } - function onScreenChanged(type, url) { - onHelpScreen = false; - } - button.clicked.connect(onClicked); - tablet.screenChanged.connect(onScreenChanged); var POLL_RATE = 500; var interval = Script.setInterval(function () { @@ -56,8 +48,8 @@ }, POLL_RATE); Script.scriptEnding.connect(function () { - if (onHelpScreen) { - tablet.gotoHomeScreen(); + if (enabled) { + Menu.closeInfoView('InfoView_html/help.html'); } button.clicked.disconnect(onClicked); Script.clearInterval(interval); diff --git a/scripts/system/html/SnapshotReview.html b/scripts/system/html/SnapshotReview.html index 145cfb16a9..d37afb180c 100644 --- a/scripts/system/html/SnapshotReview.html +++ b/scripts/system/html/SnapshotReview.html @@ -3,43 +3,45 @@ Share + -
- -
-
-
-
-
-
-
-
-
+
+
+
+ +
+
+
+
+
Would you like to share your pics in the Snapshots feed?
+
+ + + + +
+
- - - - +
-
- +
+
+ + + + + + + +
-
-
- - - - - - - - +
diff --git a/scripts/system/html/css/SnapshotReview.css b/scripts/system/html/css/SnapshotReview.css index 34b690a021..c2965f92e1 100644 --- a/scripts/system/html/css/SnapshotReview.css +++ b/scripts/system/html/css/SnapshotReview.css @@ -8,81 +8,63 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html */ -body { - padding-top: 0; - padding-bottom: 14px; + +.snapshot-container { + width: 100%; + padding-top: 3px; +} + +.snapshot-column-left { + width: 320px; + position: absolute; + padding-top: 8px; +} + +.snapshot-column-right { + margin-left: 342px; +} + +.snapshot-column-right > div > img { + width: 100%; +} + +@media (max-width: 768px) { + .snapshot-column-left { + position: initial; + width: 100%; + } + .snapshot-column-right { + margin-left: 0; + width: 100%; + } + .snapshot-column-right > div > img { + margin-top: 18px !important; + } +} + +.snapshot-column-right > div { + position: relative; + padding: 2px; +} + +.snapshot-column-right > div > img { + border: 2px solid #575757; + margin: -2px; +} + +hr { + padding-left: 0; + padding-right: 0; + margin: 21px 0; } .snapsection { - padding-top: 14px; text-align: center; } -.snapsection.title { - padding-top: 0; - text-align: left; -} - -.title label { - font-size: 18px; - position: relative; - top: 12px; -} - -#snapshot-pane { - width: 100%; - height: 100%; - position: absolute; - top: 0; - left: 0; - box-sizing: border-box; - padding-top: 56px; - padding-bottom: 175px; -} - -#snapshot-images { - height: 100%; - width: 100%; - position: relative; -} - -#snapshot-images > div { - position: relative; - text-align: center; -} - -#snapshot-images img { - max-width: 100%; - max-height: 100%; - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - vertical-align: middle; -} - -#snapshot-images div.property { - margin-top: 0; - position: absolute; - top: 50%; - left: 7px; - transform: translate(0%, -50%); -} - -#snapshot-images img { - box-sizing: border-box; - padding: 0 7px 0 7px; -} - -#snapshot-images img.multiple { - padding-left: 28px; -} - -#snapshot-controls { - width: 100%; - position: absolute; - left: 0; - bottom: 14px; +.title { + text-transform: uppercase; + font-size: 12px; } .prompt { diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 06a60b5405..251d0a2d75 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -871,7 +871,6 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { float: right; margin-right: 0; background-color: #ff0000; - min-width: 90px; } #entity-list { diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 9d774f1861..3cb79353f9 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -24,7 +24,7 @@
- +
diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 35accdd0df..5022dbd6a6 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -77,7 +77,7 @@
- +
- + \ No newline at end of file diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index e0987ecd09..4fd0978a84 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -32,8 +32,6 @@ var gui = null; var settings = new Settings(); var updateInterval; -var active = false; - var currentInputField; var storedController; //CHANGE TO WHITELIST @@ -360,25 +358,9 @@ function listenForSettingsUpdates() { settings[key] = value; }); - if (gui) { - manuallyUpdateDisplay(); - } else { - loadGUI(); - } - if (!active) { - // gui.toggleHide(); - gui.closed = false; - } - active = true; - - } else if (data.messageType === "particle_close") { - // none of this seems to work. - // if (active) { - // gui.toggleHide(); - // } - active = false; - gui.closed = true; + loadGUI(); } + }); } @@ -523,4 +505,4 @@ function registerDOMElementsForListenerBlocking() { }); }); }); -} +} \ No newline at end of file diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index b3db475ab0..8a28445c33 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -18,21 +18,26 @@ ParticleExplorerTool = function() { var that = {}; that.createWebView = function() { - that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - that.webView.setVisible = function(value) {}; + var url = PARTICLE_EXPLORER_HTML_URL; + that.webView = new OverlayWebWindow({ + title: 'Particle Explorer', + source: url, + toolWindow: true + }); + + that.webView.setVisible(true); that.webView.webEventReceived.connect(that.webEventReceived); } + that.destroyWebView = function() { if (!that.webView) { return; } - that.activeParticleEntity = 0; - var messageData = { - messageType: "particle_close" - }; - that.webView.emitScriptEvent(JSON.stringify(messageData)); + that.webView.close(); + that.webView = null; + that.activeParticleEntity = 0; } that.webEventReceived = function(data) { @@ -46,5 +51,8 @@ ParticleExplorerTool = function() { that.activeParticleEntity = id; } + return that; -}; + + +}; \ No newline at end of file diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index 010544a2c6..b9dfc43f9a 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -36,36 +36,26 @@ function showFeedWindow() { DialogsManager.showFeed(); } -var outstanding; -var readyData; -function onMessage(message) { - // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: - // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) - // 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the - // same time, show the user all of them, and have the user deselect any that they do not want to share. - // So we'll ultimately be receiving a set of objects, perhaps with different post processing for each. - message = JSON.parse(message); - if (message.type !== "snapshot") { - return; - } +var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); - var isLoggedIn; - var needsLogin = false; - switch (message.action) { - case 'ready': // Send it. - tablet.emitScriptEvent(JSON.stringify({ - type: "snapshot", - action: readyData - })); +var outstanding; +function confirmShare(data) { + var dialog = new OverlayWebWindow('Snapshot Review', SNAPSHOT_REVIEW_URL, 800, 520); + function onMessage(message) { + // Receives message from the html dialog via the qwebchannel EventBridge. This is complicated by the following: + // 1. Although we can send POJOs, we cannot receive a toplevel object. (Arrays of POJOs are fine, though.) + // 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the + // same time, show the user all of them, and have the user deselect any that they do not want to share. + // So we'll ultimately be receiving a set of objects, perhaps with different post processing for each. + var isLoggedIn; + var needsLogin = false; + switch (message) { + case 'ready': + dialog.emitScriptEvent(data); // Send it. outstanding = 0; break; case 'openSettings': - if ((HMD.active && Settings.getValue("hmdTabletBecomesToolbar")) - || (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar"))) { - Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "General Preferences"); - } else { - tablet.loadQMLSource("TabletGeneralPreferences.qml"); - } + Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog"); break; case 'setOpenFeedFalse': Settings.setValue('openFeedAfterShare', false); @@ -74,11 +64,10 @@ function onMessage(message) { Settings.setValue('openFeedAfterShare', true); break; default: - //tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?! - HMD.closeTablet(); - tablet.gotoHomeScreen(); + dialog.webEventReceived.disconnect(onMessage); + dialog.close(); isLoggedIn = Account.isLoggedIn(); - message.action.forEach(function (submessage) { + message.forEach(function (submessage) { if (submessage.share && !isLoggedIn) { needsLogin = true; submessage.share = false; @@ -92,22 +81,15 @@ function onMessage(message) { } }); if (!outstanding && shouldOpenFeedAfterShare()) { - //showFeedWindow(); + showFeedWindow(); } if (needsLogin) { // after the possible feed, so that the login is on top Account.checkAndSignalForAccessToken(); } + } } -} - -var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); -var isInSnapshotReview = false; -function confirmShare(data) { - tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL); - readyData = data; - tablet.webEventReceived.connect(onMessage); - HMD.openTablet(); - isInSnapshotReview = true; + dialog.webEventReceived.connect(onMessage); + dialog.raise(); } function snapshotShared(errorMessage) { @@ -223,18 +205,10 @@ function processingGif() { } } -function onTabletScreenChanged(type, url) { - if (isInSnapshotReview) { - tablet.webEventReceived.disconnect(onMessage); - isInSnapshotReview = false; - } -} - button.clicked.connect(onClicked); buttonConnected = true; Window.snapshotShared.connect(snapshotShared); Window.processingGif.connect(processingGif); -tablet.screenChanged.connect(onTabletScreenChanged); Script.scriptEnding.connect(function () { if (buttonConnected) { @@ -246,7 +220,6 @@ Script.scriptEnding.connect(function () { } Window.snapshotShared.disconnect(snapshotShared); Window.processingGif.disconnect(processingGif); - tablet.screenChanged.disconnect(onTabletScreenChanged); }); }()); // END LOCAL_SCOPE diff --git a/scripts/system/tablet-ui/tabletUI.js b/scripts/system/tablet-ui/tabletUI.js index a010cb0a9c..fd73578328 100644 --- a/scripts/system/tablet-ui/tabletUI.js +++ b/scripts/system/tablet-ui/tabletUI.js @@ -12,167 +12,59 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays, - MyAvatar, Menu */ +/* global Script, HMD, WebTablet, UIWebTablet, UserActivityLogger, Settings, Entities, Messages, Tablet, Overlays, MyAvatar */ (function() { // BEGIN LOCAL_SCOPE var tabletShown = false; - var tabletRezzed = false; + var tabletLocation = null; var activeHand = null; - var DEFAULT_WIDTH = 0.4375; - var DEFAULT_TABLET_SCALE = 100; - var preMakeTime = Date.now(); - var validCheckTime = Date.now(); - var debugTablet = false; - var tabletScalePercentage = 100.0; - UIWebTablet = null; Script.include("../libraries/WebTablet.js"); - function tabletIsValid() { - if (!UIWebTablet) { - return false; - } - if (UIWebTablet.tabletIsOverlay && Overlays.getProperty(HMD.tabletID, "type") != "model") { - if (debugTablet) { - print("TABLET is invalid due to frame: " + JSON.stringify(Overlays.getProperty(HMD.tabletID, "type"))); - } - return false; - } - if (Overlays.getProperty(HMD.homeButtonID, "type") != "sphere" || - Overlays.getProperty(HMD.tabletScreenID, "type") != "web3d") { - if (debugTablet) { - print("TABLET is invalid due to other"); - } - return false; - } - return true; - } + function showTabletUI() { + tabletShown = true; + print("show tablet-ui"); - function getTabletScalePercentageFromSettings() { + var DEFAULT_WIDTH = 0.4375; + var DEFAULT_TABLET_SCALE = 100; var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode; - var tabletScalePercentage = DEFAULT_TABLET_SCALE; - if (!toolbarMode) { - if (HMD.active) { - tabletScalePercentage = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE; - } else { - tabletScalePercentage = Settings.getValue("desktopTabletScale") || DEFAULT_TABLET_SCALE; - } + var TABLET_SCALE = DEFAULT_TABLET_SCALE; + if (toolbarMode) { + TABLET_SCALE = Settings.getValue("desktopTabletScale") || DEFAULT_TABLET_SCALE; + } else { + TABLET_SCALE = Settings.getValue("hmdTabletScale") || DEFAULT_TABLET_SCALE; } - return tabletScalePercentage; - } - - function updateTabletWidthFromSettings() { - var newTabletScalePercentage = getTabletScalePercentageFromSettings(); - if (newTabletScalePercentage !== tabletScalePercentage && UIWebTablet) { - tabletScalePercentage = newTabletScalePercentage; - UIWebTablet.setWidth(DEFAULT_WIDTH * (tabletScalePercentage / 100)); - } - } - - function onHmdChanged() { - updateTabletWidthFromSettings(); - } - - function rezTablet() { - if (debugTablet) { - print("TABLET rezzing"); - } - - tabletScalePercentage = getTabletScalePercentageFromSettings(); - UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", - DEFAULT_WIDTH * (tabletScalePercentage / 100), - null, activeHand, true); + UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (TABLET_SCALE / 100), null, activeHand, true); UIWebTablet.register(); HMD.tabletID = UIWebTablet.tabletEntityID; HMD.homeButtonID = UIWebTablet.homeButtonID; HMD.tabletScreenID = UIWebTablet.webOverlayID; - HMD.displayModeChanged.connect(onHmdChanged); - - tabletRezzed = true; - } - - function showTabletUI() { - tabletShown = true; - - if (!tabletRezzed || !tabletIsValid()) { - closeTabletUI() - rezTablet(); - } - - if (UIWebTablet && tabletRezzed) { - if (debugTablet) { - print("TABLET in showTabletUI, already rezzed"); - } - var tabletProperties = {}; - UIWebTablet.calculateTabletAttachmentProperties(activeHand, true, tabletProperties); - tabletProperties.visible = true; - if (UIWebTablet.tabletIsOverlay) { - Overlays.editOverlay(HMD.tabletID, tabletProperties); - } - Overlays.editOverlay(HMD.homeButtonID, { visible: true }); - Overlays.editOverlay(HMD.tabletScreenID, { visible: true }); - Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 90 }); - } } function hideTabletUI() { tabletShown = false; - if (!UIWebTablet) { - return; - } - - if (UIWebTablet.tabletIsOverlay) { - if (debugTablet) { - print("TABLET hide"); - } - if (Settings.getValue("tabletVisibleToOthers")) { - closeTabletUI(); - } else { - // Overlays.editOverlay(HMD.tabletID, { localPosition: { x: -1000, y: 0, z:0 } }); - Overlays.editOverlay(HMD.tabletID, { visible: false }); - Overlays.editOverlay(HMD.homeButtonID, { visible: false }); - Overlays.editOverlay(HMD.tabletScreenID, { visible: false }); - Overlays.editOverlay(HMD.tabletScreenID, { maxFPS: 1 }); - } - } else { - closeTabletUI(); - } - } - - function closeTabletUI() { - tabletShown = false; + print("hide tablet-ui"); if (UIWebTablet) { if (UIWebTablet.onClose) { UIWebTablet.onClose(); } - if (debugTablet) { - print("TABLET close"); - } + tabletLocation = UIWebTablet.getLocation(); UIWebTablet.unregister(); UIWebTablet.destroy(); UIWebTablet = null; HMD.tabletID = null; HMD.homeButtonID = null; HMD.tabletScreenID = null; - } else if (debugTablet) { - print("TABLET closeTabletUI, UIWebTablet is null"); } - tabletRezzed = false; } - function updateShowTablet() { - var MSECS_PER_SEC = 1000.0; - var now = Date.now(); // close the WebTablet if it we go into toolbar mode. var toolbarMode = Tablet.getTablet("com.highfidelity.interface.tablet.system").toolbarMode; - var visibleToOthers = Settings.getValue("tabletVisibleToOthers"); - if (tabletShown && toolbarMode) { - closeTabletUI(); + hideTabletUI(); HMD.closeTablet(); return; } @@ -186,51 +78,19 @@ tablet.updateAudioBar(currentMicLevel); } - updateTabletWidthFromSettings(); - - if (validCheckTime - now > MSECS_PER_SEC) { - validCheckTime = now; - if (tabletRezzed && UIWebTablet && !tabletIsValid()) { - // when we switch domains, the tablet entity gets destroyed and recreated. this causes - // the overlay to be deleted, but not recreated. If the overlay is deleted for this or any - // other reason, close the tablet. - closeTabletUI(); - HMD.closeTablet(); - if (debugTablet) { - print("TABLET autodestroying"); - } - } - } - - // check for change in tablet scale. - - if (HMD.showTablet && !tabletShown && !toolbarMode) { - UserActivityLogger.openedTablet(visibleToOthers); + if (tabletShown && UIWebTablet && Overlays.getOverlayType(UIWebTablet.webOverlayID) != "web3d") { + // when we switch domains, the tablet entity gets destroyed and recreated. this causes + // the overlay to be deleted, but not recreated. If the overlay is deleted for this or any + // other reason, close the tablet. + hideTabletUI(); + HMD.closeTablet(); + } else if (HMD.showTablet && !tabletShown && !toolbarMode) { + UserActivityLogger.openedTablet(Settings.getValue("tabletVisibleToOthers")); showTabletUI(); } else if (!HMD.showTablet && tabletShown) { UserActivityLogger.closedTablet(); - if (visibleToOthers) { - closeTabletUI(); - } else { - hideTabletUI(); - } + hideTabletUI(); } - - // if the tablet is an overlay, attempt to pre-create it and then hide it so that when it's - // summoned, it will appear quickly. - if (!toolbarMode && !visibleToOthers) { - if (now - preMakeTime > MSECS_PER_SEC) { - preMakeTime = now; - if (!tabletIsValid()) { - closeTabletUI(); - rezTablet(); - tabletShown = false; - } else if (!tabletShown) { - hideTabletUI(); - } - } - } - } function toggleHand(channel, hand, senderUUID, localOnly) { diff --git a/scripts/system/tablet-users.js b/scripts/system/tablet-users.js index 591537f9bc..d5c381917e 100644 --- a/scripts/system/tablet-users.js +++ b/scripts/system/tablet-users.js @@ -67,12 +67,9 @@ } function onWebEventReceived(event) { + print("Script received a web event, its type is " + typeof event); if (typeof event === "string") { - try { - event = JSON.parse(event); - } catch(e) { - return; - } + event = JSON.parse(event); } if (event.type === "ready") { // send username to html diff --git a/scripts/tutorials/entity_scripts/pistol.js b/scripts/tutorials/entity_scripts/pistol.js index 1a570cc80f..38eb929177 100644 --- a/scripts/tutorials/entity_scripts/pistol.js +++ b/scripts/tutorials/entity_scripts/pistol.js @@ -151,9 +151,8 @@ }); }, randFloat(10, 200)); } - var isDynamic = Entities.getEntityProperties(intersection.entityID, "dynamic").dynamic; - if (isDynamic === 1) { - // Any dynamic entity can be shot + if (intersection.properties.dynamic === 1) { + // Any dynaic entity can be shot Entities.editEntity(intersection.entityID, { velocity: Vec3.multiply(this.firingDirection, this.bulletForce) }); @@ -348,7 +347,7 @@ this.laser = Overlays.addOverlay("line3d", { start: ZERO_VECTOR, end: ZERO_VECTOR, - color: { red: 255, green: 0, blue: 0}, + color: COLORS.RED, alpha: 1, visible: true, lineWidth: 2 diff --git a/scripts/tutorials/entity_scripts/sit.js b/scripts/tutorials/entity_scripts/sit.js index 3d3bc10fb1..82afdc8974 100644 --- a/scripts/tutorials/entity_scripts/sit.js +++ b/scripts/tutorials/entity_scripts/sit.js @@ -1,21 +1,5 @@ -// -// sit.js -// -// Created by Clement Brisset on 3/3/17 -// Copyright 2017 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - (function() { Script.include("/~/system/libraries/utils.js"); - if (!String.prototype.startsWith) { - String.prototype.startsWith = function(searchString, position){ - position = position || 0; - return this.substr(position, searchString.length) === searchString; - }; - } var SETTING_KEY = "com.highfidelity.avatar.isSitting"; var ANIMATION_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/clement/production/animations/sitting_idle.fbx"; @@ -44,10 +28,6 @@ this.interval = null; this.sitDownSettlePeriod = null; this.lastTimeNoDriveKeys = null; - this.sittingDown = false; - - // Preload the animation file - this.animation = AnimationCache.prefetch(ANIMATION_URL); this.preload = function(entityID) { this.entityID = entityID; @@ -120,19 +100,12 @@ return seatUser !== null; } - this.rolesToOverride = function() { - return MyAvatar.getAnimationRoles().filter(function(role) { - return role === "fly" || role.startsWith("inAir"); - }); - } - this.sitDown = function() { if (this.checkSeatForAvatar()) { print("Someone is already sitting in that chair."); return; } print("Sitting down (" + this.entityID + ")"); - this.sittingDown = true; var now = Date.now(); this.sitDownSettlePeriod = now + IK_SETTLE_TIME; @@ -144,15 +117,10 @@ if (previousValue === "") { MyAvatar.characterControllerEnabled = false; MyAvatar.hmdLeanRecenterEnabled = false; - var roles = this.rolesToOverride(); - for (i in roles) { - MyAvatar.overrideRoleAnimation(roles[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME); + var ROLES = MyAvatar.getAnimationRoles(); + for (i in ROLES) { + MyAvatar.overrideRoleAnimation(ROLES[i], ANIMATION_URL, ANIMATION_FPS, true, ANIMATION_FIRST_FRAME, ANIMATION_LAST_FRAME); } - - for (var i in OVERRIDEN_DRIVE_KEYS) { - MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]); - } - MyAvatar.resetSensorsAndBody(); } @@ -164,27 +132,25 @@ return { headType: 0 }; }, ["headType"]); Script.update.connect(this, this.update); + for (var i in OVERRIDEN_DRIVE_KEYS) { + MyAvatar.disableDriveKey(OVERRIDEN_DRIVE_KEYS[i]); + } } this.standUp = function() { print("Standing up (" + this.entityID + ")"); MyAvatar.removeAnimationStateHandler(this.animStateHandlerID); Script.update.disconnect(this, this.update); - - if (MyAvatar.sessionUUID === this.getSeatUser()) { - this.setSeatUser(null); + for (var i in OVERRIDEN_DRIVE_KEYS) { + MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]); } + this.setSeatUser(null); if (Settings.getValue(SETTING_KEY) === this.entityID) { Settings.setValue(SETTING_KEY, ""); - - for (var i in OVERRIDEN_DRIVE_KEYS) { - MyAvatar.enableDriveKey(OVERRIDEN_DRIVE_KEYS[i]); - } - - var roles = this.rolesToOverride(); - for (i in roles) { - MyAvatar.restoreRoleAnimation(roles[i]); + var ROLES = MyAvatar.getAnimationRoles(); + for (i in ROLES) { + MyAvatar.restoreRoleAnimation(ROLES[i]); } MyAvatar.characterControllerEnabled = true; MyAvatar.hmdLeanRecenterEnabled = true; @@ -199,7 +165,6 @@ MyAvatar.bodyRoll = 0.0; }, SIT_DELAY); } - this.sittingDown = false; } // function called by teleport.js if it detects the appropriate userData @@ -250,7 +215,7 @@ } this.update = function(dt) { - if (this.sittingDown === true) { + if (MyAvatar.sessionUUID === this.getSeatUser()) { var properties = Entities.getEntityProperties(this.entityID); var avatarDistance = Vec3.distance(MyAvatar.position, properties.position); var ikError = MyAvatar.getIKErrorOnLastSolve(); @@ -279,9 +244,6 @@ shouldStandUp = true; } - if (MyAvatar.sessionUUID !== this.getSeatUser()) { - shouldStandUp = true; - } if (shouldStandUp || avatarDistance > RELEASE_DISTANCE) { print("IK error: " + ikError + ", distance from chair: " + avatarDistance); @@ -291,11 +253,7 @@ var offset = { x: 0, y: 1.0, z: -0.5 - properties.dimensions.z * properties.registrationPoint.z }; var position = Vec3.sum(properties.position, Vec3.multiplyQbyV(properties.rotation, offset)); MyAvatar.position = position; - print("Moving Avatar in front of the chair."); - // Delay standing up by 1 cycle. - // This leaves times for the avatar to actually move since a lot - // of the stand up operations are threaded - return; + print("Moving Avatar in front of the chair.") } this.standUp(); diff --git a/tests/render-texture-load/src/main.cpp b/tests/render-texture-load/src/main.cpp index f426cd8024..d924f76232 100644 --- a/tests/render-texture-load/src/main.cpp +++ b/tests/render-texture-load/src/main.cpp @@ -456,7 +456,7 @@ protected: return; } auto texture = _textures[_currentTextureIndex]; - texture->setMinMip(texture->getMinMip() + 1); + texture->setMinMip(texture->minMip() + 1); } void loadTexture() {