This commit is contained in:
Sam Gateau 2019-03-04 18:07:02 -08:00
parent fe23ef1485
commit 3d2614498b
7 changed files with 307 additions and 0 deletions

View file

@ -0,0 +1,35 @@
//
// PropBool.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import controlsUit 1.0 as HifiControls
PropItem {
Global { id: global }
id: root
property alias valueVar : checkboxControl.checked
Component.onCompleted: {
valueVar = root.valueVarGetter();
}
HifiControls.CheckBox {
id: checkboxControl
anchors.left: root.splitter.right
anchors.verticalCenter: root.verticalCenter
width: root.width * global.valueAreaWidthScale
height: global.slimHeight
checked: root.valueVar
onCheckedChanged: { root.valueVarSetter(checked); }
}
}

View file

@ -0,0 +1,60 @@
//
// PropGroup.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
Item {
Global { id: global }
id: root
// Prop Group is designed to author an array of ProItems, they are defined with an array of the tuplets describing each individual item:
// [ ..., PropItemInfo, ...]
// PropItemInfo {
// "type": "PropXXXX", "object": object, "property": "propName"
// }
//
property var propItems: []
property var label: "group"
Column {
id: column
anchors.left: parent.left
anchors.right: parent.right
PropLabel {
anchors.left: parent.left
anchors.right: parent.right
text: root.label
}
Component.onCompleted: {
var component = Qt.createComponent("PropBool.qml");
component.label = "Test";
for (var i=0; i<propItems.length; i++) {
// if (propItems[i]["type"] == "PropBool") {
var component = Qt.createComponent("PropBool.qml");
component.label = propItems[i]["property"];
// }
}
}
// PropItem is stretching horizontally accross its parent
// Fixed height
//anchors.left: parent.left
//anchors.right: parent.right
// height: global.lineHeight * propItems.length + 1
}
}

View file

@ -0,0 +1,44 @@
//
// Prop/style/Global.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import stylesUit 1.0
import controlsUit 1.0 as HifiControls
Item {
HifiConstants { id: hifi }
id: root
property real lineHeight: 32
property real slimHeight: 24
property var color: hifi.colors.baseGray
property var colorBackHighlight: hifi.colors.baseGrayHighlight
property var colorBorderLight: hifi.colors.lightGray
property var colorBorderHighight: hifi.colors.blueHighlight
property real fontSize: 12
property var fontFamily: "Raleway"
property var fontWeight: Font.DemiBold
property var fontColor: hifi.colors.faintGray
property var splitterRightWidthScale: 0.45
property real splitterWidth: 8
property var labelTextAlign: Text.AlignRight
property var labelTextElide: Text.ElideMiddle
property var valueAreaWidthScale: 0.3 * (1.0 - splitterRightWidthScale)
property var valueTextAlign: Text.AlignHCenter
property real valueBorderWidth: 1
property real valueBorderRadius: 2
}

View file

@ -0,0 +1,98 @@
//
// Prop/style/PsComboBox.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import QtQuick.Controls 2.2
ComboBox {
id: valueCombo
height: global.slimHeight
// look
flat: true
delegate: ItemDelegate {
width: valueCombo.width
height: valueCombo.height
contentItem: PiText {
text: modelData
horizontalAlignment: global.valueTextAlign
}
background: Rectangle {
color:highlighted?global.colorBackHighlight:global.color;
}
highlighted: valueCombo.highlightedIndex === index
}
indicator: Canvas {
id: canvas
x: valueCombo.width - width - valueCombo.rightPadding
y: valueCombo.topPadding + (valueCombo.availableHeight - height) / 2
width: 12
height: 8
contextType: "2d"
Connections {
target: valueCombo
onPressedChanged: canvas.requestPaint()
}
onPaint: {
context.reset();
context.moveTo(0, 0);
context.lineTo(width, 0);
context.lineTo(width / 2, height);
context.closePath();
context.fillStyle = (valueCombo.pressed) ? global.colorBorderHighight : global.colorBorderLight;
context.fill();
}
}
contentItem: PiText {
leftPadding: 0
rightPadding: valueCombo.indicator.width + valueCombo.spacing
text: valueCombo.displayText
horizontalAlignment: global.valueTextAlign
}
background: Rectangle {
implicitWidth: 120
implicitHeight: 40
color: global.color
border.color: valueCombo.popup.visible ? global.colorBorderHighight : global.colorBorderLight
border.width: global.valueBorderWidth
radius: global.valueBorderRadius
}
popup: Popup {
y: valueCombo.height - 1
width: valueCombo.width
implicitHeight: contentItem.implicitHeight + 2
padding: 1
contentItem: ListView {
clip: true
implicitHeight: contentHeight
model: valueCombo.popup.visible ? valueCombo.delegateModel : null
currentIndex: valueCombo.highlightedIndex
ScrollIndicator.vertical: ScrollIndicator { }
}
background: Rectangle {
color: global.color
border.color: global.colorBorderHighight
radius: global.valueBorderRadius
}
}
}

View file

@ -0,0 +1,25 @@
//
// Prop/style/PsLabel.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
import QtQuick.Controls 2.2
Label {
Global { id: global }
color: global.fontColor
font.pixelSize: global.fontSize
font.family: global.fontFamily
font.weight: global.fontWeight
verticalAlignment: Text.AlignVCenter
horizontalAlignment: global.labelTextAlign
elide: global.labelTextElide
}

View file

@ -0,0 +1,21 @@
//
// Prop/style/Splitter.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
Item {
id: root
property real size
width: size // Must be non-zero
height: size
anchors.verticalCenter: parent.verticalCenter
}

View file

@ -0,0 +1,24 @@
//
// Prop/style/PsText.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html
//
import QtQuick 2.7
Text {
Global { id: global }
color: global.fontColor
font.pixelSize: global.fontSize
font.family: global.fontFamily
font.weight: global.fontWeight
verticalAlignment: Text.AlignVCenter
horizontalAlignment: global.labelTextAlign
elide: global.labelTextElide
}