From 4c83c6918d2682caad29b55272bcef445fbd6e11 Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Fri, 29 May 2015 16:44:16 -0700 Subject: [PATCH 01/14] fixed avatar billboards not displaying --- interface/src/Application.cpp | 19 +++++++++++++------ interface/src/Application.h | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 877b5ed931..d4f87056cd 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3103,20 +3103,27 @@ PickRay Application::computePickRay(float x, float y) const { QImage Application::renderAvatarBillboard() { auto primaryFramebuffer = DependencyManager::get()->getPrimaryFramebuffer(); glBindFramebuffer(GL_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFramebuffer)); - + + // clear the alpha channel so the background is transparent + glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); + // the "glow" here causes an alpha of one Glower glower; - + const int BILLBOARD_SIZE = 64; renderRearViewMirror(QRect(0, _glWidget->getDeviceHeight() - BILLBOARD_SIZE, BILLBOARD_SIZE, BILLBOARD_SIZE), true); - + QImage image(BILLBOARD_SIZE, BILLBOARD_SIZE, QImage::Format_ARGB32); glReadPixels(0, 0, BILLBOARD_SIZE, BILLBOARD_SIZE, GL_BGRA, GL_UNSIGNED_BYTE, image.bits()); - + glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glBindFramebuffer(GL_FRAMEBUFFER, 0); - + return image; } @@ -3160,7 +3167,7 @@ const ViewFrustum* Application::getDisplayViewFrustum() const { return &_displayViewFrustum; } -void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs::RenderSide renderSide) { +void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, bool billboard, RenderArgs::RenderSide renderSide) { activeRenderingThread = QThread::currentThread(); PROFILE_RANGE(__FUNCTION__); PerformanceTimer perfTimer("display"); diff --git a/interface/src/Application.h b/interface/src/Application.h index 2226c97b99..b6efb6420b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -270,7 +270,7 @@ public: QImage renderAvatarBillboard(); - void displaySide(Camera& whichCamera, bool selfAvatarOnly = false, RenderArgs::RenderSide renderSide = RenderArgs::MONO); + void displaySide(Camera& whichCamera, bool selfAvatarOnly = false, bool billboard = false, RenderArgs::RenderSide renderSide = RenderArgs::MONO); /// Stores the current modelview matrix as the untranslated view matrix to use for transforms and the supplied vector as /// the view matrix translation. From c19115a4852b870cf7a6f994870aabe21f4f677f Mon Sep 17 00:00:00 2001 From: Sam Gondelman Date: Fri, 29 May 2015 16:53:01 -0700 Subject: [PATCH 02/14] actually fixed billboard --- interface/src/Application.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d4f87056cd..0db28af77f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3383,7 +3383,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, bool billb false, selfAvatarOnly); } - { + if (!billboard) { DependencyManager::get()->setAmbientLightMode(getRenderAmbientLight()); auto skyStage = DependencyManager::get()->getSkyStage(); DependencyManager::get()->setGlobalLight(skyStage->getSunLight()->getDirection(), skyStage->getSunLight()->getColor(), skyStage->getSunLight()->getIntensity(), skyStage->getSunLight()->getAmbientIntensity()); @@ -3586,7 +3586,7 @@ void Application::renderRearViewMirror(const QRect& region, bool billboard) { // render rear mirror view glPushMatrix(); - displaySide(_mirrorCamera, true); + displaySide(_mirrorCamera, true, billboard); glPopMatrix(); if (!billboard) { From 2a931119bdee73512aef793e8417adaa8274bc89 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 28 May 2015 12:17:21 -0700 Subject: [PATCH 03/14] Replace expand/collapse dialog animation with fade in/out --- interface/resources/qml/controls/Dialog.qml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/controls/Dialog.qml b/interface/resources/qml/controls/Dialog.qml index f32b4e2e66..15c8b7bafc 100644 --- a/interface/resources/qml/controls/Dialog.qml +++ b/interface/resources/qml/controls/Dialog.qml @@ -31,7 +31,7 @@ DialogBase { * Support for animating the dialog in and out. */ enabled: false - scale: 0.0 + opacity: 0.0 // The offscreen UI will enable an object, rather than manipulating it's // visibility, so that we can do animations in both directions. Because @@ -40,20 +40,20 @@ DialogBase { // opacity, and then when the target animation value is reached, we can // modify the visibility onEnabledChanged: { - scale = enabled ? 1.0 : 0.0 + opacity = enabled ? 1.0 : 0.0 } // The actual animator - Behavior on scale { + Behavior on opacity { NumberAnimation { - duration: root.animationDuration - easing.type: Easing.InOutBounce + duration: 300 + easing.type: Easing.OutCubic } } - // Once we're scaled to 0, disable the dialog's visibility - onScaleChanged: { - visible = (scale != 0.0); + // Once we're transparent, disable the dialog's visibility + onOpacityChanged: { + visible = (opacity != 0.0); } // Some dialogs should be destroyed when they become invisible, From a43593c3b2dde13b495ada6d965459db97041b36 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 29 May 2015 15:23:55 -0700 Subject: [PATCH 04/14] Dialog opacity transition tidying --- interface/resources/qml/controls/Dialog.qml | 4 ++-- interface/resources/qml/styles/HifiConstants.qml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/resources/qml/controls/Dialog.qml b/interface/resources/qml/controls/Dialog.qml index 15c8b7bafc..aa14e2fcba 100644 --- a/interface/resources/qml/controls/Dialog.qml +++ b/interface/resources/qml/controls/Dialog.qml @@ -31,7 +31,7 @@ DialogBase { * Support for animating the dialog in and out. */ enabled: false - opacity: 0.0 + opacity: 1.0 // The offscreen UI will enable an object, rather than manipulating it's // visibility, so that we can do animations in both directions. Because @@ -46,7 +46,7 @@ DialogBase { // The actual animator Behavior on opacity { NumberAnimation { - duration: 300 + duration: animationDuration easing.type: Easing.OutCubic } } diff --git a/interface/resources/qml/styles/HifiConstants.qml b/interface/resources/qml/styles/HifiConstants.qml index d24e9ca9be..702a396afb 100644 --- a/interface/resources/qml/styles/HifiConstants.qml +++ b/interface/resources/qml/styles/HifiConstants.qml @@ -56,6 +56,6 @@ Item { QtObject { id: effects - readonly property int fadeInDuration: 400 + readonly property int fadeInDuration: 300 } } From 881941b64dd89acd98af8b00b8f4db41c8e02abc Mon Sep 17 00:00:00 2001 From: David Rowe Date: Fri, 29 May 2015 15:25:35 -0700 Subject: [PATCH 05/14] Restyle address bar dialog Made the dialog a stand-alone QML file that doesn't inherit from other dialog QML files so that don't need to rework all dialogs right now. --- interface/resources/qml/AddressBarDialog.qml | 185 ++++++++++++------- 1 file changed, 116 insertions(+), 69 deletions(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index e12452472a..42a0a7dd7e 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -1,91 +1,124 @@ import Hifi 1.0 import QtQuick 2.3 +import QtQuick.Controls 1.2 import "controls" import "styles" -Dialog { +Item { id: root HifiConstants { id: hifi } - - title: "Go to..." + objectName: "AddressBarDialog" - contentImplicitWidth: addressBarDialog.implicitWidth - contentImplicitHeight: addressBarDialog.implicitHeight - destroyOnCloseButton: false + property int animationDuration: hifi.effects.fadeInDuration + property bool destroyOnInvisible: false + property bool destroyOnCloseButton: true - onVisibleChanged: { - if (!visible) { - reset(); - } - } + implicitWidth: addressBarDialog.implicitWidth + implicitHeight: addressBarDialog.implicitHeight + + x: parent ? parent.width / 2 - width / 2 : 0 + y: parent ? parent.height / 2 - height / 2 : 0 + + AddressBarDialog { + id: addressBarDialog + + implicitWidth: box.width + implicitHeight: addressLine.height + hifi.layout.spacing * 2 + + Border { + id: box + + width: 512 + height: parent.height + border.width: 0 + radius: 6 + color: "#ededee" + + MouseArea { + id: boxDrag + + anchors.fill: parent + + drag { + target: root + minimumX: 0 + minimumY: 0 + maximumX: root.parent ? root.parent.width - root.width : 0 + maximumY: root.parent ? root.parent.height - root.height : 0 + } + } + + TextInput { + id: addressLine + + anchors.fill: parent + anchors.leftMargin: hifi.layout.spacing * 2 + anchors.rightMargin: hifi.layout.spacing * 2 + anchors.topMargin: hifi.layout.spacing + anchors.bottomMargin: hifi.layout.spacing + + font.pointSize: 15 + helperText: "Go to: place, @user, /path, network address" + + onAccepted: { + event.accepted + addressBarDialog.loadAddress(addressLine.text) + } + } + } + } + + // The UI enables an object, rather than manipulating its visibility, so that we can do animations in both directions. + // Because visibility and enabled are booleans, they cannot be animated. So when enabled is changed, we modify a property + // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the + // visibility. + enabled: false + opacity: 1.0 onEnabledChanged: { + opacity = enabled ? 1.0 : 0.0 if (enabled) { addressLine.forceActiveFocus(); } } - onParentChanged: { - if (enabled && visible) { - addressLine.forceActiveFocus(); + + Behavior on opacity { + // Animate opacity. + NumberAnimation { + duration: animationDuration + easing.type: Easing.OutCubic } } + onOpacityChanged: { + // Once we're transparent, disable the dialog's visibility. + visible = (opacity != 0.0) + } + + onVisibleChanged: { + if (!visible) { + reset() + + // Some dialogs should be destroyed when they become invisible. + if (destroyOnInvisible) { + destroy() + } + } + + } + + function close() { + // The close function performs the same way as the OffscreenUI class: don't do anything but manipulate the enabled flag + // and let the other mechanisms decide if the window should be destroyed after the close animation completes. + if (destroyOnCloseButton) { + destroyOnInvisible = true + } + enabled = false + } + function reset() { addressLine.text = "" - goButton.source = "../images/address-bar-submit.svg" - } - - AddressBarDialog { - id: addressBarDialog - // The client area - x: root.clientX - y: root.clientY - implicitWidth: 512 - implicitHeight: border.height + hifi.layout.spacing * 4 - - - Border { - id: border - height: 64 - anchors.left: parent.left - anchors.leftMargin: hifi.layout.spacing * 2 - anchors.right: goButton.left - anchors.rightMargin: hifi.layout.spacing - anchors.verticalCenter: parent.verticalCenter - TextInput { - id: addressLine - anchors.fill: parent - helperText: "domain, location, @user, /x,y,z" - anchors.margins: hifi.layout.spacing - onAccepted: { - event.accepted - addressBarDialog.loadAddress(addressLine.text) - } - } - } - - Image { - id: goButton - width: 32 - height: 32 - anchors.right: parent.right - anchors.rightMargin: hifi.layout.spacing * 2 - source: "../images/address-bar-submit.svg" - anchors.verticalCenter: parent.verticalCenter - - MouseArea { - anchors.fill: parent - onClicked: { - parent.source = "../images/address-bar-submit-active.svg" - addressBarDialog.loadAddress(addressLine.text) - } - } - } - } - - Keys.onEscapePressed: { - enabled = false; } function toggleOrGo() { @@ -95,8 +128,22 @@ Dialog { addressBarDialog.loadAddress(addressLine.text) } } - + + Keys.onEscapePressed: { + enabled = false + } + + Keys.onPressed: { + switch(event.key) { + case Qt.Key_W: + if (event.modifiers == Qt.ControlModifier) { + event.accepted = true + enabled = false + } + break + } + } + Keys.onReturnPressed: toggleOrGo() Keys.onEnterPressed: toggleOrGo() } - From 05e251eba4f5e2d77524df1bf64e0cd32cc41df3 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sat, 30 May 2015 12:01:50 -0700 Subject: [PATCH 06/14] Add icon to address bar dialog --- .../resources/images/address-bar-icon.svg | 63 +++++++++++++++++++ .../images/address-bar-submit-active.svg | 18 ------ .../resources/images/address-bar-submit.svg | 18 ------ interface/resources/qml/AddressBarDialog.qml | 48 +++++++++++--- 4 files changed, 102 insertions(+), 45 deletions(-) create mode 100644 interface/resources/images/address-bar-icon.svg delete mode 100644 interface/resources/images/address-bar-submit-active.svg delete mode 100644 interface/resources/images/address-bar-submit.svg diff --git a/interface/resources/images/address-bar-icon.svg b/interface/resources/images/address-bar-icon.svg new file mode 100644 index 0000000000..a6d67aabae --- /dev/null +++ b/interface/resources/images/address-bar-icon.svg @@ -0,0 +1,63 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/interface/resources/images/address-bar-submit-active.svg b/interface/resources/images/address-bar-submit-active.svg deleted file mode 100644 index 313b366033..0000000000 --- a/interface/resources/images/address-bar-submit-active.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/interface/resources/images/address-bar-submit.svg b/interface/resources/images/address-bar-submit.svg deleted file mode 100644 index df4d7e90f6..0000000000 --- a/interface/resources/images/address-bar-submit.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 42a0a7dd7e..a3f7c6ba18 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -23,8 +23,12 @@ Item { AddressBarDialog { id: addressBarDialog - implicitWidth: box.width - implicitHeight: addressLine.height + hifi.layout.spacing * 2 + property int iconOverlap: 15 // Let the circle overlap window edges and rectangular part of dialog + property int maximumX: root.parent.width - root.width + property int maximumY: root.parent.height - root.height + + implicitWidth: box.width + icon.width - iconOverlap * 2 + implicitHeight: addressLine.height + hifi.layout.spacing * 2 Border { id: box @@ -35,6 +39,8 @@ Item { radius: 6 color: "#ededee" + x: icon.width - addressBarDialog.iconOverlap * 2 // W.r.t. addressBarDialog + MouseArea { id: boxDrag @@ -42,18 +48,18 @@ Item { drag { target: root - minimumX: 0 - minimumY: 0 - maximumX: root.parent ? root.parent.width - root.width : 0 - maximumY: root.parent ? root.parent.height - root.height : 0 - } + minimumX: 0 + minimumY: 0 + maximumX: root.parent ? addressBarDialog.maximumX : 0 + maximumY: root.parent ? addressBarDialog.maximumY : 0 + } } TextInput { id: addressLine anchors.fill: parent - anchors.leftMargin: hifi.layout.spacing * 2 + anchors.leftMargin: addressBarDialog.iconOverlap + hifi.layout.spacing * 2 anchors.rightMargin: hifi.layout.spacing * 2 anchors.topMargin: hifi.layout.spacing anchors.bottomMargin: hifi.layout.spacing @@ -67,7 +73,31 @@ Item { } } } - } + + Image { + id: icon + source: "../images/address-bar-icon.svg" + width: 80 + height: 80 + anchors.right: box.left + anchors.rightMargin: -addressBarDialog.iconOverlap + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + id: iconDrag + + anchors.fill: parent + + drag { + target: root + minimumX: 0 + minimumY: 0 + maximumX: root.parent ? addressBarDialog.maximumX : 0 + maximumY: root.parent ? addressBarDialog.maximumY : 0 + } + } + } + } // The UI enables an object, rather than manipulating its visibility, so that we can do animations in both directions. // Because visibility and enabled are booleans, they cannot be animated. So when enabled is changed, we modify a property From e41b4c1b7b4bfed4c8ba7af6a86a0842ddfc7ada Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 31 May 2015 20:56:11 -0700 Subject: [PATCH 07/14] Add new address bar dialog error message Implemented as a new simple InformationDialog so that can try it out without reworking MessageDialog immediately for all QML UI. --- .../images/address-bar-error-close.svg | 50 ++++++ .../images/address-bar-error-icon.svg | 3 + interface/resources/qml/ErrorDialog.qml | 152 ++++++++++++++++++ interface/src/Application.cpp | 14 +- interface/src/ui/AddressBarDialog.cpp | 6 +- libraries/ui/src/ErrorDialog.cpp | 38 +++++ libraries/ui/src/ErrorDialog.h | 46 ++++++ libraries/ui/src/OffscreenUi.cpp | 10 ++ libraries/ui/src/OffscreenUi.h | 2 + 9 files changed, 311 insertions(+), 10 deletions(-) create mode 100644 interface/resources/images/address-bar-error-close.svg create mode 100644 interface/resources/images/address-bar-error-icon.svg create mode 100644 interface/resources/qml/ErrorDialog.qml create mode 100644 libraries/ui/src/ErrorDialog.cpp create mode 100644 libraries/ui/src/ErrorDialog.h diff --git a/interface/resources/images/address-bar-error-close.svg b/interface/resources/images/address-bar-error-close.svg new file mode 100644 index 0000000000..45a4dd4635 --- /dev/null +++ b/interface/resources/images/address-bar-error-close.svg @@ -0,0 +1,50 @@ + +image/svg+xml \ No newline at end of file diff --git a/interface/resources/images/address-bar-error-icon.svg b/interface/resources/images/address-bar-error-icon.svg new file mode 100644 index 0000000000..f2453fb0d4 --- /dev/null +++ b/interface/resources/images/address-bar-error-icon.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/interface/resources/qml/ErrorDialog.qml b/interface/resources/qml/ErrorDialog.qml new file mode 100644 index 0000000000..72b2c24e90 --- /dev/null +++ b/interface/resources/qml/ErrorDialog.qml @@ -0,0 +1,152 @@ +// +// ErrorDialog.qml +// +// Created by David Rowe on 30 May 2015 +// 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 as Hifi +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Dialogs 1.2 +import "controls" +import "styles" + +Item { + id: root + HifiConstants { id: hifi } + + property int animationDuration: hifi.effects.fadeInDuration + property bool destroyOnInvisible: true + + Component.onCompleted: { + enabled = true + } + + onParentChanged: { + if (visible && enabled) { + forceActiveFocus(); + } + } + + implicitWidth: content.implicitWidth + implicitHeight: content.implicitHeight + + x: parent ? parent.width / 2 - width / 2 : 0 + y: parent ? parent.height / 2 - height / 2 : 0 + + Hifi.ErrorDialog { + id: content + + implicitWidth: box.width + implicitHeight: icon.height + hifi.layout.spacing * 2 + + Border { + id: box + + width: 512 + color: "#ebebeb" + radius: 2 + border.width: 1 + border.color: "#000000" + + Image { + id: icon + + source: "../images/address-bar-error-icon.svg" + width: 40 + height: 40 + anchors { + left: parent.left + leftMargin: hifi.layout.spacing + verticalCenter: parent.verticalCenter + } + } + + Text { + id: messageText + + font.pointSize: 10 + font.weight: Font.Bold + + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + + text: content.text + } + + Image { + source: "../images/address-bar-error-close.svg" + width: 20 + height: 20 + anchors { + right: parent.right + rightMargin: hifi.layout.spacing * 2 + verticalCenter: parent.verticalCenter + } + MouseArea { + anchors.fill: parent + onClicked: { + content.accept(); + } + } + } + } + } + + // The UI enables an object, rather than manipulating its visibility, so that we can do animations in both directions. + // Because visibility and enabled are booleans, they cannot be animated. So when enabled is changed, we modify a property + // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the + // visibility. + enabled: false + opacity: 1.0 + + onEnabledChanged: { + opacity = enabled ? 1.0 : 0.0 + } + + Behavior on opacity { + // Animate opacity. + NumberAnimation { + duration: animationDuration + easing.type: Easing.OutCubic + } + } + + onOpacityChanged: { + // Once we're transparent, disable the dialog's visibility. + visible = (opacity != 0.0) + } + + onVisibleChanged: { + if (!visible) { + // Some dialogs should be destroyed when they become invisible. + if (destroyOnInvisible) { + destroy() + } + } + } + + Keys.onPressed: { + if (event.modifiers === Qt.ControlModifier) + switch (event.key) { + case Qt.Key_W: + event.accepted = true + content.accept() + break + } else switch (event.key) { + case Qt.Key_Escape: + case Qt.Key_Back: + case Qt.Key_Enter: + case Qt.Key_Return: + event.accepted = true + content.accept() + break + } + } +} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 877b5ed931..d43306715a 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -55,40 +55,41 @@ #include #include -#include #include +#include #include #include #include #include #include +#include #include #include #include -#include +#include #include #include +#include #include #include #include +#include #include #include -#include #include #include #include #include #include #include +#include #include #include #include #include #include #include -#include -#include -#include +#include #include "Application.h" #include "AudioClient.h" @@ -799,6 +800,7 @@ void Application::initializeGL() { void Application::initializeUi() { AddressBarDialog::registerType(); + ErrorDialog::registerType(); LoginDialog::registerType(); MessageDialog::registerType(); VrMenu::registerType(); diff --git a/interface/src/ui/AddressBarDialog.cpp b/interface/src/ui/AddressBarDialog.cpp index 837702d253..3c3a843586 100644 --- a/interface/src/ui/AddressBarDialog.cpp +++ b/interface/src/ui/AddressBarDialog.cpp @@ -36,12 +36,10 @@ void AddressBarDialog::loadAddress(const QString& address) { } void AddressBarDialog::displayAddressOfflineMessage() { - OffscreenUi::information("Address offline", - "That user or place is currently offline."); + OffscreenUi::error("That user or place is currently offline"); } void AddressBarDialog::displayAddressNotFoundMessage() { - OffscreenUi::information("Address not found", - "There is no address information for that user or place."); + OffscreenUi::error("There is no address information for that user or place"); } diff --git a/libraries/ui/src/ErrorDialog.cpp b/libraries/ui/src/ErrorDialog.cpp new file mode 100644 index 0000000000..ab36ef8d36 --- /dev/null +++ b/libraries/ui/src/ErrorDialog.cpp @@ -0,0 +1,38 @@ +// +// ErrorDialog.cpp +// +// Created by David Rowe on 30 May 2015 +// 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 +// + +#include "ErrorDialog.h" + +HIFI_QML_DEF(ErrorDialog) + +ErrorDialog::ErrorDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) { +} + +ErrorDialog::~ErrorDialog() { +} + +QString ErrorDialog::text() const { + return _text; +} + +void ErrorDialog::setVisible(bool v) { + OffscreenQmlDialog::setVisible(v); +} + +void ErrorDialog::setText(const QString& arg) { + if (arg != _text) { + _text = arg; + emit textChanged(); + } +} + +void ErrorDialog::accept() { + OffscreenQmlDialog::accept(); +} diff --git a/libraries/ui/src/ErrorDialog.h b/libraries/ui/src/ErrorDialog.h new file mode 100644 index 0000000000..665090da1a --- /dev/null +++ b/libraries/ui/src/ErrorDialog.h @@ -0,0 +1,46 @@ +// +// ErrorDialog.h +// +// Created by David Rowe on 30 May 2015 +// 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 +// + +#pragma once + +#ifndef hifi_ErrorDialog_h +#define hifi_ErrorDialog_h + +#include "OffscreenQmlDialog.h" + +class ErrorDialog : public OffscreenQmlDialog +{ + Q_OBJECT + HIFI_QML_DECL + +private: + Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) + +public: + ErrorDialog(QQuickItem* parent = 0); + virtual ~ErrorDialog(); + + QString text() const; + +public slots: + virtual void setVisible(bool v); + void setText(const QString& arg); + +signals: + void textChanged(); + +protected slots: + virtual void accept(); + +private: + QString _text; +}; + +#endif // hifi_ErrorDialog_h diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index 449657ca04..d94cad20d2 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -13,6 +13,7 @@ #include #include #include +#include "ErrorDialog.h" #include "MessageDialog.h" @@ -130,6 +131,15 @@ void OffscreenUi::critical(const QString& title, const QString& text, static_cast(MessageDialog::Critical), buttons); } +void OffscreenUi::error(const QString& text) { + ErrorDialog* pDialog{ nullptr }; + ErrorDialog::show([&](QQmlContext* ctx, QObject* item) { + pDialog = item->findChild(); + pDialog->setText(text); + }); + pDialog->setEnabled(true); +} + OffscreenUi::ButtonCallback OffscreenUi::NO_OP_CALLBACK = [](QMessageBox::StandardButton) {}; diff --git a/libraries/ui/src/OffscreenUi.h b/libraries/ui/src/OffscreenUi.h index d3567bbb5e..4d0044e775 100644 --- a/libraries/ui/src/OffscreenUi.h +++ b/libraries/ui/src/OffscreenUi.h @@ -115,6 +115,8 @@ public: static void critical(const QString& title, const QString& text, ButtonCallback callback = NO_OP_CALLBACK, QMessageBox::StandardButtons buttons = QMessageBox::Ok); + + static void error(const QString& text); // Interim dialog in new style }; #endif From 9a8bb67f37cae3b9e328fa49227daebe6329b246 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Sun, 31 May 2015 20:56:26 -0700 Subject: [PATCH 08/14] Tidy address bar dialog code --- interface/resources/qml/AddressBarDialog.qml | 56 ++++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index a3f7c6ba18..2a18c21bdf 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -1,3 +1,13 @@ +// +// AddressBarDialog.qml +// +// Created by Austin Davis on 2015/04/14 +// 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.3 import QtQuick.Controls 1.2 @@ -12,7 +22,6 @@ Item { property int animationDuration: hifi.effects.fadeInDuration property bool destroyOnInvisible: false - property bool destroyOnCloseButton: true implicitWidth: addressBarDialog.implicitWidth implicitHeight: addressBarDialog.implicitHeight @@ -24,8 +33,8 @@ Item { id: addressBarDialog property int iconOverlap: 15 // Let the circle overlap window edges and rectangular part of dialog - property int maximumX: root.parent.width - root.width - property int maximumY: root.parent.height - root.height + property int maximumX: root.parent ? root.parent.width - root.width : 0 + property int maximumY: root.parent ? root.parent.height - root.height : 0 implicitWidth: box.width + icon.width - iconOverlap * 2 implicitHeight: addressLine.height + hifi.layout.spacing * 2 @@ -39,13 +48,10 @@ Item { radius: 6 color: "#ededee" - x: icon.width - addressBarDialog.iconOverlap * 2 // W.r.t. addressBarDialog + x: icon.width - addressBarDialog.iconOverlap * 2 // Relative to addressBarDialog MouseArea { - id: boxDrag - anchors.fill: parent - drag { target: root minimumX: 0 @@ -58,18 +64,20 @@ Item { TextInput { id: addressLine - anchors.fill: parent - anchors.leftMargin: addressBarDialog.iconOverlap + hifi.layout.spacing * 2 - anchors.rightMargin: hifi.layout.spacing * 2 - anchors.topMargin: hifi.layout.spacing - anchors.bottomMargin: hifi.layout.spacing + anchors { + fill: parent + leftMargin: addressBarDialog.iconOverlap + hifi.layout.spacing * 2 + rightMargin: hifi.layout.spacing * 2 + topMargin: hifi.layout.spacing + bottomMargin: hifi.layout.spacing + } font.pointSize: 15 helperText: "Go to: place, @user, /path, network address" onAccepted: { - event.accepted - addressBarDialog.loadAddress(addressLine.text) + event.accepted = true // Generates erroneous error in program log, "ReferenceError: event is not defined". + addressBarDialog.loadAddress(addressLine.text) } } } @@ -79,15 +87,14 @@ Item { source: "../images/address-bar-icon.svg" width: 80 height: 80 - anchors.right: box.left - anchors.rightMargin: -addressBarDialog.iconOverlap - anchors.verticalCenter: parent.verticalCenter + anchors { + right: box.left + rightMargin: -addressBarDialog.iconOverlap + verticalCenter: parent.verticalCenter + } MouseArea { - id: iconDrag - anchors.fill: parent - drag { target: root minimumX: 0 @@ -138,15 +145,6 @@ Item { } - function close() { - // The close function performs the same way as the OffscreenUI class: don't do anything but manipulate the enabled flag - // and let the other mechanisms decide if the window should be destroyed after the close animation completes. - if (destroyOnCloseButton) { - destroyOnInvisible = true - } - enabled = false - } - function reset() { addressLine.text = "" } From 45331e5a0e0edc2c1c747c93c3ba6d0b63f819d4 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Mon, 1 Jun 2015 09:37:54 -0700 Subject: [PATCH 09/14] removed sounds from grab script --- examples/grab.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/examples/grab.js b/examples/grab.js index f1e1b6571c..7ed69e9664 100644 --- a/examples/grab.js +++ b/examples/grab.js @@ -36,8 +36,6 @@ var angularVelocity = { z: 0 }; -var grabSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/CloseClamp.wav"); -var releaseSound = SoundCache.getSound("https://hifi-public.s3.amazonaws.com/eric/sounds/ReleaseClamp.wav"); var DROP_DISTANCE = 5.0; var DROP_COLOR = { @@ -90,10 +88,6 @@ function mousePressEvent(event) { gravity: {x: 0, y: 0, z: 0} }); - Audio.playSound(grabSound, { - position: props.position, - volume: 0.4 - }); } } @@ -135,11 +129,6 @@ function mouseReleaseEvent() { }); targetPosition = null; - Audio.playSound(grabSound, { - position: entityProps.position, - volume: 0.25 - }); - } } From b166e24ff5daac0bef3c4d401e7c5d7b6f307f65 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 1 Jun 2015 11:06:33 -0700 Subject: [PATCH 10/14] Fix initial fade-in --- interface/resources/qml/AddressBarDialog.qml | 2 +- interface/resources/qml/ErrorDialog.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 2a18c21bdf..30890c0050 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -111,7 +111,7 @@ Item { // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the // visibility. enabled: false - opacity: 1.0 + opacity: 0.0 onEnabledChanged: { opacity = enabled ? 1.0 : 0.0 diff --git a/interface/resources/qml/ErrorDialog.qml b/interface/resources/qml/ErrorDialog.qml index 72b2c24e90..c0f8132f14 100644 --- a/interface/resources/qml/ErrorDialog.qml +++ b/interface/resources/qml/ErrorDialog.qml @@ -104,7 +104,7 @@ Item { // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the // visibility. enabled: false - opacity: 1.0 + opacity: 0.0 onEnabledChanged: { opacity = enabled ? 1.0 : 0.0 From 293af425acaf17f3b61ff79317d4d5643fa48436 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 1 Jun 2015 12:49:26 -0700 Subject: [PATCH 11/14] remove vhacd block from windows build guide --- BUILD_WIN.md | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/BUILD_WIN.md b/BUILD_WIN.md index 169077ed78..e905a83ace 100644 --- a/BUILD_WIN.md +++ b/BUILD_WIN.md @@ -75,21 +75,6 @@ To prevent these problems, install OpenSSL yourself. Download the following bina Install OpenSSL into the Windows system directory, to make sure that Qt uses the version that you've just installed, and not some other version. -###vhacd -Download it directly from https://github.com/virneo/v-hacd - -To build it run the following commands - 1. cd src\ - 2. mkdir build - 3. cd build - 4. cmake .. - -Build using visual studio 2013. Build ALL_BUILD and INSTALL targets both in Release and Debug. - -This will create an output folder with include and lib directory inside it. - -Either copy the contents of output folder to ENV %HIFI_LIB_DIR%/vhacd or create an environment variable VHACD_ROOT_DIR to this output directory. - ###Build High Fidelity using Visual Studio Follow the same build steps from the CMake section of [BUILD.md](BUILD.md), but pass a different generator to CMake. From 9c52c79fe1df20bcf00ed5ff2c00fa95c3cd8860 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 1 Jun 2015 13:29:36 -0700 Subject: [PATCH 12/14] Combine icon and input areas into a single SVG --- .../{address-bar-icon.svg => address-bar.svg} | 23 +++-- interface/resources/qml/AddressBarDialog.qml | 89 +++++++++---------- 2 files changed, 57 insertions(+), 55 deletions(-) rename interface/resources/images/{address-bar-icon.svg => address-bar.svg} (81%) diff --git a/interface/resources/images/address-bar-icon.svg b/interface/resources/images/address-bar.svg similarity index 81% rename from interface/resources/images/address-bar-icon.svg rename to interface/resources/images/address-bar.svg index a6d67aabae..0a472cbe4e 100644 --- a/interface/resources/images/address-bar-icon.svg +++ b/interface/resources/images/address-bar.svg @@ -8,14 +8,14 @@ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" - width="200" + width="1440" height="200" data-icon="map-marker" data-container-transform="translate(24)" - viewBox="0 0 200 200" + viewBox="0 0 1440 200" id="svg4136" inkscape:version="0.91 r13725" - sodipodi:docname="address-icon.svg"> + sodipodi:docname="address-bar.svg"> @@ -24,7 +24,7 @@ image/svg+xml - + @@ -43,13 +43,22 @@ inkscape:window-height="1057" id="namedview4140" showgrid="false" - inkscape:zoom="0.43359375" - inkscape:cx="64" - inkscape:cy="144.72072" + inkscape:zoom="0.8671875" + inkscape:cx="707.02439" + inkscape:cy="52.468468" inkscape:window-x="72" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="svg4136" /> + Date: Mon, 1 Jun 2015 13:54:14 -0700 Subject: [PATCH 13/14] Untabify --- interface/resources/qml/AddressBarDialog.qml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/interface/resources/qml/AddressBarDialog.qml b/interface/resources/qml/AddressBarDialog.qml index 8d11fa9bb5..3893c26f3c 100644 --- a/interface/resources/qml/AddressBarDialog.qml +++ b/interface/resources/qml/AddressBarDialog.qml @@ -100,9 +100,9 @@ Item { } // The UI enables an object, rather than manipulating its visibility, so that we can do animations in both directions. - // Because visibility and enabled are booleans, they cannot be animated. So when enabled is changed, we modify a property - // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the - // visibility. + // Because visibility and enabled are booleans, they cannot be animated. So when enabled is changed, we modify a property + // that can be animated, like scale or opacity, and then when the target animation value is reached, we can modify the + // visibility. enabled: false opacity: 0.0 @@ -122,7 +122,7 @@ Item { } onOpacityChanged: { - // Once we're transparent, disable the dialog's visibility. + // Once we're transparent, disable the dialog's visibility. visible = (opacity != 0.0) } @@ -130,10 +130,10 @@ Item { if (!visible) { reset() - // Some dialogs should be destroyed when they become invisible. - if (destroyOnInvisible) { - destroy() - } + // Some dialogs should be destroyed when they become invisible. + if (destroyOnInvisible) { + destroy() + } } } From 94131908fb856b2f60fc0b217c2a0d1404824e2e Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 1 Jun 2015 14:53:11 -0700 Subject: [PATCH 14/14] update polyvox for xcode C++11 build --- cmake/externals/polyvox/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/externals/polyvox/CMakeLists.txt b/cmake/externals/polyvox/CMakeLists.txt index 76302f9b4a..28aec6dab7 100644 --- a/cmake/externals/polyvox/CMakeLists.txt +++ b/cmake/externals/polyvox/CMakeLists.txt @@ -3,8 +3,8 @@ set(EXTERNAL_NAME polyvox) include(ExternalProject) ExternalProject_Add( ${EXTERNAL_NAME} - URL http://hifi-public.s3.amazonaws.com/dependencies/polyvox-master-2015-5-27.zip - URL_MD5 e3dd09a24df4db29ba370e3bea753388 + URL http://hifi-public.s3.amazonaws.com/dependencies/polyvox.zip + URL_MD5 904b840328278c9b36fa7a14be730c34 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build LOG_DOWNLOAD 1 @@ -45,7 +45,7 @@ else () endif () -if (WIN32) +if (WIN32) set(${EXTERNAL_NAME_UPPER}_CORE_LIBRARY ${INSTALL_DIR}/PolyVoxCore/lib/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)