From 067ed4aa3d5a4d8287d5a779b414bfe048289cdf Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Mon, 1 Jan 2024 14:37:22 +0300 Subject: [PATCH] Property editor minor refactoring --- .../kscience/visionforge/compose/PropertyEditor.kt | 13 ++++++++----- .../visionforge/solid/three/compose/ThreeView.kt | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt index 82277701..89bae724 100644 --- a/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt +++ b/visionforge-compose-html/src/jsMain/kotlin/space/kscience/visionforge/compose/PropertyEditor.kt @@ -31,7 +31,6 @@ public sealed class EditorPropertyState { public data object Defined : EditorPropertyState() public data class Default(public val source: String = "unknown") : EditorPropertyState() public data object Undefined : EditorPropertyState() - } /** @@ -44,8 +43,8 @@ public fun PropertyEditor( rootMeta: MutableMeta, getPropertyState: (Name) -> EditorPropertyState, updates: Flow, - name: Name = Name.EMPTY, - rootDescriptor: MetaDescriptor? = null, + name: Name, + rootDescriptor: MetaDescriptor?, initialExpanded: Boolean? = null, ) { var expanded: Boolean by remember { mutableStateOf(initialExpanded ?: true) } @@ -97,8 +96,12 @@ public fun PropertyEditor( } Span({ classes(TreeStyles.treeLabel) - if (editorPropertyState != EditorPropertyState.Defined) { - classes(TreeStyles.treeLabelInactive) + when (editorPropertyState) { + is EditorPropertyState.Default, EditorPropertyState.Undefined -> { + classes(TreeStyles.treeLabelInactive) + } + + EditorPropertyState.Defined -> {} } }) { Text(token) diff --git a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt index 1c69ddb9..21a61ebd 100644 --- a/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt +++ b/visionforge-threejs/src/jsMain/kotlin/space/kscience/visionforge/solid/three/compose/ThreeView.kt @@ -148,6 +148,7 @@ public fun ThreeView( EditorPropertyState.Undefined } }, + name = Name.EMPTY, updates = vision.properties.changes, rootDescriptor = vision.descriptor )