forked from kscience/visionforge
Merge pull request #4 from kiruma524/tutorial
Pre-version of inheritance.md
This commit is contained in:
commit
a3eaa167a5
@ -2,19 +2,16 @@
|
|||||||
|
|
||||||
Inheritance is an ability of an element to transfer a pack of properties to its `children` elements 'wrapped inside'.
|
Inheritance is an ability of an element to transfer a pack of properties to its `children` elements 'wrapped inside'.
|
||||||
|
|
||||||
|
Properties, which can be inherited by objects, are `styles`, `prototypes` (if the object is a reference), `inherit` (it stands for the presence of `parent` objects), and `defaults`.
|
||||||
|
|
||||||
Properties have to be set in a specific order:
|
All values of `styles` property are contained in class `StyleSheet`, where they all are defined at `Group`s level. The `prototypes` property tree is defined in `SolidGroup` class via `PrototypeHolder` interface, and
|
||||||
### Main properties' inheritance:
|
`SolidReference` class helps to reuse a template object.
|
||||||
* styles
|
|
||||||
* parents
|
|
||||||
* parent's styles
|
|
||||||
* defaults
|
|
||||||
|
|
||||||
As for `prototypes`, this property has to be set after styles, but before parents. So the order will be this:
|
The order of inheritance of properties is set in function `getPropertyValue` in `VisionBase` class.
|
||||||
### Reference properties' inheritance:
|
The order is this:
|
||||||
* styles
|
* own styles
|
||||||
* prototypes
|
* prototypes
|
||||||
* parents
|
* parent
|
||||||
* parent's styles
|
* parent's styles
|
||||||
* defaults
|
* defaults
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public interface Vision : Described, Configurable {
|
|||||||
public val manager: VisionManager? get() = parent?.manager
|
public val manager: VisionManager? get() = parent?.manager
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Vision own properties (ignoring inheritance, styles and defaults
|
* This Vision own properties (ignoring inheritance, styles and defaults)
|
||||||
*/
|
*/
|
||||||
override val meta: ObservableMutableMeta
|
override val meta: ObservableMutableMeta
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ public val Vision.propertyChanges: Flow<Name>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribe on property updates. The subscription is bound to the given [scope] and canceled when the scope is canceled
|
* Subscribe on property updates. The subscription is bound to the given scope and canceled when the scope is canceled
|
||||||
*/
|
*/
|
||||||
public fun Vision.onPropertyChange(callback: Meta.(Name) -> Unit) {
|
public fun Vision.onPropertyChange(callback: Meta.(Name) -> Unit) {
|
||||||
meta.onChange(null, callback)
|
meta.onChange(null, callback)
|
||||||
|
Loading…
Reference in New Issue
Block a user