Make Edit view more consistant with original one

This commit is contained in:
vladest 2018-03-01 11:02:05 +01:00
parent 531c4dc41d
commit 7cbdbe9ab0
4 changed files with 259 additions and 533 deletions

View file

@ -6,289 +6,42 @@ import "../../controls-uit" as HifiControls
import "../../controls" import "../../controls"
import "../toolbars" import "../toolbars"
ColumnLayout { StackView {
id: editRoot id: editRoot
objectName: "stack" objectName: "stack"
anchors.fill: parent //anchors.fill: parent
topPadding: 40
readonly property var webTabsLinks: [ property var itemProperties: {"y": editRoot.topPadding,
"", "width": editRoot.availableWidth,
"/system/html/entityList.html", "height": editRoot.availableHeight }
"/system/html/entityProperties.html", Component.onCompleted: {
"/system/html/gridControls.html", tab.currentIndex = 0
"/system/particle_explorer/particleExplorer.html" }
]
background: Rectangle {
color: "#404040" //default background color
EditTabView {
id: tab
currentIndex: -1
onCurrentIndexChanged: {
editRoot.replace(null, tab.itemAt(currentIndex).visualItem,
itemProperties,
StackView.Immediate)
}
}
}
signal sendToScript(var message); signal sendToScript(var message);
function pushSource(path) { function pushSource(path) {
editStack.push(Qt.resolvedUrl("../../" + path)); editRoot.push(Qt.resolvedUrl("../../" + path), itemProperties,
editStack.currentItem.sendToScript.connect(editRoot.sendToScript); StackView.Immediate);
editRoot.currentItem.sendToScript.connect(editRoot.sendToScript);
} }
function popSource() { function popSource() {
editStack.pop(); editRoot.pop(StackView.Immediate);
}
function fromScript(message) {
console.error("from script", JSON.stringify(message))
switch (message.method) {
case 'selectTab':
selectTab(message.params.id);
break;
default:
var currentItem = editStack.currentItem;
if (currentItem && currentItem.fromScript) {
currentItem.fromScript(message);
} else {
console.warn('Unrecognized message:', JSON.stringify(message));
}
}
}
// Changes the current tab based on tab index or title as input
function selectTab(id) {
console.error("selecting tab", id)
if (typeof id === 'number') {
if (id >= 0 && id <= 4) {
editTabView.currentIndex = id;
} else {
console.warn('Attempt to switch to invalid tab:', id);
}
} else if (typeof id === 'string'){
switch (id.toLowerCase()) {
case 'create':
editTabView.currentIndex = 0;
break;
case 'list':
editTabView.currentIndex = 1;
break;
case 'properties':
editTabView.currentIndex = 2;
break;
case 'grid':
editTabView.currentIndex = 3;
break;
case 'particle':
editTabView.currentIndex = 4;
break;
default:
console.warn('Attempt to switch to invalid tab:', id);
}
} else {
console.warn('Attempt to switch tabs with invalid input:', JSON.stringify(id));
}
}
spacing: 0
HifiConstants { id: hifi }
TabBar {
id: editTabView
height: 60
width: parent.width
contentWidth: parent.width
currentIndex: 0
padding: 0
spacing: 0
onCurrentIndexChanged: {
if (currentIndex === 0) {
editStack.replace(null, mainTab, {}, StackView.Immediate)
} else {
editStack.replace(null, webViewTab,
{url: Paths.defaultScripts + webTabsLinks[currentIndex]},
StackView.Immediate)
}
}
EditTabButton {
text: "CREATE"
}
EditTabButton {
text: "LIST"
}
EditTabButton {
text: "PROPERTIES"
}
EditTabButton {
text: "GRID"
}
EditTabButton {
text: "P"
}
}
StackView {
id: editStack
Layout.fillHeight: true
Layout.fillWidth: true
initialItem: mainTab//Qt.resolvedUrl('EditTabView.qml')
}
Component {
id: mainTab
Rectangle { //1st tab
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 = 4
}
}
}
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" }
});
}
}
}
}
Component {
id: webViewTab
WebView {}
} }
} }

View file

