Skip to content

Implement more functions #197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Implement more functions #197

wants to merge 19 commits into from

Conversation

SakiiCode
Copy link

@SakiiCode SakiiCode commented Apr 19, 2025

This PR reworks the LvArgs and LvFunc implementations to handle mutable/immutable primitives, structs, NativeObjects and strings. Also fixes the examples.

List of functions implemented
+ lv_animimg_set_duration
- lv_animimg_set_src
+ lv_arc_align_obj_to_angle
+ lv_arc_get_mode
+ lv_arc_rotate_obj_to_angle
+ lv_arc_set_mode
+ lv_arc_set_range
+ lv_arc_set_value
+ lv_bar_get_mode
+ lv_bar_set_mode
+ lv_bar_set_start_value
+ lv_bar_set_value
+ lv_btnmatrix_clear_btn_ctrl
+ lv_btnmatrix_clear_btn_ctrl_all
- lv_btnmatrix_get_btn_text
- lv_btnmatrix_get_map
+ lv_btnmatrix_has_btn_ctrl
+ lv_btnmatrix_set_btn_ctrl
+ lv_btnmatrix_set_btn_ctrl_all
+ lv_btnmatrix_set_ctrl_map
- lv_btnmatrix_set_map
- lv_calendar_get_btnmatrix
- lv_calendar_get_highlighted_dates
+ lv_calendar_get_pressed_date
- lv_calendar_get_showed_date
- lv_calendar_get_today_date
- lv_calendar_set_day_names
+ lv_calendar_set_highlighted_dates
+ lv_calendar_set_showed_date
+ lv_calendar_set_today_date
+ lv_canvas_blur_hor
+ lv_canvas_blur_ver
- lv_canvas_copy_buf
+ lv_canvas_draw_arc
- lv_canvas_draw_img
+ lv_canvas_draw_line
+ lv_canvas_draw_polygon
+ lv_canvas_draw_rect
+ lv_canvas_draw_text
+ lv_canvas_fill_bg
- lv_canvas_get_img
+ lv_canvas_get_px
- lv_canvas_set_buffer
+ lv_canvas_set_palette
+ lv_canvas_set_px_color
+ lv_canvas_set_px_opa
+ lv_canvas_transform
- lv_chart_add_cursor
- lv_chart_add_series
+ lv_chart_get_cursor_point
+ lv_chart_get_point_pos_by_id
- lv_chart_get_series_next
+ lv_chart_get_type
- lv_chart_get_x_array
+ lv_chart_get_x_start_point
- lv_chart_get_y_array
+ lv_chart_hide_series
+ lv_chart_remove_series
+ lv_chart_set_all_value
+ lv_chart_set_axis_tick
+ lv_chart_set_cursor_point
+ lv_chart_set_cursor_pos
+ lv_chart_set_ext_x_array
+ lv_chart_set_ext_y_array
+ lv_chart_set_next_value
+ lv_chart_set_next_value2
+ lv_chart_set_range
+ lv_chart_set_series_color
+ lv_chart_set_type
+ lv_chart_set_update_mode
+ lv_chart_set_value_by_id
+ lv_chart_set_value_by_id2
+ lv_chart_set_x_start_point
- lv_checkbox_get_text
+ lv_dropdown_add_option
+ lv_dropdown_get_dir
- lv_dropdown_get_list
- lv_dropdown_get_options
+ lv_dropdown_get_selected_str
- lv_dropdown_get_symbol
- lv_dropdown_get_text
+ lv_dropdown_set_dir
- lv_dropdown_set_symbol
- lv_imgbtn_get_src_left
- lv_imgbtn_get_src_middle
- lv_imgbtn_get_src_right
- lv_imgbtn_set_src
+ lv_imgbtn_set_state
+ lv_img_get_offset_x
+ lv_img_get_offset_y
+ lv_img_get_pivot
+ lv_img_get_size_mode
- lv_img_get_src
+ lv_img_set_angle
+ lv_img_set_offset_x
+ lv_img_set_offset_y
+ lv_img_set_pivot
+ lv_img_set_size_mode
- lv_img_set_src
+ lv_keyboard_get_mode
- lv_keyboard_get_textarea
- lv_keyboard_set_map
+ lv_keyboard_set_mode
+ lv_keyboard_set_textarea
+ lv_label_cut_text
+ lv_label_get_letter_on
+ lv_label_get_letter_pos
+ lv_label_get_long_mode
- lv_label_get_text
+ lv_label_ins_text
+ lv_label_is_char_under_pos
+ lv_label_set_long_mode
+ lv_label_set_text_sel_end
+ lv_label_set_text_sel_start
+ lv_led_set_color
+ lv_line_set_points
- lv_list_add_btn
- lv_list_add_text
- lv_list_get_btn_text
+ lv_menu_back_btn_is_root
- lv_menu_get_cur_main_page
- lv_menu_get_cur_sidebar_page
- lv_menu_get_main_header
- lv_menu_get_main_header_back_btn
- lv_menu_get_sidebar_header
- lv_menu_get_sidebar_header_back_btn
+ lv_menu_set_load_page_event
+ lv_menu_set_mode_header
+ lv_menu_set_mode_root_back_btn
+ lv_menu_set_page
+ lv_menu_set_sidebar_page
- lv_meter_add_arc
- lv_meter_add_needle_img
- lv_meter_add_needle_line
- lv_meter_add_scale
- lv_meter_add_scale_lines
+ lv_meter_set_indicator_end_value
+ lv_meter_set_indicator_start_value
+ lv_meter_set_indicator_value
+ lv_meter_set_scale_major_ticks
+ lv_meter_set_scale_range
+ lv_meter_set_scale_ticks
- lv_obj_add_event_cb
+ lv_obj_add_flag
+ lv_obj_add_state
+ lv_obj_add_style
+ lv_obj_align
+ lv_obj_align_to
+ lv_obj_area_is_visible
+ lv_obj_calculate_ext_draw_size
+ lv_obj_calculate_style_text_align
+ lv_obj_check_type
+ lv_obj_clear_flag
+ lv_obj_clear_state
+ lv_obj_del_delayed
+ lv_obj_fade_in
+ lv_obj_fade_out
- lv_obj_get_child
- lv_obj_get_class
+ lv_obj_get_click_area
+ lv_obj_get_content_coords
+ lv_obj_get_content_height
+ lv_obj_get_content_width
+ lv_obj_get_coords
- lv_obj_get_disp
- lv_obj_get_event_user_data
- lv_obj_get_group
+ lv_obj_get_height
+ lv_obj_get_local_style_prop
- lv_obj_get_parent
- lv_obj_get_screen
+ lv_obj_get_scrollbar_area
+ lv_obj_get_scrollbar_mode
+ lv_obj_get_scroll_bottom
+ lv_obj_get_scroll_dir
+ lv_obj_get_scroll_end
+ lv_obj_get_scroll_left
+ lv_obj_get_scroll_right
+ lv_obj_get_scroll_snap_x
+ lv_obj_get_scroll_snap_y
+ lv_obj_get_scroll_top
+ lv_obj_get_scroll_x
+ lv_obj_get_scroll_y
+ lv_obj_get_self_height
+ lv_obj_get_self_width
+ lv_obj_get_state
+ lv_obj_get_style_prop
+ lv_obj_get_transformed_area
+ lv_obj_get_width
+ lv_obj_get_x
+ lv_obj_get_x2
+ lv_obj_get_x_aligned
+ lv_obj_get_y
+ lv_obj_get_y2
+ lv_obj_get_y_aligned
+ lv_obj_has_class
+ lv_obj_has_flag
+ lv_obj_has_flag_any
+ lv_obj_has_state
+ lv_obj_hit_test
+ lv_obj_init_draw_arc_dsc
+ lv_obj_init_draw_img_dsc
+ lv_obj_init_draw_label_dsc
+ lv_obj_init_draw_line_dsc
+ lv_obj_init_draw_rect_dsc
+ lv_obj_invalidate_area
+ lv_obj_move_children_by
+ lv_obj_move_to
+ lv_obj_readjust_scroll
+ lv_obj_refresh_style
+ lv_obj_remove_event_cb
- lv_obj_remove_event_cb_with_user_data
+ lv_obj_remove_event_dsc
+ lv_obj_remove_local_style_prop
+ lv_obj_remove_style
+ lv_obj_scroll_by
+ lv_obj_scroll_by_bounded
+ lv_obj_scroll_to
+ lv_obj_scroll_to_view
+ lv_obj_scroll_to_view_recursive
+ lv_obj_scroll_to_x
+ lv_obj_scroll_to_y
+ lv_obj_set_align
+ lv_obj_set_content_height
+ lv_obj_set_content_width
+ lv_obj_set_ext_click_area
+ lv_obj_set_flex_align
+ lv_obj_set_flex_flow
+ lv_obj_set_grid_align
+ lv_obj_set_grid_cell
+ lv_obj_set_grid_dsc_array
+ lv_obj_set_height
+ lv_obj_set_layout
+ lv_obj_set_local_style_prop
+ lv_obj_set_local_style_prop_meta
+ lv_obj_set_parent
+ lv_obj_set_pos
+ lv_obj_set_scrollbar_mode
+ lv_obj_set_scroll_dir
+ lv_obj_set_scroll_snap_x
+ lv_obj_set_scroll_snap_y
+ lv_obj_set_size
+ lv_obj_set_style_align
+ lv_obj_set_style_anim
+ lv_obj_set_style_anim_speed
+ lv_obj_set_style_anim_time
+ lv_obj_set_style_arc_color
- lv_obj_set_style_arc_img_src
+ lv_obj_set_style_arc_opa
+ lv_obj_set_style_arc_rounded
+ lv_obj_set_style_arc_width
+ lv_obj_set_style_base_dir
+ lv_obj_set_style_bg_color
+ lv_obj_set_style_bg_dither_mode
+ lv_obj_set_style_bg_grad
+ lv_obj_set_style_bg_grad_color
+ lv_obj_set_style_bg_grad_dir
+ lv_obj_set_style_bg_grad_stop
+ lv_obj_set_style_bg_img_opa
+ lv_obj_set_style_bg_img_recolor
+ lv_obj_set_style_bg_img_recolor_opa
- lv_obj_set_style_bg_img_src
+ lv_obj_set_style_bg_img_tiled
+ lv_obj_set_style_bg_main_stop
+ lv_obj_set_style_bg_opa
+ lv_obj_set_style_blend_mode
+ lv_obj_set_style_border_color
+ lv_obj_set_style_border_opa
+ lv_obj_set_style_border_post
+ lv_obj_set_style_border_side
+ lv_obj_set_style_border_width
+ lv_obj_set_style_clip_corner
+ lv_obj_set_style_color_filter_dsc
+ lv_obj_set_style_color_filter_opa
+ lv_obj_set_style_flex_cross_place
+ lv_obj_set_style_flex_flow
+ lv_obj_set_style_flex_grow
+ lv_obj_set_style_flex_main_place
+ lv_obj_set_style_flex_track_place
+ lv_obj_set_style_grid_cell_column_pos
+ lv_obj_set_style_grid_cell_column_span
+ lv_obj_set_style_grid_cell_row_pos
+ lv_obj_set_style_grid_cell_row_span
+ lv_obj_set_style_grid_cell_x_align
+ lv_obj_set_style_grid_cell_y_align
+ lv_obj_set_style_grid_column_align
+ lv_obj_set_style_grid_column_dsc_array
+ lv_obj_set_style_grid_row_align
+ lv_obj_set_style_grid_row_dsc_array
+ lv_obj_set_style_height
+ lv_obj_set_style_img_opa
+ lv_obj_set_style_img_recolor
+ lv_obj_set_style_img_recolor_opa
+ lv_obj_set_style_layout
+ lv_obj_set_style_line_color
+ lv_obj_set_style_line_dash_gap
+ lv_obj_set_style_line_dash_width
+ lv_obj_set_style_line_opa
+ lv_obj_set_style_line_rounded
+ lv_obj_set_style_line_width
+ lv_obj_set_style_max_height
+ lv_obj_set_style_max_width
+ lv_obj_set_style_min_height
+ lv_obj_set_style_min_width
+ lv_obj_set_style_opa
+ lv_obj_set_style_outline_color
+ lv_obj_set_style_outline_opa
+ lv_obj_set_style_outline_pad
+ lv_obj_set_style_outline_width
+ lv_obj_set_style_pad_bottom
+ lv_obj_set_style_pad_column
+ lv_obj_set_style_pad_left
+ lv_obj_set_style_pad_right
+ lv_obj_set_style_pad_row
+ lv_obj_set_style_pad_top
+ lv_obj_set_style_radius
+ lv_obj_set_style_shadow_color
+ lv_obj_set_style_shadow_ofs_x
+ lv_obj_set_style_shadow_ofs_y
+ lv_obj_set_style_shadow_opa
+ lv_obj_set_style_shadow_spread
+ lv_obj_set_style_shadow_width
+ lv_obj_set_style_text_align
+ lv_obj_set_style_text_color
+ lv_obj_set_style_text_decor
+ lv_obj_set_style_text_font
+ lv_obj_set_style_text_letter_space
+ lv_obj_set_style_text_line_space
+ lv_obj_set_style_text_opa
+ lv_obj_set_style_transform_angle
+ lv_obj_set_style_transform_height
+ lv_obj_set_style_transform_pivot_x
+ lv_obj_set_style_transform_pivot_y
+ lv_obj_set_style_transform_width
+ lv_obj_set_style_transform_zoom
+ lv_obj_set_style_transition
+ lv_obj_set_style_translate_x
+ lv_obj_set_style_translate_y
+ lv_obj_set_style_width
+ lv_obj_set_style_x
+ lv_obj_set_style_y
+ lv_obj_set_tile
+ lv_obj_set_tile_id
+ lv_obj_set_width
+ lv_obj_set_x
+ lv_obj_set_y
+ lv_obj_swap
+ lv_obj_transform_point
- lv_obj_tree_walk
+ lv_obj_update_snap
- lv_roller_get_options
+ lv_roller_get_selected_str
+ lv_roller_set_options
+ lv_roller_set_selected
+ lv_spangroup_del_span
+ lv_spangroup_get_align
- lv_spangroup_get_child
+ lv_spangroup_get_expand_height
+ lv_spangroup_get_expand_width
+ lv_spangroup_get_indent
+ lv_spangroup_get_max_line_h
+ lv_spangroup_get_mode
+ lv_spangroup_get_overflow
- lv_spangroup_new_span
+ lv_spangroup_set_align
+ lv_spangroup_set_indent
+ lv_spangroup_set_mode
+ lv_spangroup_set_overflow
+ lv_spinbox_set_digit_step_direction
+ lv_spinbox_set_step
+ lv_table_add_cell_ctrl
+ lv_table_clear_cell_ctrl
- lv_table_get_cell_value
+ lv_table_get_col_width
+ lv_table_get_selected_cell
+ lv_table_has_cell_ctrl
+ lv_table_set_col_width
+ lv_textarea_add_char
- lv_textarea_get_accepted_chars
- lv_textarea_get_label
- lv_textarea_get_password_bullet
- lv_textarea_get_placeholder_text
- lv_textarea_get_text
+ lv_textarea_set_align
+ lv_textarea_set_max_length
- lv_tileview_add_tile
- lv_tileview_get_tile_act

