Better propGroup

This commit is contained in:
Sam Gateau 2019-03-06 22:24:43 -08:00
parent 26b581fc74
commit f7896b6407
3 changed files with 98 additions and 45 deletions

View file

@ -25,13 +25,13 @@ Prop.PropGroup {
property var rootConfig : Render
property var jobPath: ""
property alias jobName: root.label
property alias label: root.label
Component.onCompleted: {
var props = Jet.job_propKeys(rootConfig.getConfig(jobPath));
//console.log(JSON.stringify(props));
console.log(JSON.stringify(props));
for (var p in props) {
root.propItems.push({"type": "PropBool", "object": rootConfig.getConfig(jobPath), "property":props[p] })
root.propItems.push({"object": rootConfig.getConfig(jobPath), "property":props[p] })
}
root.updatePropItems();
}

View file

@ -25,56 +25,102 @@ Item {
property var label: "group"
Column {
id: column
anchors.left: parent.left
anchors.right: parent.right
Item {
id: header
height: global.slimHeight
anchors.left: parent.left
anchors.right: parent.right
PropLabel {
anchors.left: parent.left
anchors.right: parent.right
id: labelControl
anchors.left: header.left
width: 0.8 * header.width
anchors.verticalCenter: header.verticalCenter
text: root.label
horizontalAlignment: Text.AlignHCenter
}
Rectangle {
id: headerRect
color: global.color
border.color: global.colorBorderLight
border.width: global.valueBorderWidth
radius: global.valueBorderRadius
anchors.left: labelControl.right
anchors.right: header.right
anchors.verticalCenter: header.verticalCenter
height: parent.height
}
}
height: column.height
Column {
id: column
anchors.top: header.bottom
anchors.left: parent.left
anchors.right: parent.right
clip: true
// Where the propItems are added
}
height: header.height + column.height
function updatePropItems() {
for (var i = 0; i < root.propItems.length; i++) {
var proItem = root.propItems[i];
switch(proItem.type) {
case 'PropBool': {
var component = Qt.createComponent("PropBool.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property
})
} break;
case 'PropScalar': {
var component = Qt.createComponent("PropScalar.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property,
"min": (proItem["min"] !== undefined ? proItem.min : 0.0),
"max": (proItem["max"] !== undefined ? proItem.max : 1.0),
"integer": (proItem["integral"] !== undefined ? proItem.integral : false),
})
} break;
case 'PropEnum': {
var component = Qt.createComponent("PropEnum.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property,
"enums": (proItem["enums"] !== undefined ? proItem.enums : ["Undefined Enums !!!"]),
})
} break;
}
// valid object
if (proItem['object'] !== undefined && proItem['object'] !== null ) {
// valid property
if (proItem['property'] !== undefined && proItem.object[proItem.property] !== undefined) {
// check type
if (proItem['type'] === undefined) {
proItem['type'] = typeof(proItem.object[proItem.property])
}
switch(proItem.type) {
case 'boolean':
case 'PropBool': {
var component = Qt.createComponent("PropBool.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property
})
} break;
case 'number':
case 'PropScalar': {
var component = Qt.createComponent("PropScalar.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property,
"min": (proItem["min"] !== undefined ? proItem.min : 0.0),
"max": (proItem["max"] !== undefined ? proItem.max : 1.0),
"integer": (proItem["integral"] !== undefined ? proItem.integral : false),
})
} break;
case 'PropEnum': {
var component = Qt.createComponent("PropEnum.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property,
"enums": (proItem["enums"] !== undefined ? proItem.enums : ["Undefined Enums !!!"]),
})
} break;
case 'object': {
var component = Qt.createComponent("PropItem.qml");
component.createObject(column, {
"label": proItem.property,
"object": proItem.object,
"property": proItem.property,
})
} break;
}
} else {
console.log('Invalid property: ' + JSON.stringify(proItem));
}
} else {
console.log('Invalid object: ' + JSON.stringify(proItem));
}
}
}
Component.onCompleted: {

View file

@ -81,8 +81,15 @@ Rectangle {
}*/
Jet.TaskPropView {
jobPath: "RenderMainView.LightingModel"
label: "Le tone mapping Job"
jobPath: "RenderMainView.ToneMapping"
label: "Le ToneMapping Job"
anchors.left: parent.left
anchors.right: parent.right
}
Jet.TaskPropView {
jobPath: "RenderMainView.Antialiasing"
label: "Le Antialiasing Job"
anchors.left: parent.left
anchors.right: parent.right