forked from kscience/visionforge
Hide nodes without visible children in the property editor
This commit is contained in:
parent
f7301805fd
commit
4820082248
@ -45,7 +45,7 @@ public val TabPane: FunctionalComponent<TabPaneProps> = functionalComponent("Tab
|
||||
+(cp.title ?: cp.id)
|
||||
attrs {
|
||||
if (cp.id == activeTab) {
|
||||
classes += "active"
|
||||
classes = classes + "active"
|
||||
}
|
||||
onClickFunction = {
|
||||
activeTab = cp.id
|
||||
|
@ -22,7 +22,7 @@ public external interface ThreeControlsProps : RProps {
|
||||
@JsExport
|
||||
public val ThreeControls: FunctionalComponent<ThreeControlsProps> = functionalComponent { props ->
|
||||
val vision = props.canvas.content
|
||||
tabPane {
|
||||
tabPane(if (props.selected != null) "Properties" else null) {
|
||||
tab("Canvas") {
|
||||
card("Canvas configuration") {
|
||||
canvasControls(props.canvas)
|
||||
|
@ -66,12 +66,9 @@ private val PropertyEditorItem: FunctionalComponent<PropertyEditorProps> =
|
||||
private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
|
||||
var expanded: Boolean by useState { true }
|
||||
val descriptorItem: ItemDescriptor? = props.descriptor?.get(props.name)
|
||||
if (descriptorItem?.hidden == true) return //fail fast for hidden property
|
||||
var ownProperty: MetaItem? by useState { props.ownProperties.getItem(props.name) }
|
||||
val actualItem: MetaItem? = props.allProperties?.getItem(props.name)
|
||||
|
||||
println("Actual item for ${props.name?.toString()} is ${actualItem.toString()}")
|
||||
|
||||
val token = props.name.lastOrNull()?.toString() ?: "Properties"
|
||||
|
||||
fun update() {
|
||||
@ -108,6 +105,17 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
|
||||
}
|
||||
|
||||
if (actualItem is NodeItem) {
|
||||
val keys = buildSet {
|
||||
(descriptorItem as? NodeDescriptor)?.items?.filterNot {
|
||||
it.key.startsWith("@") || it.value.hidden
|
||||
}?.forEach {
|
||||
add(NameToken(it.key))
|
||||
}
|
||||
ownProperty?.node?.items?.keys?.filterNot { it.body.startsWith("@") }?.let { addAll(it) }
|
||||
}
|
||||
// Do not show nodes without visible children
|
||||
if (keys.isEmpty()) return
|
||||
|
||||
styledDiv {
|
||||
css {
|
||||
+TreeStyles.treeLeaf
|
||||
@ -138,14 +146,7 @@ private fun RBuilder.propertyEditorItem(props: PropertyEditorProps) {
|
||||
css {
|
||||
+TreeStyles.tree
|
||||
}
|
||||
val keys = buildSet {
|
||||
(descriptorItem as? NodeDescriptor)?.items?.keys?.forEach {
|
||||
add(NameToken(it))
|
||||
}
|
||||
ownProperty?.node?.items?.keys?.let { addAll(it) }
|
||||
}
|
||||
|
||||
keys.filter { !it.body.startsWith("@") }.forEach { token ->
|
||||
keys.forEach { token ->
|
||||
styledLi {
|
||||
css {
|
||||
+TreeStyles.treeItem
|
||||
|
Loading…
Reference in New Issue
Block a user