This breaks the API as what previously took a Rust enum, now takes an i32.

-        bar.set_value(i, AnimationState::ON);
+        bar.set_value(i, AnimationState::ON.into());
-        button.set_align(Align::LeftMid, 30, 0);
+        button.align(Align::LeftMid.into(), 30, 0);
-        screen.add_style(Part::Main, &mut screen_style);
+        screen.add_style(screen_style.into_raw(), Part::Main.into());

Arrays, void pointers and returned pointers still do not work (those functions are skipped)

This was referenced Apr 25, 2025
@SakiiCode
Copy link
Author

@C47D @AlixANNERAUD Are you still active? Do you have time to review?

@AlixANNERAUD
Copy link
Collaborator

AlixANNERAUD commented May 12, 2025

Great work on the extended type support and the example fixes 👌

Why were the Rust enums replaced with i32? It breaks the API and removes the type safety and clarity that enums offer on the Rust side. Was there a technical limitation that required this?

Also, It seems that functions returning *const pointers were removed from binding. Is there a specific reason for skipping those?

@SakiiCode
Copy link
Author

SakiiCode commented May 12, 2025

Why were the Rust enums replaced with i32? It breaks the API and removes the type safety and clarity that enums offer on the Rust side. Was there a technical limitation that required this?

I could not find and easy way to infer that lv_align_t becomes Align. Maybe a HashMap could be used to manually map types?

Also, It seems that functions returning *const pointers were removed from binding. Is there a specific reason for skipping those?

Can you give an example for these functions? Every pointer return is skipped because they need an unsafe block. They should be turned into a reference, but I did not know what lifetime to use

@AlixANNERAUD
Copy link
Collaborator

I could not find an easy way to infer that lv_align_t becomes Align. Maybe a HashMap could be used to manually map types?

You might want to consider using #[repr(i32)] along with explicitly setting the value for each enum variant from lv_align_t C enum. That allows safe casting from a Rust enum to an i32, which helps preserve both type safety and FFI compatibility.

Can you give an example for these functions? Every pointer return is skipped because they need an unsafe block. They should be turned into a reference, but I did not know what lifetime to use.

From the list of functions you provided (marked in red and prefixed with a -, like in a git diff).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants