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