@ -1,6 +1,6 @@
// //
// AudioTabButton.qml // EditTabButton.qml
// qml/hifi/audio // qml/hifi/tablet
// //
// Created by Vlad Stelmahovsky on 8/16/2017 // Created by Vlad Stelmahovsky on 8/16/2017
// Copyright 2017 High Fidelity, Inc. // Copyright 2017 High Fidelity, Inc.
@ -16,6 +16,9 @@ import "../../styles-uit"
TabButton { TabButton {
id: control id: control
property alias title: control.text
property alias active: control.checkable
height: 40
font.pixelSize: height / 2 font.pixelSize: height / 2
padding: 0 padding: 0
spacing: 0 spacing: 0
@ -26,7 +29,7 @@ TabButton {
text: control.text text: control.text
font.pixelSize: 14 font.pixelSize: 14
font.bold: true font.bold: true
color: control.checked ? "white" : "white" color: "white"
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
property string glyphtext: "" property string glyphtext: ""

View file

@ -1,316 +1,286 @@
import QtQuick 2.5 import QtQuick 2.7
import QtQuick.Controls 1.4 import QtQuick.Controls 2.2
import QtQuick.Controls 2.2 // Need both for short-term fix
import QtWebEngine 1.1
import QtWebChannel 1.0 import QtWebChannel 1.0
import QtQuick.Controls.Styles 1.4
import "../../controls" import "../../controls"
import "../toolbars" import "../toolbars"
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import "../../controls-uit" as HifiControls import "../../controls-uit" as HifiControls
import "../../styles-uit" import "../../styles-uit"
TabBar {
TabView {
id: editTabView id: editTabView
// anchors.fill: parent // anchors.fill: parent
height: 60 width: parent.width
contentWidth: parent.width
padding: 0
spacing: 0
Tab { readonly property HifiConstants hifi: HifiConstants {}
EditTabButton {
title: "CREATE" title: "CREATE"
active: true active: true
enabled: true enabled: true
property string originalUrl: "" property string originalUrl: ""
Rectangle { property Component visualItem: Component {
color: "#404040"
id: container
Flickable { Rectangle {
height: parent.height color: "#404040"
width: parent.width id: container
contentHeight: createEntitiesFlow.height + importButton.height + assetServerButton.height + Flickable {
header.anchors.topMargin + createEntitiesFlow.anchors.topMargin + height: parent.height
assetServerButton.anchors.topMargin + importButton.anchors.topMargin width: parent.width
contentWidth: width clip: true
ScrollBar.vertical : ScrollBar { contentHeight: createEntitiesFlow.height + importButton.height + assetServerButton.height +
visible: parent.contentHeight > parent.height header.anchors.topMargin + createEntitiesFlow.anchors.topMargin +
width: 20 assetServerButton.anchors.topMargin + importButton.anchors.topMargin +
background: Rectangle { header.paintedHeight
color: hifi.colors.tableScrollBackgroundDark
}
}
Text { contentWidth: width
id: header
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 { ScrollBar.vertical : ScrollBar {
id: createEntitiesFlow visible: parent.contentHeight > parent.height
spacing: 35 width: 20
anchors.right: parent.right background: Rectangle {
anchors.rightMargin: 55 color: hifi.colors.tableScrollBackgroundDark
anchors.left: parent.left }
anchors.leftMargin: 55 }
anchors.top: parent.top
anchors.topMargin: 70 Text {
id: header
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 { NewEntityButton {
icon: "icons/create-icons/94-model-01.svg" icon: "icons/create-icons/94-model-01.svg"
text: "MODEL" text: "MODEL"
onClicked: { onClicked: {
editRoot.sendToScript({ editRoot.sendToScript({
method: "newEntityButtonClicked", params: { buttonName: "newModelButton" } method: "newEntityButtonClicked", params: { buttonName: "newModelButton" }
}); });
editTabView.currentIndex = 2 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/image.svg"
text: "IMAGE"
onClicked: {
editRoot.sendToScript({
method: "newEntityButtonClicked", params: { buttonName: "newImageButton" }
});
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 = 4
}
}
NewEntityButton {
icon: "icons/create-icons/126-material-01.svg"
text: "MATERIAL"
onClicked: {
editRoot.sendToScript({
method: "newEntityButtonClicked", params: { buttonName: "newMaterialButton" }
});
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 {
id: importButton
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" }
});
}
} }
} }
} // Flickable
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/image.svg"
text: "IMAGE"
onClicked: {
editRoot.sendToScript({
method: "newEntityButtonClicked", params: { buttonName: "newImageButton" }
});
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 = 4
}
}
NewEntityButton {
icon: "icons/create-icons/126-material-01.svg"
text: "MATERIAL"
onClicked: {
editRoot.sendToScript({
method: "newEntityButtonClicked", params: { buttonName: "newMaterialButton" }
});
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 {
id: importButton
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" }
});
}
}
} }
} // Flickable
} }
Tab { EditTabButton {
title: "LIST" title: "LIST"
active: true active: true
enabled: true enabled: true
property string originalUrl: "" property string originalUrl: ""
WebView { property Component visualItem: Component {
id: entityListToolWebView WebView {
url: Paths.defaultScripts + "/system/html/entityList.html" id: entityListToolWebView
anchors.fill: parent url: Paths.defaultScripts + "/system/html/entityList.html"
enabled: true enabled: true
}
} }
} }
Tab { EditTabButton {
title: "PROPERTIES" title: "PROPERTIES"
active: true active: true
enabled: true enabled: true
property string originalUrl: "" property string originalUrl: ""
WebView { property Component visualItem: Component {
id: entityPropertiesWebView WebView {
url: Paths.defaultScripts + "/system/html/entityProperties.html" id: entityPropertiesWebView
anchors.fill: parent url: Paths.defaultScripts + "/system/html/entityProperties.html"
enabled: true enabled: true
}
} }
} }
Tab { EditTabButton {
title: "GRID" title: "GRID"
active: true active: true
enabled: true enabled: true
property string originalUrl: "" property string originalUrl: ""
WebView { property Component visualItem: Component {
id: gridControlsWebView WebView {
url: Paths.defaultScripts + "/system/html/gridControls.html" id: gridControlsWebView
anchors.fill: parent url: Paths.defaultScripts + "/system/html/gridControls.html"
enabled: true enabled: true
}
} }
} }
Tab { EditTabButton {
title: "P" title: "P"
active: true active: true
enabled: true enabled: true
property string originalUrl: "" property string originalUrl: ""
WebView { property Component visualItem: Component {
id: particleExplorerWebView WebView {
url: Paths.defaultScripts + "/system/particle_explorer/particleExplorer.html" id: particleExplorerWebView
anchors.fill: parent url: Paths.defaultScripts + "/system/particle_explorer/particleExplorer.html"
enabled: true 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
}
} }
function fromScript(message) { function fromScript(message) {

View file

@ -8,8 +8,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
import QtQuick 2.5 import QtQuick 2.7
import QtQuick.Controls 1.4 import QtQuick.Controls 2.2
import "tabletWindows" import "tabletWindows"
import "../../dialogs" import "../../dialogs"