Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use orbtk::*;
struct MainView;
// Positing with horizontal / vertical alignment
//impl Widget for MainView {
// fn create() -> Template {
// Template::default()
// .as_parent_type(ParentType::Single)
// .with_debug_name("MainView")
// .with_child(
// Grid::create()
// .with_child(Grid::create().with_property(Selector::from("test")))
// .with_child(
// Grid::create()
// .with_property(Selector::from("testa"))
// .with_property(HorizontalAlignment::Center)
// .with_property(VerticalAlignment::Center)
// ),
// )
// }
//}
// todo: use ParentType::Single as default
// todo: column definitions are not functional now (wip)
impl Widget for MainView {
fn create() -> Template {
Template::default()
.as_parent_type(ParentType::Single)
.with_debug_name("MainView")
.with_child(
Grid::create()
.with_property(
Columns::create()
.with(Column::create().with_width(ColumnWidth::Stretch).build())
.with(Column::create().with_width(ColumnWidth::Auto).build())
.with(
Column::create()
.with_width(ColumnWidth::Width(50.0))
.build(),
)
.build(),
)
.with_child(
Grid::create()
.with_property(Selector::from("test"))
.with_property(GridColumn(0)),
)
.with_child(
Grid::create()
.with_property(Selector::from("testa"))
.with_property(GridColumn(1)),
)
.with_child(
Grid::create()
.with_property(Selector::from("testb"))
.with_property(GridColumn(2)),
),
)
}
}
fn main() {
let mut application = Application::default();
application
.create_window()
.with_bounds(Bounds::new(100.0, 100.0, 420.0, 730.0))
.with_title("OrbTk - grid example")
.with_root(MainView::create())
.with_theme(
Theme::create()
.with_extenstion_path("examples/res/grid.css")
.build(),
)
.with_debug_flag(true)
.build();
application.run();
}