azul_layout/widgets/
mod.rs1#[macro_export]
8macro_rules! impl_widget_callback {
9 (
10 $callback_wrapper:ident,
11 $option_callback_wrapper:ident,
12 $callback_value:ident,
13 $callback_ty:ident
14 ) => {
15 #[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash)]
16 #[repr(C)]
17 pub struct $callback_wrapper {
18 pub refany: RefAny,
19 pub callback: $callback_value,
20 }
21
22 #[repr(C)]
23 pub struct $callback_value {
24 pub cb: $callback_ty,
25 pub ctx: azul_core::refany::OptionRefAny,
28 }
29
30 azul_css::impl_option!(
31 $callback_wrapper,
32 $option_callback_wrapper,
33 copy = false,
34 [Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash]
35 );
36
37 impl $callback_value {
38 pub fn create<I: Into<$callback_value>>(cb: I) -> $callback_value {
40 cb.into()
41 }
42 }
43
44 impl ::core::fmt::Display for $callback_value {
45 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
46 write!(f, "{:?}", self)
47 }
48 }
49
50 impl ::core::fmt::Debug for $callback_value {
51 fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
52 let callback = stringify!($callback_value);
53 write!(f, "{} @ 0x{:x}", callback, self.cb as usize)
54 }
55 }
56
57 impl Clone for $callback_value {
58 fn clone(&self) -> Self {
59 $callback_value {
60 cb: self.cb.clone(),
61 ctx: self.ctx.clone(),
62 }
63 }
64 }
65
66 impl core::hash::Hash for $callback_value {
67 fn hash<H>(&self, state: &mut H)
68 where
69 H: ::core::hash::Hasher,
70 {
71 state.write_usize(self.cb as usize);
72 }
73 }
74
75 impl PartialEq for $callback_value {
76 fn eq(&self, rhs: &Self) -> bool {
77 self.cb as usize == rhs.cb as usize
78 }
79 }
80
81 impl PartialOrd for $callback_value {
82 fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> {
83 Some((self.cb as usize).cmp(&(other.cb as usize)))
84 }
85 }
86
87 impl Ord for $callback_value {
88 fn cmp(&self, other: &Self) -> ::core::cmp::Ordering {
89 (self.cb as usize).cmp(&(other.cb as usize))
90 }
91 }
92
93 impl Eq for $callback_value {}
94
95 impl From<$callback_ty> for $callback_value {
98 fn from(cb: $callback_ty) -> $callback_value {
99 $callback_value {
100 cb,
101 ctx: azul_core::refany::OptionRefAny::None,
102 }
103 }
104 }
105
106 impl From<crate::callbacks::Callback> for $callback_value {
109 fn from(cb: crate::callbacks::Callback) -> $callback_value {
110 $callback_value {
111 cb: unsafe { core::mem::transmute(cb.cb) },
112 ctx: cb.ctx,
113 }
114 }
115 }
116 };
117}
118
119pub mod button;
121pub mod check_box;
123pub mod color_input;
125pub mod file_input;
127pub mod label;
129pub mod drop_down;
132pub mod frame;
134pub mod list_view;
136pub mod node_graph;
138pub mod number_input;
140pub mod progressbar;
142pub mod ribbon;
144pub mod tabs;
146pub mod text_input;
147pub mod tree_view;
149