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
macro_rules! define_control {
{$(#[$attr:meta])* rust_type: $rust_type:ident, sys_type: $sys_type:ident$(,)* } => {
#[allow(non_snake_case)]
$(#[$attr])*
pub struct $rust_type {
$sys_type: *mut $sys_type,
}
impl Drop for $rust_type {
fn drop(&mut self) {
}
}
impl Clone for $rust_type {
fn clone(&self) -> $rust_type {
$rust_type {
$sys_type: self.$sys_type,
}
}
}
impl Into<Control> for $rust_type {
fn into(self) -> Control {
unsafe {
let control = Control::from_ui_control(self.$sys_type as *mut uiControl);
mem::forget(self);
control
}
}
}
impl $rust_type {
pub fn show(&mut self, _ctx: &UI) {
let control: Control = self.clone().into();
unsafe { ui_sys::uiControlShow(control.ui_control) }
}
pub fn hide(&mut self, _ctx: &UI) {
let control: Control = self.clone().into();
unsafe { ui_sys::uiControlHide(control.ui_control) }
}
#[allow(non_snake_case)]
#[allow(unused)]
pub unsafe fn from_raw($sys_type: *mut $sys_type) -> $rust_type {
$rust_type {
$sys_type: $sys_type
}
}
#[allow(non_snake_case)]
pub fn ptr(&self) -> *mut $sys_type {
self.$sys_type
}
}
}
}