pitch updates login pos/fix signup errors

This commit is contained in:
Wayne Chen 2018-12-05 11:24:06 -08:00
parent eb51a5b7b6
commit 27e4e1c245
4 changed files with 25 additions and 20 deletions

View file

@ -140,7 +140,7 @@ Item {
styleRenderType: Text.QtRendering styleRenderType: Text.QtRendering
anchors { anchors {
top: parent.top top: parent.top
topMargin: loginErrorMessage.height topMargin: errorContainer.height
} }
placeholderText: "Username or Email" placeholderText: "Username or Email"
activeFocusOnPress: true activeFocusOnPress: true

View file

@ -102,7 +102,7 @@ Item {
} else if (loggingInBody.withOculus) { } else if (loggingInBody.withOculus) {
// reset the flag. // reset the flag.
loggingInGlyph.visible = false; loggingInGlyph.visible = false;
loggingInText.text = "You are now logged into Oculus!" loggingInText.text = "You are now logged into Oculus!"
loggingInText.anchors.centerIn = loggingInHeader; loggingInText.anchors.centerIn = loggingInHeader;
loggingInText.anchors.bottom = loggingInHeader.bottom; loggingInText.anchors.bottom = loggingInHeader.bottom;
loggedInGlyph.text = hifi.glyphs.oculus; loggedInGlyph.text = hifi.glyphs.oculus;

View file

@ -64,22 +64,14 @@ Item {
} }
} }
function login() { function signup() {
loginDialog.signup(emailField.text, usernameField.text, passwordField.text); loginDialog.signup(emailField.text, usernameField.text, passwordField.text);
return; return;
bodyLoader.setSource("LoggingInBody.qml", { "loginDialog": loginDialog, "root": root, "bodyLoader": bodyLoader, "withSteam": false, "withOculus": false, "linkSteam": false });
} }
function init() { function init() {
// going to/from sign in/up dialog. // going to/from sign in/up dialog.
loginDialog.isLogIn = false; loginDialog.isLogIn = false;
loginErrorMessage.visible = (signUpBody.errorString !== "");
if (signUpBody.errorString !== "") {
loginErrorMessage.text = signUpBody.errorString;
errorContainer.anchors.bottom = usernameField.top;
errorContainer.anchors.bottomMargin = hifi.dimensions.contentSpacing.y;
errorContainer.anchors.left = usernameField.left;
}
emailField.placeholderText = "Email"; emailField.placeholderText = "Email";
emailField.text = ""; emailField.text = "";
emailField.anchors.top = usernameField.bottom; emailField.anchors.top = usernameField.bottom;
@ -133,7 +125,7 @@ Item {
Item { Item {
id: errorContainer id: errorContainer
width: loginErrorMessageTextMetrics.width width: parent.width
height: loginErrorMessageTextMetrics.height height: loginErrorMessageTextMetrics.height
anchors { anchors {
bottom: usernameField.top; bottom: usernameField.top;
@ -147,6 +139,7 @@ Item {
} }
Text { Text {
id: loginErrorMessage; id: loginErrorMessage;
width: root.bannerWidth
color: "red"; color: "red";
font.family: signUpBody.fontFamily font.family: signUpBody.fontFamily
font.pixelSize: 18 font.pixelSize: 18
@ -192,7 +185,7 @@ Item {
if (keepMeLoggedInCheckbox.checked) { if (keepMeLoggedInCheckbox.checked) {
Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text);
} }
signUpBody.login(); signUpBody.signup();
break; break;
} }
} }
@ -235,7 +228,7 @@ Item {
if (keepMeLoggedInCheckbox.checked) { if (keepMeLoggedInCheckbox.checked) {
Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text);
} }
signUpBody.login(); signUpBody.signup();
break; break;
} }
} }
@ -319,7 +312,7 @@ Item {
if (keepMeLoggedInCheckbox.checked) { if (keepMeLoggedInCheckbox.checked) {
Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text); Settings.setValue("keepMeLoggedIn/savedUsername", usernameField.text);
} }
signUpBody.login(); signUpBody.signup();
break; break;
} }
} }
@ -387,7 +380,7 @@ Item {
} }
onClicked: { onClicked: {
signUpBody.login() signUpBody.signup();
} }
} }
} }
@ -442,6 +435,13 @@ Item {
loginErrorMessage.visible = (errorStringEdited !== ""); loginErrorMessage.visible = (errorStringEdited !== "");
if (errorStringEdited !== "") { if (errorStringEdited !== "") {
loginErrorMessage.text = errorStringEdited; loginErrorMessage.text = errorStringEdited;
loginErrorMessageTextMetrics.text = errorStringEdited;
if (loginErrorMessageTextMetrics.width > 350 && root.isTablet) {
loginErrorMessage.wrapMode = Text.WordWrap;
loginErrorMessage.verticalAlignment = Text.AlignLeft;
loginErrorMessage.horizontalAlignment = Text.AlignLeft;
errorContainer.height = 2 * loginErrorMessageTextMetrics.height;
}
errorContainer.anchors.bottom = usernameField.top; errorContainer.anchors.bottom = usernameField.top;
errorContainer.anchors.left = usernameField.left; errorContainer.anchors.left = usernameField.left;
} }

View file

@ -8656,11 +8656,13 @@ void Application::createLoginDialogOverlay() {
} }
void Application::updateLoginDialogOverlayPosition() { void Application::updateLoginDialogOverlayPosition() {
auto overlayPosition = getOverlays().getProperty(_loginDialogOverlayID, "position"); const float LOOK_AWAY_THRESHOLD_ANGLE = 40.0f;
auto& overlays = getOverlays();
auto overlayPosition = overlays.getProperty(_loginDialogOverlayID, "position");
auto overlayPositionVec = vec3FromVariant(overlayPosition.value); auto overlayPositionVec = vec3FromVariant(overlayPosition.value);
auto cameraPositionVec = _myCamera.getPosition(); auto cameraPositionVec = _myCamera.getPosition();
auto cameraOrientation = _myCamera.getOrientation(); auto cameraOrientation = _myCamera.getOrientation();
cameraOrientation = cancelOutRollAndPitch(cameraOrientation); cameraOrientation = cancelOutRoll(cameraOrientation);
auto headLookVec = (cameraOrientation * Vectors::FRONT); auto headLookVec = (cameraOrientation * Vectors::FRONT);
auto overlayToHeadVec = overlayPositionVec - cameraPositionVec; auto overlayToHeadVec = overlayPositionVec - cameraPositionVec;
auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI); auto pointAngle = (glm::acos(glm::dot(glm::normalize(overlayToHeadVec), glm::normalize(headLookVec))) * 180.0f / PI);
@ -8669,12 +8671,15 @@ void Application::updateLoginDialogOverlayPosition() {
auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f); auto newOverlayPositionVec = (cameraPositionVec + offset) + (upVec * -0.1f);
auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180; auto newOverlayOrientation = glm::inverse(glm::quat_cast(glm::lookAt(newOverlayPositionVec, cameraPositionVec, upVec))) * Quaternions::Y_180;
if (pointAngle > 40.0f) { //auto isOverlayTooFar = (glm::distance(overlayPositionVec, getMyAvatar()->getWorldPosition()) > 1.0f);
//if (pointAngle > LOOK_AWAY_THRESHOLD_ANGLE || isOverlayTooFar) {
if (pointAngle > LOOK_AWAY_THRESHOLD_ANGLE) {
QVariantMap properties { QVariantMap properties {
{"position", vec3toVariant(newOverlayPositionVec)}, {"position", vec3toVariant(newOverlayPositionVec)},
{"orientation", quatToVariant(newOverlayOrientation)} {"orientation", quatToVariant(newOverlayOrientation)}
}; };
getOverlays().editOverlay(_loginDialogOverlayID, properties); overlays.editOverlay(_loginDialogOverlayID, properties);
} }
} }