-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomponent_toolbar.v
More file actions
52 lines (47 loc) · 967 Bytes
/
component_toolbar.v
File metadata and controls
52 lines (47 loc) · 967 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
module uicomponent
import ui
[heap]
struct ToolBar {
pub mut:
layout &ui.Stack // required
items []ui.Widget
// To become a component of a parent component
component voidptr
}
[params]
pub struct ToolBarConfig {
id string
widths ui.Size
heights ui.Size
spacing f64 // Size = Size(0.) // Spacing = Spacing(0) // int
spacings []f64 = []f64{}
items []ui.Widget
}
pub fn toolbar(c ToolBarConfig) &ui.Stack {
mut layout := ui.row(
id: c.id
widths: c.widths
heights: c.heights
spacing: c.spacing
spacings: c.spacings
children: c.items
)
tb := &ToolBar{
layout: layout
items: c.items
}
for mut child in c.items {
if mut child is ui.Button {
child.component = tb
} else if mut child is ui.Label {
child.component = tb
} else if mut child is ui.Rectangle {
child.component = tb
}
}
return layout
}
// component access
pub fn component_toolbar(w ui.ComponentChild) &ToolBar {
return &ToolBar(w.component)
}