-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface_components.v
25 lines (21 loc) · 1.06 KB
/
interface_components.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module ui
//---
// A Composable Widget is concretely a Layout (Stack, Group or CanvasLayout) to be added to the window children tree (sort of DOM).
// A Component is the struct gathering ComponentChild:
// 1) the unique composable widget ( i.e this unique root layout)
// 2) the children of this root layout (i.e. widgets or sub-components). N.B.: the other sub-layouts possibly used in the root layout children tree are not in the component struct.
// All composable widget and children widgets/sub-components have a unique field `component` corresponding to this Component structure.
// All members (layout and children) are then all connected as ComponentChild having `component` field.
// Remark: To become possibly a member of a parent component, a component has to have this field `component` to be connected to
//---
pub interface ComponentChild {
mut:
component voidptr
}
pub type ComponentInitFn = fn (layout voidptr)
pub fn component_connect(comp voidptr, children ...ComponentChild) {
mut c := children.clone()
for mut child in c {
child.component = comp
}
}