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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#![deny(missing_copy_implementations)]
#![warn(missing_docs)]
extern crate daggy;
extern crate num;
extern crate input as piston_input;
extern crate rusttype;
pub use color::{Color, Colorable};
pub use border::{Bordering, Borderable};
pub use graph::NodeIndex;
pub use label::{FontSize, Labelable};
pub use position::{Align, Axis, Corner, Depth, Direction, Dimension, Dimensions, Edge, Margin,
Padding, Place, Point, Position, Positionable, Range, Rect, Scalar, Sizeable};
pub use theme::Theme;
pub use ui::{Ui, UiCell, UiBuilder};
pub use widget::{scroll, Widget};
pub mod backend;
mod border;
pub mod color;
pub mod event;
pub mod graph;
pub mod guide;
pub mod image;
pub mod input;
mod label;
mod position;
pub mod render;
pub mod text;
pub mod theme;
mod ui;
pub mod utils;
pub mod widget;
#[cfg(test)] mod tests;
#[macro_export]
macro_rules! widget_ids {
( $widget_id:ident , $($rest:tt)* ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id(0);
widget_ids!($widget_id.0 => $($rest)*);
);
( $widget_id:ident with $step:expr , $($rest:tt)* ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id(0);
widget_ids!($widget_id.0 + $step => $($rest)*);
);
( $prev_id:expr => $widget_id:ident , $($rest:tt)* ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id($prev_id + 1);
widget_ids!($widget_id.0 => $($rest)*);
);
( $prev_id:expr => $widget_id:ident with $step:expr , $($rest:tt)* ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id($prev_id + 1);
widget_ids!($widget_id.0 + $step => $($rest)*);
);
() => ();
( $prev_id:expr => ) => ();
( $widget_id:ident ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id(0);
);
( $widget_id:ident with $step:expr ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id(0);
);
( $prev_id:expr => $widget_id:ident ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id($prev_id + 1);
);
( $prev_id:expr => $widget_id:ident with $step:expr ) => (
const $widget_id: $crate::widget::Id = $crate::widget::Id($prev_id + 1);
);
}
#[test]
fn test() {
widget_ids! {
A,
B with 64,
C with 32,
D,
E with 8,
}
assert_eq!(A, widget::Id(0));
assert_eq!(B, widget::Id(1));
assert_eq!(C, widget::Id(66));
assert_eq!(D, widget::Id(99));
assert_eq!(E, widget::Id(100));
}