dora_ssr/dora/
node.rs

1/* Copyright (c) 2016-2025 Li Jin <dragon-fly@qq.com>
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
5The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
7THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8
9extern "C" {
10	fn node_type() -> i32;
11	fn node_set_order(slf: i64, val: i32);
12	fn node_get_order(slf: i64) -> i32;
13	fn node_set_angle(slf: i64, val: f32);
14	fn node_get_angle(slf: i64) -> f32;
15	fn node_set_angle_x(slf: i64, val: f32);
16	fn node_get_angle_x(slf: i64) -> f32;
17	fn node_set_angle_y(slf: i64, val: f32);
18	fn node_get_angle_y(slf: i64) -> f32;
19	fn node_set_scale_x(slf: i64, val: f32);
20	fn node_get_scale_x(slf: i64) -> f32;
21	fn node_set_scale_y(slf: i64, val: f32);
22	fn node_get_scale_y(slf: i64) -> f32;
23	fn node_set_x(slf: i64, val: f32);
24	fn node_get_x(slf: i64) -> f32;
25	fn node_set_y(slf: i64, val: f32);
26	fn node_get_y(slf: i64) -> f32;
27	fn node_set_z(slf: i64, val: f32);
28	fn node_get_z(slf: i64) -> f32;
29	fn node_set_position(slf: i64, val: i64);
30	fn node_get_position(slf: i64) -> i64;
31	fn node_set_skew_x(slf: i64, val: f32);
32	fn node_get_skew_x(slf: i64) -> f32;
33	fn node_set_skew_y(slf: i64, val: f32);
34	fn node_get_skew_y(slf: i64) -> f32;
35	fn node_set_visible(slf: i64, val: i32);
36	fn node_is_visible(slf: i64) -> i32;
37	fn node_set_anchor(slf: i64, val: i64);
38	fn node_get_anchor(slf: i64) -> i64;
39	fn node_set_width(slf: i64, val: f32);
40	fn node_get_width(slf: i64) -> f32;
41	fn node_set_height(slf: i64, val: f32);
42	fn node_get_height(slf: i64) -> f32;
43	fn node_set_size(slf: i64, val: i64);
44	fn node_get_size(slf: i64) -> i64;
45	fn node_set_tag(slf: i64, val: i64);
46	fn node_get_tag(slf: i64) -> i64;
47	fn node_set_opacity(slf: i64, val: f32);
48	fn node_get_opacity(slf: i64) -> f32;
49	fn node_set_color(slf: i64, val: i32);
50	fn node_get_color(slf: i64) -> i32;
51	fn node_set_color3(slf: i64, val: i32);
52	fn node_get_color3(slf: i64) -> i32;
53	fn node_set_pass_opacity(slf: i64, val: i32);
54	fn node_is_pass_opacity(slf: i64) -> i32;
55	fn node_set_pass_color3(slf: i64, val: i32);
56	fn node_is_pass_color3(slf: i64) -> i32;
57	fn node_set_transform_target(slf: i64, val: i64);
58	fn node_get_transform_target(slf: i64) -> i64;
59	fn node_set_scheduler(slf: i64, val: i64);
60	fn node_get_scheduler(slf: i64) -> i64;
61	fn node_get_children(slf: i64) -> i64;
62	fn node_get_parent(slf: i64) -> i64;
63	fn node_is_running(slf: i64) -> i32;
64	fn node_is_scheduled(slf: i64) -> i32;
65	fn node_get_action_count(slf: i64) -> i32;
66	fn node_get_data(slf: i64) -> i64;
67	fn node_set_touch_enabled(slf: i64, val: i32);
68	fn node_is_touch_enabled(slf: i64) -> i32;
69	fn node_set_swallow_touches(slf: i64, val: i32);
70	fn node_is_swallow_touches(slf: i64) -> i32;
71	fn node_set_swallow_mouse_wheel(slf: i64, val: i32);
72	fn node_is_swallow_mouse_wheel(slf: i64) -> i32;
73	fn node_set_keyboard_enabled(slf: i64, val: i32);
74	fn node_is_keyboard_enabled(slf: i64) -> i32;
75	fn node_set_controller_enabled(slf: i64, val: i32);
76	fn node_is_controller_enabled(slf: i64) -> i32;
77	fn node_set_render_group(slf: i64, val: i32);
78	fn node_is_render_group(slf: i64) -> i32;
79	fn node_set_show_debug(slf: i64, val: i32);
80	fn node_is_show_debug(slf: i64) -> i32;
81	fn node_set_render_order(slf: i64, val: i32);
82	fn node_get_render_order(slf: i64) -> i32;
83	fn node_add_child_with_order_tag(slf: i64, child: i64, order: i32, tag: i64);
84	fn node_add_child_with_order(slf: i64, child: i64, order: i32);
85	fn node_add_child(slf: i64, child: i64);
86	fn node_add_to_with_order_tag(slf: i64, parent: i64, order: i32, tag: i64) -> i64;
87	fn node_add_to_with_order(slf: i64, parent: i64, order: i32) -> i64;
88	fn node_add_to(slf: i64, parent: i64) -> i64;
89	fn node_remove_child(slf: i64, child: i64, cleanup: i32);
90	fn node_remove_child_by_tag(slf: i64, tag: i64, cleanup: i32);
91	fn node_remove_all_children(slf: i64, cleanup: i32);
92	fn node_remove_from_parent(slf: i64, cleanup: i32);
93	fn node_move_to_parent(slf: i64, parent: i64);
94	fn node_cleanup(slf: i64);
95	fn node_get_child_by_tag(slf: i64, tag: i64) -> i64;
96	fn node_schedule(slf: i64, func0: i32, stack0: i64);
97	fn node_unschedule(slf: i64);
98	fn node_convert_to_node_space(slf: i64, world_point: i64) -> i64;
99	fn node_convert_to_world_space(slf: i64, node_point: i64) -> i64;
100	fn node_convert_to_window_space(slf: i64, node_point: i64, func0: i32, stack0: i64);
101	fn node_each_child(slf: i64, func0: i32, stack0: i64) -> i32;
102	fn node_traverse(slf: i64, func0: i32, stack0: i64) -> i32;
103	fn node_traverse_all(slf: i64, func0: i32, stack0: i64) -> i32;
104	fn node_run_action_def(slf: i64, def: i64, looped: i32) -> f32;
105	fn node_run_action(slf: i64, action: i64, looped: i32) -> f32;
106	fn node_stop_all_actions(slf: i64);
107	fn node_perform_def(slf: i64, action_def: i64, looped: i32) -> f32;
108	fn node_perform(slf: i64, action: i64, looped: i32) -> f32;
109	fn node_stop_action(slf: i64, action: i64);
110	fn node_align_items_vertically(slf: i64, padding: f32) -> i64;
111	fn node_align_items_vertically_with_size(slf: i64, size: i64, padding: f32) -> i64;
112	fn node_align_items_horizontally(slf: i64, padding: f32) -> i64;
113	fn node_align_items_horizontally_with_size(slf: i64, size: i64, padding: f32) -> i64;
114	fn node_align_items(slf: i64, padding: f32) -> i64;
115	fn node_align_items_with_size(slf: i64, size: i64, padding: f32) -> i64;
116	fn node_move_and_cull_items(slf: i64, delta: i64);
117	fn node_attach_ime(slf: i64);
118	fn node_detach_ime(slf: i64);
119	fn node_grab(slf: i64) -> i64;
120	fn node_grab_with_size(slf: i64, grid_x: i32, grid_y: i32) -> i64;
121	fn node_stop_grab(slf: i64);
122	fn node_set_transform_target_null(slf: i64);
123	fn node_slot(slf: i64, event_name: i64, func0: i32, stack0: i64);
124	fn node_gslot(slf: i64, event_name: i64, func0: i32, stack0: i64);
125	fn node_emit(slf: i64, name: i64, stack: i64);
126	fn node_on_update(slf: i64, func0: i32, stack0: i64);
127	fn node_on_render(slf: i64, func0: i32, stack0: i64);
128	fn node_new() -> i64;
129}
130use crate::dora::IObject;
131/// Struct used for building a hierarchical tree structure of game objects.
132pub struct Node { raw: i64 }
133crate::dora_object!(Node);
134impl INode for Node { }
135pub trait INode: IObject {
136	/// Sets the order of the node in the parent's children array.
137	fn set_order(&mut self, val: i32) {
138		unsafe { node_set_order(self.raw(), val) };
139	}
140	/// Gets the order of the node in the parent's children array.
141	fn get_order(&self) -> i32 {
142		return unsafe { node_get_order(self.raw()) };
143	}
144	/// Sets the rotation angle of the node in degrees.
145	fn set_angle(&mut self, val: f32) {
146		unsafe { node_set_angle(self.raw(), val) };
147	}
148	/// Gets the rotation angle of the node in degrees.
149	fn get_angle(&self) -> f32 {
150		return unsafe { node_get_angle(self.raw()) };
151	}
152	/// Sets the X-axis rotation angle of the node in degrees.
153	fn set_angle_x(&mut self, val: f32) {
154		unsafe { node_set_angle_x(self.raw(), val) };
155	}
156	/// Gets the X-axis rotation angle of the node in degrees.
157	fn get_angle_x(&self) -> f32 {
158		return unsafe { node_get_angle_x(self.raw()) };
159	}
160	/// Sets the Y-axis rotation angle of the node in degrees.
161	fn set_angle_y(&mut self, val: f32) {
162		unsafe { node_set_angle_y(self.raw(), val) };
163	}
164	/// Gets the Y-axis rotation angle of the node in degrees.
165	fn get_angle_y(&self) -> f32 {
166		return unsafe { node_get_angle_y(self.raw()) };
167	}
168	/// Sets the X-axis scale factor of the node.
169	fn set_scale_x(&mut self, val: f32) {
170		unsafe { node_set_scale_x(self.raw(), val) };
171	}
172	/// Gets the X-axis scale factor of the node.
173	fn get_scale_x(&self) -> f32 {
174		return unsafe { node_get_scale_x(self.raw()) };
175	}
176	/// Sets the Y-axis scale factor of the node.
177	fn set_scale_y(&mut self, val: f32) {
178		unsafe { node_set_scale_y(self.raw(), val) };
179	}
180	/// Gets the Y-axis scale factor of the node.
181	fn get_scale_y(&self) -> f32 {
182		return unsafe { node_get_scale_y(self.raw()) };
183	}
184	/// Sets the X-axis position of the node.
185	fn set_x(&mut self, val: f32) {
186		unsafe { node_set_x(self.raw(), val) };
187	}
188	/// Gets the X-axis position of the node.
189	fn get_x(&self) -> f32 {
190		return unsafe { node_get_x(self.raw()) };
191	}
192	/// Sets the Y-axis position of the node.
193	fn set_y(&mut self, val: f32) {
194		unsafe { node_set_y(self.raw(), val) };
195	}
196	/// Gets the Y-axis position of the node.
197	fn get_y(&self) -> f32 {
198		return unsafe { node_get_y(self.raw()) };
199	}
200	/// Sets the Z-axis position of the node.
201	fn set_z(&mut self, val: f32) {
202		unsafe { node_set_z(self.raw(), val) };
203	}
204	/// Gets the Z-axis position of the node.
205	fn get_z(&self) -> f32 {
206		return unsafe { node_get_z(self.raw()) };
207	}
208	/// Sets the position of the node as a Vec2 object.
209	fn set_position(&mut self, val: &crate::dora::Vec2) {
210		unsafe { node_set_position(self.raw(), val.into_i64()) };
211	}
212	/// Gets the position of the node as a Vec2 object.
213	fn get_position(&self) -> crate::dora::Vec2 {
214		return unsafe { crate::dora::Vec2::from(node_get_position(self.raw())) };
215	}
216	/// Sets the X-axis skew angle of the node in degrees.
217	fn set_skew_x(&mut self, val: f32) {
218		unsafe { node_set_skew_x(self.raw(), val) };
219	}
220	/// Gets the X-axis skew angle of the node in degrees.
221	fn get_skew_x(&self) -> f32 {
222		return unsafe { node_get_skew_x(self.raw()) };
223	}
224	/// Sets the Y-axis skew angle of the node in degrees.
225	fn set_skew_y(&mut self, val: f32) {
226		unsafe { node_set_skew_y(self.raw(), val) };
227	}
228	/// Gets the Y-axis skew angle of the node in degrees.
229	fn get_skew_y(&self) -> f32 {
230		return unsafe { node_get_skew_y(self.raw()) };
231	}
232	/// Sets whether the node is visible.
233	fn set_visible(&mut self, val: bool) {
234		unsafe { node_set_visible(self.raw(), if val { 1 } else { 0 }) };
235	}
236	/// Gets whether the node is visible.
237	fn is_visible(&self) -> bool {
238		return unsafe { node_is_visible(self.raw()) != 0 };
239	}
240	/// Sets the anchor point of the node as a Vec2 object.
241	fn set_anchor(&mut self, val: &crate::dora::Vec2) {
242		unsafe { node_set_anchor(self.raw(), val.into_i64()) };
243	}
244	/// Gets the anchor point of the node as a Vec2 object.
245	fn get_anchor(&self) -> crate::dora::Vec2 {
246		return unsafe { crate::dora::Vec2::from(node_get_anchor(self.raw())) };
247	}
248	/// Sets the width of the node.
249	fn set_width(&mut self, val: f32) {
250		unsafe { node_set_width(self.raw(), val) };
251	}
252	/// Gets the width of the node.
253	fn get_width(&self) -> f32 {
254		return unsafe { node_get_width(self.raw()) };
255	}
256	/// Sets the height of the node.
257	fn set_height(&mut self, val: f32) {
258		unsafe { node_set_height(self.raw(), val) };
259	}
260	/// Gets the height of the node.
261	fn get_height(&self) -> f32 {
262		return unsafe { node_get_height(self.raw()) };
263	}
264	/// Sets the size of the node as a Size object.
265	fn set_size(&mut self, val: &crate::dora::Size) {
266		unsafe { node_set_size(self.raw(), val.into_i64()) };
267	}
268	/// Gets the size of the node as a Size object.
269	fn get_size(&self) -> crate::dora::Size {
270		return unsafe { crate::dora::Size::from(node_get_size(self.raw())) };
271	}
272	/// Sets the tag of the node as a string.
273	fn set_tag(&mut self, val: &str) {
274		unsafe { node_set_tag(self.raw(), crate::dora::from_string(val)) };
275	}
276	/// Gets the tag of the node as a string.
277	fn get_tag(&self) -> String {
278		return unsafe { crate::dora::to_string(node_get_tag(self.raw())) };
279	}
280	/// Sets the opacity of the node, should be 0 to 1.0.
281	fn set_opacity(&mut self, val: f32) {
282		unsafe { node_set_opacity(self.raw(), val) };
283	}
284	/// Gets the opacity of the node, should be 0 to 1.0.
285	fn get_opacity(&self) -> f32 {
286		return unsafe { node_get_opacity(self.raw()) };
287	}
288	/// Sets the color of the node as a Color object.
289	fn set_color(&mut self, val: &crate::dora::Color) {
290		unsafe { node_set_color(self.raw(), val.to_argb() as i32) };
291	}
292	/// Gets the color of the node as a Color object.
293	fn get_color(&self) -> crate::dora::Color {
294		return unsafe { crate::dora::Color::from(node_get_color(self.raw())) };
295	}
296	/// Sets the color of the node as a Color3 object.
297	fn set_color3(&mut self, val: &crate::dora::Color3) {
298		unsafe { node_set_color3(self.raw(), val.to_rgb() as i32) };
299	}
300	/// Gets the color of the node as a Color3 object.
301	fn get_color3(&self) -> crate::dora::Color3 {
302		return unsafe { crate::dora::Color3::from(node_get_color3(self.raw())) };
303	}
304	/// Sets whether to pass the opacity value to child nodes.
305	fn set_pass_opacity(&mut self, val: bool) {
306		unsafe { node_set_pass_opacity(self.raw(), if val { 1 } else { 0 }) };
307	}
308	/// Gets whether to pass the opacity value to child nodes.
309	fn is_pass_opacity(&self) -> bool {
310		return unsafe { node_is_pass_opacity(self.raw()) != 0 };
311	}
312	/// Sets whether to pass the color value to child nodes.
313	fn set_pass_color3(&mut self, val: bool) {
314		unsafe { node_set_pass_color3(self.raw(), if val { 1 } else { 0 }) };
315	}
316	/// Gets whether to pass the color value to child nodes.
317	fn is_pass_color3(&self) -> bool {
318		return unsafe { node_is_pass_color3(self.raw()) != 0 };
319	}
320	/// Sets the target node acts as a parent node for transforming this node.
321	fn set_transform_target(&mut self, val: &dyn crate::dora::INode) {
322		unsafe { node_set_transform_target(self.raw(), val.raw()) };
323	}
324	/// Gets the target node acts as a parent node for transforming this node.
325	fn get_transform_target(&self) -> Option<crate::dora::Node> {
326		return unsafe { crate::dora::Node::from(node_get_transform_target(self.raw())) };
327	}
328	/// Sets the scheduler used for scheduling update and action callbacks.
329	fn set_scheduler(&mut self, val: &crate::dora::Scheduler) {
330		unsafe { node_set_scheduler(self.raw(), val.raw()) };
331	}
332	/// Gets the scheduler used for scheduling update and action callbacks.
333	fn get_scheduler(&self) -> crate::dora::Scheduler {
334		return unsafe { crate::dora::Scheduler::from(node_get_scheduler(self.raw())).unwrap() };
335	}
336	/// Gets the children of the node as an Array object, could be None.
337	fn get_children(&self) -> Option<crate::dora::Array> {
338		return unsafe { crate::dora::Array::from(node_get_children(self.raw())) };
339	}
340	/// Gets the parent of the node, could be None.
341	fn get_parent(&self) -> Option<crate::dora::Node> {
342		return unsafe { crate::dora::Node::from(node_get_parent(self.raw())) };
343	}
344	/// Gets whether the node is currently running in a scene tree.
345	fn is_running(&self) -> bool {
346		return unsafe { node_is_running(self.raw()) != 0 };
347	}
348	/// Gets whether the node is currently scheduling a function for updates.
349	fn is_scheduled(&self) -> bool {
350		return unsafe { node_is_scheduled(self.raw()) != 0 };
351	}
352	/// Gets the number of actions currently running on the node.
353	fn get_action_count(&self) -> i32 {
354		return unsafe { node_get_action_count(self.raw()) };
355	}
356	/// Gets additional data stored on the node as a Dictionary object.
357	fn get_data(&self) -> crate::dora::Dictionary {
358		return unsafe { crate::dora::Dictionary::from(node_get_data(self.raw())).unwrap() };
359	}
360	/// Sets whether touch events are enabled on the node.
361	fn set_touch_enabled(&mut self, val: bool) {
362		unsafe { node_set_touch_enabled(self.raw(), if val { 1 } else { 0 }) };
363	}
364	/// Gets whether touch events are enabled on the node.
365	fn is_touch_enabled(&self) -> bool {
366		return unsafe { node_is_touch_enabled(self.raw()) != 0 };
367	}
368	/// Sets whether the node should swallow touch events.
369	fn set_swallow_touches(&mut self, val: bool) {
370		unsafe { node_set_swallow_touches(self.raw(), if val { 1 } else { 0 }) };
371	}
372	/// Gets whether the node should swallow touch events.
373	fn is_swallow_touches(&self) -> bool {
374		return unsafe { node_is_swallow_touches(self.raw()) != 0 };
375	}
376	/// Sets whether the node should swallow mouse wheel events.
377	fn set_swallow_mouse_wheel(&mut self, val: bool) {
378		unsafe { node_set_swallow_mouse_wheel(self.raw(), if val { 1 } else { 0 }) };
379	}
380	/// Gets whether the node should swallow mouse wheel events.
381	fn is_swallow_mouse_wheel(&self) -> bool {
382		return unsafe { node_is_swallow_mouse_wheel(self.raw()) != 0 };
383	}
384	/// Sets whether keyboard events are enabled on the node.
385	fn set_keyboard_enabled(&mut self, val: bool) {
386		unsafe { node_set_keyboard_enabled(self.raw(), if val { 1 } else { 0 }) };
387	}
388	/// Gets whether keyboard events are enabled on the node.
389	fn is_keyboard_enabled(&self) -> bool {
390		return unsafe { node_is_keyboard_enabled(self.raw()) != 0 };
391	}
392	/// Sets whether controller events are enabled on the node.
393	fn set_controller_enabled(&mut self, val: bool) {
394		unsafe { node_set_controller_enabled(self.raw(), if val { 1 } else { 0 }) };
395	}
396	/// Gets whether controller events are enabled on the node.
397	fn is_controller_enabled(&self) -> bool {
398		return unsafe { node_is_controller_enabled(self.raw()) != 0 };
399	}
400	/// Sets whether to group the node's rendering with all its recursive children.
401	fn set_render_group(&mut self, val: bool) {
402		unsafe { node_set_render_group(self.raw(), if val { 1 } else { 0 }) };
403	}
404	/// Gets whether to group the node's rendering with all its recursive children.
405	fn is_render_group(&self) -> bool {
406		return unsafe { node_is_render_group(self.raw()) != 0 };
407	}
408	/// Sets whether debug graphic should be displayed for the node.
409	fn set_show_debug(&mut self, val: bool) {
410		unsafe { node_set_show_debug(self.raw(), if val { 1 } else { 0 }) };
411	}
412	/// Gets whether debug graphic should be displayed for the node.
413	fn is_show_debug(&self) -> bool {
414		return unsafe { node_is_show_debug(self.raw()) != 0 };
415	}
416	/// Sets the rendering order number for group rendering. Nodes with lower rendering orders are rendered earlier.
417	fn set_render_order(&mut self, val: i32) {
418		unsafe { node_set_render_order(self.raw(), val) };
419	}
420	/// Gets the rendering order number for group rendering. Nodes with lower rendering orders are rendered earlier.
421	fn get_render_order(&self) -> i32 {
422		return unsafe { node_get_render_order(self.raw()) };
423	}
424	/// Adds a child node to the current node.
425	///
426	/// # Arguments
427	///
428	/// * `child` - The child node to add.
429	/// * `order` - The drawing order of the child node.
430	/// * `tag` - The tag of the child node.
431	fn add_child_with_order_tag(&mut self, child: &dyn crate::dora::INode, order: i32, tag: &str) {
432		unsafe { node_add_child_with_order_tag(self.raw(), child.raw(), order, crate::dora::from_string(tag)); }
433	}
434	/// Adds a child node to the current node.
435	///
436	/// # Arguments
437	///
438	/// * `child` - The child node to add.
439	/// * `order` - The drawing order of the child node.
440	fn add_child_with_order(&mut self, child: &dyn crate::dora::INode, order: i32) {
441		unsafe { node_add_child_with_order(self.raw(), child.raw(), order); }
442	}
443	/// Adds a child node to the current node.
444	///
445	/// # Arguments
446	///
447	/// * `child` - The child node to add.
448	fn add_child(&mut self, child: &dyn crate::dora::INode) {
449		unsafe { node_add_child(self.raw(), child.raw()); }
450	}
451	/// Adds the current node to a parent node.
452	///
453	/// # Arguments
454	///
455	/// * `parent` - The parent node to add the current node to.
456	/// * `order` - The drawing order of the current node.
457	/// * `tag` - The tag of the current node.
458	///
459	/// # Returns
460	///
461	/// * `Node` - The current node.
462	fn add_to_with_order_tag(&mut self, parent: &dyn crate::dora::INode, order: i32, tag: &str) -> crate::dora::Node {
463		unsafe { return crate::dora::Node::from(node_add_to_with_order_tag(self.raw(), parent.raw(), order, crate::dora::from_string(tag))).unwrap(); }
464	}
465	/// Adds the current node to a parent node.
466	///
467	/// # Arguments
468	///
469	/// * `parent` - The parent node to add the current node to.
470	/// * `order` - The drawing order of the current node.
471	///
472	/// # Returns
473	///
474	/// * `Node` - The current node.
475	fn add_to_with_order(&mut self, parent: &dyn crate::dora::INode, order: i32) -> crate::dora::Node {
476		unsafe { return crate::dora::Node::from(node_add_to_with_order(self.raw(), parent.raw(), order)).unwrap(); }
477	}
478	/// Adds the current node to a parent node.
479	///
480	/// # Arguments
481	///
482	/// * `parent` - The parent node to add the current node to.
483	///
484	/// # Returns
485	///
486	/// * `Node` - The current node.
487	fn add_to(&mut self, parent: &dyn crate::dora::INode) -> crate::dora::Node {
488		unsafe { return crate::dora::Node::from(node_add_to(self.raw(), parent.raw())).unwrap(); }
489	}
490	/// Removes a child node from the current node.
491	///
492	/// # Arguments
493	///
494	/// * `child` - The child node to remove.
495	/// * `cleanup` - Whether to cleanup the child node.
496	fn remove_child(&mut self, child: &dyn crate::dora::INode, cleanup: bool) {
497		unsafe { node_remove_child(self.raw(), child.raw(), if cleanup { 1 } else { 0 }); }
498	}
499	/// Removes a child node from the current node by tag.
500	///
501	/// # Arguments
502	///
503	/// * `tag` - The tag of the child node to remove.
504	/// * `cleanup` - Whether to cleanup the child node.
505	fn remove_child_by_tag(&mut self, tag: &str, cleanup: bool) {
506		unsafe { node_remove_child_by_tag(self.raw(), crate::dora::from_string(tag), if cleanup { 1 } else { 0 }); }
507	}
508	/// Removes all child nodes from the current node.
509	///
510	/// # Arguments
511	///
512	/// * `cleanup` - Whether to cleanup the child nodes.
513	fn remove_all_children(&mut self, cleanup: bool) {
514		unsafe { node_remove_all_children(self.raw(), if cleanup { 1 } else { 0 }); }
515	}
516	/// Removes the current node from its parent node.
517	///
518	/// # Arguments
519	///
520	/// * `cleanup` - Whether to cleanup the current node.
521	fn remove_from_parent(&mut self, cleanup: bool) {
522		unsafe { node_remove_from_parent(self.raw(), if cleanup { 1 } else { 0 }); }
523	}
524	/// Moves the current node to a new parent node without triggering node events.
525	///
526	/// # Arguments
527	///
528	/// * `parent` - The new parent node to move the current node to.
529	fn move_to_parent(&mut self, parent: &dyn crate::dora::INode) {
530		unsafe { node_move_to_parent(self.raw(), parent.raw()); }
531	}
532	/// Cleans up the current node.
533	fn cleanup(&mut self) {
534		unsafe { node_cleanup(self.raw()); }
535	}
536	/// Gets a child node by tag.
537	///
538	/// # Arguments
539	///
540	/// * `tag` - The tag of the child node to get.
541	///
542	/// # Returns
543	///
544	/// * `Option<Node>` - The child node, or `None` if not found.
545	fn get_child_by_tag(&mut self, tag: &str) -> Option<crate::dora::Node> {
546		unsafe { return crate::dora::Node::from(node_get_child_by_tag(self.raw(), crate::dora::from_string(tag))); }
547	}
548	/// Schedules a main function to run every frame. Call this function again to replace the previous scheduled main function or coroutine.
549	///
550	/// # Arguments
551	///
552	/// * `updateFunc` - The function to be called. If the function returns `true`, it will not be called again.
553	fn schedule(&mut self, mut update_func: Box<dyn FnMut(f64) -> bool>) {
554		let mut stack0 = crate::dora::CallStack::new();
555		let stack_raw0 = stack0.raw();
556		let func_id0 = crate::dora::push_function(Box::new(move || {
557			let result = update_func(stack0.pop_f64().unwrap());
558			stack0.push_bool(result);
559		}));
560		unsafe { node_schedule(self.raw(), func_id0, stack_raw0); }
561	}
562	/// Unschedules the current node's scheduled main function.
563	fn unschedule(&mut self) {
564		unsafe { node_unschedule(self.raw()); }
565	}
566	/// Converts a point from world space to node space.
567	///
568	/// # Arguments
569	///
570	/// * `world_point` - The point in world space, represented by a Vec2 object.
571	///
572	/// # Returns
573	///
574	/// * `Vec2` - The converted point in world space.
575	fn convert_to_node_space(&mut self, world_point: &crate::dora::Vec2) -> crate::dora::Vec2 {
576		unsafe { return crate::dora::Vec2::from(node_convert_to_node_space(self.raw(), world_point.into_i64())); }
577	}
578	/// Converts a point from node space to world space.
579	///
580	/// # Arguments
581	///
582	/// * `node_point` - The point in node space, represented by a Vec2 object.
583	///
584	/// # Returns
585	///
586	/// * `Vec2` - The converted point in world space.
587	fn convert_to_world_space(&mut self, node_point: &crate::dora::Vec2) -> crate::dora::Vec2 {
588		unsafe { return crate::dora::Vec2::from(node_convert_to_world_space(self.raw(), node_point.into_i64())); }
589	}
590	/// Converts a point from node space to world space.
591	///
592	/// # Arguments
593	///
594	/// * `node_point` - The point in node space, represented by a Vec2 object.
595	/// * `callback` - The function to call with the converted point in world space.
596	///
597	/// # Returns
598	///
599	/// * `Vec2` - The converted point in world space.
600	fn convert_to_window_space(&mut self, node_point: &crate::dora::Vec2, mut callback: Box<dyn FnMut(&crate::dora::Vec2)>) {
601		let mut stack0 = crate::dora::CallStack::new();
602		let stack_raw0 = stack0.raw();
603		let func_id0 = crate::dora::push_function(Box::new(move || {
604			callback(&stack0.pop_vec2().unwrap())
605		}));
606		unsafe { node_convert_to_window_space(self.raw(), node_point.into_i64(), func_id0, stack_raw0); }
607	}
608	/// Calls the given function for each child node of this node.
609	///
610	/// # Arguments
611	///
612	/// * `visitorFunc` - The function to call for each child node. The function should return a boolean value indicating whether to continue the iteration. Return true to stop iteration.
613	///
614	/// # Returns
615	///
616	/// * `bool` - `false` if all children have been visited, `true` if the iteration was interrupted by the function.
617	fn each_child(&mut self, mut visitor_func: Box<dyn FnMut(&dyn crate::dora::INode) -> bool>) -> bool {
618		let mut stack0 = crate::dora::CallStack::new();
619		let stack_raw0 = stack0.raw();
620		let func_id0 = crate::dora::push_function(Box::new(move || {
621			let result = visitor_func(&stack0.pop_cast::<crate::dora::Node>().unwrap());
622			stack0.push_bool(result);
623		}));
624		unsafe { return node_each_child(self.raw(), func_id0, stack_raw0) != 0; }
625	}
626	/// Traverses the node hierarchy starting from this node and calls the given function for each visited node. The nodes without `TraverseEnabled` flag are not visited.
627	///
628	/// # Arguments
629	///
630	/// * `visitorFunc` - The function to call for each visited node. The function should return a boolean value indicating whether to continue the traversal. Return true to stop iteration.
631	///
632	/// # Returns
633	///
634	/// * `bool` - `false` if all nodes have been visited, `true` if the traversal was interrupted by the function.
635	fn traverse(&mut self, mut visitor_func: Box<dyn FnMut(&dyn crate::dora::INode) -> bool>) -> bool {
636		let mut stack0 = crate::dora::CallStack::new();
637		let stack_raw0 = stack0.raw();
638		let func_id0 = crate::dora::push_function(Box::new(move || {
639			let result = visitor_func(&stack0.pop_cast::<crate::dora::Node>().unwrap());
640			stack0.push_bool(result);
641		}));
642		unsafe { return node_traverse(self.raw(), func_id0, stack_raw0) != 0; }
643	}
644	/// Traverses the entire node hierarchy starting from this node and calls the given function for each visited node.
645	///
646	/// # Arguments
647	///
648	/// * `visitorFunc` - The function to call for each visited node. The function should return a boolean value indicating whether to continue the traversal.
649	///
650	/// # Returns
651	///
652	/// * `bool` - `false` if all nodes have been visited, `true` if the traversal was interrupted by the function.
653	fn traverse_all(&mut self, mut visitor_func: Box<dyn FnMut(&dyn crate::dora::INode) -> bool>) -> bool {
654		let mut stack0 = crate::dora::CallStack::new();
655		let stack_raw0 = stack0.raw();
656		let func_id0 = crate::dora::push_function(Box::new(move || {
657			let result = visitor_func(&stack0.pop_cast::<crate::dora::Node>().unwrap());
658			stack0.push_bool(result);
659		}));
660		unsafe { return node_traverse_all(self.raw(), func_id0, stack_raw0) != 0; }
661	}
662	/// Runs an action defined by the given action definition on this node.
663	///
664	/// # Arguments
665	///
666	/// * `action_def` - The action definition to run.
667	/// * `looped` - Whether to loop the action.
668	///
669	/// # Returns
670	///
671	/// * `f32` - The duration of the newly running action in seconds.
672	fn run_action_def(&mut self, def: crate::dora::ActionDef, looped: bool) -> f32 {
673		unsafe { return node_run_action_def(self.raw(), def.raw(), if looped { 1 } else { 0 }); }
674	}
675	/// Runs an action on this node.
676	///
677	/// # Arguments
678	///
679	/// * `action` - The action to run.
680	/// * `looped` - Whether to loop the action.
681	///
682	/// # Returns
683	///
684	/// * `f32` - The duration of the newly running action in seconds.
685	fn run_action(&mut self, action: &crate::dora::Action, looped: bool) -> f32 {
686		unsafe { return node_run_action(self.raw(), action.raw(), if looped { 1 } else { 0 }); }
687	}
688	/// Stops all actions running on this node.
689	fn stop_all_actions(&mut self) {
690		unsafe { node_stop_all_actions(self.raw()); }
691	}
692	/// Runs an action defined by the given action definition right after clearing all the previous running actions.
693	///
694	/// # Arguments
695	///
696	/// * `action_def` - The action definition to run.
697	/// * `looped` - Whether to loop the action.
698	///
699	/// # Returns
700	///
701	/// * `f32` - The duration of the newly running action in seconds.
702	fn perform_def(&mut self, action_def: crate::dora::ActionDef, looped: bool) -> f32 {
703		unsafe { return node_perform_def(self.raw(), action_def.raw(), if looped { 1 } else { 0 }); }
704	}
705	/// Runs an action on this node right after clearing all the previous running actions.
706	///
707	/// # Arguments
708	///
709	/// * `action` - The action to run.
710	/// * `looped` - Whether to loop the action.
711	///
712	/// # Returns
713	///
714	/// * `f32` - The duration of the newly running action in seconds.
715	fn perform(&mut self, action: &crate::dora::Action, looped: bool) -> f32 {
716		unsafe { return node_perform(self.raw(), action.raw(), if looped { 1 } else { 0 }); }
717	}
718	/// Stops the given action running on this node.
719	///
720	/// # Arguments
721	///
722	/// * `action` - The action to stop.
723	fn stop_action(&mut self, action: &crate::dora::Action) {
724		unsafe { node_stop_action(self.raw(), action.raw()); }
725	}
726	/// Vertically aligns all child nodes within the node using the given size and padding.
727	///
728	/// # Arguments
729	///
730	/// * `padding` - The amount of padding to use between each child node.
731	///
732	/// # Returns
733	///
734	/// * `Size` - The size of the node after alignment.
735	fn align_items_vertically(&mut self, padding: f32) -> crate::dora::Size {
736		unsafe { return crate::dora::Size::from(node_align_items_vertically(self.raw(), padding)); }
737	}
738	/// Vertically aligns all child nodes within the node using the given size and padding.
739	///
740	/// # Arguments
741	///
742	/// * `size` - The size to use for alignment.
743	/// * `padding` - The amount of padding to use between each child node.
744	///
745	/// # Returns
746	///
747	/// * `Size` - The size of the node after alignment.
748	fn align_items_vertically_with_size(&mut self, size: &crate::dora::Size, padding: f32) -> crate::dora::Size {
749		unsafe { return crate::dora::Size::from(node_align_items_vertically_with_size(self.raw(), size.into_i64(), padding)); }
750	}
751	/// Horizontally aligns all child nodes within the node using the given size and padding.
752	///
753	/// # Arguments
754	///
755	/// * `padding` - The amount of padding to use between each child node.
756	///
757	/// # Returns
758	///
759	/// * `Size` - The size of the node after alignment.
760	fn align_items_horizontally(&mut self, padding: f32) -> crate::dora::Size {
761		unsafe { return crate::dora::Size::from(node_align_items_horizontally(self.raw(), padding)); }
762	}
763	/// Horizontally aligns all child nodes within the node using the given size and padding.
764	///
765	/// # Arguments
766	///
767	/// * `size` - The size to hint for alignment.
768	/// * `padding` - The amount of padding to use between each child node.
769	///
770	/// # Returns
771	///
772	/// * `Size` - The size of the node after alignment.
773	fn align_items_horizontally_with_size(&mut self, size: &crate::dora::Size, padding: f32) -> crate::dora::Size {
774		unsafe { return crate::dora::Size::from(node_align_items_horizontally_with_size(self.raw(), size.into_i64(), padding)); }
775	}
776	/// Aligns all child nodes within the node using the given size and padding.
777	///
778	/// # Arguments
779	///
780	/// * `padding` - The amount of padding to use between each child node.
781	///
782	/// # Returns
783	///
784	/// * `Size` - The size of the node after alignment.
785	fn align_items(&mut self, padding: f32) -> crate::dora::Size {
786		unsafe { return crate::dora::Size::from(node_align_items(self.raw(), padding)); }
787	}
788	/// Aligns all child nodes within the node using the given size and padding.
789	///
790	/// # Arguments
791	///
792	/// * `size` - The size to use for alignment.
793	/// * `padding` - The amount of padding to use between each child node.
794	///
795	/// # Returns
796	///
797	/// * `Size` - The size of the node after alignment.
798	fn align_items_with_size(&mut self, size: &crate::dora::Size, padding: f32) -> crate::dora::Size {
799		unsafe { return crate::dora::Size::from(node_align_items_with_size(self.raw(), size.into_i64(), padding)); }
800	}
801	/// Moves and changes child nodes' visibility based on their position in parent's area.
802	///
803	/// # Arguments
804	///
805	/// * `delta` - The distance to move its children, represented by a Vec2 object.
806	fn move_and_cull_items(&mut self, delta: &crate::dora::Vec2) {
807		unsafe { node_move_and_cull_items(self.raw(), delta.into_i64()); }
808	}
809	/// Attaches the input method editor (IME) to the node.
810	/// Makes node recieving "AttachIME", "DetachIME", "TextInput", "TextEditing" events.
811	fn attach_ime(&mut self) {
812		unsafe { node_attach_ime(self.raw()); }
813	}
814	/// Detaches the input method editor (IME) from the node.
815	fn detach_ime(&mut self) {
816		unsafe { node_detach_ime(self.raw()); }
817	}
818	/// Creates a texture grabber for the specified node.
819	///
820	/// # Returns
821	///
822	/// * `Grabber` - A Grabber object with gridX == 1 and gridY == 1.
823	fn grab(&mut self) -> crate::dora::Grabber {
824		unsafe { return crate::dora::Grabber::from(node_grab(self.raw())).unwrap(); }
825	}
826	/// Creates a texture grabber for the specified node with a specified grid size.
827	///
828	/// # Arguments
829	///
830	/// * `grid_x` - The number of horizontal grid cells to divide the grabber into.
831	/// * `grid_y` - The number of vertical grid cells to divide the grabber into.
832	///
833	/// # Returns
834	///
835	/// * `Grabber` - A Grabber object.
836	fn grab_with_size(&mut self, grid_x: i32, grid_y: i32) -> crate::dora::Grabber {
837		unsafe { return crate::dora::Grabber::from(node_grab_with_size(self.raw(), grid_x, grid_y)).unwrap(); }
838	}
839	/// Removes the texture grabber for the specified node.
840	fn stop_grab(&mut self) {
841		unsafe { node_stop_grab(self.raw()); }
842	}
843	/// Removes the transform target for the specified node.
844	fn set_transform_target_null(&mut self) {
845		unsafe { node_set_transform_target_null(self.raw()); }
846	}
847	/// Associates the given handler function with the node event.
848	///
849	/// # Arguments
850	///
851	/// * `event_name` - The name of the node event.
852	/// * `handler` - The handler function to associate with the node event.
853	fn slot(&mut self, event_name: &str, mut handler: Box<dyn FnMut(&mut crate::dora::CallStack)>) {
854		let mut stack0 = crate::dora::CallStack::new();
855		let stack_raw0 = stack0.raw();
856		let func_id0 = crate::dora::push_function(Box::new(move || {
857			handler(&mut stack0)
858		}));
859		unsafe { node_slot(self.raw(), crate::dora::from_string(event_name), func_id0, stack_raw0); }
860	}
861	/// Associates the given handler function with a global event.
862	///
863	/// # Arguments
864	///
865	/// * `event_name` - The name of the global event.
866	/// * `handler` - The handler function to associate with the event.
867	fn gslot(&mut self, event_name: &str, mut handler: Box<dyn FnMut(&mut crate::dora::CallStack)>) {
868		let mut stack0 = crate::dora::CallStack::new();
869		let stack_raw0 = stack0.raw();
870		let func_id0 = crate::dora::push_function(Box::new(move || {
871			handler(&mut stack0)
872		}));
873		unsafe { node_gslot(self.raw(), crate::dora::from_string(event_name), func_id0, stack_raw0); }
874	}
875	/// Emits an event to a node, triggering the event handler associated with the event name.
876	///
877	/// # Arguments
878	///
879	/// * `name` - The name of the event.
880	/// * `stack` - The argument stack to be passed to the event handler.
881	fn emit(&mut self, name: &str, stack: &crate::dora::CallStack) {
882		unsafe { node_emit(self.raw(), crate::dora::from_string(name), stack.raw()); }
883	}
884	/// Schedules a function to run every frame. Call this function again to schedule multiple functions.
885	///
886	/// # Arguments
887	///
888	/// * `updateFunc` - The function to run every frame. If the function returns `true`, it will not be called again.
889	fn on_update(&mut self, mut update_func: Box<dyn FnMut(f64) -> bool>) {
890		let mut stack0 = crate::dora::CallStack::new();
891		let stack_raw0 = stack0.raw();
892		let func_id0 = crate::dora::push_function(Box::new(move || {
893			let result = update_func(stack0.pop_f64().unwrap());
894			stack0.push_bool(result);
895		}));
896		unsafe { node_on_update(self.raw(), func_id0, stack_raw0); }
897	}
898	/// Registers a callback for event triggered when the node is entering the rendering phase. The callback is called every frame, and ensures that its call order is consistent with the rendering order of the scene tree, such as rendering child nodes after their parent nodes. Recommended for calling vector drawing functions.
899	///
900	/// # Arguments
901	///
902	/// * `func` - The function to call when the node is entering the rendering phase, returns true to stop.
903	///
904	/// # Returns
905	///
906	/// * `void` - True to stop the function from running.
907	fn on_render(&mut self, mut render_func: Box<dyn FnMut(f64) -> bool>) {
908		let mut stack0 = crate::dora::CallStack::new();
909		let stack_raw0 = stack0.raw();
910		let func_id0 = crate::dora::push_function(Box::new(move || {
911			let result = render_func(stack0.pop_f64().unwrap());
912			stack0.push_bool(result);
913		}));
914		unsafe { node_on_render(self.raw(), func_id0, stack_raw0); }
915	}
916}
917impl Node {
918	pub(crate) fn type_info() -> (i32, fn(i64) -> Option<Box<dyn IObject>>) {
919		(unsafe { node_type() }, |raw: i64| -> Option<Box<dyn IObject>> {
920			match raw {
921				0 => None,
922				_ => Some(Box::new(Node { raw: raw }))
923			}
924		})
925	}
926	/// Creates a new instance of the `Node` struct.
927	pub fn new() -> Node {
928		unsafe { return Node { raw: node_new() }; }
929	}
930}