Fixing the bins and exploring the REpeater

This commit is contained in:
Sam Gateau 2019-03-04 23:44:14 -08:00
parent 3d2614498b
commit e4518ba234
12 changed files with 58 additions and 217 deletions

View file

@ -1,44 +0,0 @@
//
// Prop/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.44
property real splitterWidth: 4
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

@ -29,7 +29,6 @@ PropItem {
width: root.width * global.valueAreaWidthScale
height: global.slimHeight
checked: root.valueVar
onCheckedChanged: { root.valueVarSetter(checked); }
}
}

View file

@ -18,7 +18,11 @@ PropItem {
property alias valueVar : valueCombo.currentIndex
property alias enums : valueCombo.model
ComboBox {
Component.onCompleted: {
valueVar = root.valueVarGetter();
}
PropComboBox {
id: valueCombo
flat: true
@ -28,83 +32,6 @@ PropItem {
anchors.verticalCenter: root.verticalCenter
height: global.slimHeight
currentIndex: root.valueVarGetter()
onCurrentIndexChanged: { root.valueVarSetter(currentIndex); }
delegate: ItemDelegate {
width: valueCombo.width
height: valueCombo.height
contentItem: PropText {
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: PropText {
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

@ -25,6 +25,19 @@ Item {
property var label: "group"
/* Component.onCompleted: {
var component1 = Qt.createComponent("PropBool.qml");
component1.label = "Test";
for (var i=0; i<root.propItems.length; i++) {
// if (propItems[i]["type"] == "PropBool") {
var component = Qt.createComponent("PropBool.qml");
component.label = propItems[i]["property"];
// }
}
}*/
Column {
id: column
anchors.left: parent.left
@ -34,27 +47,20 @@ Item {
anchors.left: parent.left
anchors.right: parent.right
text: root.label
horizontalAlignment: Text.AlignHCenter
}
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"];
// }
Repeater {
model: root.propItems
PropBool {
label: qsTr(modelData["property"])
object: modelData["object"]
property: modelData["property"]
anchors.left: parent.left
anchors.right: parent.right
}
}
// PropItem is stretching horizontally accross its parent
// Fixed height
//anchors.left: parent.left
//anchors.right: parent.right
// height: global.lineHeight * propItems.length + 1
}
}
height: column.height
}

View file

@ -32,7 +32,8 @@ Item {
anchors.left: parent.left
anchors.right: parent.right
height: global.lineHeight
anchors.leftMargin: global.horizontalMargin
anchors.rightMargin: global.horizontalMargin
// LabelControl And SplitterControl are on the left side of the PropItem
property bool showLabel: true

View file

@ -1,25 +0,0 @@
//
// PropLabel.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

@ -1,21 +0,0 @@
//
// PropSplitter.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

@ -1,24 +0,0 @@
//
// Prop/Text.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
}

View file

@ -1,7 +1,10 @@
PropGlobal 1.0 PropGlobal.qml
PropText 1.0 PropText.qml
PropLabel 1.0 PropLabel.qml
PropSplitter 1.0 PropSplitter.qml
Module Prop
Global 1.0 style/Global.qml
PropText 1.0 style/PiText.qml
PropLabel 1.0 style/PiLabel.qml
PropSplitter 1.0 style/PiSplitter.qml
PropComboBox 1.0 style/PiComboBox.qml
PropItem 1.0 PropItem.qml
PropScalar 1.0 PropScalar.qml
PropEnum 1.0 PropEnum.qml

View file

@ -21,6 +21,8 @@ Item {
property real lineHeight: 32
property real slimHeight: 24
property real horizontalMargin: 2
property var color: hifi.colors.baseGray
property var colorBackHighlight: hifi.colors.baseGrayHighlight
property var colorBorderLight: hifi.colors.lightGray

View file

@ -1,5 +1,5 @@
//
// Prop/style/PsComboBox.qml
// Prop/style/PiComboBox.qml
//
// Created by Sam Gateau on 3/2/2019
// Copyright 2019 High Fidelity, Inc.

View file

@ -55,5 +55,22 @@ Rectangle {
anchors.left: parent.left
anchors.right: parent.right
}
Prop.PropBool {
label: "Background"
object: render.mainViewTask.getConfig("LightingModel")
property: "enableBackground"
anchors.left: parent.left
anchors.right: parent.right
}
Prop.PropGroup {
label: "My group"
propItems: [
{"type": "PropBool", "object": render.mainViewTask.getConfig("LightingModel"), "property": "enableBackground"},
{"type": "PropBool", "object": render.mainViewTask.getConfig("LightingModel"), "property": "enableDiffuse"},
{"type": "PropBool", "object": render.mainViewTask.getConfig("LightingModel"), "property": "enableEmissive"},
]
anchors.left: parent.left
anchors.right: parent.right
}
}
}