TreeView

class TreeView<T>(roots: List<T>, val childrenOf: (T) -> List<T>, val label: (T) -> String, val rowHeight: Double = 24.0) : Div(source)

A tree of items that expand and collapse, like a scene graph or a file system: roots are the items at the top, childrenOf gives the children of an item, label its text. Only the rows in view are built, see VirtualList, so large trees are as quick as small ones.

A click selects an item, a click on its arrow or a double click expands or collapses it. With the keyboard focus, up and down select the item above and below, right expands an item or moves to its first child, left collapses it or moves to its parent, enter activates it. The rows are tree-row elements, :selected when selected, with the attribute data-depth.

Constructors

Link copied to clipboard
constructor(roots: List<T>, childrenOf: (T) -> List<T>, label: (T) -> String, rowHeight: Double = 24.0)

Types

Link copied to clipboard

the events of the tree

Link copied to clipboard
data class ItemDrag(val tree: TreeView<*>, val item: Any?)

a dragged item of tree

Properties

Link copied to clipboard

the attributes of the element, which attribute selectors like [label="OK"] select, see setAttribute

Link copied to clipboard
Link copied to clipboard
val childrenOf: (T) -> List<T>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

builds the menu that opens when the element is clicked with the right button, null for none

Link copied to clipboard

The radius of the corners of this in pixels, of its org.openrndr.panel.style.borderRadius: in pixels, or a percentage of its shorter side; at most half of it

Link copied to clipboard
Link copied to clipboard

what the element does in drag and drop, see DragAndDrop

Link copied to clipboard

true when items can be dragged onto other items, see Events.dropped; the tree does not change itself

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

the history of the control manager of this element, null when it is not in one

Link copied to clipboard
Link copied to clipboard

the items that are expanded, a change shows the tree again

Link copied to clipboard
open val handlesDoubleClick: Boolean = false
Link copied to clipboard
open override val handlesKeyboardFocus: Boolean = true
Link copied to clipboard
open val heightHint: Double?
Link copied to clipboard
var id: String?
Link copied to clipboard
Link copied to clipboard
val label: (T) -> String
Link copied to clipboard
Link copied to clipboard
var layoutOffset: Vector2

an offset of the element from where it is laid out, while it moves there, see org.openrndr.panel.animateMoveFrom

Link copied to clipboard

false for elements that place their children themselves, like the spans of RichText

Link copied to clipboard

The largest scrollLeft: how far the content of the element extends beyond its right side, as found by the last layout.

Link copied to clipboard

The largest scrollTop: how far the content of the element extends beyond its bottom, as found by the last layout.

Link copied to clipboard
Link copied to clipboard
val Element.ownTransform: Matrix44?

The transform of the element itself, in the coordinates of the window, around its transform origin; null when it has none

Link copied to clipboard
open val paintArea: Rectangle

The area the element draws in, on the screen: its box and what is drawn around it, like knobs, focus rings and outlines. Only the areas of the elements that changed are drawn again, a control that draws further than this gives a larger area.

Link copied to clipboard

the text of the control manager of the element, null when it is not in one

Link copied to clipboard
Link copied to clipboard
var roots: List<T>

the items at the top, a change shows the tree again

Link copied to clipboard
Link copied to clipboard
val screenArea: Rectangle
Link copied to clipboard
val screenPosition: Vector2
Link copied to clipboard
val Element.screenTransform: Matrix44?

the transform of the element by its own transform and those of its ancestors, null when there are none

Link copied to clipboard

how far the content of an element that scrolls is scrolled to the left, in pixels

Link copied to clipboard
val scrollTarget: Vector2

where the content is scrolled to: the end of smooth scrolling, or the scroll position

Link copied to clipboard
Link copied to clipboard
var selection: T?

the item that is selected, null when none is

Link copied to clipboard
Link copied to clipboard
open val textInputArea: TextInputArea?

Where text is typed in this element while it has the focus: the line of the caret, in the coordinates of the window, with the caret from its left edge. The control manager gives it to the window, so that input methods place their candidates and on-screen keyboards next to the caret; null for elements that do not take text.

Link copied to clipboard
open var tooltip: String?

the text shown next to the pointer when it rests on the element, null for none

