dear_imnodes/context/editor/
deprecated.rs1use super::super::NodeEditor;
2use crate::sys;
3
4impl<'ui> NodeEditor<'ui> {
5 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
6 pub fn is_link_created(&self) -> Option<crate::LinkCreated> {
7 self.bind();
8 let mut start_attr = 0i32;
9 let mut end_attr = 0i32;
10 let mut from_snap = false;
11 let created = unsafe {
12 sys::imnodes_IsLinkCreated_BoolPtr(
13 &mut start_attr as *mut i32,
14 &mut end_attr as *mut i32,
15 &mut from_snap as *mut bool,
16 )
17 };
18 if created {
19 Some(crate::LinkCreated {
20 start_attr,
21 end_attr,
22 from_snap,
23 })
24 } else {
25 None
26 }
27 }
28
29 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
31 pub fn is_link_created_with_nodes(&self) -> Option<crate::LinkCreatedEx> {
32 self.bind();
33 let mut start_node = 0i32;
34 let mut start_attr = 0i32;
35 let mut end_node = 0i32;
36 let mut end_attr = 0i32;
37 let mut from_snap = false;
38 let created = unsafe {
39 sys::imnodes_IsLinkCreated_IntPtr(
40 &mut start_node as *mut i32,
41 &mut start_attr as *mut i32,
42 &mut end_node as *mut i32,
43 &mut end_attr as *mut i32,
44 &mut from_snap as *mut bool,
45 )
46 };
47 if created {
48 Some(crate::LinkCreatedEx {
49 start_node,
50 start_attr,
51 end_node,
52 end_attr,
53 from_snap,
54 })
55 } else {
56 None
57 }
58 }
59
60 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
62 pub fn selected_nodes(&self) -> Vec<i32> {
63 self.bind();
64 let n = unsafe { sys::imnodes_NumSelectedNodes() };
65 if n <= 0 {
66 return Vec::new();
67 }
68 let mut buf = vec![0i32; n as usize];
69 unsafe { sys::imnodes_GetSelectedNodes(buf.as_mut_ptr()) };
70 buf
71 }
72
73 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
74 pub fn selected_links(&self) -> Vec<i32> {
75 self.bind();
76 let n = unsafe { sys::imnodes_NumSelectedLinks() };
77 if n <= 0 {
78 return Vec::new();
79 }
80 let mut buf = vec![0i32; n as usize];
81 unsafe { sys::imnodes_GetSelectedLinks(buf.as_mut_ptr()) };
82 buf
83 }
84
85 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
86 pub fn clear_selection(&self) {
87 self.bind();
88 unsafe {
89 sys::imnodes_ClearNodeSelection_Nil();
90 sys::imnodes_ClearLinkSelection_Nil();
91 }
92 }
93
94 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
96 pub fn is_editor_hovered(&self) -> bool {
97 self.bind();
98 unsafe { sys::imnodes_IsEditorHovered() }
99 }
100 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
101 pub fn hovered_node(&self) -> Option<i32> {
102 self.bind();
103 let mut id = 0;
104 if unsafe { sys::imnodes_IsNodeHovered(&mut id) } {
105 Some(id)
106 } else {
107 None
108 }
109 }
110 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
111 pub fn hovered_link(&self) -> Option<i32> {
112 self.bind();
113 let mut id = 0;
114 if unsafe { sys::imnodes_IsLinkHovered(&mut id) } {
115 Some(id)
116 } else {
117 None
118 }
119 }
120 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
121 pub fn hovered_pin(&self) -> Option<i32> {
122 self.bind();
123 let mut id = 0;
124 if unsafe { sys::imnodes_IsPinHovered(&mut id) } {
125 Some(id)
126 } else {
127 None
128 }
129 }
130
131 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
133 pub fn is_attribute_active(&self) -> bool {
134 self.bind();
135 unsafe { sys::imnodes_IsAttributeActive() }
136 }
137 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
138 pub fn any_attribute_active(&self) -> Option<i32> {
139 self.bind();
140 let mut id = 0;
141 if unsafe { sys::imnodes_IsAnyAttributeActive(&mut id) } {
142 Some(id)
143 } else {
144 None
145 }
146 }
147
148 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
150 pub fn is_link_started(&self) -> Option<i32> {
151 self.bind();
152 let mut id = 0;
153 if unsafe { sys::imnodes_IsLinkStarted(&mut id) } {
154 Some(id)
155 } else {
156 None
157 }
158 }
159 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
160 pub fn is_link_dropped(&self, including_detached: bool) -> Option<i32> {
161 self.bind();
162 let mut id = 0;
163 if unsafe { sys::imnodes_IsLinkDropped(&mut id, including_detached) } {
164 Some(id)
165 } else {
166 None
167 }
168 }
169
170 #[deprecated(note = "Call `editor.end()` and use the returned `PostEditor` handle.")]
171 pub fn is_link_destroyed(&self) -> Option<i32> {
172 self.bind();
173 let mut id = 0i32;
174 let destroyed = unsafe { sys::imnodes_IsLinkDestroyed(&mut id as *mut i32) };
175 if destroyed { Some(id) } else { None }
176 }
177}