Skip to main content

graphics_bindgen/
additional.rs

1use proc_macro2::TokenStream;
2use quote::quote;
3
4pub fn get() -> TokenStream {
5    quote! {
6        extern "C" {
7            pub fn keyboard_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
8            pub fn keyboard_set_textarea(keyboard: *mut lv_obj_t, textarea: *mut lv_obj_t);
9            pub fn object_set_padding(object: *mut lv_obj_t, padding: i32);
10            /// Encodes a bounded fractional Grid track weight for a guest descriptor array.
11            pub fn grid_fr(weight: u8) -> i32;
12            /// Validated local styling without exposing native style or color pointers.
13            pub fn object_set_background(object: *mut lv_obj_t, rgb: u32, opacity: u8, selector: u32);
14            pub fn object_set_text_color(object: *mut lv_obj_t, rgb: u32, selector: u32);
15            pub fn object_set_border(object: *mut lv_obj_t, rgb: u32, width: i32, side: u32, selector: u32);
16            pub fn object_set_radius(object: *mut lv_obj_t, radius: i32, selector: u32);
17            pub fn object_set_text_align(object: *mut lv_obj_t, align: u32, selector: u32);
18            /// Font and semantic surface IDs are host-defined, not native pointers.
19            pub fn object_set_font(object: *mut lv_obj_t, font: u32, selector: u32);
20            pub fn object_set_surface(object: *mut lv_obj_t, surface: u32);
21            pub fn object_set_min_max_size(object: *mut lv_obj_t, min_width: i32, max_width: i32, min_height: i32, max_height: i32, selector: u32);
22            /// Shared bounded operations for LVGL range controls.
23            pub fn bar_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
24            pub fn switch_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
25            pub fn spinner_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
26            pub fn range_set_range(object: *mut lv_obj_t, min: i32, max: i32);
27            pub fn range_set_value(object: *mut lv_obj_t, value: i32, animated: bool);
28            pub fn range_get_value(object: *const lv_obj_t) -> i32;
29            pub fn range_get_start_value(object: *const lv_obj_t) -> i32;
30            pub fn range_set_mode(object: *mut lv_obj_t, mode: u32);
31            pub fn range_set_orientation(object: *mut lv_obj_t, orientation: u32);
32            pub fn spinner_set_animation(object: *mut lv_obj_t, duration_ms: u32, sweep_degrees: u32);
33            pub fn spinner_get_animation_duration(object: *const lv_obj_t) -> u32;
34            pub fn spinner_get_arc_sweep(object: *const lv_obj_t) -> u32;
35            /// Copies a selected option into a checked guest output span.
36            pub fn dropdown_get_selected_string(object: *mut lv_obj_t, output: *mut i8, capacity: u32) -> i32;
37            pub fn roller_get_selected_string(object: *mut lv_obj_t, output: *mut i8, capacity: u32) -> i32;
38            /// Boolean results are widened to guest u32 values.
39            pub fn dropdown_get_highlight(object: *mut lv_obj_t) -> u32;
40            pub fn dropdown_is_open_state(object: *mut lv_obj_t) -> u32;
41            /// Validated Calendar operations; date arrays and output records use packed guest ABI bytes.
42            pub fn calendar_set_today(calendar: *mut lv_obj_t, year: u32, month: u32, day: u32);
43            pub fn calendar_set_highlights(calendar: *mut lv_obj_t, dates: *const u8, count: usize);
44            pub fn calendar_get_shown_date(calendar: *mut lv_obj_t, output: *mut u8);
45            /// Chart series stay host-selected by slot; these helpers never expose LVGL series pointers.
46            pub fn chart_add_series_slot(chart: *mut lv_obj_t, rgb: u32) -> u32;
47            pub fn chart_set_values(chart: *mut lv_obj_t, series_slot: u32, values: *const i32, count: usize);
48            pub fn chart_get_value(chart: *mut lv_obj_t, series_slot: u32, index: u32) -> i32;
49            /// List helpers use checked object handles and copied UTF-8 strings.
50            pub fn list_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
51            pub fn list_add_text(list: *mut lv_obj_t, text: *const core::ffi::c_char) -> *mut lv_obj_t;
52            pub fn list_add_text_button(list: *mut lv_obj_t, text: *const core::ffi::c_char) -> *mut lv_obj_t;
53            pub fn list_set_button_text(list: *mut lv_obj_t, button: *mut lv_obj_t, text: *const core::ffi::c_char);
54            /// Semantic shadcn styling delegates to the shared LVGL theme.
55            pub fn object_set_theme_variant(object: *mut lv_obj_t, variant: u32);
56            pub fn object_set_theme_error(object: *mut lv_obj_t, error: bool);
57            pub fn badge_create(parent: *mut lv_obj_t, text: *const core::ffi::c_char, variant: u32) -> *mut lv_obj_t;
58            pub fn card_create(parent: *mut lv_obj_t) -> *mut lv_obj_t;
59            /// Host-owned indexed canvas. Dimensions and uploads are bounded by the host.
60            pub fn indexed_canvas_create(parent: *mut lv_obj_t, width: u16, height: u16) -> *mut lv_obj_t;
61
62            /// Copies all pixels and RGB888 palette entries; no guest pointers are retained.
63            pub fn indexed_canvas_set_pixels(canvas: *mut lv_obj_t, pixels: *const u8, length: usize, palette: *const u32, colors: usize);
64
65            /// Like window_pop_event, with event-time pointer coordinates and content size.
66            /// Non-pointer events write i32::MIN to x/y and zero to width/height.
67            pub fn window_pop_pointer_event(window: *mut lv_obj_t, code: *mut u32, target: *mut WasmPointer, x: *mut i32, y: *mut i32, width: *mut i32, height: *mut i32);
68            pub fn object_delete(__translator : &mut Translator, object: u16);
69
70            /// Create a system LVGL picker. Modes: 0=open, 1=save, 2=directory.
71            /// Initial path is copied; filesystem access uses the calling guest task.
72            /// Retain the handle and call file_picker_reset for subsequent sessions;
73            /// delete with its parent to avoid exhausting monotonic guest handles.
74            pub fn file_picker_create(parent: *mut lv_obj_t, mode: u32, initial: *const core::ffi::c_char) -> *mut lv_obj_t;
75            /// Reuse a retained picker without allocating another guest handle.
76            /// Clears its prior result, changes mode/path, and reactivates the UI.
77            pub fn file_picker_reset(picker: *mut lv_obj_t, mode: u32, initial: *const core::ffi::c_char);
78            /// 0=pending, 1=selected, 2=cancelled. Result persists until reset/deletion.
79            pub fn file_picker_get_status(picker: *mut lv_obj_t) -> u32;
80            /// Copy selected absolute VFS path including NUL. Returns byte count
81            /// excluding NUL, or -1 without a selection. Short buffers are errors.
82            pub fn file_picker_get_path(picker: *mut lv_obj_t, buffer: *mut i8, size: usize) -> i32;
83
84            pub fn window_create() -> *mut lv_obj_t;
85
86            pub fn window_pop_event(
87                __translator: &mut Translator,
88                window: *mut lv_obj_t,
89                code: *mut u32,
90                target: *mut WasmPointer
91            );
92
93            pub fn window_get_event_code(window: *mut lv_obj_t) -> u32;
94
95            pub fn window_get_event_target(__translator: &mut Translator, window: *mut lv_obj_t) -> u16;
96
97            pub fn window_next_event(window: *mut lv_obj_t);
98
99            pub fn window_set_icon(
100                window: *mut lv_obj_t,
101                icon_string: *const core::ffi::c_char,
102                icon_color: lv_color_t
103            );
104
105            pub fn percentage(value: i32) -> i32;
106
107            pub fn textarea_get_text(textarea: *mut lv_obj_t, buffer: *mut i8, buffer_size: usize) -> i32;
108
109            pub fn textarea_get_text_length(textarea: *mut lv_obj_t) -> i32;
110        }
111    }
112}