NodeEditor

A graph of nodes with ports, connected by wires. Dragging a node moves it with the other selected nodes, dragging from an output draws a wire that connects to the input it is released on, dragging a wire off an input detaches it; an input has one wire at most. A click selects a node, with shift more; dragging on the background selects the nodes in the box, and delete removes the selected nodes. The wheel zooms around the pointer, dragging with the middle button or with alt pans. The changes can be undone, see org.openrndr.panel.History. Nodes are drawn in the colors of the style of the editor, the selected ones and wires in that of accent, ports and their wires in portColor.

Every change of nodes and wires fires an event, also those of undo and redo and those of the host: Events.added and Events.removed for nodes, Events.connected and Events.disconnected for wires, Events.moved for moves, so a model can follow the editor by its events alone.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard
var accent: ColorRGBa

the color of selections and wires

Link copied to clipboard

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

Link copied to clipboard

the badges of a node, drawn next to each other on its top right corner, at the same size at every zoom, and over the nodes; a press on a badge neither selects nor moves the node, a click fires Events.badgeClicked. Call requestRedraw when the badges change

Link copied to clipboard
var canConnect: (output: Port, input: Port) -> Boolean

true when a wire can go from output to input, by default when their types are the same or either has none

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

true when the nodes whose GraphNode.compact is null are drawn compact

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
Link copied to clipboard
Link copied to clipboard

true when dragging nodes, a wire or a selection box near or past the edges of the editor pans the view

Link copied to clipboard

the distance from the edges, in pixels, within which a drag pans the view

Link copied to clipboard

how fast the view pans, in pixels per second, with the pointer at an edge; it pans faster further past it

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
open override val handlesDoubleClick: Boolean = true
Link copied to clipboard
open override val handlesKeyboardFocus: Boolean = true
Link copied to clipboard
open val heightHint: Double?
Link copied to clipboard
var highlightColor: ColorRGBa

the color of the outlines of the nodes that are highlighted, see highlightUpstream and highlightDownstream

Link copied to clipboard

true when hovering over an output highlights its downstream: the wires and nodes it leads to, through all outputs

Link copied to clipboard

the nodes and wires that are highlighted now, empty when nothing is

Link copied to clipboard
Link copied to clipboard

true when hovering over an input highlights its upstream: the wires and nodes that lead to it, through all inputs

Link copied to clipboard
var id: String?
Link copied to clipboard
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

the nodes, the last drawn on top; changed by add and remove

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
var pan: Vector2

the offset of the graph in the element, in pixels

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 portColor: (Port) -> ColorRGBa?

the color of a port and of the wires from it, by default its own; none draws it in accent

Link copied to clipboard
var portLabel: (node: GraphNode, port: Port, isOutput: Boolean) -> String?

a text drawn after the name of a port, like its current value, or none; call requestRedraw when the texts change

Link copied to clipboard
var recordEdit: (name: String, undo: () -> Unit, redo: () -> Unit) -> Unit

Records an edit of this element, named name, in the history so that it can be undone and redone, by default in org.openrndr.panel.editHistory. A program can take this over, like to wrap undo and redo so that they leave alone what others changed since, or to keep the edits in a history of its own.

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

the nodes that are selected

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 override var tooltip: String?

the tooltip of the badge under the pointer, or the tooltip of the editor

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?
Link copied to clipboard
var wireRoute: (Wire) -> List<Vector2>?

the points, in the coordinates of the graph, that a wire goes through on its way from its output to its input, like to go around nodes, or none for the direct way; drawn as one smooth curve that leaves the output and enters the input horizontally. Call requestRedraw when the routes change

Link copied to clipboard

the wires; changed by connect and disconnect

Link copied to clipboard

the scale of the graph

Functions

Link copied to clipboard
fun add(node: GraphNode, position: Vector2 = node.position): GraphNode

adds node at position in the coordinates of the graph

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 badgeArea(node: GraphNode, key: Any): Rectangle?

the area of the window of the badge of node with key, or with that index when the badges have no keys; null when it has none, like when the node is removed, or when the badge is out of view of the editor. For a popover that follows the badge when the graph pans and zooms, and hides while it is out of view: cm.popover({ editor.badgeArea(node, key) }) { ... }

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 connect(from: GraphNode, output: Int, to: GraphNode, input: Int): Wire?

connects the output output of from to the input input of to, replacing the wire at that input

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 disconnect(wire: Wire)

removes wire

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)
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 graph(id: (GraphNode) -> String? = { it.data?.toString() }): NodeGraphModel

the nodes and wires as they are now, id gives the NodeModel.id of a node, by default its data as a string

Link copied to clipboard
fun graphPosition(p: Vector2): Vector2

p, a point of the window, in the coordinates of the graph

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 override 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?

fun remove(removed: Collection<GraphNode>)

removes removed and their wires

Link copied to clipboard
open fun replace(builder: Element.() -> Unit)
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 restore(model: NodeGraphModel, create: (NodeModel) -> GraphNode? = { m -> GraphNode(m.title, m.inputs.map { Port(it.name, it.type, it.color) }, m.outputs.map { Port(it.name, it.type, it.color) }, data = m.id) }): List<GraphNode?>

Replaces the nodes and wires by those of model, firing the events of the removals and the additions; create makes the node of a NodeModel, by default with its ports and with its id as data, or none to leave it out. Wires that do not fit their nodes, or that canConnect refuses, are left out. Not recorded in the history.

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 setCompact(changed: Collection<GraphNode>, compact: Boolean?)

makes changed compact when compact is true, expands them when it is false, or lets them follow compactNodes when it is null; the change can be undone

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 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 Element.toggle(vararg classes: String, init: Toggle.() -> Unit): Toggle
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