Procs
proc bindingImpl(obj: NimNode; target: NimNode; body: NimNode; init: bool; kind: BindingKind; ctor: NimNode = newEmptyNode()): NimNode {. ...raises: [], tags: [], forbids: [].}
-
connects update proc to every x[] property changed, and invokes update proc instantly
type MyObj = ref object of Uiobj c: Property[int] let obj = MyObj() obj.binding c: if config.csd[]: parent[].b else: 10[]
converts to (roughly):
block bindingBlock: let o {.cursor.} = obj proc updateC(this: MyObj) = this.c[] = if config.csd[]: parent[].b else: 10[] config.csd.changed.connectTo o: updateC(this) parent.changed.connectTo o: updateC(this) 10.changed.connectTo o: updateC(this) # yes, 10[] will considered property too updateC(o)
Source Edit
Macros
macro binding(obj: EventHandler | HasEventHandler; body: untyped; init: static bool = true): untyped
- Source Edit
macro binding(obj: EventHandler; target: untyped; body: typed; init: static bool = true): untyped {. ...deprecated: "use bindingProperty instead".}
- Source Edit
macro binding[T: HasEventHandler](obj: T; target: untyped; body: typed; init: static bool = true): untyped {. ...deprecated: "use bindingProperty instead".}
- Source Edit
macro bindingProc(obj: EventHandler; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro bindingProc[T: HasEventHandler](obj: T; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro bindingProperty(obj: EventHandler; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro bindingProperty[T: HasEventHandler](obj: T; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro bindingValue(obj: EventHandler; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro bindingValue[T: HasEventHandler](obj: T; target: untyped; body: typed; init: static bool = true): untyped
- Source Edit
macro makeLayout(obj: Uiobj; body: untyped)
-
tip: use a.makeLauyout(-soMeFuN()) instead of (let b = soMeFuN(); a.addChild(b); init b)
import sigui/uibase let a = UiRect.new let b = UiRect.new let c = UiRect.new var ooo: ChangableChild[UiRect] a.makeLayout: - RectShadow( radius: 7.5'f32.property, # pre-initialization of properties (not recommended) blurRadius: 10'f32.property, color: color(0, 0, 0, 0.3).property ) as shadowEffect - newUiRect(): this.fill(parent) echo shadowEffect.radius doassert parent.Uiobj == this.parent - ClipRect.new: this.radius[] = 7.5 this.fill(parent, 10) doassert root.Uiobj == this.parent.parent ooo --- UiRect.new: # add changable child this.fill(parent) - b - UiRect.new - c: this.fill(parent)
Source Edit
Templates
template makeLayoutInside[T](res: var T; container: Uiobj; init: T; body: untyped)
- Source Edit
Exports
-
changed, disconnect, emit, disconnect, emit, EventHandler, Event, connectTo, connectTo, connectTo, hasHandlers, disconnect, connectTo, disconnect, connect, connect, connect, hasExternalHandlers, =copy, val, {}, val=, AnyProperty, []=, toValue, {}, {}=, unsafeVal, [], val=, CustomProperty, val, property, {}=, Property, unsafeVal=, =copy, toValue, []=, []