Link copied to clipboard
Link copied to clipboard

the bindings of values of the element, checked every frame, see org.openrndr.panel.binding.bindValue

Link copied to clipboard
open val widthHint: Double?

Functions

Link copied to clipboard
Link copied to clipboard
fun Element.animateMoveFrom(from: Vector2)

Moves the element from from, a point of the window where its top-left corner was, to where it is laid out in the next frame, like when it moved to another place in a list

Link copied to clipboard
inline fun append(builder: Element.() -> Unit)
open fun append(element: Element)
Link copied to clipboard
fun attribute(name: String): String?

the value of the attribute name, null when the element does not have it

Link copied to clipboard
fun TextElement.bind(property: KMutableProperty0<String>, program: Program? = null): Binding0<Unit, String>
Link copied to clipboard
fun <T> Element.bindValue(changed: Event<*>, property: KMutableProperty0<T>, elementValue: () -> T, setElementValue: (T) -> Unit): PropertyBinding<T>

binds the value of this element to property, see bindValue

fun <T> Element.bindValue(changed: Event<*>, get: () -> T, set: (T) -> Unit, elementValue: () -> T, setElementValue: (T) -> Unit): PropertyBinding<T>

Binds the value of this element to get and set: when changed happens, elementValue is set with set, and when get changes, setElementValue shows it in the element

Link copied to clipboard
fun Element.button(vararg classes: String, label: String = "button", init: Button.() -> Unit): Button
Link copied to clipboard
fun Element.canvas(vararg classes: String, init: Canvas.() -> Unit): Canvas
Link copied to clipboard
fun childIndex(element: Element): Int?
Link copied to clipboard
Link copied to clipboard
open override fun close()
Link copied to clipboard
fun Element.colorEditor(vararg classes: String, init: ColorEditor.() -> Unit): ColorEditor
Link copied to clipboard
fun Element.colorpicker(vararg classes: String, init: Colorpicker.() -> Unit): Colorpicker
Link copied to clipboard
Link copied to clipboard
fun Element.console(vararg classes: String, init: Console.() -> Unit = {}): Console

a Console, init sets it up

Link copied to clipboard
fun Element.containsScreenPoint(position: Vector2): Boolean

true when the point position of the window is in the box of the element as it is drawn, transformed

Link copied to clipboard

sets the menu that opens when this element is clicked with the right button, see Element.contextMenu

Link copied to clipboard
fun Element.curveEditor(vararg classes: String, init: CurveEditor.() -> Unit): CurveEditor
Link copied to clipboard
fun <T> Element.dataTable(rows: List<T>, columns: List<Column<T>>, vararg classes: String, rowHeight: Double = 24.0, init: DataTable<T>.() -> Unit = {}): DataTable<T>
Link copied to clipboard
Link copied to clipboard
fun Element.div(vararg classes: String, init: Div.() -> Unit): Div
Link copied to clipboard
fun Element.dock(vararg classes: String, init: Dock.() -> Unit): Dock

a Dock, init adds its panels with Dock.panel

Link copied to clipboard
open override fun draw(drawer: Drawer)

draws the background and the border of the box when they are set, the text is drawn by its text nodes

Link copied to clipboard
fun Element.dropdownButton(vararg classes: String, id: String? = null, label: String = "button", init: DropdownButton.() -> Unit): DropdownButton
Link copied to clipboard
inline fun <reified T> elementWithId(id: String): T?
Link copied to clipboard
Link copied to clipboard
fun Element.envelopeButton(vararg classes: String, init: EnvelopeButton.() -> Unit): EnvelopeButton
Link copied to clipboard
fun Element.envelopeEditor(vararg classes: String, init: EnvelopeEditor.() -> Unit): EnvelopeEditor
Link copied to clipboard
fun Element.expressionArea(vararg classes: String, init: ExpressionArea.() -> Unit): ExpressionArea
Link copied to clipboard
fun Element.fadeIn(duration: Double = 0.15)

fades the element in over duration seconds

