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
//! Helpers that reduce the ceremony of adding a new widget kind.
//!
//! The retained UI registers each widget kind across roughly seven sites
//! (component struct in components, freecs ecs! macro registration in world.rs,
//! WidgetData impl, query loop in widget_systems.rs, handler module, builder
//! method, scope wrapper, optional UiEvent variant). The macros below batch
//! the data definition pieces so adding a new widget is closer to two sites
//! (the macro invocation and the handler).
//!
//! The freecs ecs! macro and the widget_systems.rs dispatch loops still need
//! manual registration, but those are mechanical edits in fixed locations.
/// Defines a widget data struct with `Default`, `Clone`, `Debug` derived and
/// a [`WidgetData`](crate::ecs::ui::components::WidgetData) impl, removing the
/// `impl_widget_data!` line that would otherwise be needed.
///
/// Usage:
/// ```ignore
/// widget_data! {
/// UiFooData {
/// pub bar: f32,
/// pub baz: bool,
/// }
/// get: get_ui_foo,
/// get_mut: get_ui_foo_mut,
/// set: set_ui_foo,
/// }
/// ```
///
/// You still need to add a corresponding line to the `freecs::ecs!` macro in
/// `crates/nightshade/src/ecs/world.rs` like:
/// `ui_foo: crate::ecs::ui::components::UiFooData => UI_FOO,`
get: $get:ident,
get_mut: $get_mut:ident,
set: $set:ident,
) =>
};
}