From 2a931119bdee73512aef793e8417adaa8274bc89 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Thu, 28 May 2015 12:17:21 -0700 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 b166e24ff5daac0bef3c4d401e7c5d7b6f307f65 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 1 Jun 2015 11:06:33 -0700 Subject: [PATCH 7/9] 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 9c52c79fe1df20bcf00ed5ff2c00fa95c3cd8860 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 1 Jun 2015 13:29:36 -0700 Subject: [PATCH 8/9] 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 9/9] 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() + } } }