Link copied to clipboard
fun Element.fcurveEditor(vararg classes: String, init: FCurveEditor.() -> Unit): FCurveEditor
Link copied to clipboard
Link copied to clipboard
fun Element.findAll(predicate: (Element) -> Boolean): List<Element>
Link copied to clipboard
Link copied to clipboard
fun findFirst(element: Element, matches: (Element) -> Boolean): Element?
Link copied to clipboard
fun findNext(premise: (Element) -> Boolean): Element?
Link copied to clipboard
fun findPrevious(premise: (Element) -> Boolean): Element?
Link copied to clipboard
Link copied to clipboard
fun Element.gradientEditor(vararg classes: String, init: GradientEditor.() -> Unit): GradientEditor
Link copied to clipboard
fun Element.h1(vararg classes: String, init: H1.() -> String): H1
Link copied to clipboard
fun Element.h2(vararg classes: String, init: H2.() -> String): H2
Link copied to clipboard
fun Element.h3(vararg classes: String, init: H3.() -> String): H3
Link copied to clipboard
open fun heightForWidth(width: Double): Double?

the height of the content of the element when it is width wide, for content that wraps; null when it has none

Link copied to clipboard
fun Element.histogram(vararg classes: String, init: Histogram.() -> Unit): Histogram
Link copied to clipboard
fun <T : Element> Element.initElement(classes: Array<out String>, element: T, init: T.() -> Unit): T
Link copied to clipboard

the styles of this element and its descendants are computed again before the next redraw

Link copied to clipboard
Link copied to clipboard

Determines whether the current element, or any of its ancestors, has a display style of Display.NONE.

Link copied to clipboard
fun Element.knob(vararg classes: String, init: Knob.() -> Unit): Knob
Link copied to clipboard
fun Element.label(vararg classes: String, init: Label.() -> String): Label
Link copied to clipboard
fun Element.layout(init: Element.() -> Unit)
Link copied to clipboard
fun Element.localPosition(position: Vector2): Vector2

position, a point of the window, in the coordinates of the element before its transforms

Link copied to clipboard
fun Element.menuBar(vararg classes: String, init: MenuBar.() -> Unit): MenuBar

a MenuBar that init adds menus to

Link copied to clipboard
fun move(steps: Int)
Link copied to clipboard
fun next(): Element?
Link copied to clipboard
fun Element.nodeEditor(vararg classes: String, init: NodeEditor.() -> Unit): NodeEditor

a NodeEditor, init adds its nodes and wires

Link copied to clipboard
fun Element.numberField(vararg classes: String, init: NumberField.() -> Unit): NumberField
Link copied to clipboard
fun Element.p(vararg classes: String, init: P.() -> String): P
Link copied to clipboard
fun Element.plot(vararg classes: String, init: Plot.() -> Unit): Plot
Link copied to clipboard
open fun prepare()

Called in every frame before the styles are computed, by the control manager, so that the element can change its children for what is in view, like a VirtualList

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Element.rangeSlider(vararg classes: String, init: RangeSlider.() -> Unit): RangeSlider
Link copied to clipboard
fun remove(element: Element): Element?
Link copied to clipboard
open fun replace(builder: Element.() -> Unit)
Link copied to clipboard
fun replaceText(text: String)
Link copied to clipboard

The layout is computed again before the next redraw, of the element and its descendants, and of the elements around it as far as its size can change theirs, see org.openrndr.panel.document.Document.layoutRequests

Link copied to clipboard

Draws the element again, what it shows changed. The layout is computed again when the size hints of the element changed; changes to the children, the classes, states and styles of elements and to scrolling lay out again by themselves, other changes that move or size elements call Element.requestLayout.

Link copied to clipboard
fun Element.richText(vararg classes: String, init: RichText.() -> Unit): RichText

a RichText that init adds spans to

Link copied to clipboard
fun root(): Element
Link copied to clipboard
fun Element.scope(vararg classes: String, init: Scope.() -> Unit): Scope
Link copied to clipboard
fun scrollIntoView(margin: Double = 0.0)

Scrolls the elements that scroll this element so that it is in view, with margin pixels around it, each by its StyleSheet.scrollBehavior

Link copied to clipboard
fun scrollTo(left: Double = scrollTarget.x, top: Double = scrollTarget.y, smooth: Boolean? = null)

Scrolls the content to left and top, within the content: smoothly when the StyleSheet.scrollBehavior of the element is smooth and smooth is not false, and the element is in a control manager

