Fix all compilations and errors.

This commit is contained in:
Alexander Nozik 2020-12-19 12:33:29 +03:00
parent 97cdfd3719
commit be1d79c229
6 changed files with 30 additions and 29 deletions

View File

@ -9,10 +9,10 @@ import hep.dataforge.vision.Vision
import hep.dataforge.vision.bootstrap.canvasControls import hep.dataforge.vision.bootstrap.canvasControls
import hep.dataforge.vision.bootstrap.card import hep.dataforge.vision.bootstrap.card
import hep.dataforge.vision.bootstrap.gridRow import hep.dataforge.vision.bootstrap.gridRow
import hep.dataforge.vision.bootstrap.visionPropertyEditor
import hep.dataforge.vision.react.ThreeCanvasComponent import hep.dataforge.vision.react.ThreeCanvasComponent
import hep.dataforge.vision.react.flexColumn import hep.dataforge.vision.react.flexColumn
import hep.dataforge.vision.react.objectTree import hep.dataforge.vision.react.objectTree
import hep.dataforge.vision.react.propertyEditor
import hep.dataforge.vision.solid.specifications.Camera import hep.dataforge.vision.solid.specifications.Camera
import hep.dataforge.vision.solid.specifications.Canvas3DOptions import hep.dataforge.vision.solid.specifications.Canvas3DOptions
import hep.dataforge.vision.solid.three.ThreeCanvas import hep.dataforge.vision.solid.three.ThreeCanvas
@ -57,7 +57,7 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
val root = props.model.root val root = props.model.root
gridRow{ gridRow {
flexColumn { flexColumn {
css { css {
+"col-lg-3" +"col-lg-3"
@ -109,8 +109,8 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
height = 100.vh height = 100.vh
} }
styledDiv { styledDiv {
css{ css {
flex(0.0,1.0, FlexBasis.zero) flex(0.0, 1.0, FlexBasis.zero)
} }
//settings //settings
canvas?.let { canvas?.let {
@ -140,8 +140,8 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
} }
} }
} }
styledDiv{ styledDiv {
css{ css {
padding(0.px) padding(0.px)
} }
nav { nav {
@ -180,10 +180,10 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
} }
} }
} }
styledDiv{ styledDiv {
css{ css {
overflowY = Overflow.auto overflowY = Overflow.auto
} }
//properties //properties
card("Properties") { card("Properties") {
selected.let { selected -> selected.let { selected ->
@ -193,12 +193,7 @@ val MMApp = functionalComponent<MMAppProps>("Muon monitor") { props ->
else -> root[selected] else -> root[selected]
} }
if (selectedObject != null) { if (selectedObject != null) {
propertyEditor( visionPropertyEditor(selectedObject, key = selected)
selectedObject.config,
selectedObject.descriptor,
default = selectedObject.allProperties,
key = selected
)
} }
} }
} }

View File

@ -4,7 +4,6 @@ import hep.dataforge.names.Name
import hep.dataforge.names.isEmpty import hep.dataforge.names.isEmpty
import hep.dataforge.vision.Vision import hep.dataforge.vision.Vision
import hep.dataforge.vision.VisionGroup import hep.dataforge.vision.VisionGroup
import hep.dataforge.vision.describedProperties
import hep.dataforge.vision.react.objectTree import hep.dataforge.vision.react.objectTree
import hep.dataforge.vision.solid.three.ThreeCanvas import hep.dataforge.vision.solid.three.ThreeCanvas
import kotlinx.css.* import kotlinx.css.*
@ -52,11 +51,7 @@ public val ThreeControls: FunctionalComponent<ThreeControlsProps> = functionalCo
else -> (vision as? VisionGroup)?.get(selected) else -> (vision as? VisionGroup)?.get(selected)
} }
if (selectedObject != null) { if (selectedObject != null) {
visionPropertyEditor( visionPropertyEditor(selectedObject, key = selected)
selectedObject,
default = selectedObject.describedProperties,
key = selected
)
} }
} }
} }
@ -70,7 +65,7 @@ public fun RBuilder.threeControls(
canvas: ThreeCanvas, canvas: ThreeCanvas,
selected: Name?, selected: Name?,
onSelect: (Name) -> Unit = {}, onSelect: (Name) -> Unit = {},
builder: TabBuilder.() -> Unit = {} builder: TabBuilder.() -> Unit = {},
): ReactElement = child(ThreeControls) { ): ReactElement = child(ThreeControls) {
attrs { attrs {
this.canvas = canvas this.canvas = canvas

View File

@ -5,8 +5,8 @@ import hep.dataforge.meta.descriptors.NodeDescriptor
import hep.dataforge.vision.Vision import hep.dataforge.vision.Vision
import hep.dataforge.vision.allProperties import hep.dataforge.vision.allProperties
import hep.dataforge.vision.getStyle import hep.dataforge.vision.getStyle
import hep.dataforge.vision.react.configEditor
import hep.dataforge.vision.react.metaViewer import hep.dataforge.vision.react.metaViewer
import hep.dataforge.vision.react.propertyEditor
import hep.dataforge.vision.styles import hep.dataforge.vision.styles
import org.w3c.dom.Element import org.w3c.dom.Element
import react.RBuilder import react.RBuilder
@ -15,11 +15,14 @@ import react.dom.render
public fun RBuilder.visionPropertyEditor( public fun RBuilder.visionPropertyEditor(
vision: Vision, vision: Vision,
descriptor: NodeDescriptor? = vision.descriptor, descriptor: NodeDescriptor? = vision.descriptor,
default: Meta? = null,
key: Any? = null, key: Any? = null,
) { ) {
card("Properties") { card("Properties") {
configEditor(vision.allProperties(), descriptor, default, key) propertyEditor(
vision.allProperties(),
updateFlow = vision.propertyNameFlow,
descriptor = descriptor,
key = key)
} }
val styles = vision.styles val styles = vision.styles
if (styles.isNotEmpty()) { if (styles.isNotEmpty()) {

View File

@ -82,15 +82,16 @@ public interface Vision : Described {
*/ */
public fun Vision.allProperties( public fun Vision.allProperties(
inherit: Boolean? = null, inherit: Boolean? = null,
includeStyles: Boolean = true, includeStyles: Boolean? = null,
includeDefaults: Boolean = true, includeDefaults: Boolean = true,
): MutableItemProvider = object : MutableItemProvider { ): MutableItemProvider = object : MutableItemProvider {
override fun getItem(name: Name): MetaItem<*>? { override fun getItem(name: Name): MetaItem<*>? {
val actualInherit = inherit ?: descriptor?.get(name)?.inherited ?: false val actualInherit = inherit ?: descriptor?.get(name)?.inherited ?: false
val actualUseStyles = includeStyles ?: descriptor?.get(name)?.usesStyles ?: true
return getProperty( return getProperty(
name, name,
inherit = actualInherit, inherit = actualInherit,
includeStyles = includeStyles, includeStyles = actualUseStyles,
includeDefaults = includeDefaults includeDefaults = includeDefaults
) )
} }

View File

@ -8,6 +8,7 @@ import hep.dataforge.meta.get
import hep.dataforge.meta.set import hep.dataforge.meta.set
private const val INHERITED_DESCRIPTOR_ATTRIBUTE = "inherited" private const val INHERITED_DESCRIPTOR_ATTRIBUTE = "inherited"
private const val STYLE_DESCRIPTOR_ATTRIBUTE = "useStyles"
public var ItemDescriptor.inherited: Boolean public var ItemDescriptor.inherited: Boolean
get() = attributes[INHERITED_DESCRIPTOR_ATTRIBUTE].boolean ?: false get() = attributes[INHERITED_DESCRIPTOR_ATTRIBUTE].boolean ?: false
@ -15,6 +16,12 @@ public var ItemDescriptor.inherited: Boolean
set(INHERITED_DESCRIPTOR_ATTRIBUTE, value) set(INHERITED_DESCRIPTOR_ATTRIBUTE, value)
} }
public var ItemDescriptor.usesStyles: Boolean
get() = attributes[STYLE_DESCRIPTOR_ATTRIBUTE].boolean ?: true
set(value) = attributes {
set(STYLE_DESCRIPTOR_ATTRIBUTE, value)
}
public val Vision.describedProperties: Meta public val Vision.describedProperties: Meta
get() = Meta { get() = Meta {

View File

@ -34,7 +34,7 @@ class HtmlTagTest {
div { div {
h2 { +"Properties" } h2 { +"Properties" }
ul { ul {
(vision as? VisionBase)?.ownProperties?.items?.forEach { (vision as? VisionBase)?.properties?.items?.forEach {
li { li {
a { +it.key.toString() } a { +it.key.toString() }
p { +it.value.toString() } p { +it.value.toString() }