Link copied to clipboard
fun Element.sequenceEditor(vararg classes: String, init: SequenceEditor.() -> Unit): SequenceEditor
Link copied to clipboard
fun setAttribute(name: String, value: String?)

sets the attribute name to value, or removes it when value is null; the styles are computed again

Link copied to clipboard
fun Element.slideOut(x: Double, y: Double, width: Double, height: Double, vararg classes: String, aboveY: Double? = null, closeDelayMillis: Long = 0, init: SlideOut.() -> Unit): SlideOut
Link copied to clipboard
fun Element.slider(vararg classes: String, init: Slider.() -> Unit): Slider
Link copied to clipboard
fun Element.slidersVector2(vararg classes: String, init: SlidersVector2.() -> Unit): SlidersVector2
Link copied to clipboard
fun Element.slidersVector3(vararg classes: String, init: SlidersVector3.() -> Unit): SlidersVector3
Link copied to clipboard
fun Element.slidersVector4(vararg classes: String, init: SlidersVector4.() -> Unit): SlidersVector4
Link copied to clipboard
fun Element.splitPane(vararg classes: String, vertical: Boolean = false, init: SplitPane.() -> Unit): SplitPane

a SplitPane, see there

Link copied to clipboard
fun Element.style(function: StyleSheet.() -> Unit): StyleSheet

Applies the provided styling function to the element's stylesheet. If the element does not already have a stylesheet, a new one is created and the function is applied to it.

Link copied to clipboard
fun Element.tabs(vararg classes: String, init: Tabs.() -> Unit): Tabs

adds Tabs, init adds their pages with Tabs.tab

Link copied to clipboard
fun text(text: String)
Link copied to clipboard
fun Element.textArea(vararg classes: String, init: TextArea.() -> Unit): TextArea
Link copied to clipboard
inline fun <reified T : TextElement> Element.textElement(classes: Array<out String>, init: T.() -> String): T
Link copied to clipboard
fun Element.textfield(vararg classes: String, init: Textfield.() -> Unit): Textfield
Link copied to clipboard
fun Element.textInput(vararg classes: String, init: TextInput.() -> Unit): TextInput
Link copied to clipboard
fun Element.timeline(vararg classes: String, init: Timeline.() -> Unit): Timeline
Link copied to clipboard
fun toggle(item: T)

expands item when it is collapsed, collapses it otherwise

Link copied to clipboard
fun Element.toggle(vararg classes: String, init: Toggle.() -> Unit): Toggle
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun <T> Element.treeView(roots: List<T>, childrenOf: (T) -> List<T>, label: (T) -> String = { it.toString() }, vararg classes: String, rowHeight: Double = 24.0, init: TreeView<T>.() -> Unit = {}): TreeView<T>

a TreeView of roots, whose children childrenOf gives, labeled by label

Link copied to clipboard
fun Element.viewBox(viewBox: ViewBox)
fun Element.viewBox(program: Program, f: ViewBox.() -> Unit): ViewBoxElement
Link copied to clipboard
fun <T> Element.virtualList(items: List<T>, rowHeight: Double, vararg classes: String, row: Div.(item: T, index: Int) -> Unit): VirtualList<T>

a VirtualList of items with rows of rowHeight pixels that row builds

Link copied to clipboard
fun Element.visit(function: Element.() -> Unit)
Link copied to clipboard
fun Element.visitVisible(function: Element.() -> Unit)
Link copied to clipboard
fun <T : Any> Element.watchListDiv(vararg classes: String, watchList: List<T>, builder: WatchListDiv<T>.(T) -> Unit)
Link copied to clipboard
fun <T : Any> Element.watchObjectDiv(vararg classes: String, watchObject: T, builder: WatchObjectDiv<T>.(T) -> Unit): WatchObjectDiv<T>

Creates a Div element with the provided classes, and runs builder to populate the Div any time watchObject changes.

Link copied to clipboard
fun <T : Any> Element.watchPropertyDiv(vararg classes: String, watchProperty: KMutableProperty0<T>, builder: WatchPropertyDiv<T>.(T) -> Unit)
Link copied to clipboard
fun Element.xyPad(vararg classes: String, init: XYPad.() -> Unit): XYPad