mirror of https://github.com/arendst/Tasmota.git
LVGL update from 8.0.2 to 8.1.0
This commit is contained in:
parent
b5f913ed18
commit
dca794dbf1
|
@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
|
|||
### Added
|
||||
- Command ``SSerialConfig <serialconfig>`` to change Serial Bridge configuration
|
||||
|
||||
### Changed
|
||||
- LVGL update from 8.0.2 to 8.1.0
|
||||
|
||||
## [10.1.0.2] 20211225
|
||||
### Changed
|
||||
- TasmotaSerial library from v3.3.0 to v3.4.0 - reverted (#14153)
|
||||
|
|
|
@ -489,6 +489,7 @@ extern const bcstring be_const_str_lv_obj;
|
|||
extern const bcstring be_const_str_lv_obj_class;
|
||||
extern const bcstring be_const_str_lv_signal_arcs;
|
||||
extern const bcstring be_const_str_lv_signal_bars;
|
||||
extern const bcstring be_const_str_lv_solidified;
|
||||
extern const bcstring be_const_str_lv_wifi_arcs;
|
||||
extern const bcstring be_const_str_lv_wifi_arcs_icon;
|
||||
extern const bcstring be_const_str_lv_wifi_bars;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,7 +19,7 @@ const be_ntv_func_def_t lv_style_func[] = {
|
|||
{ "set_arc_color_filtered", (void*) &lv_style_set_arc_color_filtered, "", "(lv.lv_style)(lv.lv_color)" },
|
||||
{ "set_arc_img_src", (void*) &lv_style_set_arc_img_src, "", "(lv.lv_style)." },
|
||||
{ "set_arc_opa", (void*) &lv_style_set_arc_opa, "", "(lv.lv_style)i" },
|
||||
{ "set_arc_rounded", (void*) &lv_style_set_arc_rounded, "", "(lv.lv_style)i" },
|
||||
{ "set_arc_rounded", (void*) &lv_style_set_arc_rounded, "", "(lv.lv_style)b" },
|
||||
{ "set_arc_width", (void*) &lv_style_set_arc_width, "", "(lv.lv_style)i" },
|
||||
{ "set_base_dir", (void*) &lv_style_set_base_dir, "", "(lv.lv_style)i" },
|
||||
{ "set_bg_color", (void*) &lv_style_set_bg_color, "", "(lv.lv_style)(lv.lv_color)" },
|
||||
|
@ -57,7 +57,7 @@ const be_ntv_func_def_t lv_style_func[] = {
|
|||
{ "set_line_dash_gap", (void*) &lv_style_set_line_dash_gap, "", "(lv.lv_style)i" },
|
||||
{ "set_line_dash_width", (void*) &lv_style_set_line_dash_width, "", "(lv.lv_style)i" },
|
||||
{ "set_line_opa", (void*) &lv_style_set_line_opa, "", "(lv.lv_style)i" },
|
||||
{ "set_line_rounded", (void*) &lv_style_set_line_rounded, "", "(lv.lv_style)i" },
|
||||
{ "set_line_rounded", (void*) &lv_style_set_line_rounded, "", "(lv.lv_style)b" },
|
||||
{ "set_line_width", (void*) &lv_style_set_line_width, "", "(lv.lv_style)i" },
|
||||
{ "set_max_height", (void*) &lv_style_set_max_height, "", "(lv.lv_style)i" },
|
||||
{ "set_max_width", (void*) &lv_style_set_max_width, "", "(lv.lv_style)i" },
|
||||
|
@ -130,6 +130,7 @@ const be_ntv_func_def_t lv_img_func[] = {
|
|||
{ "set_offset_x", (void*) &lv_img_set_offset_x, "", "(lv.lv_obj)i" },
|
||||
{ "set_offset_y", (void*) &lv_img_set_offset_y, "", "(lv.lv_obj)i" },
|
||||
{ "set_pivot", (void*) &lv_img_set_pivot, "", "(lv.lv_obj)ii" },
|
||||
{ "set_size_mode", (void*) &lv_img_set_size_mode, "", "(lv.lv_obj)(lv.lv_img_size_mode)" },
|
||||
{ "set_src", (void*) &lv_img_set_src, "", "(lv.lv_obj)." },
|
||||
{ "set_tasmota_logo", (void*) &lv_img_set_tasmota_logo, "", "(lv.lv_obj)" },
|
||||
{ "set_zoom", (void*) &lv_img_set_zoom, "", "(lv.lv_obj)i" },
|
||||
|
@ -165,6 +166,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "allocate_spec_attr", (void*) &lv_obj_allocate_spec_attr, "", "(lv.lv_obj)" },
|
||||
{ "area_is_visible", (void*) &lv_obj_area_is_visible, "b", "(lv.lv_obj)(lv.lv_area)" },
|
||||
{ "calculate_ext_draw_size", (void*) &lv_obj_calculate_ext_draw_size, "i", "(lv.lv_obj)i" },
|
||||
{ "calculate_style_text_align", (void*) &lv_obj_calculate_style_text_align, "i", "(lv.lv_obj)is" },
|
||||
{ "center", (void*) &lv_obj_center, "", "(lv.lv_obj)" },
|
||||
{ "check_type", (void*) &lv_obj_check_type, "b", "(lv.lv_obj)(lv.lv_obj_class)" },
|
||||
{ "class_init_obj", (void*) &lv_obj_class_init_obj, "", "(lv.lv_obj)" },
|
||||
|
@ -173,12 +175,12 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "clear_state", (void*) &lv_obj_clear_state, "", "(lv.lv_obj)i" },
|
||||
{ "del", (void*) &lv_obj_del, "", "(lv.lv_obj)" },
|
||||
{ "del_async", (void*) &lv_obj_del_async, "", "(lv.lv_obj)" },
|
||||
{ "del_delayed", (void*) &lv_obj_del_delayed, "", "(lv.lv_obj)i" },
|
||||
{ "dpx", (void*) &lv_obj_dpx, "i", "(lv.lv_obj)i" },
|
||||
{ "fade_in", (void*) &lv_obj_fade_in, "", "(lv.lv_obj)ii" },
|
||||
{ "fade_out", (void*) &lv_obj_fade_out, "", "(lv.lv_obj)ii" },
|
||||
{ "get_child", (void*) &lv_obj_get_child, "lv.lv_obj", "(lv.lv_obj)i" },
|
||||
{ "get_child_cnt", (void*) &lv_obj_get_child_cnt, "i", "(lv.lv_obj)" },
|
||||
{ "get_child_id", (void*) &lv_obj_get_child_id, "i", "(lv.lv_obj)" },
|
||||
{ "get_class", (void*) &lv_obj_get_class, "lv.lv_obj_class", "(lv.lv_obj)" },
|
||||
{ "get_click_area", (void*) &lv_obj_get_click_area, "", "(lv.lv_obj)(lv.lv_area)" },
|
||||
{ "get_content_coords", (void*) &lv_obj_get_content_coords, "", "(lv.lv_obj)(lv.lv_area)" },
|
||||
|
@ -188,6 +190,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "get_disp", (void*) &lv_obj_get_disp, "lv.lv_disp", "(lv.lv_obj)" },
|
||||
{ "get_group", (void*) &lv_obj_get_group, ".", "(lv.lv_obj)" },
|
||||
{ "get_height", (void*) &lv_obj_get_height, "i", "(lv.lv_obj)" },
|
||||
{ "get_index", (void*) &lv_obj_get_index, "i", "(lv.lv_obj)" },
|
||||
{ "get_local_style_prop", (void*) &lv_obj_get_local_style_prop, "i", "(lv.lv_obj)(lv.lv_style_prop)(lv.lv_style_value)i" },
|
||||
{ "get_parent", (void*) &lv_obj_get_parent, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
{ "get_screen", (void*) &lv_obj_get_screen, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
|
@ -213,7 +216,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "get_style_arc_color_filtered", (void*) &lv_obj_get_style_arc_color_filtered, "lv.lv_color", "(lv.lv_obj)i" },
|
||||
{ "get_style_arc_img_src", (void*) &lv_obj_get_style_arc_img_src, ".", "(lv.lv_obj)i" },
|
||||
{ "get_style_arc_opa", (void*) &lv_obj_get_style_arc_opa, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_arc_rounded", (void*) &lv_obj_get_style_arc_rounded, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_arc_rounded", (void*) &lv_obj_get_style_arc_rounded, "b", "(lv.lv_obj)i" },
|
||||
{ "get_style_arc_width", (void*) &lv_obj_get_style_arc_width, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_base_dir", (void*) &lv_obj_get_style_base_dir, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_bg_color", (void*) &lv_obj_get_style_bg_color, "lv.lv_color", "(lv.lv_obj)i" },
|
||||
|
@ -250,7 +253,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "get_style_line_dash_gap", (void*) &lv_obj_get_style_line_dash_gap, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_line_dash_width", (void*) &lv_obj_get_style_line_dash_width, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_line_opa", (void*) &lv_obj_get_style_line_opa, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_line_rounded", (void*) &lv_obj_get_style_line_rounded, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_line_rounded", (void*) &lv_obj_get_style_line_rounded, "b", "(lv.lv_obj)i" },
|
||||
{ "get_style_line_width", (void*) &lv_obj_get_style_line_width, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_max_height", (void*) &lv_obj_get_style_max_height, "i", "(lv.lv_obj)i" },
|
||||
{ "get_style_max_width", (void*) &lv_obj_get_style_max_width, "i", "(lv.lv_obj)i" },
|
||||
|
@ -298,8 +301,10 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "get_width", (void*) &lv_obj_get_width, "i", "(lv.lv_obj)" },
|
||||
{ "get_x", (void*) &lv_obj_get_x, "i", "(lv.lv_obj)" },
|
||||
{ "get_x2", (void*) &lv_obj_get_x2, "i", "(lv.lv_obj)" },
|
||||
{ "get_x_aligned", (void*) &lv_obj_get_x_aligned, "i", "(lv.lv_obj)" },
|
||||
{ "get_y", (void*) &lv_obj_get_y, "i", "(lv.lv_obj)" },
|
||||
{ "get_y2", (void*) &lv_obj_get_y2, "i", "(lv.lv_obj)" },
|
||||
{ "get_y_aligned", (void*) &lv_obj_get_y_aligned, "i", "(lv.lv_obj)" },
|
||||
{ "has_class", (void*) &lv_obj_has_class, "b", "(lv.lv_obj)(lv.lv_obj_class)" },
|
||||
{ "has_flag", (void*) &lv_obj_has_flag, "b", "(lv.lv_obj)i" },
|
||||
{ "has_flag_any", (void*) &lv_obj_has_flag_any, "b", "(lv.lv_obj)i" },
|
||||
|
@ -319,10 +324,9 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "is_valid", (void*) &lv_obj_is_valid, "b", "(lv.lv_obj)" },
|
||||
{ "is_visible", (void*) &lv_obj_is_visible, "b", "(lv.lv_obj)" },
|
||||
{ "mark_layout_as_dirty", (void*) &lv_obj_mark_layout_as_dirty, "", "(lv.lv_obj)" },
|
||||
{ "move_background", (void*) &lv_obj_move_background, "", "(lv.lv_obj)" },
|
||||
{ "move_children_by", (void*) &lv_obj_move_children_by, "", "(lv.lv_obj)iib" },
|
||||
{ "move_foreground", (void*) &lv_obj_move_foreground, "", "(lv.lv_obj)" },
|
||||
{ "move_to", (void*) &lv_obj_move_to, "", "(lv.lv_obj)ii" },
|
||||
{ "move_to_index", (void*) &lv_obj_move_to_index, "", "(lv.lv_obj)i" },
|
||||
{ "readjust_scroll", (void*) &lv_obj_readjust_scroll, "", "(lv.lv_obj)(lv.lv_anim_enable)" },
|
||||
{ "refr_pos", (void*) &lv_obj_refr_pos, "", "(lv.lv_obj)" },
|
||||
{ "refr_size", (void*) &lv_obj_refr_size, "b", "(lv.lv_obj)" },
|
||||
|
@ -330,6 +334,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "refresh_self_size", (void*) &lv_obj_refresh_self_size, "b", "(lv.lv_obj)" },
|
||||
{ "refresh_style", (void*) &lv_obj_refresh_style, "", "(lv.lv_obj)i(lv.lv_style_prop)" },
|
||||
{ "remove_event_cb", (void*) &lv_obj_remove_event_cb, "b", "(lv.lv_obj)^lv_event_cb^" },
|
||||
{ "remove_event_cb_with_user_data", (void*) &lv_obj_remove_event_cb_with_user_data, "b", "(lv.lv_obj)^lv_event_cb^." },
|
||||
{ "remove_event_dsc", (void*) &lv_obj_remove_event_dsc, "b", "(lv.lv_obj)i" },
|
||||
{ "remove_local_style_prop", (void*) &lv_obj_remove_local_style_prop, "b", "(lv.lv_obj)(lv.lv_style_prop)i" },
|
||||
{ "remove_style", (void*) &lv_obj_remove_style, "", "(lv.lv_obj)(lv.lv_style)i" },
|
||||
|
@ -362,7 +367,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "set_style_arc_color_filtered", (void*) &lv_obj_set_style_arc_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" },
|
||||
{ "set_style_arc_img_src", (void*) &lv_obj_set_style_arc_img_src, "", "(lv.lv_obj).i" },
|
||||
{ "set_style_arc_opa", (void*) &lv_obj_set_style_arc_opa, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_arc_rounded", (void*) &lv_obj_set_style_arc_rounded, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_arc_rounded", (void*) &lv_obj_set_style_arc_rounded, "", "(lv.lv_obj)bi" },
|
||||
{ "set_style_arc_width", (void*) &lv_obj_set_style_arc_width, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_base_dir", (void*) &lv_obj_set_style_base_dir, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_bg_color", (void*) &lv_obj_set_style_bg_color, "", "(lv.lv_obj)(lv.lv_color)i" },
|
||||
|
@ -400,7 +405,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "set_style_line_dash_gap", (void*) &lv_obj_set_style_line_dash_gap, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_line_dash_width", (void*) &lv_obj_set_style_line_dash_width, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_line_opa", (void*) &lv_obj_set_style_line_opa, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_line_rounded", (void*) &lv_obj_set_style_line_rounded, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_line_rounded", (void*) &lv_obj_set_style_line_rounded, "", "(lv.lv_obj)bi" },
|
||||
{ "set_style_line_width", (void*) &lv_obj_set_style_line_width, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_max_height", (void*) &lv_obj_set_style_max_height, "", "(lv.lv_obj)ii" },
|
||||
{ "set_style_max_width", (void*) &lv_obj_set_style_max_width, "", "(lv.lv_obj)ii" },
|
||||
|
@ -453,6 +458,7 @@ const be_ntv_func_def_t lv_obj_func[] = {
|
|||
{ "set_width", (void*) &lv_obj_set_width, "", "(lv.lv_obj)i" },
|
||||
{ "set_x", (void*) &lv_obj_set_x, "", "(lv.lv_obj)i" },
|
||||
{ "set_y", (void*) &lv_obj_set_y, "", "(lv.lv_obj)i" },
|
||||
{ "swap", (void*) &lv_obj_swap, "", "(lv.lv_obj)(lv.lv_obj)" },
|
||||
{ "tree_walk", (void*) &lv_obj_tree_walk, "", "(lv.lv_obj)^lv_obj_tree_walk_cb^." },
|
||||
{ "update_layout", (void*) &lv_obj_update_layout, "", "(lv.lv_obj)" },
|
||||
{ "update_snap", (void*) &lv_obj_update_snap, "", "(lv.lv_obj)(lv.lv_anim_enable)" },
|
||||
|
@ -479,6 +485,7 @@ const be_ntv_func_def_t lv_group_func[] = {
|
|||
{ "set_focus_cb", (void*) &lv_group_set_focus_cb, "", "(lv.lv_group)^lv_group_focus_cb^" },
|
||||
{ "set_refocus_policy", (void*) &lv_group_set_refocus_policy, "", "(lv.lv_group)(lv.lv_group_refocus_policy)" },
|
||||
{ "set_wrap", (void*) &lv_group_set_wrap, "", "(lv.lv_group)b" },
|
||||
{ "swap_obj", (void*) &lv_group_swap_obj, "", "(lv.lv_obj)(lv.lv_obj)" },
|
||||
};
|
||||
|
||||
/* `lv_indev` methods */
|
||||
|
@ -557,6 +564,7 @@ const be_ntv_func_def_t lv_colorwheel_func[] = {
|
|||
#ifdef BE_LV_WIDGET_IMGBTN
|
||||
const be_ntv_func_def_t lv_imgbtn_func[] = {
|
||||
{ "set_src", (void*) &lv_imgbtn_set_src, "", "(lv.lv_obj)(lv.lv_imgbtn_state)..." },
|
||||
{ "set_state", (void*) &lv_imgbtn_set_state, "", "(lv.lv_obj)(lv.lv_imgbtn_state)" },
|
||||
};
|
||||
#endif // BE_LV_WIDGET_IMGBTN
|
||||
|
||||
|
@ -593,9 +601,12 @@ const be_ntv_func_def_t lv_meter_func[] = {
|
|||
#ifdef BE_LV_WIDGET_MSGBOX
|
||||
const be_ntv_func_def_t lv_msgbox_func[] = {
|
||||
{ "close", (void*) &lv_msgbox_close, "", "(lv.lv_obj)" },
|
||||
{ "close_async", (void*) &lv_msgbox_close_async, "", "(lv.lv_obj)" },
|
||||
{ "get_active_btn", (void*) &lv_msgbox_get_active_btn, "i", "(lv.lv_obj)" },
|
||||
{ "get_active_btn_text", (void*) &lv_msgbox_get_active_btn_text, "s", "(lv.lv_obj)" },
|
||||
{ "get_btns", (void*) &lv_msgbox_get_btns, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
{ "get_close_btn", (void*) &lv_msgbox_get_close_btn, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
{ "get_content", (void*) &lv_msgbox_get_content, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
{ "get_text", (void*) &lv_msgbox_get_text, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
{ "get_title", (void*) &lv_msgbox_get_title, "lv.lv_obj", "(lv.lv_obj)" },
|
||||
};
|
||||
|
@ -610,6 +621,8 @@ const be_ntv_func_def_t lv_spinbox_func[] = {
|
|||
{ "get_value", (void*) &lv_spinbox_get_value, "i", "(lv.lv_obj)" },
|
||||
{ "increment", (void*) &lv_spinbox_increment, "", "(lv.lv_obj)" },
|
||||
{ "set_digit_format", (void*) &lv_spinbox_set_digit_format, "", "(lv.lv_obj)ii" },
|
||||
{ "set_digit_step_direction", (void*) &lv_spinbox_set_digit_step_direction, "", "(lv.lv_obj)i" },
|
||||
{ "set_pos", (void*) &lv_spinbox_set_pos, "", "(lv.lv_obj)i" },
|
||||
{ "set_range", (void*) &lv_spinbox_set_range, "", "(lv.lv_obj)ii" },
|
||||
{ "set_rollover", (void*) &lv_spinbox_set_rollover, "", "(lv.lv_obj)b" },
|
||||
{ "set_step", (void*) &lv_spinbox_set_step, "", "(lv.lv_obj)i" },
|
||||
|
@ -707,6 +720,8 @@ const be_ntv_func_def_t lv_canvas_func[] = {
|
|||
{ "set_buffer", (void*) &lv_canvas_set_buffer, "", "(lv.lv_obj).iii" },
|
||||
{ "set_palette", (void*) &lv_canvas_set_palette, "", "(lv.lv_obj)i(lv.lv_color)" },
|
||||
{ "set_px", (void*) &lv_canvas_set_px, "", "(lv.lv_obj)ii(lv.lv_color)" },
|
||||
{ "set_px_color", (void*) &lv_canvas_set_px_color, "", "(lv.lv_obj)ii(lv.lv_color)" },
|
||||
{ "set_px_opa", (void*) &lv_canvas_set_px_opa, "", "(lv.lv_obj)iii" },
|
||||
{ "transform", (void*) &lv_canvas_transform, "", "(lv.lv_obj)(lv.lv_img_dsc)iiiiiib" },
|
||||
};
|
||||
#endif // BE_LV_WIDGET_CANVAS
|
||||
|
|
|
@ -41,7 +41,9 @@ const be_ntv_func_def_t lv_func[] = {
|
|||
{ "draw_mask_add", (void*) &lv_draw_mask_add, "i", ".." },
|
||||
{ "draw_mask_angle_init", (void*) &lv_draw_mask_angle_init, "", "(lv.lv_draw_mask_angle_param)iiii" },
|
||||
{ "draw_mask_fade_init", (void*) &lv_draw_mask_fade_init, "", "(lv.lv_draw_mask_fade_param)(lv.lv_area)iiii" },
|
||||
{ "draw_mask_free_param", (void*) &lv_draw_mask_free_param, "", "." },
|
||||
{ "draw_mask_get_cnt", (void*) &lv_draw_mask_get_cnt, "i", "" },
|
||||
{ "draw_mask_is_any", (void*) &lv_draw_mask_is_any, "b", "(lv.lv_area)" },
|
||||
{ "draw_mask_line_angle_init", (void*) &lv_draw_mask_line_angle_init, "", "(lv.lv_draw_mask_line_param)iiii" },
|
||||
{ "draw_mask_line_points_init", (void*) &lv_draw_mask_line_points_init, "", "(lv.lv_draw_mask_line_param)iiiii" },
|
||||
{ "draw_mask_map_init", (void*) &lv_draw_mask_map_init, "", "(lv.lv_draw_mask_map_param)(lv.lv_area)(lv.lv_opa)" },
|
||||
|
@ -63,12 +65,14 @@ const be_ntv_func_def_t lv_func[] = {
|
|||
{ "indev_get_act", (void*) &lv_indev_get_act, "lv.lv_indev", "" },
|
||||
{ "indev_get_obj_act", (void*) &lv_indev_get_obj_act, "lv.lv_obj", "" },
|
||||
{ "indev_read_timer_cb", (void*) &lv_indev_read_timer_cb, "", "(lv.lv_timer)" },
|
||||
{ "is_initialized", (void*) &lv_is_initialized, "b", "" },
|
||||
{ "layer_sys", (void*) &lv_layer_sys, "lv.lv_obj", "" },
|
||||
{ "layer_top", (void*) &lv_layer_top, "lv.lv_obj", "" },
|
||||
{ "layout_register", (void*) &lv_layout_register, "i", "^lv_layout_update_cb^." },
|
||||
{ "obj_class_create_obj", (void*) &lv_obj_class_create_obj, "lv.lv_obj", "(lv._lv_obj_class)(lv.lv_obj)" },
|
||||
{ "obj_del_anim_ready_cb", (void*) &lv_obj_del_anim_ready_cb, "", "(lv.lv_anim)" },
|
||||
{ "obj_draw_dsc_init", (void*) &lv_obj_draw_dsc_init, "", "(lv.lv_obj_draw_part_dsc)(lv.lv_area)" },
|
||||
{ "obj_draw_part_check_type", (void*) &lv_obj_draw_part_check_type, "b", "(lv.lv_obj_draw_part_dsc)(lv._lv_obj_class)i" },
|
||||
{ "obj_enable_style_refresh", (void*) &lv_obj_enable_style_refresh, "", "b" },
|
||||
{ "obj_event_base", (void*) &lv_obj_event_base, "i", "(lv.lv_obj_class)(lv.lv_event)" },
|
||||
{ "obj_report_style_change", (void*) &lv_obj_report_style_change, "", "(lv.lv_style)" },
|
||||
|
@ -79,6 +83,7 @@ const be_ntv_func_def_t lv_func[] = {
|
|||
{ "scr_load", (void*) &lv_scr_load, "", "(lv.lv_obj)" },
|
||||
{ "scr_load_anim", (void*) &lv_scr_load_anim, "", "(lv.lv_obj)iiib" },
|
||||
{ "theme_apply", (void*) &lv_theme_apply, "", "(lv.lv_obj)" },
|
||||
{ "theme_default_get", (void*) &lv_theme_default_get, "lv.lv_theme", "" },
|
||||
{ "theme_default_init", (void*) &lv_theme_default_init, "lv.lv_theme", "(lv.lv_disp)(lv.lv_color)(lv.lv_color)b(lv.lv_font)" },
|
||||
{ "theme_default_is_inited", (void*) &lv_theme_default_is_inited, "b", "" },
|
||||
{ "theme_get_color_primary", (void*) &lv_theme_get_color_primary, "lv.lv_color", "(lv.lv_obj)" },
|
||||
|
@ -126,9 +131,13 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "ANIM_IMG_PART_MAIN", LV_ANIM_IMG_PART_MAIN },
|
||||
{ "ANIM_OFF", LV_ANIM_OFF },
|
||||
{ "ANIM_ON", LV_ANIM_ON },
|
||||
{ "ARC_DRAW_PART_BACKGROUND", LV_ARC_DRAW_PART_BACKGROUND },
|
||||
{ "ARC_DRAW_PART_FOREGROUND", LV_ARC_DRAW_PART_FOREGROUND },
|
||||
{ "ARC_DRAW_PART_KNOB", LV_ARC_DRAW_PART_KNOB },
|
||||
{ "ARC_MODE_NORMAL", LV_ARC_MODE_NORMAL },
|
||||
{ "ARC_MODE_REVERSE", LV_ARC_MODE_REVERSE },
|
||||
{ "ARC_MODE_SYMMETRICAL", LV_ARC_MODE_SYMMETRICAL },
|
||||
{ "BAR_DRAW_PART_INDICATOR", LV_BAR_DRAW_PART_INDICATOR },
|
||||
{ "BAR_MODE_NORMAL", LV_BAR_MODE_NORMAL },
|
||||
{ "BAR_MODE_RANGE", LV_BAR_MODE_RANGE },
|
||||
{ "BAR_MODE_SYMMETRICAL", LV_BAR_MODE_SYMMETRICAL },
|
||||
|
@ -138,6 +147,7 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "BASE_DIR_RTL", LV_BASE_DIR_RTL },
|
||||
{ "BASE_DIR_WEAK", LV_BASE_DIR_WEAK },
|
||||
{ "BLEND_MODE_ADDITIVE", LV_BLEND_MODE_ADDITIVE },
|
||||
{ "BLEND_MODE_MULTIPLY", LV_BLEND_MODE_MULTIPLY },
|
||||
{ "BLEND_MODE_NORMAL", LV_BLEND_MODE_NORMAL },
|
||||
{ "BLEND_MODE_SUBTRACTIVE", LV_BLEND_MODE_SUBTRACTIVE },
|
||||
{ "BORDER_SIDE_BOTTOM", LV_BORDER_SIDE_BOTTOM },
|
||||
|
@ -155,17 +165,27 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "BTNMATRIX_CTRL_DISABLED", LV_BTNMATRIX_CTRL_DISABLED },
|
||||
{ "BTNMATRIX_CTRL_HIDDEN", LV_BTNMATRIX_CTRL_HIDDEN },
|
||||
{ "BTNMATRIX_CTRL_NO_REPEAT", LV_BTNMATRIX_CTRL_NO_REPEAT },
|
||||
{ "BTNMATRIX_CTRL_POPOVER", LV_BTNMATRIX_CTRL_POPOVER },
|
||||
{ "BTNMATRIX_CTRL_RECOLOR", LV_BTNMATRIX_CTRL_RECOLOR },
|
||||
{ "BTNMATRIX_DRAW_PART_BTN", LV_BTNMATRIX_DRAW_PART_BTN },
|
||||
{ "CHART_AXIS_PRIMARY_X", LV_CHART_AXIS_PRIMARY_X },
|
||||
{ "CHART_AXIS_PRIMARY_Y", LV_CHART_AXIS_PRIMARY_Y },
|
||||
{ "CHART_AXIS_SECONDARY_X", LV_CHART_AXIS_SECONDARY_X },
|
||||
{ "CHART_AXIS_SECONDARY_Y", LV_CHART_AXIS_SECONDARY_Y },
|
||||
{ "CHART_DRAW_PART_BAR", LV_CHART_DRAW_PART_BAR },
|
||||
{ "CHART_DRAW_PART_CURSOR", LV_CHART_DRAW_PART_CURSOR },
|
||||
{ "CHART_DRAW_PART_DIV_LINE_HOR", LV_CHART_DRAW_PART_DIV_LINE_HOR },
|
||||
{ "CHART_DRAW_PART_DIV_LINE_INIT", LV_CHART_DRAW_PART_DIV_LINE_INIT },
|
||||
{ "CHART_DRAW_PART_DIV_LINE_VER", LV_CHART_DRAW_PART_DIV_LINE_VER },
|
||||
{ "CHART_DRAW_PART_LINE_AND_POINT", LV_CHART_DRAW_PART_LINE_AND_POINT },
|
||||
{ "CHART_DRAW_PART_TICK_LABEL", LV_CHART_DRAW_PART_TICK_LABEL },
|
||||
{ "CHART_TYPE_BAR", LV_CHART_TYPE_BAR },
|
||||
{ "CHART_TYPE_LINE", LV_CHART_TYPE_LINE },
|
||||
{ "CHART_TYPE_NONE", LV_CHART_TYPE_NONE },
|
||||
{ "CHART_TYPE_SCATTER", LV_CHART_TYPE_SCATTER },
|
||||
{ "CHART_UPDATE_MODE_CIRCULAR", LV_CHART_UPDATE_MODE_CIRCULAR },
|
||||
{ "CHART_UPDATE_MODE_SHIFT", LV_CHART_UPDATE_MODE_SHIFT },
|
||||
{ "CHECKBOX_DRAW_PART_BOX", LV_CHECKBOX_DRAW_PART_BOX },
|
||||
{ "COLORWHEEL_MODE_HUE", LV_COLORWHEEL_MODE_HUE },
|
||||
{ "COLORWHEEL_MODE_SATURATION", LV_COLORWHEEL_MODE_SATURATION },
|
||||
{ "COLORWHEEL_MODE_VALUE", LV_COLORWHEEL_MODE_VALUE },
|
||||
|
@ -217,6 +237,8 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "EVENT_ALL", LV_EVENT_ALL },
|
||||
{ "EVENT_CANCEL", LV_EVENT_CANCEL },
|
||||
{ "EVENT_CHILD_CHANGED", LV_EVENT_CHILD_CHANGED },
|
||||
{ "EVENT_CHILD_CREATED", LV_EVENT_CHILD_CREATED },
|
||||
{ "EVENT_CHILD_DELETED", LV_EVENT_CHILD_DELETED },
|
||||
{ "EVENT_CLICKED", LV_EVENT_CLICKED },
|
||||
{ "EVENT_COVER_CHECK", LV_EVENT_COVER_CHECK },
|
||||
{ "EVENT_DEFOCUSED", LV_EVENT_DEFOCUSED },
|
||||
|
@ -246,6 +268,10 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "EVENT_REFRESH", LV_EVENT_REFRESH },
|
||||
{ "EVENT_REFR_EXT_DRAW_SIZE", LV_EVENT_REFR_EXT_DRAW_SIZE },
|
||||
{ "EVENT_RELEASED", LV_EVENT_RELEASED },
|
||||
{ "EVENT_SCREEN_LOADED", LV_EVENT_SCREEN_LOADED },
|
||||
{ "EVENT_SCREEN_LOAD_START", LV_EVENT_SCREEN_LOAD_START },
|
||||
{ "EVENT_SCREEN_UNLOADED", LV_EVENT_SCREEN_UNLOADED },
|
||||
{ "EVENT_SCREEN_UNLOAD_START", LV_EVENT_SCREEN_UNLOAD_START },
|
||||
{ "EVENT_SCROLL", LV_EVENT_SCROLL },
|
||||
{ "EVENT_SCROLL_BEGIN", LV_EVENT_SCROLL_BEGIN },
|
||||
{ "EVENT_SCROLL_END", LV_EVENT_SCROLL_END },
|
||||
|
@ -253,20 +279,6 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "EVENT_SIZE_CHANGED", LV_EVENT_SIZE_CHANGED },
|
||||
{ "EVENT_STYLE_CHANGED", LV_EVENT_STYLE_CHANGED },
|
||||
{ "EVENT_VALUE_CHANGED", LV_EVENT_VALUE_CHANGED },
|
||||
{ "FLEX_ALIGN_CENTER", LV_FLEX_ALIGN_CENTER },
|
||||
{ "FLEX_ALIGN_END", LV_FLEX_ALIGN_END },
|
||||
{ "FLEX_ALIGN_SPACE_AROUND", LV_FLEX_ALIGN_SPACE_AROUND },
|
||||
{ "FLEX_ALIGN_SPACE_BETWEEN", LV_FLEX_ALIGN_SPACE_BETWEEN },
|
||||
{ "FLEX_ALIGN_SPACE_EVENLY", LV_FLEX_ALIGN_SPACE_EVENLY },
|
||||
{ "FLEX_ALIGN_START", LV_FLEX_ALIGN_START },
|
||||
{ "FLEX_FLOW_COLUMN", LV_FLEX_FLOW_COLUMN },
|
||||
{ "FLEX_FLOW_COLUMN_REVERSE", LV_FLEX_FLOW_COLUMN_REVERSE },
|
||||
{ "FLEX_FLOW_COLUMN_WRAP", LV_FLEX_FLOW_COLUMN_WRAP },
|
||||
{ "FLEX_FLOW_COLUMN_WRAP_REVERSE", LV_FLEX_FLOW_COLUMN_WRAP_REVERSE },
|
||||
{ "FLEX_FLOW_ROW", LV_FLEX_FLOW_ROW },
|
||||
{ "FLEX_FLOW_ROW_REVERSE", LV_FLEX_FLOW_ROW_REVERSE },
|
||||
{ "FLEX_FLOW_ROW_WRAP", LV_FLEX_FLOW_ROW_WRAP },
|
||||
{ "FLEX_FLOW_ROW_WRAP_REVERSE", LV_FLEX_FLOW_ROW_WRAP_REVERSE },
|
||||
{ "FS_MODE_RD", LV_FS_MODE_RD },
|
||||
{ "FS_MODE_WR", LV_FS_MODE_WR },
|
||||
{ "FS_RES_BUSY", LV_FS_RES_BUSY },
|
||||
|
@ -288,13 +300,6 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "GRAD_DIR_HOR", LV_GRAD_DIR_HOR },
|
||||
{ "GRAD_DIR_NONE", LV_GRAD_DIR_NONE },
|
||||
{ "GRAD_DIR_VER", LV_GRAD_DIR_VER },
|
||||
{ "GRID_ALIGN_CENTER", LV_GRID_ALIGN_CENTER },
|
||||
{ "GRID_ALIGN_END", LV_GRID_ALIGN_END },
|
||||
{ "GRID_ALIGN_SPACE_AROUND", LV_GRID_ALIGN_SPACE_AROUND },
|
||||
{ "GRID_ALIGN_SPACE_BETWEEN", LV_GRID_ALIGN_SPACE_BETWEEN },
|
||||
{ "GRID_ALIGN_SPACE_EVENLY", LV_GRID_ALIGN_SPACE_EVENLY },
|
||||
{ "GRID_ALIGN_START", LV_GRID_ALIGN_START },
|
||||
{ "GRID_ALIGN_STRETCH", LV_GRID_ALIGN_STRETCH },
|
||||
{ "GROUP_REFOCUS_POLICY_NEXT", LV_GROUP_REFOCUS_POLICY_NEXT },
|
||||
{ "GROUP_REFOCUS_POLICY_PREV", LV_GROUP_REFOCUS_POLICY_PREV },
|
||||
{ "IMGBTN_STATE_CHECKED_DISABLED", LV_IMGBTN_STATE_CHECKED_DISABLED },
|
||||
|
@ -318,6 +323,8 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "IMG_CF_TRUE_COLOR_ALPHA", LV_IMG_CF_TRUE_COLOR_ALPHA },
|
||||
{ "IMG_CF_TRUE_COLOR_CHROMA_KEYED", LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED },
|
||||
{ "IMG_CF_UNKNOWN", LV_IMG_CF_UNKNOWN },
|
||||
{ "IMG_SIZE_MODE_REAL", LV_IMG_SIZE_MODE_REAL },
|
||||
{ "IMG_SIZE_MODE_VIRTUAL", LV_IMG_SIZE_MODE_VIRTUAL },
|
||||
{ "IMG_SRC_FILE", LV_IMG_SRC_FILE },
|
||||
{ "IMG_SRC_SYMBOL", LV_IMG_SRC_SYMBOL },
|
||||
{ "IMG_SRC_UNKNOWN", LV_IMG_SRC_UNKNOWN },
|
||||
|
@ -346,6 +353,11 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "LABEL_LONG_SCROLL", LV_LABEL_LONG_SCROLL },
|
||||
{ "LABEL_LONG_SCROLL_CIRCULAR", LV_LABEL_LONG_SCROLL_CIRCULAR },
|
||||
{ "LABEL_LONG_WRAP", LV_LABEL_LONG_WRAP },
|
||||
{ "LED_DRAW_PART_RECTANGLE", LV_LED_DRAW_PART_RECTANGLE },
|
||||
{ "METER_DRAW_PART_ARC", LV_METER_DRAW_PART_ARC },
|
||||
{ "METER_DRAW_PART_NEEDLE_IMG", LV_METER_DRAW_PART_NEEDLE_IMG },
|
||||
{ "METER_DRAW_PART_NEEDLE_LINE", LV_METER_DRAW_PART_NEEDLE_LINE },
|
||||
{ "METER_DRAW_PART_TICK", LV_METER_DRAW_PART_TICK },
|
||||
{ "METER_INDICATOR_TYPE_ARC", LV_METER_INDICATOR_TYPE_ARC },
|
||||
{ "METER_INDICATOR_TYPE_NEEDLE_IMG", LV_METER_INDICATOR_TYPE_NEEDLE_IMG },
|
||||
{ "METER_INDICATOR_TYPE_NEEDLE_LINE", LV_METER_INDICATOR_TYPE_NEEDLE_LINE },
|
||||
|
@ -356,6 +368,9 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "OBJ_CLASS_GROUP_DEF_FALSE", LV_OBJ_CLASS_GROUP_DEF_FALSE },
|
||||
{ "OBJ_CLASS_GROUP_DEF_INHERIT", LV_OBJ_CLASS_GROUP_DEF_INHERIT },
|
||||
{ "OBJ_CLASS_GROUP_DEF_TRUE", LV_OBJ_CLASS_GROUP_DEF_TRUE },
|
||||
{ "OBJ_DRAW_PART_BORDER_POST", LV_OBJ_DRAW_PART_BORDER_POST },
|
||||
{ "OBJ_DRAW_PART_RECTANGLE", LV_OBJ_DRAW_PART_RECTANGLE },
|
||||
{ "OBJ_DRAW_PART_SCROLLBAR", LV_OBJ_DRAW_PART_SCROLLBAR },
|
||||
{ "OBJ_FLAG_ADV_HITTEST", LV_OBJ_FLAG_ADV_HITTEST },
|
||||
{ "OBJ_FLAG_CHECKABLE", LV_OBJ_FLAG_CHECKABLE },
|
||||
{ "OBJ_FLAG_CLICKABLE", LV_OBJ_FLAG_CLICKABLE },
|
||||
|
@ -374,7 +389,7 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "OBJ_FLAG_SCROLL_MOMENTUM", LV_OBJ_FLAG_SCROLL_MOMENTUM },
|
||||
{ "OBJ_FLAG_SCROLL_ONE", LV_OBJ_FLAG_SCROLL_ONE },
|
||||
{ "OBJ_FLAG_SCROLL_ON_FOCUS", LV_OBJ_FLAG_SCROLL_ON_FOCUS },
|
||||
{ "OBJ_FLAG_SNAPABLE", LV_OBJ_FLAG_SNAPABLE },
|
||||
{ "OBJ_FLAG_SNAPPABLE", LV_OBJ_FLAG_SNAPPABLE },
|
||||
{ "OBJ_FLAG_USER_1", LV_OBJ_FLAG_USER_1 },
|
||||
{ "OBJ_FLAG_USER_2", LV_OBJ_FLAG_USER_2 },
|
||||
{ "OBJ_FLAG_USER_3", LV_OBJ_FLAG_USER_3 },
|
||||
|
@ -452,6 +467,8 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "SCR_LOAD_ANIM_OVER_RIGHT", LV_SCR_LOAD_ANIM_OVER_RIGHT },
|
||||
{ "SCR_LOAD_ANIM_OVER_TOP", LV_SCR_LOAD_ANIM_OVER_TOP },
|
||||
{ "SIZE_CONTENT", LV_SIZE_CONTENT },
|
||||
{ "SLIDER_DRAW_PART_KNOB", LV_SLIDER_DRAW_PART_KNOB },
|
||||
{ "SLIDER_DRAW_PART_KNOB_LEFT", LV_SLIDER_DRAW_PART_KNOB_LEFT },
|
||||
{ "SLIDER_MODE_NORMAL", LV_SLIDER_MODE_NORMAL },
|
||||
{ "SLIDER_MODE_RANGE", LV_SLIDER_MODE_RANGE },
|
||||
{ "SLIDER_MODE_SYMMETRICAL", LV_SLIDER_MODE_SYMMETRICAL },
|
||||
|
@ -630,6 +647,7 @@ const be_const_member_t lv0_constants[] = {
|
|||
{ "TABLE_CELL_CTRL_CUSTOM_4", LV_TABLE_CELL_CTRL_CUSTOM_4 },
|
||||
{ "TABLE_CELL_CTRL_MERGE_RIGHT", LV_TABLE_CELL_CTRL_MERGE_RIGHT },
|
||||
{ "TABLE_CELL_CTRL_TEXT_CROP", LV_TABLE_CELL_CTRL_TEXT_CROP },
|
||||
{ "TABLE_DRAW_PART_CELL", LV_TABLE_DRAW_PART_CELL },
|
||||
{ "TEXTAREA_CURSOR_LAST", LV_TEXTAREA_CURSOR_LAST },
|
||||
{ "TEXT_ALIGN_AUTO", LV_TEXT_ALIGN_AUTO },
|
||||
{ "TEXT_ALIGN_CENTER", LV_TEXT_ALIGN_CENTER },
|
||||
|
@ -664,19 +682,21 @@ be_local_closure(lv_lv_module_init, /* name */
|
|||
0, /* has sup protos */
|
||||
NULL, /* no sub protos */
|
||||
1, /* has constants */
|
||||
( &(const bvalue[ 2]) { /* constants */
|
||||
( &(const bvalue[ 3]) { /* constants */
|
||||
/* K0 */ be_nested_str(lv),
|
||||
/* K1 */ be_nested_str(member),
|
||||
/* K2 */ be_nested_str(lv_solidified),
|
||||
}),
|
||||
&be_const_str_lv_module_init,
|
||||
&be_const_str_solidified,
|
||||
( &(const binstruction[ 6]) { /* code */
|
||||
( &(const binstruction[ 7]) { /* code */
|
||||
0x6004000B, // 0000 GETGBL R1 G11
|
||||
0x58080000, // 0001 LDCONST R2 K0
|
||||
0x7C040200, // 0002 CALL R1 1
|
||||
0x88080101, // 0003 GETMBR R2 R0 K1
|
||||
0x90060202, // 0004 SETMBR R1 K1 R2
|
||||
0x80040200, // 0005 RET 1 R1
|
||||
0x90060400, // 0005 SETMBR R1 K2 R0
|
||||
0x80040200, // 0006 RET 1 R1
|
||||
})
|
||||
)
|
||||
);
|
||||
|
@ -696,3 +716,5 @@ be_local_module(lv,
|
|||
);
|
||||
BE_EXPORT_VARIABLE be_define_const_native_module(lv);
|
||||
/********************************************************************/
|
||||
|
||||
/********************************************************************/
|
||||
|
|
|
@ -135,6 +135,7 @@ extern int lvbe_img_set_angle(bvm *vm);
|
|||
extern int lvbe_img_set_pivot(bvm *vm);
|
||||
extern int lvbe_img_set_zoom(bvm *vm);
|
||||
extern int lvbe_img_set_antialias(bvm *vm);
|
||||
extern int lvbe_img_set_size_mode(bvm *vm);
|
||||
extern int lvbe_img_get_src(bvm *vm);
|
||||
extern int lvbe_img_get_offset_x(bvm *vm);
|
||||
extern int lvbe_img_get_offset_y(bvm *vm);
|
||||
|
@ -162,6 +163,7 @@ extern int lvbe_disp_dpx(bvm *vm);
|
|||
/* `lv_obj` external functions definitions */
|
||||
extern int lvbe_obj_add_event_cb(bvm *vm);
|
||||
extern int lvbe_obj_remove_event_cb(bvm *vm);
|
||||
extern int lvbe_obj_remove_event_cb_with_user_data(bvm *vm);
|
||||
extern int lvbe_obj_remove_event_dsc(bvm *vm);
|
||||
extern int lvbe_obj_create(bvm *vm);
|
||||
extern int lvbe_obj_add_flag(bvm *vm);
|
||||
|
@ -272,6 +274,9 @@ extern int lvbe_obj_set_style_pad_hor(bvm *vm);
|
|||
extern int lvbe_obj_set_style_pad_ver(bvm *vm);
|
||||
extern int lvbe_obj_set_style_pad_gap(bvm *vm);
|
||||
extern int lvbe_obj_set_style_size(bvm *vm);
|
||||
extern int lvbe_obj_calculate_style_text_align(bvm *vm);
|
||||
extern int lvbe_obj_get_x_aligned(bvm *vm);
|
||||
extern int lvbe_obj_get_y_aligned(bvm *vm);
|
||||
extern int lvbe_obj_get_style_width(bvm *vm);
|
||||
extern int lvbe_obj_get_style_min_width(bvm *vm);
|
||||
extern int lvbe_obj_get_style_max_width(bvm *vm);
|
||||
|
@ -450,16 +455,17 @@ extern int lvbe_obj_set_style_arc_opa(bvm *vm);
|
|||
extern int lvbe_obj_set_style_arc_img_src(bvm *vm);
|
||||
extern int lvbe_obj_del(bvm *vm);
|
||||
extern int lvbe_obj_clean(bvm *vm);
|
||||
extern int lvbe_obj_del_delayed(bvm *vm);
|
||||
extern int lvbe_obj_del_async(bvm *vm);
|
||||
extern int lvbe_obj_set_parent(bvm *vm);
|
||||
extern int lvbe_obj_move_foreground(bvm *vm);
|
||||
extern int lvbe_obj_move_background(bvm *vm);
|
||||
extern int lvbe_obj_swap(bvm *vm);
|
||||
extern int lvbe_obj_move_to_index(bvm *vm);
|
||||
extern int lvbe_obj_get_screen(bvm *vm);
|
||||
extern int lvbe_obj_get_disp(bvm *vm);
|
||||
extern int lvbe_obj_get_parent(bvm *vm);
|
||||
extern int lvbe_obj_get_child(bvm *vm);
|
||||
extern int lvbe_obj_get_child_cnt(bvm *vm);
|
||||
extern int lvbe_obj_get_child_id(bvm *vm);
|
||||
extern int lvbe_obj_get_index(bvm *vm);
|
||||
extern int lvbe_obj_tree_walk(bvm *vm);
|
||||
|
||||
/* `lv_group` external functions definitions */
|
||||
|
@ -467,6 +473,7 @@ extern int lvbe_group_create(bvm *vm);
|
|||
extern int lvbe_group_del(bvm *vm);
|
||||
extern int lvbe_group_set_default(bvm *vm);
|
||||
extern int lvbe_group_add_obj(bvm *vm);
|
||||
extern int lvbe_group_swap_obj(bvm *vm);
|
||||
extern int lvbe_group_remove_obj(bvm *vm);
|
||||
extern int lvbe_group_remove_all_objs(bvm *vm);
|
||||
extern int lvbe_group_focus_obj(bvm *vm);
|
||||
|
@ -551,6 +558,7 @@ extern int lvbe_colorwheel_get_color_mode_fixed(bvm *vm);
|
|||
/* `lv_imgbtn` external functions definitions */
|
||||
extern int lvbe_imgbtn_create(bvm *vm);
|
||||
extern int lvbe_imgbtn_set_src(bvm *vm);
|
||||
extern int lvbe_imgbtn_set_state(bvm *vm);
|
||||
|
||||
/* `lv_led` external functions definitions */
|
||||
extern int lvbe_led_create(bvm *vm);
|
||||
|
@ -580,9 +588,12 @@ extern int lvbe_msgbox_create(bvm *vm);
|
|||
extern int lvbe_msgbox_get_title(bvm *vm);
|
||||
extern int lvbe_msgbox_get_close_btn(bvm *vm);
|
||||
extern int lvbe_msgbox_get_text(bvm *vm);
|
||||
extern int lvbe_msgbox_get_content(bvm *vm);
|
||||
extern int lvbe_msgbox_get_btns(bvm *vm);
|
||||
extern int lvbe_msgbox_get_active_btn(bvm *vm);
|
||||
extern int lvbe_msgbox_get_active_btn_text(bvm *vm);
|
||||
extern int lvbe_msgbox_close(bvm *vm);
|
||||
extern int lvbe_msgbox_close_async(bvm *vm);
|
||||
|
||||
/* `lv_spinbox` external functions definitions */
|
||||
extern int lvbe_spinbox_create(bvm *vm);
|
||||
|
@ -591,6 +602,8 @@ extern int lvbe_spinbox_set_rollover(bvm *vm);
|
|||
extern int lvbe_spinbox_set_digit_format(bvm *vm);
|
||||
extern int lvbe_spinbox_set_step(bvm *vm);
|
||||
extern int lvbe_spinbox_set_range(bvm *vm);
|
||||
extern int lvbe_spinbox_set_pos(bvm *vm);
|
||||
extern int lvbe_spinbox_set_digit_step_direction(bvm *vm);
|
||||
extern int lvbe_spinbox_get_rollover(bvm *vm);
|
||||
extern int lvbe_spinbox_get_value(bvm *vm);
|
||||
extern int lvbe_spinbox_get_step(bvm *vm);
|
||||
|
@ -658,7 +671,9 @@ extern int lvbe_btnmatrix_get_one_checked(bvm *vm);
|
|||
/* `lv_canvas` external functions definitions */
|
||||
extern int lvbe_canvas_create(bvm *vm);
|
||||
extern int lvbe_canvas_set_buffer(bvm *vm);
|
||||
extern int lvbe_canvas_set_px_color(bvm *vm);
|
||||
extern int lvbe_canvas_set_px(bvm *vm);
|
||||
extern int lvbe_canvas_set_px_opa(bvm *vm);
|
||||
extern int lvbe_canvas_set_palette(bvm *vm);
|
||||
extern int lvbe_canvas_get_px(bvm *vm);
|
||||
extern int lvbe_canvas_copy_buf(bvm *vm);
|
||||
|
|
|
@ -104,6 +104,7 @@ SYMBOL_BULLET="\xE2\x80\xA2"
|
|||
// Generated from headers
|
||||
// ======================================================================
|
||||
|
||||
// File: ../../lvgl/src/core/lv_disp.h
|
||||
LV_SCR_LOAD_ANIM_NONE
|
||||
LV_SCR_LOAD_ANIM_OVER_LEFT
|
||||
LV_SCR_LOAD_ANIM_OVER_RIGHT
|
||||
|
@ -115,6 +116,7 @@ LV_SCR_LOAD_ANIM_MOVE_TOP
|
|||
LV_SCR_LOAD_ANIM_MOVE_BOTTOM
|
||||
LV_SCR_LOAD_ANIM_FADE_ON
|
||||
|
||||
// File: ../../lvgl/src/core/lv_event.h
|
||||
LV_EVENT_ALL
|
||||
LV_EVENT_PRESSED
|
||||
LV_EVENT_PRESSING
|
||||
|
@ -150,10 +152,17 @@ LV_EVENT_READY
|
|||
LV_EVENT_CANCEL
|
||||
LV_EVENT_DELETE
|
||||
LV_EVENT_CHILD_CHANGED
|
||||
LV_EVENT_CHILD_CREATED
|
||||
LV_EVENT_CHILD_DELETED
|
||||
LV_EVENT_SCREEN_UNLOAD_START
|
||||
LV_EVENT_SCREEN_LOAD_START
|
||||
LV_EVENT_SCREEN_LOADED
|
||||
LV_EVENT_SCREEN_UNLOADED
|
||||
LV_EVENT_SIZE_CHANGED
|
||||
LV_EVENT_STYLE_CHANGED
|
||||
LV_EVENT_LAYOUT_CHANGED
|
||||
LV_EVENT_GET_SELF_SIZE
|
||||
// File: ../../lvgl/src/core/lv_group.h
|
||||
LV_KEY_UP
|
||||
LV_KEY_DOWN
|
||||
LV_KEY_RIGHT
|
||||
|
@ -169,6 +178,9 @@ LV_KEY_END
|
|||
|
||||
LV_GROUP_REFOCUS_POLICY_NEXT
|
||||
LV_GROUP_REFOCUS_POLICY_PREV
|
||||
// File: ../../lvgl/src/core/lv_indev.h
|
||||
// File: ../../lvgl/src/core/lv_indev_scroll.h
|
||||
// File: ../../lvgl/src/core/lv_obj.h
|
||||
LV_STATE_DEFAULT
|
||||
LV_STATE_CHECKED
|
||||
LV_STATE_FOCUSED
|
||||
|
@ -205,7 +217,7 @@ LV_OBJ_FLAG_SCROLL_MOMENTUM
|
|||
LV_OBJ_FLAG_SCROLL_ONE
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS
|
||||
LV_OBJ_FLAG_SNAPABLE
|
||||
LV_OBJ_FLAG_SNAPPABLE
|
||||
LV_OBJ_FLAG_PRESS_LOCK
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE
|
||||
|
@ -221,6 +233,11 @@ LV_OBJ_FLAG_USER_2
|
|||
LV_OBJ_FLAG_USER_3
|
||||
LV_OBJ_FLAG_USER_4
|
||||
|
||||
LV_OBJ_DRAW_PART_RECTANGLE
|
||||
LV_OBJ_DRAW_PART_BORDER_POST
|
||||
LV_OBJ_DRAW_PART_SCROLLBAR
|
||||
|
||||
// File: ../../lvgl/src/core/lv_obj_class.h
|
||||
LV_OBJ_CLASS_EDITABLE_INHERIT
|
||||
LV_OBJ_CLASS_EDITABLE_TRUE
|
||||
LV_OBJ_CLASS_EDITABLE_FALSE
|
||||
|
@ -229,10 +246,13 @@ LV_OBJ_CLASS_GROUP_DEF_INHERIT
|
|||
LV_OBJ_CLASS_GROUP_DEF_TRUE
|
||||
LV_OBJ_CLASS_GROUP_DEF_FALSE
|
||||
|
||||
// File: ../../lvgl/src/core/lv_obj_draw.h
|
||||
LV_COVER_RES_COVER
|
||||
LV_COVER_RES_NOT_COVER
|
||||
LV_COVER_RES_MASKED
|
||||
|
||||
// File: ../../lvgl/src/core/lv_obj_pos.h
|
||||
// File: ../../lvgl/src/core/lv_obj_scroll.h
|
||||
LV_SCROLLBAR_MODE_OFF
|
||||
LV_SCROLLBAR_MODE_ON
|
||||
LV_SCROLLBAR_MODE_ACTIVE
|
||||
|
@ -242,11 +262,23 @@ LV_SCROLL_SNAP_NONE
|
|||
LV_SCROLL_SNAP_START
|
||||
LV_SCROLL_SNAP_END
|
||||
LV_SCROLL_SNAP_CENTER
|
||||
// File: ../../lvgl/src/core/lv_obj_style.h
|
||||
|
||||
// File: ../../lvgl/src/core/lv_obj_style_gen.h
|
||||
// File: ../../lvgl/src/core/lv_obj_tree.h
|
||||
LV_OBJ_TREE_WALK_NEXT
|
||||
LV_OBJ_TREE_WALK_SKIP_CHILDREN
|
||||
LV_OBJ_TREE_WALK_END
|
||||
|
||||
// File: ../../lvgl/src/core/lv_refr.h
|
||||
// File: ../../lvgl/src/core/lv_theme.h
|
||||
// File: ../../lvgl/src/draw/lv_draw.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_arc.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_blend.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_img.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_label.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_line.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_mask.h
|
||||
LV_DRAW_MASK_RES_TRANSP
|
||||
LV_DRAW_MASK_RES_FULL_COVER
|
||||
LV_DRAW_MASK_RES_CHANGED
|
||||
|
@ -262,6 +294,9 @@ LV_DRAW_MASK_LINE_SIDE_RIGHT
|
|||
LV_DRAW_MASK_LINE_SIDE_TOP
|
||||
LV_DRAW_MASK_LINE_SIDE_BOTTOM
|
||||
|
||||
// File: ../../lvgl/src/draw/lv_draw_rect.h
|
||||
// File: ../../lvgl/src/draw/lv_draw_triangle.h
|
||||
// File: ../../lvgl/src/draw/lv_img_buf.h
|
||||
LV_IMG_CF_UNKNOWN
|
||||
LV_IMG_CF_RAW
|
||||
LV_IMG_CF_RAW_ALPHA
|
||||
|
@ -278,37 +313,20 @@ LV_IMG_CF_ALPHA_2BIT
|
|||
LV_IMG_CF_ALPHA_4BIT
|
||||
LV_IMG_CF_ALPHA_8BIT
|
||||
|
||||
// File: ../../lvgl/src/draw/lv_img_cache.h
|
||||
// File: ../../lvgl/src/draw/lv_img_decoder.h
|
||||
LV_IMG_SRC_VARIABLE
|
||||
LV_IMG_SRC_FILE
|
||||
LV_IMG_SRC_SYMBOL
|
||||
LV_IMG_SRC_UNKNOWN
|
||||
|
||||
LV_FLEX_ALIGN_START
|
||||
LV_FLEX_ALIGN_END
|
||||
LV_FLEX_ALIGN_CENTER
|
||||
LV_FLEX_ALIGN_SPACE_EVENLY
|
||||
LV_FLEX_ALIGN_SPACE_AROUND
|
||||
LV_FLEX_ALIGN_SPACE_BETWEEN
|
||||
|
||||
LV_FLEX_FLOW_ROW
|
||||
LV_FLEX_FLOW_COLUMN
|
||||
LV_FLEX_FLOW_ROW_WRAP
|
||||
LV_FLEX_FLOW_ROW_REVERSE
|
||||
LV_FLEX_FLOW_ROW_WRAP_REVERSE
|
||||
LV_FLEX_FLOW_COLUMN_WRAP
|
||||
LV_FLEX_FLOW_COLUMN_REVERSE
|
||||
LV_FLEX_FLOW_COLUMN_WRAP_REVERSE
|
||||
|
||||
LV_GRID_ALIGN_START
|
||||
LV_GRID_ALIGN_CENTER
|
||||
LV_GRID_ALIGN_END
|
||||
LV_GRID_ALIGN_STRETCH
|
||||
LV_GRID_ALIGN_SPACE_EVENLY
|
||||
LV_GRID_ALIGN_SPACE_AROUND
|
||||
LV_GRID_ALIGN_SPACE_BETWEEN
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/animimg/lv_animimg.h
|
||||
LV_ANIM_IMG_PART_MAIN
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/calendar/lv_calendar.h
|
||||
// File: ../../lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.h
|
||||
// File: ../../lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.h
|
||||
// File: ../../lvgl/src/extra/widgets/chart/lv_chart.h
|
||||
LV_CHART_TYPE_NONE
|
||||
LV_CHART_TYPE_LINE
|
||||
LV_CHART_TYPE_BAR
|
||||
|
@ -321,9 +339,19 @@ LV_CHART_AXIS_PRIMARY_Y
|
|||
LV_CHART_AXIS_SECONDARY_Y
|
||||
LV_CHART_AXIS_PRIMARY_X
|
||||
LV_CHART_AXIS_SECONDARY_X
|
||||
LV_CHART_DRAW_PART_DIV_LINE_INIT
|
||||
LV_CHART_DRAW_PART_DIV_LINE_HOR
|
||||
LV_CHART_DRAW_PART_DIV_LINE_VER
|
||||
LV_CHART_DRAW_PART_LINE_AND_POINT
|
||||
LV_CHART_DRAW_PART_BAR
|
||||
LV_CHART_DRAW_PART_CURSOR
|
||||
LV_CHART_DRAW_PART_TICK_LABEL
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/colorwheel/lv_colorwheel.h
|
||||
LV_COLORWHEEL_MODE_HUE
|
||||
LV_COLORWHEEL_MODE_SATURATION
|
||||
LV_COLORWHEEL_MODE_VALUE
|
||||
// File: ../../lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h
|
||||
LV_IMGBTN_STATE_RELEASED
|
||||
LV_IMGBTN_STATE_PRESSED
|
||||
LV_IMGBTN_STATE_DISABLED
|
||||
|
@ -331,12 +359,26 @@ LV_IMGBTN_STATE_CHECKED_RELEASED
|
|||
LV_IMGBTN_STATE_CHECKED_PRESSED
|
||||
LV_IMGBTN_STATE_CHECKED_DISABLED
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/keyboard/lv_keyboard.h
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/led/lv_led.h
|
||||
LV_LED_DRAW_PART_RECTANGLE
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/list/lv_list.h
|
||||
// File: ../../lvgl/src/extra/widgets/lv_widgets.h
|
||||
// File: ../../lvgl/src/extra/widgets/meter/lv_meter.h
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_IMG
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_LINE
|
||||
LV_METER_INDICATOR_TYPE_SCALE_LINES
|
||||
LV_METER_INDICATOR_TYPE_ARC
|
||||
|
||||
LV_METER_DRAW_PART_ARC
|
||||
LV_METER_DRAW_PART_NEEDLE_LINE
|
||||
LV_METER_DRAW_PART_NEEDLE_IMG
|
||||
LV_METER_DRAW_PART_TICK
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/msgbox/lv_msgbox.h
|
||||
// File: ../../lvgl/src/extra/widgets/span/lv_span.h
|
||||
LV_SPAN_OVERFLOW_CLIP
|
||||
LV_SPAN_OVERFLOW_ELLIPSIS
|
||||
|
||||
|
@ -344,14 +386,18 @@ LV_SPAN_MODE_FIXED
|
|||
LV_SPAN_MODE_EXPAND
|
||||
LV_SPAN_MODE_BREAK
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// File: ../../lvgl/src/extra/widgets/spinbox/lv_spinbox.h
|
||||
// File: ../../lvgl/src/extra/widgets/spinner/lv_spinner.h
|
||||
// File: ../../lvgl/src/extra/widgets/tabview/lv_tabview.h
|
||||
// File: ../../lvgl/src/extra/widgets/tileview/lv_tileview.h
|
||||
// File: ../../lvgl/src/extra/widgets/win/lv_win.h
|
||||
// File: ../../lvgl/src/hal/lv_hal.h
|
||||
// File: ../../lvgl/src/hal/lv_hal_disp.h
|
||||
LV_DISP_ROT_NONE
|
||||
LV_DISP_ROT_90
|
||||
LV_DISP_ROT_180
|
||||
LV_DISP_ROT_270
|
||||
// File: ../../lvgl/src/hal/lv_hal_indev.h
|
||||
LV_INDEV_TYPE_NONE
|
||||
LV_INDEV_TYPE_POINTER
|
||||
LV_INDEV_TYPE_KEYPAD
|
||||
|
@ -360,9 +406,13 @@ LV_INDEV_TYPE_ENCODER
|
|||
|
||||
LV_INDEV_STATE_RELEASED
|
||||
LV_INDEV_STATE_PRESSED
|
||||
// File: ../../lvgl/src/hal/lv_hal_tick.h
|
||||
// File: ../../lvgl/src/misc/lv_anim.h
|
||||
LV_ANIM_OFF
|
||||
LV_ANIM_ON
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_anim_timeline.h
|
||||
// File: ../../lvgl/src/misc/lv_area.h
|
||||
LV_ALIGN_DEFAULT
|
||||
LV_ALIGN_TOP_LEFT
|
||||
LV_ALIGN_TOP_MID
|
||||
|
@ -395,12 +445,16 @@ LV_DIR_HOR
|
|||
LV_DIR_VER
|
||||
LV_DIR_ALL
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_assert.h
|
||||
// File: ../../lvgl/src/misc/lv_async.h
|
||||
// File: ../../lvgl/src/misc/lv_bidi.h
|
||||
LV_BASE_DIR_LTR
|
||||
LV_BASE_DIR_RTL
|
||||
LV_BASE_DIR_AUTO
|
||||
LV_BASE_DIR_NEUTRAL
|
||||
LV_BASE_DIR_WEAK
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_color.h
|
||||
LV_OPA_TRANSP
|
||||
LV_OPA_0
|
||||
LV_OPA_10
|
||||
|
@ -436,6 +490,7 @@ LV_PALETTE_BLUE_GREY
|
|||
LV_PALETTE_GREY
|
||||
LV_PALETTE_NONE
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_fs.h
|
||||
LV_FS_RES_OK
|
||||
LV_FS_RES_HW_ERR
|
||||
LV_FS_RES_FS_ERR
|
||||
|
@ -457,9 +512,17 @@ LV_FS_SEEK_SET
|
|||
LV_FS_SEEK_CUR
|
||||
LV_FS_SEEK_END
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_gc.h
|
||||
// File: ../../lvgl/src/misc/lv_ll.h
|
||||
// File: ../../lvgl/src/misc/lv_log.h
|
||||
// File: ../../lvgl/src/misc/lv_math.h
|
||||
// File: ../../lvgl/src/misc/lv_mem.h
|
||||
// File: ../../lvgl/src/misc/lv_printf.h
|
||||
// File: ../../lvgl/src/misc/lv_style.h
|
||||
LV_BLEND_MODE_NORMAL
|
||||
LV_BLEND_MODE_ADDITIVE
|
||||
LV_BLEND_MODE_SUBTRACTIVE
|
||||
LV_BLEND_MODE_MULTIPLY
|
||||
|
||||
LV_TEXT_DECOR_NONE
|
||||
LV_TEXT_DECOR_UNDERLINE
|
||||
|
@ -568,6 +631,11 @@ LV_STYLE_BLEND_MODE
|
|||
LV_STYLE_LAYOUT
|
||||
LV_STYLE_BASE_DIR
|
||||
LV_STYLE_PROP_ANY
|
||||
// File: ../../lvgl/src/misc/lv_style_gen.h
|
||||
// File: ../../lvgl/src/misc/lv_templ.h
|
||||
// File: ../../lvgl/src/misc/lv_timer.h
|
||||
// File: ../../lvgl/src/misc/lv_tlsf.h
|
||||
// File: ../../lvgl/src/misc/lv_txt.h
|
||||
LV_TEXT_FLAG_NONE
|
||||
LV_TEXT_FLAG_RECOLOR
|
||||
LV_TEXT_FLAG_EXPAND
|
||||
|
@ -582,37 +650,72 @@ LV_TEXT_ALIGN_LEFT
|
|||
LV_TEXT_ALIGN_CENTER
|
||||
LV_TEXT_ALIGN_RIGHT
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_txt_ap.h
|
||||
// File: ../../lvgl/src/misc/lv_types.h
|
||||
LV_RES_INV
|
||||
LV_RES_OK
|
||||
|
||||
// File: ../../lvgl/src/misc/lv_utils.h
|
||||
// File: ../../lvgl/src/widgets/lv_arc.h
|
||||
LV_ARC_MODE_NORMAL
|
||||
LV_ARC_MODE_SYMMETRICAL
|
||||
LV_ARC_MODE_REVERSE
|
||||
LV_ARC_DRAW_PART_BACKGROUND
|
||||
LV_ARC_DRAW_PART_FOREGROUND
|
||||
LV_ARC_DRAW_PART_KNOB
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_bar.h
|
||||
LV_BAR_MODE_NORMAL
|
||||
LV_BAR_MODE_SYMMETRICAL
|
||||
LV_BAR_MODE_RANGE
|
||||
LV_BAR_DRAW_PART_INDICATOR
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_btn.h
|
||||
// File: ../../lvgl/src/widgets/lv_btnmatrix.h
|
||||
LV_BTNMATRIX_CTRL_HIDDEN
|
||||
LV_BTNMATRIX_CTRL_NO_REPEAT
|
||||
LV_BTNMATRIX_CTRL_DISABLED
|
||||
LV_BTNMATRIX_CTRL_CHECKABLE
|
||||
LV_BTNMATRIX_CTRL_CHECKED
|
||||
LV_BTNMATRIX_CTRL_CLICK_TRIG
|
||||
LV_BTNMATRIX_CTRL_POPOVER
|
||||
LV_BTNMATRIX_CTRL_RECOLOR
|
||||
LV_BTNMATRIX_CTRL_CUSTOM_1
|
||||
LV_BTNMATRIX_CTRL_CUSTOM_2
|
||||
|
||||
LV_BTNMATRIX_DRAW_PART_BTN
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_canvas.h
|
||||
// File: ../../lvgl/src/widgets/lv_checkbox.h
|
||||
LV_CHECKBOX_DRAW_PART_BOX
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_dropdown.h
|
||||
// File: ../../lvgl/src/widgets/lv_img.h
|
||||
LV_IMG_SIZE_MODE_VIRTUAL
|
||||
LV_IMG_SIZE_MODE_REAL
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_label.h
|
||||
LV_LABEL_LONG_WRAP
|
||||
LV_LABEL_LONG_DOT
|
||||
LV_LABEL_LONG_SCROLL
|
||||
LV_LABEL_LONG_SCROLL_CIRCULAR
|
||||
LV_LABEL_LONG_CLIP
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_line.h
|
||||
// File: ../../lvgl/src/widgets/lv_objx_templ.h
|
||||
// File: ../../lvgl/src/widgets/lv_roller.h
|
||||
LV_ROLLER_MODE_NORMAL
|
||||
LV_ROLLER_MODE_INFINITE
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_slider.h
|
||||
LV_SLIDER_MODE_NORMAL
|
||||
LV_SLIDER_MODE_SYMMETRICAL
|
||||
LV_SLIDER_MODE_RANGE
|
||||
LV_SLIDER_DRAW_PART_KNOB
|
||||
LV_SLIDER_DRAW_PART_KNOB_LEFT
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_switch.h
|
||||
// File: ../../lvgl/src/widgets/lv_table.h
|
||||
LV_TABLE_CELL_CTRL_MERGE_RIGHT
|
||||
LV_TABLE_CELL_CTRL_TEXT_CROP
|
||||
LV_TABLE_CELL_CTRL_CUSTOM_1
|
||||
|
@ -620,5 +723,8 @@ LV_TABLE_CELL_CTRL_CUSTOM_2
|
|||
LV_TABLE_CELL_CTRL_CUSTOM_3
|
||||
LV_TABLE_CELL_CTRL_CUSTOM_4
|
||||
|
||||
LV_TABLE_DRAW_PART_CELL
|
||||
|
||||
// File: ../../lvgl/src/widgets/lv_textarea.h
|
||||
LV_PART_TEXTAREA_PLACEHOLDER
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ lv_res_t lv_obj_event_base(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
uint32_t lv_event_register_id(void)
|
||||
struct _lv_event_dsc_t * lv_obj_add_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data)
|
||||
bool lv_obj_remove_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb)
|
||||
bool lv_obj_remove_event_cb_with_user_data(struct _lv_obj_t * obj, lv_event_cb_t event_cb, const void * event_user_data)
|
||||
bool lv_obj_remove_event_dsc(struct _lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc)
|
||||
void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size)
|
||||
void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res)
|
||||
|
@ -66,6 +67,7 @@ void lv_group_del(lv_group_t * group)
|
|||
void lv_group_set_default(lv_group_t * group)
|
||||
lv_group_t * lv_group_get_default(void)
|
||||
void lv_group_add_obj(lv_group_t * group, struct _lv_obj_t * obj)
|
||||
void lv_group_swap_obj(struct _lv_obj_t * obj1, struct _lv_obj_t * obj2)
|
||||
void lv_group_remove_obj(struct _lv_obj_t * obj)
|
||||
void lv_group_remove_all_objs(lv_group_t * group)
|
||||
void lv_group_focus_obj(struct _lv_obj_t * obj)
|
||||
|
@ -107,6 +109,7 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
|
|||
// ../../lvgl/src/core/lv_indev_scroll.h
|
||||
|
||||
// ../../lvgl/src/core/lv_obj.h
|
||||
bool lv_is_initialized(void)
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent)
|
||||
void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
|
@ -140,6 +143,7 @@ void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_li
|
|||
void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc)
|
||||
lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part)
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area)
|
||||
bool lv_obj_draw_part_check_type(lv_obj_draw_part_dsc_t * dsc, const struct _lv_obj_class_t * class_p, uint32_t type)
|
||||
void lv_obj_refresh_ext_draw_size(struct _lv_obj_t * obj)
|
||||
|
||||
// ../../lvgl/src/core/lv_obj_pos.h
|
||||
|
@ -235,6 +239,9 @@ static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, lv_coord_t v
|
|||
static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt)
|
||||
static inline lv_coord_t lv_obj_get_x_aligned(const struct _lv_obj_t * obj)
|
||||
static inline lv_coord_t lv_obj_get_y_aligned(const struct _lv_obj_t * obj)
|
||||
|
||||
// ../../lvgl/src/core/lv_obj_style_gen.h
|
||||
static inline lv_coord_t lv_obj_get_style_width(const struct _lv_obj_t * obj, uint32_t part)
|
||||
|
@ -316,12 +323,12 @@ static inline lv_opa_t lv_obj_get_style_shadow_opa(const struct _lv_obj_t * obj,
|
|||
static inline lv_coord_t lv_obj_get_style_line_width(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_coord_t lv_obj_get_style_line_dash_width(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline bool lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_color_t lv_obj_get_style_line_color_filtered(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_opa_t lv_obj_get_style_line_opa(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_coord_t lv_obj_get_style_arc_width(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_coord_t lv_obj_get_style_arc_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline bool lv_obj_get_style_arc_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_color_t lv_obj_get_style_arc_color(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_color_t lv_obj_get_style_arc_color_filtered(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline lv_opa_t lv_obj_get_style_arc_opa(const struct _lv_obj_t * obj, uint32_t part)
|
||||
|
@ -405,12 +412,12 @@ void lv_obj_set_style_shadow_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_styl
|
|||
void lv_obj_set_style_line_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_dash_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_dash_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_color_filtered(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_color_filtered(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector)
|
||||
|
@ -419,17 +426,18 @@ void lv_obj_set_style_arc_img_src(struct _lv_obj_t * obj, const void * value, lv
|
|||
// ../../lvgl/src/core/lv_obj_tree.h
|
||||
void lv_obj_del(struct _lv_obj_t * obj)
|
||||
void lv_obj_clean(struct _lv_obj_t * obj)
|
||||
void lv_obj_del_delayed(struct _lv_obj_t * obj, uint32_t delay_ms)
|
||||
void lv_obj_del_anim_ready_cb(lv_anim_t * a)
|
||||
void lv_obj_del_async(struct _lv_obj_t * obj)
|
||||
void lv_obj_set_parent(struct _lv_obj_t * obj, struct _lv_obj_t * parent)
|
||||
void lv_obj_move_foreground(struct _lv_obj_t * obj)
|
||||
void lv_obj_move_background(struct _lv_obj_t * obj)
|
||||
void lv_obj_swap(struct _lv_obj_t * obj1, struct _lv_obj_t * obj2)
|
||||
void lv_obj_move_to_index(struct _lv_obj_t * obj, int32_t index)
|
||||
struct _lv_obj_t * lv_obj_get_screen(const struct _lv_obj_t * obj)
|
||||
lv_disp_t * lv_obj_get_disp(const struct _lv_obj_t * obj)
|
||||
struct _lv_obj_t * lv_obj_get_parent(const struct _lv_obj_t * obj)
|
||||
struct _lv_obj_t * lv_obj_get_child(const struct _lv_obj_t * obj, int32_t id)
|
||||
uint32_t lv_obj_get_child_cnt(const struct _lv_obj_t * obj)
|
||||
uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj)
|
||||
uint32_t lv_obj_get_index(const struct _lv_obj_t * obj)
|
||||
void lv_obj_tree_walk(struct _lv_obj_t * start_obj, lv_obj_tree_walk_cb_t cb, void * user_data)
|
||||
|
||||
// ../../lvgl/src/core/lv_refr.h
|
||||
|
@ -471,11 +479,15 @@ void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc)
|
|||
|
||||
// ../../lvgl/src/draw/lv_draw_mask.h
|
||||
static inline uint8_t lv_draw_mask_get_cnt(void)
|
||||
static inline bool lv_draw_mask_is_any(const lv_area_t * a)
|
||||
int16_t lv_draw_mask_add(void * param, void * custom_id)
|
||||
lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len)
|
||||
lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len, const int16_t *ids, int16_t ids_count)
|
||||
void * lv_draw_mask_remove_id(int16_t id)
|
||||
void * lv_draw_mask_remove_custom(void * custom_id)
|
||||
void lv_draw_mask_free_param(void * p)
|
||||
uint8_t lv_draw_mask_get_cnt(void)
|
||||
bool lv_draw_mask_is_any(const lv_area_t * a)
|
||||
void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t p1y, lv_coord_t p2x, lv_coord_t p2y, lv_draw_mask_line_side_t side)
|
||||
void lv_draw_mask_line_angle_init(lv_draw_mask_line_param_t * param, lv_coord_t p1x, lv_coord_t py, int16_t angle, lv_draw_mask_line_side_t side)
|
||||
void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vertex_x, lv_coord_t vertex_y, lv_coord_t start_angle, lv_coord_t end_angle)
|
||||
|
@ -485,7 +497,7 @@ void lv_draw_mask_map_init(lv_draw_mask_map_param_t * param, const lv_area_t * c
|
|||
|
||||
// ../../lvgl/src/draw/lv_draw_rect.h
|
||||
void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc)
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc)
|
||||
|
||||
// ../../lvgl/src/draw/lv_draw_triangle.h
|
||||
void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc)
|
||||
|
@ -499,6 +511,7 @@ void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_are
|
|||
|
||||
// ../../lvgl/src/extra/themes/default/lv_theme_default.h
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
|
||||
lv_theme_t * lv_theme_default_get(void)
|
||||
bool lv_theme_default_is_inited(void)
|
||||
|
||||
// ../../lvgl/src/extra/themes/mono/lv_theme_mono.h
|
||||
|
@ -556,6 +569,7 @@ bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj)
|
|||
// ../../lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * parent)
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, const void * src_right)
|
||||
void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state)
|
||||
|
||||
// ../../lvgl/src/extra/widgets/led/lv_led.h
|
||||
lv_obj_t * lv_led_create(lv_obj_t * parent)
|
||||
|
@ -582,12 +596,15 @@ void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * ind
|
|||
|
||||
// ../../lvgl/src/extra/widgets/msgbox/lv_msgbox.h
|
||||
lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[], bool add_close_btn)
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj)
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj)
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj)
|
||||
lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj)
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj)
|
||||
uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox)
|
||||
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox)
|
||||
void lv_msgbox_close(lv_obj_t * mbox)
|
||||
void lv_msgbox_close_async(lv_obj_t * mbox)
|
||||
|
||||
// ../../lvgl/src/extra/widgets/spinbox/lv_spinbox.h
|
||||
lv_obj_t * lv_spinbox_create(lv_obj_t * parent)
|
||||
|
@ -596,7 +613,9 @@ void lv_spinbox_set_rollover(lv_obj_t * obj, bool b)
|
|||
void lv_spinbox_set_digit_format(lv_obj_t * obj, uint8_t digit_count, uint8_t separator_position)
|
||||
void lv_spinbox_set_step(lv_obj_t * obj, uint32_t step)
|
||||
void lv_spinbox_set_range(lv_obj_t * obj, int32_t range_min, int32_t range_max)
|
||||
bool lv_spinbox_get_rollover(lv_obj_t * obj)
|
||||
void lv_spinbox_set_pos(lv_obj_t * obj, uint8_t pos)
|
||||
void lv_spinbox_set_digit_step_direction(lv_obj_t * obj, lv_dir_t direction)
|
||||
bool lv_spinbox_get_rollover(lv_obj_t *obj)
|
||||
int32_t lv_spinbox_get_value(lv_obj_t * obj)
|
||||
int32_t lv_spinbox_get_step(lv_obj_t * obj)
|
||||
void lv_spinbox_step_next(lv_obj_t * obj)
|
||||
|
@ -687,12 +706,12 @@ void lv_style_set_shadow_opa(lv_style_t * style, lv_opa_t value)
|
|||
void lv_style_set_line_width(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_line_dash_width(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_line_dash_gap(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_line_rounded(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_line_rounded(lv_style_t * style, bool value)
|
||||
void lv_style_set_line_color(lv_style_t * style, lv_color_t value)
|
||||
void lv_style_set_line_color_filtered(lv_style_t * style, lv_color_t value)
|
||||
void lv_style_set_line_opa(lv_style_t * style, lv_opa_t value)
|
||||
void lv_style_set_arc_width(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_arc_rounded(lv_style_t * style, lv_coord_t value)
|
||||
void lv_style_set_arc_rounded(lv_style_t * style, bool value)
|
||||
void lv_style_set_arc_color(lv_style_t * style, lv_color_t value)
|
||||
void lv_style_set_arc_color_filtered(lv_style_t * style, lv_color_t value)
|
||||
void lv_style_set_arc_opa(lv_style_t * style, lv_opa_t value)
|
||||
|
@ -741,7 +760,7 @@ void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[])
|
|||
void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_map[])
|
||||
void lv_btnmatrix_set_selected_btn(lv_obj_t * obj, uint16_t btn_id)
|
||||
void lv_btnmatrix_set_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
|
||||
void lv_btnmatrix_clear_btn_ctrl(const lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
|
||||
void lv_btnmatrix_clear_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl)
|
||||
void lv_btnmatrix_set_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl)
|
||||
void lv_btnmatrix_clear_btn_ctrl_all(lv_obj_t * obj, lv_btnmatrix_ctrl_t ctrl)
|
||||
void lv_btnmatrix_set_btn_width(lv_obj_t * obj, uint16_t btn_id, uint8_t width)
|
||||
|
@ -755,7 +774,9 @@ bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj)
|
|||
// ../../lvgl/src/widgets/lv_canvas.h
|
||||
lv_obj_t * lv_canvas_create(lv_obj_t * parent)
|
||||
void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf)
|
||||
void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
void lv_canvas_set_px_color(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
static inline void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
|
||||
void lv_canvas_set_px_opa(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_opa_t opa)
|
||||
void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c)
|
||||
lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y)
|
||||
lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas)
|
||||
|
@ -809,6 +830,7 @@ void lv_img_set_angle(lv_obj_t * obj, int16_t angle)
|
|||
void lv_img_set_pivot(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
||||
void lv_img_set_zoom(lv_obj_t * obj, uint16_t zoom)
|
||||
void lv_img_set_antialias(lv_obj_t * obj, bool antialias)
|
||||
void lv_img_set_size_mode(lv_obj_t * obj, lv_img_size_mode_t mode)
|
||||
const void * lv_img_get_src(lv_obj_t * obj)
|
||||
lv_coord_t lv_img_get_offset_x(lv_obj_t * obj)
|
||||
lv_coord_t lv_img_get_offset_y(lv_obj_t * obj)
|
||||
|
@ -816,6 +838,7 @@ uint16_t lv_img_get_angle(lv_obj_t * obj)
|
|||
void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot)
|
||||
uint16_t lv_img_get_zoom(lv_obj_t * obj)
|
||||
bool lv_img_get_antialias(lv_obj_t * obj)
|
||||
lv_img_size_mode_t lv_img_get_size_mode(lv_obj_t * obj)
|
||||
|
||||
// ../../lvgl/src/widgets/lv_label.h
|
||||
lv_obj_t * lv_label_create(lv_obj_t * parent)
|
||||
|
|
|
@ -170,7 +170,14 @@ sys.stdout.close()
|
|||
# ################################################################################
|
||||
|
||||
lv_src_prefix = "../../lvgl/src/"
|
||||
lv_fun_globs = [ "**/*.h" ]
|
||||
lv_fun_globs = [
|
||||
"core/*.h",
|
||||
"draw/*.h",
|
||||
"hal/*.h",
|
||||
"misc/*.h",
|
||||
"widgets/*.h",
|
||||
"extra/widgets/**/*.h",
|
||||
]
|
||||
headers_names = list_files(lv_src_prefix, lv_fun_globs)
|
||||
|
||||
output_filename = "../mapping/lv_enum.h"
|
||||
|
@ -282,12 +289,11 @@ SYMBOL_BULLET="\\xE2\\x80\\xA2"
|
|||
// ======================================================================
|
||||
""")
|
||||
|
||||
|
||||
|
||||
for header_name in headers_names:
|
||||
with open(header_name) as f:
|
||||
raw = clean_source(f.read())
|
||||
|
||||
print(f"// File: {header_name}")
|
||||
# extract enums
|
||||
enums = re.findall('enum\s+{(.*?)}', raw, flags=re.DOTALL)
|
||||
for enum in enums: # iterate on all matches
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
MIT licence
|
||||
Copyright (c) 2020 LVGL LLC
|
||||
Copyright (c) 2021 LVGL Kft
|
||||
|
||||
Permission 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:
|
||||
|
||||
|
|
|
@ -1,46 +1,52 @@
|
|||
**The master branch now contains the test version of v8. For the last v7 version use the release/v7 branch.**
|
||||
|
||||
|
||||
<h1 align="center"> LVGL - Light and Versatile Graphics Library</h1>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://lvgl.io/assets/images/img_1.png">
|
||||
<img src="https://lvgl.io/assets/images/lvgl_widgets_demo.gif">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
LVGL provides everything you need to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint.
|
||||
LVGL provides everything you need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects and a low memory footprint.
|
||||
</p>
|
||||
|
||||
<h4 align="center">
|
||||
<a href="https://lvgl.io">Website </a> ·
|
||||
<a href="https://lvgl.io/demos">Online demo</a> ·
|
||||
<a href="https://lvgl.github.io/lv_examples/">Nightly demos</a> ·
|
||||
<a href="https://docs.lvgl.io/">Docs</a> ·
|
||||
<a href="https://forum.lvgl.io">Forum</a>
|
||||
<a href="https://forum.lvgl.io">Forum</a> ·
|
||||
<a href="https://lvgl.io/services">Services</a> ·
|
||||
<a href="https://docs.lvgl.io/master/examples.html">Interactive examples</a>
|
||||
</h4>
|
||||
|
||||
---
|
||||
|
||||
## Features
|
||||
* Powerful [building blocks](https://docs.lvgl.io/latest/en/html/widgets/index.html): buttons, charts, lists, sliders, images, etc.
|
||||
* Advanced graphics: animations, anti-aliasing, opacity, smooth scrolling
|
||||
* Use [various input devices](https://docs.lvgl.io/latest/en/html/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc.
|
||||
* Use [multiple displays](https://docs.lvgl.io/latest/en/html/overview/display.html): e.g. monochrome and color display
|
||||
* Hardware independent to use with any microcontroller or display
|
||||
* Scalable to operate with little memory (64 kB Flash, 10 kB RAM)
|
||||
* Multi-language support with UTF-8 handling, Bidirectional and Arabic script support
|
||||
* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/latest/en/html/overview/style.html)
|
||||
* OS, External memory and GPU are supported but not required
|
||||
* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/latest/en/html/porting/display.html)
|
||||
* Written in C for maximal compatibility (C++ compatible)
|
||||
#### Table of content
|
||||
- [Overview](#overview)
|
||||
- [Get started](#get-started)
|
||||
- [Examples](#examples)
|
||||
- [Services](#services)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
|
||||
## Overview
|
||||
### Features
|
||||
* Powerful [building blocks](https://docs.lvgl.io/master/widgets/index.html): buttons, charts, lists, sliders, images, etc.
|
||||
* Advanced graphics engine: animations, anti-aliasing, opacity, smooth scrolling, blending modes, etc
|
||||
* Supports [various input devices](https://docs.lvgl.io/master/overview/indev.html): touchscreen, mouse, keyboard, encoder, buttons, etc.
|
||||
* Supports [multiple displays](https://docs.lvgl.io/master/overview/display.html)
|
||||
* Hardware independent, can be use with any microcontroller and display
|
||||
* Scalable to operate with little memory (64 kB Flash, 16 kB RAM)
|
||||
* Multi-language support with UTF-8 handling, CJK, Bidirectional and Arabic script support
|
||||
* Fully customizable graphical elements via [CSS-like styles](https://docs.lvgl.io/master/overview/style.html)
|
||||
* Powerful layouts inspired by CSS: [Flexbox](https://docs.lvgl.io/master/layouts/flex.html) and [Grid](https://docs.lvgl.io/master/layouts/grid.html)
|
||||
* OS, External memory and GPU are supported but not required. (built in support for STM32 DMA2D, and NXP PXP and VGLite)
|
||||
* Smooth rendering even with a [single frame buffer](https://docs.lvgl.io/master/porting/display.html)
|
||||
* Written in C and compatibile with C++
|
||||
* Micropython Binding exposes [LVGL API in Micropython](https://blog.lvgl.io/2019-02-20/micropython-bindings)
|
||||
* [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) to develop on PC without embedded hardware
|
||||
* [Examples](lv_examples) and tutorials for rapid development
|
||||
* [Documentation](http://docs.lvgl.io/) and API references
|
||||
* [Simulator](https://docs.lvgl.io/master/get-started/pc-simulator.html) to develop on PC without embedded hardware
|
||||
* 100+ simple [Examples](https://github.com/lvgl/lvgl/tree/master/examples)
|
||||
* [Documentation](http://docs.lvgl.io/) and API references online and in PDF
|
||||
|
||||
## Requirements
|
||||
### Requirements
|
||||
Basically, every modern controller (which is able to drive a display) is suitable to run LVGL. The minimal requirements are:
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td> <strong>Name</strong> </td>
|
||||
|
@ -65,26 +71,14 @@ Basically, every modern controller (which is able to drive a display) is suitabl
|
|||
|
||||
<tr>
|
||||
<td> <strong>Static RAM</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 4 kB</td>
|
||||
<td> > 16 kB </td>
|
||||
<td> > 48 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Stack</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 8 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Heap</strong></td>
|
||||
<td> > 2 kB </td>
|
||||
<td> > 8 kB</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td> <strong>Display buffer</strong></td>
|
||||
<td> <strong>Draw buffer</strong></td>
|
||||
<td> > 1 × <em>hor. res.</em> pixels </td>
|
||||
<td> > 10 × <em>hor. res.</em> pixels </td>
|
||||
<td> > 1/10 screen size </td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
|
@ -95,10 +89,12 @@ Basically, every modern controller (which is able to drive a display) is suitabl
|
|||
|
||||
*Note that the memory usage might vary depending on the architecture, compiler and build options.*
|
||||
|
||||
### Supported platforms
|
||||
LVGL is completely platform independent and can be used with any MCU that fulfills the requirements.
|
||||
Just to mention some platforms:
|
||||
- NXP: Kinetis, LPC, iMX, iMX RT
|
||||
- STM32F1, STM32F3, STM32F4, STM32F7, STM32L4, STM32L5, STM32H7
|
||||
- Microchip dsPIC33, PIC24, PIC32MX, PIC32MZ
|
||||
- NXP: Kinetis, LPC, iMX, iMX RT
|
||||
- [Linux frame buffer](https://blog.lvgl.io/2018-01-03/linux_fb) (/dev/fb)
|
||||
- [Raspberry Pi](http://www.vk3erw.com/index.php/16-software/63-raspberry-pi-official-7-touchscreen-and-littlevgl)
|
||||
- [Espressif ESP32](https://github.com/lvgl/lv_port_esp32)
|
||||
|
@ -106,60 +102,80 @@ Just to mention some platforms:
|
|||
- Nordic NRF52 Bluetooth modules
|
||||
- Quectel modems
|
||||
|
||||
LVGL is also avaiable as:
|
||||
- [Arduino library](https://docs.lvgl.io/master/get-started/arduino.html)
|
||||
- [PlatformIO package](https://platformio.org/lib/show/12440/lvgl)
|
||||
- [Zephyr library](https://docs.zephyrproject.org/latest/reference/kconfig/CONFIG_LVGL.html)
|
||||
- [ESP32 component](https://docs.lvgl.io/master/get-started/espressif.html)
|
||||
- [NXP MCUXpresso component](https://www.nxp.com/design/software/embedded-software/lvgl-open-source-graphics-library:LITTLEVGL-OPEN-SOURCE-GRAPHICS-LIBRARY)
|
||||
- [NuttX library](https://docs.lvgl.io/master/get-started/nuttx.html)
|
||||
|
||||
|
||||
## Get started
|
||||
This list shows the recommended way of learning the library:
|
||||
1. Check the [Online demos](https://lvgl.io/demos) to see LVGL in action (3 minutes)
|
||||
2. Read the [Introduction](https://docs.lvgl.io/latest/en/html/intro/index.html) page of the documentation (5 minutes)
|
||||
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/latest/en/html/get-started/quick-overview.html) page (15 minutes)
|
||||
4. Set up a [Simulator](https://docs.lvgl.io/latest/en/html/get-started/pc-simulator.html) (10 minutes)
|
||||
5. Try out some [Examples](https://github.com/lvgl/lv_examples/)
|
||||
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/latest/en/html/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_&type=&language=)
|
||||
7. Read the [Overview](https://docs.lvgl.io/latest/en/html/overview/index.html) page to get a better understanding of the library (2-3 hours)
|
||||
8. Check the documentation of the [Widgets](https://docs.lvgl.io/latest/en/html/widgets/index.html) to see their features and usage
|
||||
2. Read the [Introduction](https://docs.lvgl.io/master/intro/index.html) page of the documentation (5 minutes)
|
||||
3. Get familiar with the basics on the [Quick overview](https://docs.lvgl.io/master/get-started/quick-overview.html) page (15 minutes)
|
||||
4. Set up a [Simulator](https://docs.lvgl.io/master/get-started/pc-simulator.html) (10 minutes)
|
||||
5. Try out some [Examples](https://github.com/lvgl/lvgl/tree/master/examples)
|
||||
6. Port LVGL to a board. See the [Porting](https://docs.lvgl.io/master/porting/index.html) guide or check the ready to use [Projects](https://github.com/lvgl?q=lv_port_)
|
||||
7. Read the [Overview](https://docs.lvgl.io/master/overview/index.html) page to get a better understanding of the library (2-3 hours)
|
||||
8. Check the documentation of the [Widgets](https://docs.lvgl.io/master/widgets/index.html) to see their features and usage
|
||||
9. If you have questions go to the [Forum](http://forum.lvgl.io/)
|
||||
10. Read the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) guide to see how you can help to improve LVGL (15 minutes)
|
||||
10. Read the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) guide to see how you can help to improve LVGL (15 minutes)
|
||||
|
||||
## Examples
|
||||
|
||||
For more examples see the [lv_examples](https://github.com/lvgl/lv_examples) repository.
|
||||
For more examples see the [examples](https://github.com/lvgl/lvgl/tree/master/examples) folder.
|
||||
|
||||
### Button with label
|
||||
![LVGL button with label example](https://github.com/lvgl/lvgl/raw/master/docs/misc/btn_example.png)
|
||||
|
||||
### C
|
||||
```c
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act(), NULL); /*Add a button to the current screen*/
|
||||
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
|
||||
lv_obj_set_size(btn, 100, 50); /*Set its size*/
|
||||
lv_obj_set_event_cb(btn, btn_event_cb); /*Assign a callback to the button*/
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn, NULL); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_t * btn = lv_btn_create(lv_scr_act()); /*Add a button to the current screen*/
|
||||
lv_obj_set_pos(btn, 10, 10); /*Set its position*/
|
||||
lv_obj_set_size(btn, 100, 50); /*Set its size*/
|
||||
lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, NULL); /*Assign a callback to the button*/
|
||||
|
||||
lv_obj_t * label = lv_label_create(btn); /*Add a label to the button*/
|
||||
lv_label_set_text(label, "Button"); /*Set the labels text*/
|
||||
lv_obj_center(label); /*Align the label to the center*/
|
||||
...
|
||||
|
||||
void btn_event_cb(lv_obj_t * btn, lv_event_t event)
|
||||
void btn_event_cb(lv_event_t * e)
|
||||
{
|
||||
if(event == LV_EVENT_CLICKED) {
|
||||
printf("Clicked\n");
|
||||
}
|
||||
printf("Clicked\n");
|
||||
}
|
||||
```
|
||||
![LVGL button with label example](https://raw.githubusercontent.com/lvgl/docs/latest/misc/simple_button_example.gif)
|
||||
|
||||
### LVGL from Micropython
|
||||
Learn more about [Micropython](https://docs.lvgl.io/latest/en/html/get-started/micropython.html).
|
||||
### Micropython
|
||||
Learn more about [Micropython](https://docs.lvgl.io/master/get-started/micropython.html).
|
||||
```python
|
||||
def btn_event_cb(e):
|
||||
print("Clicked")
|
||||
|
||||
# Create a Button and a Label
|
||||
scr = lv.obj()
|
||||
btn = lv.btn(scr)
|
||||
btn.align(lv.scr_act(), lv.ALIGN.CENTER, 0, 0)
|
||||
btn = lv.btn(lv.scr_act())
|
||||
btn.set_pos(10, 10)
|
||||
btn.set_size(100, 50)
|
||||
btn.add_event_cb(btn_event_cb, lv.EVENT.CLICKED, None)
|
||||
|
||||
label = lv.label(btn)
|
||||
label.set_text("Button")
|
||||
|
||||
# Load the screen
|
||||
lv.scr_load(scr)
|
||||
label.center()
|
||||
```
|
||||
|
||||
## Contributing
|
||||
LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosing your own project under in LVGL.
|
||||
## Services
|
||||
LVGL Kft was established to provide a solid background for LVGL library. We offer several type of services to help you in UI development:
|
||||
- Graphics design
|
||||
- UI implementation
|
||||
- Consulting/Support
|
||||
|
||||
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/latest/en/html/contributing/index.html) section of the documentation.
|
||||
For more information see https://lvgl.io/services
|
||||
Feel free to contact us if you have any questions.
|
||||
|
||||
|
||||
## Contributing
|
||||
LVGL is an open project and contribution is very welcome. There are many ways to contribute from simply speaking about your project, through writing examples, improving the documentation, fixing bugs to hosting your own project under the LVGL organization.
|
||||
|
||||
For a detailed description of contribution opportunities visit the [Contributing](https://docs.lvgl.io/master/CONTRIBUTING.html) section of the documentation.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "lvgl8",
|
||||
"version": "8.0.2",
|
||||
"name": "lvgl",
|
||||
"version": "8.1.0",
|
||||
"keywords": "graphics, gui, embedded, tft, lvgl",
|
||||
"description": "Graphics library to create embedded GUI with easy-to-use graphical elements, beautiful visual effects and low memory footprint. It offers anti-aliasing, opacity, and animations using only one frame buffer.",
|
||||
"repository": {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name=lvgl
|
||||
version=8.0.2
|
||||
version=8.1.0
|
||||
author=kisvegabor
|
||||
maintainer=kisvegabor,embeddedt,pete-pjb
|
||||
sentence=Full-featured Graphics Library for Embedded Systems
|
||||
|
|
|
@ -1,82 +1,99 @@
|
|||
/**
|
||||
* @file lv_conf.h
|
||||
* Configuration file for v8.0.2
|
||||
* Configuration file for v8.1.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* COPY THIS FILE AS `lv_conf.h` NEXT TO the `lvgl` FOLDER
|
||||
* Copy this file as `lv_conf.h`
|
||||
* 1. simply next to the `lvgl` folder
|
||||
* 2. or any other places and
|
||||
* - define `LV_CONF_INCLUDE_SIMPLE`
|
||||
* - add the path as include path
|
||||
*/
|
||||
|
||||
/* clang-format off */
|
||||
#if 0 /*Set it to "1" to enable content*/
|
||||
|
||||
#ifndef LV_CONF_H
|
||||
#define LV_CONF_H
|
||||
/*clang-format off*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/*====================
|
||||
COLOR SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/
|
||||
#define LV_COLOR_DEPTH 32
|
||||
#define LV_COLOR_DEPTH 16
|
||||
|
||||
/*Swap the 2 bytes of RGB565 color. Useful if the display has a 8 bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_16_SWAP 0
|
||||
/*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/
|
||||
#define LV_COLOR_16_SWAP 0
|
||||
|
||||
/*Enable more complex drawing routines to manage screens transparency.
|
||||
*Can be used if the UI is above another layer, e.g. an OSD menu or video player.
|
||||
*Requires `LV_COLOR_DEPTH = 32` colors and the screen's `bg_opa` should be set to non LV_OPA_COVER value*/
|
||||
#define LV_COLOR_SCREEN_TRANSP 0
|
||||
#define LV_COLOR_SCREEN_TRANSP 0
|
||||
|
||||
/*Images pixels with this color will not be drawn if they are chroma keyed)*/
|
||||
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/
|
||||
/* Adjust color mix functions rounding. GPUs might calculate color mix (blending) differently.
|
||||
* 0: round down, 64: round up from x.75, 128: round up from half, 192: round up from x.25, 254: round up */
|
||||
#define LV_COLOR_MIX_ROUND_OFS (LV_COLOR_DEPTH == 32 ? 0: 128)
|
||||
|
||||
/*Images pixels with this color will not be drawn if they are chroma keyed)*/
|
||||
#define LV_COLOR_CHROMA_KEY lv_color_hex(0x00ff00) /*pure green*/
|
||||
|
||||
/*=========================
|
||||
MEMORY SETTINGS
|
||||
*=========================*/
|
||||
|
||||
/*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#define LV_MEM_CUSTOM 0
|
||||
#if LV_MEM_CUSTOM == 0
|
||||
/*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
|
||||
# define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/
|
||||
# define LV_MEM_SIZE (32U * 1024U) /*[bytes]*/
|
||||
|
||||
/*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
|
||||
# define LV_MEM_ADR 0 /*0: unused*/
|
||||
# define LV_MEM_ADR 0 /*0: unused*/
|
||||
/*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
|
||||
#if LV_MEM_ADR == 0
|
||||
//#define LV_MEM_POOL_INCLUDE your_alloc_library /* Uncomment if using an external allocator*/
|
||||
//#define LV_MEM_POOL_ALLOC your_alloc /* Uncomment if using an external allocator*/
|
||||
#endif
|
||||
|
||||
#else /*LV_MEM_CUSTOM*/
|
||||
# define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
|
||||
# define LV_MEM_CUSTOM_ALLOC malloc
|
||||
# define LV_MEM_CUSTOM_FREE free
|
||||
# define LV_MEM_CUSTOM_REALLOC realloc
|
||||
# define LV_MEM_CUSTOM_ALLOC malloc
|
||||
# define LV_MEM_CUSTOM_FREE free
|
||||
# define LV_MEM_CUSTOM_REALLOC realloc
|
||||
#endif /*LV_MEM_CUSTOM*/
|
||||
|
||||
/*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
|
||||
*You will see an error log message if there wasn't enough buffers. */
|
||||
#define LV_MEM_BUF_MAX_NUM 16
|
||||
|
||||
/*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
|
||||
#define LV_MEMCPY_MEMSET_STD 0
|
||||
#define LV_MEMCPY_MEMSET_STD 0
|
||||
|
||||
/*====================
|
||||
HAL SETTINGS
|
||||
*====================*/
|
||||
|
||||
/*Default display refresh period. LVG will redraw changed ares with this period time*/
|
||||
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
|
||||
/*Default display refresh period. LVG will redraw changed areas with this period time*/
|
||||
#define LV_DISP_DEF_REFR_PERIOD 30 /*[ms]*/
|
||||
|
||||
/*Input device read period in milliseconds*/
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/
|
||||
#define LV_INDEV_DEF_READ_PERIOD 30 /*[ms]*/
|
||||
|
||||
/*Use a custom tick source that tells the elapsed time in milliseconds.
|
||||
*It removes the need to manually update the tick with `lv_tick_inc()`)*/
|
||||
#define LV_TICK_CUSTOM 0
|
||||
#define LV_TICK_CUSTOM 0
|
||||
#if LV_TICK_CUSTOM
|
||||
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
|
||||
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
|
||||
#define LV_TICK_CUSTOM_INCLUDE "Arduino.h" /*Header for the system time function*/
|
||||
#define LV_TICK_CUSTOM_SYS_TIME_EXPR (millis()) /*Expression evaluating to current system time in ms*/
|
||||
#endif /*LV_TICK_CUSTOM*/
|
||||
|
||||
/*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
|
||||
*(Not so important, you can adjust it to modify default sizes and spaces)*/
|
||||
#define LV_DPI_DEF 130 /*[px/inch]*/
|
||||
#define LV_DPI_DEF 130 /*[px/inch]*/
|
||||
|
||||
/*=======================
|
||||
* FEATURE CONFIGURATION
|
||||
|
@ -94,7 +111,14 @@
|
|||
/*Allow buffering some shadow calculation.
|
||||
*LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
|
||||
*Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/
|
||||
#define LV_SHADOW_CACHE_SIZE 0
|
||||
#define LV_SHADOW_CACHE_SIZE 0
|
||||
|
||||
/* Set number of maximally cached circle data.
|
||||
* The circumference of 1/4 circle are saved for anti-aliasing
|
||||
* radius * 4 bytes are used per circle (the most often used radiuses are saved)
|
||||
* 0: to disable caching */
|
||||
#define LV_CIRCLE_CACHE_SIZE 4
|
||||
|
||||
#endif /*LV_DRAW_COMPLEX*/
|
||||
|
||||
/*Default image cache size. Image caching keeps the images opened.
|
||||
|
@ -102,16 +126,17 @@
|
|||
*With complex image decoders (e.g. PNG or JPG) caching can save the continuous open/decode of images.
|
||||
*However the opened images might consume additional RAM.
|
||||
*0: to disable caching*/
|
||||
#define LV_IMG_CACHE_DEF_SIZE 0
|
||||
#define LV_IMG_CACHE_DEF_SIZE 0
|
||||
|
||||
/*Maximum buffer size to allocate for rotation. Only used if software rotation is enabled in the display driver.*/
|
||||
#define LV_DISP_ROT_MAX_BUF (10*1024)
|
||||
#define LV_DISP_ROT_MAX_BUF (10*1024)
|
||||
|
||||
/*-------------
|
||||
* GPU
|
||||
*-----------*/
|
||||
|
||||
/*Use STM32's DMA2D (aka Chrom Art) GPU*/
|
||||
#define LV_USE_GPU_STM32_DMA2D 0
|
||||
#define LV_USE_GPU_STM32_DMA2D 0
|
||||
#if LV_USE_GPU_STM32_DMA2D
|
||||
/*Must be defined to include path of CMSIS header of target processor
|
||||
e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
||||
|
@ -119,7 +144,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#endif
|
||||
|
||||
/*Use NXP's PXP GPU iMX RTxxx platforms*/
|
||||
#define LV_USE_GPU_NXP_PXP 0
|
||||
#define LV_USE_GPU_NXP_PXP 0
|
||||
#if LV_USE_GPU_NXP_PXP
|
||||
/*1: Add default bare metal and FreeRTOS interrupt handling routines for PXP (lv_gpu_nxp_pxp_osa.c)
|
||||
* and call lv_gpu_nxp_pxp_init() automatically during lv_init(). Note that symbol SDK_OS_FREE_RTOS
|
||||
|
@ -130,14 +155,23 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#endif
|
||||
|
||||
/*Use NXP's VG-Lite GPU iMX RTxxx platforms*/
|
||||
#define LV_USE_GPU_NXP_VG_LITE 0
|
||||
#define LV_USE_GPU_NXP_VG_LITE 0
|
||||
|
||||
/*Use exnternal renderer*/
|
||||
#define LV_USE_EXTERNAL_RENDERER 0
|
||||
|
||||
/*Use SDL renderer API. Requires LV_USE_EXTERNAL_RENDERER*/
|
||||
#define LV_USE_GPU_SDL 0
|
||||
#if LV_USE_GPU_SDL
|
||||
# define LV_GPU_SDL_INCLUDE_PATH <SDL2/SDL.h>
|
||||
#endif
|
||||
|
||||
/*-------------
|
||||
* Logging
|
||||
*-----------*/
|
||||
|
||||
/*Enable the log module*/
|
||||
#define LV_USE_LOG 0 // change to 0 in normal conditions
|
||||
#define LV_USE_LOG 0
|
||||
#if LV_USE_LOG
|
||||
|
||||
/*How important log should be added:
|
||||
|
@ -147,21 +181,21 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
*LV_LOG_LEVEL_ERROR Only critical issue, when the system may fail
|
||||
*LV_LOG_LEVEL_USER Only logs added by the user
|
||||
*LV_LOG_LEVEL_NONE Do not log anything*/
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
# define LV_LOG_LEVEL LV_LOG_LEVEL_WARN
|
||||
|
||||
/*1: Print the log with 'printf';
|
||||
*0: User need to register a callback with `lv_log_register_print_cb()`*/
|
||||
# define LV_LOG_PRINTF 0
|
||||
# define LV_LOG_PRINTF 0
|
||||
|
||||
/*Enable/disable LV_LOG_TRACE in modules that produces a huge number of logs*/
|
||||
# define LV_LOG_TRACE_MEM 1
|
||||
# define LV_LOG_TRACE_TIMER 1
|
||||
# define LV_LOG_TRACE_INDEV 1
|
||||
# define LV_LOG_TRACE_DISP_REFR 1
|
||||
# define LV_LOG_TRACE_EVENT 1
|
||||
# define LV_LOG_TRACE_OBJ_CREATE 1
|
||||
# define LV_LOG_TRACE_LAYOUT 1
|
||||
# define LV_LOG_TRACE_ANIM 1
|
||||
# define LV_LOG_TRACE_MEM 1
|
||||
# define LV_LOG_TRACE_TIMER 1
|
||||
# define LV_LOG_TRACE_INDEV 1
|
||||
# define LV_LOG_TRACE_DISP_REFR 1
|
||||
# define LV_LOG_TRACE_EVENT 1
|
||||
# define LV_LOG_TRACE_OBJ_CREATE 1
|
||||
# define LV_LOG_TRACE_LAYOUT 1
|
||||
# define LV_LOG_TRACE_ANIM 1
|
||||
|
||||
#endif /*LV_USE_LOG*/
|
||||
|
||||
|
@ -178,37 +212,43 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_USE_ASSERT_OBJ 0 /*Check the object's type and existence (e.g. not deleted). (Slow)*/
|
||||
|
||||
/*Add a custom handler when assert happens e.g. to restart the MCU*/
|
||||
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
||||
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
||||
#define LV_ASSERT_HANDLER_INCLUDE <stdint.h>
|
||||
#define LV_ASSERT_HANDLER while(1); /*Halt by default*/
|
||||
|
||||
/*-------------
|
||||
* Others
|
||||
*-----------*/
|
||||
|
||||
/*1: Show CPU usage and FPS count in the right bottom corner*/
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#define LV_USE_PERF_MONITOR 0
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_PERF_MONITOR_POS LV_ALIGN_BOTTOM_RIGHT
|
||||
#endif
|
||||
|
||||
/*1: Show the used memory and the memory fragmentation in the left bottom corner
|
||||
/*1: Show the used memory and the memory fragmentation in the left bottom corner
|
||||
* Requires LV_MEM_CUSTOM = 0*/
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#define LV_USE_MEM_MONITOR 0
|
||||
#if LV_USE_PERF_MONITOR
|
||||
#define LV_USE_MEM_MONITOR_POS LV_ALIGN_BOTTOM_LEFT
|
||||
#endif
|
||||
|
||||
/*1: Draw random colored rectangles over the redrawn areas*/
|
||||
#define LV_USE_REFR_DEBUG 0
|
||||
#define LV_USE_REFR_DEBUG 0
|
||||
|
||||
/*Change the built in (v)snprintf functions*/
|
||||
#define LV_SPRINTF_CUSTOM 0
|
||||
#define LV_SPRINTF_CUSTOM 0
|
||||
#if LV_SPRINTF_CUSTOM
|
||||
# define LV_SPRINTF_INCLUDE <stdio.h>
|
||||
# define lv_snprintf snprintf
|
||||
# define lv_vsnprintf vsnprintf
|
||||
# define lv_snprintf snprintf
|
||||
# define lv_vsnprintf vsnprintf
|
||||
#else /*LV_SPRINTF_CUSTOM*/
|
||||
# define LV_SPRINTF_USE_FLOAT 0
|
||||
#endif /*LV_SPRINTF_CUSTOM*/
|
||||
|
||||
#define LV_USE_USER_DATA 1
|
||||
#define LV_USE_USER_DATA 1
|
||||
|
||||
/*Garbage Collector settings
|
||||
*Used if lvgl is binded to higher level language and the memory is managed by that language*/
|
||||
*Used if lvgl is bound to higher level language and the memory is managed by that language*/
|
||||
#define LV_ENABLE_GC 0
|
||||
#if LV_ENABLE_GC != 0
|
||||
# define LV_GC_INCLUDE "gc.h" /*Include Garbage Collector related things*/
|
||||
|
@ -219,7 +259,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
*====================*/
|
||||
|
||||
/*For big endian systems set to 1*/
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
#define LV_BIG_ENDIAN_SYSTEM 0
|
||||
|
||||
/*Define a custom attribute to `lv_tick_inc` function*/
|
||||
#define LV_ATTRIBUTE_TICK_INC
|
||||
|
@ -231,7 +271,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_ATTRIBUTE_FLUSH_READY
|
||||
|
||||
/*Required alignment size for buffers*/
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE
|
||||
#define LV_ATTRIBUTE_MEM_ALIGN_SIZE 1
|
||||
|
||||
/*Will be added where memories needs to be aligned (with -Os data might not be aligned to boundary by default).
|
||||
* E.g. __attribute__((aligned(4)))*/
|
||||
|
@ -254,7 +294,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_EXPORT_CONST_INT(int_value) struct _silence_gcc_warning /*The default value just prevents GCC warning*/
|
||||
|
||||
/*Extend the default -32k..32k coordinate range to -4M..4M by using int32_t for coordinates instead of int16_t*/
|
||||
#define LV_USE_LARGE_COORD 0
|
||||
#define LV_USE_LARGE_COORD 0
|
||||
|
||||
/*==================
|
||||
* FONT USAGE
|
||||
|
@ -262,27 +302,27 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
|
||||
/*Montserrat fonts with ASCII range and some symbols using bpp = 4
|
||||
*https://fonts.google.com/specimen/Montserrat*/
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
#define LV_FONT_MONTSERRAT_22 0
|
||||
#define LV_FONT_MONTSERRAT_24 0
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
#define LV_FONT_MONTSERRAT_28 0
|
||||
#define LV_FONT_MONTSERRAT_30 0
|
||||
#define LV_FONT_MONTSERRAT_32 0
|
||||
#define LV_FONT_MONTSERRAT_34 0
|
||||
#define LV_FONT_MONTSERRAT_36 0
|
||||
#define LV_FONT_MONTSERRAT_38 0
|
||||
#define LV_FONT_MONTSERRAT_40 0
|
||||
#define LV_FONT_MONTSERRAT_42 0
|
||||
#define LV_FONT_MONTSERRAT_44 0
|
||||
#define LV_FONT_MONTSERRAT_46 0
|
||||
#define LV_FONT_MONTSERRAT_48 0
|
||||
#define LV_FONT_MONTSERRAT_8 0
|
||||
#define LV_FONT_MONTSERRAT_10 0
|
||||
#define LV_FONT_MONTSERRAT_12 0
|
||||
#define LV_FONT_MONTSERRAT_14 1
|
||||
#define LV_FONT_MONTSERRAT_16 0
|
||||
#define LV_FONT_MONTSERRAT_18 0
|
||||
#define LV_FONT_MONTSERRAT_20 0
|
||||
#define LV_FONT_MONTSERRAT_22 0
|
||||
#define LV_FONT_MONTSERRAT_24 0
|
||||
#define LV_FONT_MONTSERRAT_26 0
|
||||
#define LV_FONT_MONTSERRAT_28 0
|
||||
#define LV_FONT_MONTSERRAT_30 0
|
||||
#define LV_FONT_MONTSERRAT_32 0
|
||||
#define LV_FONT_MONTSERRAT_34 0
|
||||
#define LV_FONT_MONTSERRAT_36 0
|
||||
#define LV_FONT_MONTSERRAT_38 0
|
||||
#define LV_FONT_MONTSERRAT_40 0
|
||||
#define LV_FONT_MONTSERRAT_42 0
|
||||
#define LV_FONT_MONTSERRAT_44 0
|
||||
#define LV_FONT_MONTSERRAT_46 0
|
||||
#define LV_FONT_MONTSERRAT_48 0
|
||||
|
||||
/*Demonstrate special features*/
|
||||
#define LV_FONT_MONTSERRAT_12_SUBPX 0
|
||||
|
@ -291,8 +331,8 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_FONT_SIMSUN_16_CJK 0 /*1000 most common CJK radicals*/
|
||||
|
||||
/*Pixel perfect monospace fonts*/
|
||||
#define LV_FONT_UNSCII_8 0
|
||||
#define LV_FONT_UNSCII_16 0
|
||||
#define LV_FONT_UNSCII_8 0
|
||||
#define LV_FONT_UNSCII_16 0
|
||||
|
||||
/*Optionally declare custom fonts here.
|
||||
*You can use these fonts as default font too and they will be available globally.
|
||||
|
@ -305,16 +345,16 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
/*Enable handling large font and/or fonts with a lot of characters.
|
||||
*The limit depends on the font size, font face and bpp.
|
||||
*Compiler error will be triggered if a font needs it.*/
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
#define LV_FONT_FMT_TXT_LARGE 0
|
||||
|
||||
/*Enables/disables support for compressed fonts.*/
|
||||
#define LV_USE_FONT_COMPRESSED 0
|
||||
#define LV_USE_FONT_COMPRESSED 0
|
||||
|
||||
/*Enable subpixel rendering*/
|
||||
#define LV_USE_FONT_SUBPX 0
|
||||
#define LV_USE_FONT_SUBPX 0
|
||||
#if LV_USE_FONT_SUBPX
|
||||
/*Set the pixel order of the display. Physical order of RGB channels. Doesn't matter with "normal" fonts.*/
|
||||
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
|
||||
#define LV_FONT_SUBPX_BGR 0 /*0: RGB; 1:BGR order*/
|
||||
#endif
|
||||
|
||||
/*=================
|
||||
|
@ -330,15 +370,15 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_TXT_ENC LV_TXT_ENC_UTF8
|
||||
|
||||
/*Can break (wrap) texts on these chars*/
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_"
|
||||
#define LV_TXT_BREAK_CHARS " ,.;:-_"
|
||||
|
||||
/*If a word is at least this long, will break wherever "prettiest"
|
||||
*To disable, set to a value <= 0*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 0
|
||||
#define LV_TXT_LINE_BREAK_LONG_LEN 0
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line before a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
|
||||
#define LV_TXT_LINE_BREAK_LONG_PRE_MIN_LEN 3
|
||||
|
||||
/*Minimum number of characters in a long word to put on a line after a break.
|
||||
*Depends on LV_TXT_LINE_BREAK_LONG_LEN.*/
|
||||
|
@ -348,15 +388,15 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
#define LV_TXT_COLOR_CMD "#"
|
||||
|
||||
/*Support bidirectional texts. Allows mixing Left-to-Right and Right-to-Left texts.
|
||||
*The direction will be processed according to the Unicode Bidirectioanl Algorithm:
|
||||
*The direction will be processed according to the Unicode Bidirectional Algorithm:
|
||||
*https://www.w3.org/International/articles/inline-bidi-markup/uba-basics*/
|
||||
#define LV_USE_BIDI 0
|
||||
#define LV_USE_BIDI 0
|
||||
#if LV_USE_BIDI
|
||||
/*Set the default direction. Supported values:
|
||||
*`LV_BASE_DIR_LTR` Left-to-Right
|
||||
*`LV_BASE_DIR_RTL` Right-to-Left
|
||||
*`LV_BASE_DIR_AUTO` detect texts base direction*/
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||
#define LV_BIDI_BASE_DIR_DEF LV_BASE_DIR_AUTO
|
||||
#endif
|
||||
|
||||
/*Enable Arabic/Persian processing
|
||||
|
@ -369,48 +409,47 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
|
||||
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||
|
||||
#define LV_USE_ARC 1
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
#define LV_USE_ANIMIMG 1
|
||||
#define LV_USE_ANIMIMG 1
|
||||
|
||||
#define LV_USE_BAR 1
|
||||
#define LV_USE_BAR 1
|
||||
|
||||
#define LV_USE_BTN 1
|
||||
#define LV_USE_BTN 1
|
||||
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
#define LV_USE_BTNMATRIX 1
|
||||
|
||||
#define LV_USE_CANVAS 1
|
||||
#define LV_USE_CANVAS 1
|
||||
|
||||
#define LV_USE_CHECKBOX 1
|
||||
#define LV_USE_CHECKBOX 1
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_DROPDOWN 1 /*Requires: lv_label*/
|
||||
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_IMG 1 /*Requires: lv_label*/
|
||||
|
||||
#define LV_USE_LABEL 1
|
||||
#define LV_USE_LABEL 1
|
||||
#if LV_USE_LABEL
|
||||
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||
# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||
# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_LINE 1
|
||||
#define LV_USE_LINE 1
|
||||
|
||||
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
|
||||
#define LV_USE_ROLLER 1 /*Requires: lv_label*/
|
||||
#if LV_USE_ROLLER
|
||||
# define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/
|
||||
# define LV_ROLLER_INF_PAGES 7 /*Number of extra "pages" when the roller is infinite*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
|
||||
#define LV_USE_SLIDER 1 /*Requires: lv_bar*/
|
||||
|
||||
#define LV_USE_SWITCH 1
|
||||
#define LV_USE_SWITCH 1
|
||||
|
||||
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
|
||||
#define LV_USE_TEXTAREA 1 /*Requires: lv_label*/
|
||||
#if LV_USE_TEXTAREA != 0
|
||||
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||
# define LV_TEXTAREA_DEF_PWD_SHOW_TIME 1500 /*ms*/
|
||||
#endif
|
||||
|
||||
#define LV_USE_TABLE 1
|
||||
#define LV_USE_TABLE 1
|
||||
|
||||
/*==================
|
||||
* EXTRA COMPONENTS
|
||||
|
@ -419,7 +458,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
/*-----------
|
||||
* Widgets
|
||||
*----------*/
|
||||
#define LV_USE_CALENDAR 1
|
||||
#define LV_USE_CALENDAR 1
|
||||
#if LV_USE_CALENDAR
|
||||
# define LV_CALENDAR_WEEK_STARTS_MONDAY 0
|
||||
# if LV_CALENDAR_WEEK_STARTS_MONDAY
|
||||
|
@ -429,81 +468,133 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||
# endif
|
||||
|
||||
# define LV_CALENDAR_DEFAULT_MONTH_NAMES {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
|
||||
# define LV_USE_CALENDAR_HEADER_ARROW 1
|
||||
# define LV_USE_CALENDAR_HEADER_DROPDOWN 1
|
||||
# define LV_USE_CALENDAR_HEADER_ARROW 1
|
||||
# define LV_USE_CALENDAR_HEADER_DROPDOWN 1
|
||||
#endif /*LV_USE_CALENDAR*/
|
||||
|
||||
#define LV_USE_CHART 1
|
||||
#define LV_USE_CHART 1
|
||||
|
||||
#define LV_USE_COLORWHEEL 1
|
||||
#define LV_USE_COLORWHEEL 1
|
||||
|
||||
#define LV_USE_IMGBTN 1
|
||||
#define LV_USE_IMGBTN 1
|
||||
|
||||
#define LV_USE_KEYBOARD 1
|
||||
#define LV_USE_KEYBOARD 1
|
||||
|
||||
#define LV_USE_LED 1
|
||||
#define LV_USE_LED 1
|
||||
|
||||
#define LV_USE_LIST 1
|
||||
#define LV_USE_LIST 1
|
||||
|
||||
#define LV_USE_METER 1
|
||||
#define LV_USE_METER 1
|
||||
|
||||
#define LV_USE_MSGBOX 1
|
||||
#define LV_USE_MSGBOX 1
|
||||
|
||||
#define LV_USE_SPINBOX 1
|
||||
#define LV_USE_SPINBOX 1
|
||||
|
||||
#define LV_USE_SPINNER 1
|
||||
#define LV_USE_SPINNER 1
|
||||
|
||||
#define LV_USE_TABVIEW 1
|
||||
#define LV_USE_TABVIEW 1
|
||||
|
||||
#define LV_USE_TILEVIEW 1
|
||||
#define LV_USE_TILEVIEW 1
|
||||
|
||||
#define LV_USE_WIN 1
|
||||
#define LV_USE_WIN 1
|
||||
|
||||
#define LV_USE_SPAN 1
|
||||
#define LV_USE_SPAN 1
|
||||
#if LV_USE_SPAN
|
||||
/*A line text can contain maximum num of span descriptor */
|
||||
# define LV_SPAN_SNIPPET_STACK_SIZE 64
|
||||
# define LV_SPAN_SNIPPET_STACK_SIZE 64
|
||||
#endif
|
||||
|
||||
/*-----------
|
||||
* Themes
|
||||
*----------*/
|
||||
|
||||
/*A simple, impressive and very complete theme*/
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#define LV_USE_THEME_DEFAULT 1
|
||||
#if LV_USE_THEME_DEFAULT
|
||||
|
||||
/*0: Light mode; 1: Dark mode*/
|
||||
# define LV_THEME_DEFAULT_DARK 0
|
||||
# define LV_THEME_DEFAULT_DARK 0
|
||||
|
||||
/*1: Enable grow on press*/
|
||||
# define LV_THEME_DEFAULT_GROW 1
|
||||
# define LV_THEME_DEFAULT_GROW 1
|
||||
|
||||
/*Default transition time in [ms]*/
|
||||
# define LV_THEME_DEFAULT_TRANSITON_TIME 80
|
||||
# define LV_THEME_DEFAULT_TRANSITION_TIME 80
|
||||
#endif /*LV_USE_THEME_DEFAULT*/
|
||||
|
||||
/*An very simple them that is a good starting point for a custom theme*/
|
||||
#define LV_USE_THEME_BASIC 1
|
||||
/*A very simple theme that is a good starting point for a custom theme*/
|
||||
#define LV_USE_THEME_BASIC 1
|
||||
|
||||
/*A theme designed for monochrome displays*/
|
||||
#define LV_USE_THEME_MONO 1
|
||||
#define LV_USE_THEME_MONO 1
|
||||
|
||||
/*-----------
|
||||
* Layouts
|
||||
*----------*/
|
||||
|
||||
/*A layout similar to Flexbox in CSS.*/
|
||||
#define LV_USE_FLEX 1
|
||||
#define LV_USE_FLEX 1
|
||||
|
||||
/*A layout similar to Grid in CSS.*/
|
||||
#define LV_USE_GRID 1
|
||||
#define LV_USE_GRID 1
|
||||
|
||||
/*---------------------
|
||||
* 3rd party libraries
|
||||
*--------------------*/
|
||||
|
||||
/*File system interfaces for common APIs
|
||||
*To enable set a driver letter for that API*/
|
||||
#define LV_USE_FS_STDIO '\0' /*Uses fopen, fread, etc*/
|
||||
//#define LV_FS_STDIO_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */
|
||||
|
||||
#define LV_USE_FS_POSIX '\0' /*Uses open, read, etc*/
|
||||
//#define LV_FS_POSIX_PATH "/home/john/" /*Set the working directory. If commented it will be "./" */
|
||||
|
||||
#define LV_USE_FS_WIN32 '\0' /*Uses CreateFile, ReadFile, etc*/
|
||||
//#define LV_FS_WIN32_PATH "C:\\Users\\john\\" /*Set the working directory. If commented it will be ".\\" */
|
||||
|
||||
#define LV_USE_FS_FATFS '\0' /*Uses f_open, f_read, etc*/
|
||||
|
||||
/*PNG decoder library*/
|
||||
#define LV_USE_PNG 0
|
||||
|
||||
/*BMP decoder library*/
|
||||
#define LV_USE_BMP 0
|
||||
|
||||
/* JPG + split JPG decoder library.
|
||||
* Split JPG is a custom format optimized for embedded systems. */
|
||||
#define LV_USE_SJPG 0
|
||||
|
||||
/*GIF decoder library*/
|
||||
#define LV_USE_GIF 0
|
||||
|
||||
/*QR code library*/
|
||||
#define LV_USE_QRCODE 0
|
||||
|
||||
/*FreeType library*/
|
||||
#define LV_USE_FREETYPE 0
|
||||
#if LV_USE_FREETYPE
|
||||
/*Memory used by FreeType to cache characters [bytes] (-1: no caching)*/
|
||||
# define LV_FREETYPE_CACHE_SIZE (16 * 1024)
|
||||
#endif
|
||||
|
||||
/*Rlottie library*/
|
||||
#define LV_USE_RLOTTIE 0
|
||||
|
||||
/*-----------
|
||||
* Others
|
||||
*----------*/
|
||||
|
||||
/*1: Enable API to take snapshot for object*/
|
||||
#define LV_USE_SNAPSHOT 1
|
||||
|
||||
|
||||
/*==================
|
||||
* EXAMPLES
|
||||
*==================*/
|
||||
|
||||
/*Enable the examples to be built with the library*/
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
#define LV_BUILD_EXAMPLES 1
|
||||
|
||||
/*--END OF LV_CONF_H--*/
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@ extern "C" {
|
|||
* CURRENT VERSION OF LVGL
|
||||
***************************/
|
||||
#define LVGL_VERSION_MAJOR 8
|
||||
#define LVGL_VERSION_MINOR 0
|
||||
#define LVGL_VERSION_PATCH 2
|
||||
#define LVGL_VERSION_MINOR 1
|
||||
#define LVGL_VERSION_PATCH 0
|
||||
#define LVGL_VERSION_INFO ""
|
||||
|
||||
/*********************
|
||||
|
@ -25,14 +25,16 @@ extern "C" {
|
|||
#include "src/misc/lv_log.h"
|
||||
#include "src/misc/lv_timer.h"
|
||||
#include "src/misc/lv_math.h"
|
||||
#include "src/misc/lv_mem.h"
|
||||
#include "src/misc/lv_async.h"
|
||||
#include "src/misc/lv_anim_timeline.h"
|
||||
#include "src/misc/lv_printf.h"
|
||||
|
||||
#include "src/hal/lv_hal.h"
|
||||
|
||||
#include "src/core/lv_obj.h"
|
||||
#include "src/core/lv_group.h"
|
||||
#include "src/core/lv_indev.h"
|
||||
|
||||
#include "src/core/lv_refr.h"
|
||||
#include "src/core/lv_disp.h"
|
||||
#include "src/core/lv_theme.h"
|
||||
|
@ -40,7 +42,6 @@ extern "C" {
|
|||
#include "src/font/lv_font.h"
|
||||
#include "src/font/lv_font_loader.h"
|
||||
#include "src/font/lv_font_fmt_txt.h"
|
||||
#include "src/misc/lv_printf.h"
|
||||
|
||||
#include "src/widgets/lv_arc.h"
|
||||
#include "src/widgets/lv_btn.h"
|
||||
|
@ -69,6 +70,8 @@ extern "C" {
|
|||
#include "src/extra/widgets/lv_widgets.h"
|
||||
#include "src/extra/layouts/lv_layouts.h"
|
||||
#include "src/extra/themes/lv_themes.h"
|
||||
#include "src/extra/others/lv_others.h"
|
||||
#include "src/extra/libs/lv_libs.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
|
|
|
@ -82,15 +82,24 @@ void lv_disp_load_scr(lv_obj_t * scr)
|
|||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(scr);
|
||||
if(!d) return; /*Shouldn't happen, just to be sure*/
|
||||
|
||||
lv_obj_t * old_scr = d->act_scr;
|
||||
|
||||
if(d->act_scr) lv_event_send(old_scr, LV_EVENT_SCREEN_UNLOAD_START, NULL);
|
||||
if(d->act_scr) lv_event_send(scr, LV_EVENT_SCREEN_LOAD_START, NULL);
|
||||
|
||||
d->act_scr = scr;
|
||||
|
||||
if(d->act_scr) lv_event_send(scr, LV_EVENT_SCREEN_LOADED, NULL);
|
||||
if(d->act_scr) lv_event_send(old_scr, LV_EVENT_SCREEN_UNLOADED, NULL);
|
||||
|
||||
lv_obj_invalidate(scr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
||||
* @param disp pointer to display which top layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp)
|
||||
{
|
||||
|
@ -106,8 +115,8 @@ lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp)
|
|||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top
|
||||
* layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
* @param disp pointer to display which sys. layer should be retrieved. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
|
||||
{
|
||||
|
@ -121,20 +130,18 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the theme of a display
|
||||
* Set the theme of a display
|
||||
* @param disp pointer to a display
|
||||
* @return the display's theme (can be NULL)
|
||||
*/
|
||||
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
disp->theme = th;
|
||||
|
||||
if(disp->screen_cnt == 3 &&
|
||||
lv_obj_get_child_cnt(disp->screens[0]) == 0 &&
|
||||
lv_obj_get_child_cnt(disp->screens[1]) == 0 &&
|
||||
lv_obj_get_child_cnt(disp->screens[2]) == 0)
|
||||
{
|
||||
lv_obj_get_child_cnt(disp->screens[0]) == 0 &&
|
||||
lv_obj_get_child_cnt(disp->screens[1]) == 0 &&
|
||||
lv_obj_get_child_cnt(disp->screens[2]) == 0) {
|
||||
lv_theme_apply(disp->screens[0]);
|
||||
}
|
||||
}
|
||||
|
@ -145,7 +152,7 @@ void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
|
|||
*/
|
||||
lv_theme_t * lv_disp_get_theme(lv_disp_t * disp)
|
||||
{
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
if(disp == NULL) disp = lv_disp_get_default();
|
||||
return disp->theme;
|
||||
}
|
||||
|
||||
|
@ -191,7 +198,7 @@ void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src)
|
|||
}
|
||||
|
||||
/**
|
||||
* Opacity of the background
|
||||
* Set opacity of the background
|
||||
* @param disp pointer to a display
|
||||
* @param opa opacity (0..255)
|
||||
*/
|
||||
|
@ -220,16 +227,21 @@ void lv_disp_set_bg_opa(lv_disp_t * disp, lv_opa_t opa)
|
|||
*/
|
||||
void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t time, uint32_t delay, bool auto_del)
|
||||
{
|
||||
|
||||
lv_disp_t * d = lv_obj_get_disp(new_scr);
|
||||
lv_obj_t * act_scr = lv_scr_act();
|
||||
|
||||
if(d->del_prev && act_scr != d->scr_to_load && d->scr_to_load) {
|
||||
lv_obj_del(act_scr);
|
||||
/*If an other screen load animation is in progress
|
||||
*make target screen loaded immediately. */
|
||||
if(d->scr_to_load && act_scr != d->scr_to_load) {
|
||||
lv_disp_load_scr(d->scr_to_load);
|
||||
lv_anim_del(d->scr_to_load, NULL);
|
||||
lv_obj_set_pos(d->scr_to_load, 0, 0);
|
||||
lv_obj_remove_local_style_prop(d->scr_to_load, LV_STYLE_OPA, 0);
|
||||
|
||||
if(d->del_prev) {
|
||||
lv_obj_del(act_scr);
|
||||
}
|
||||
act_scr = d->scr_to_load;
|
||||
}
|
||||
|
||||
|
@ -323,13 +335,16 @@ void lv_scr_load_anim(lv_obj_t * new_scr, lv_scr_load_anim_t anim_type, uint32_t
|
|||
break;
|
||||
}
|
||||
|
||||
lv_event_send(act_scr, LV_EVENT_SCREEN_UNLOAD_START, NULL);
|
||||
|
||||
lv_anim_start(&a_new);
|
||||
lv_anim_start(&a_old);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get elapsed time since last user activity on a display (e.g. click)
|
||||
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
|
||||
* @param disp pointer to a display (NULL to get the overall smallest inactivity)
|
||||
* @return elapsed ticks (milliseconds) since the last activity
|
||||
*/
|
||||
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
|
||||
|
@ -350,7 +365,7 @@ uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp)
|
|||
|
||||
/**
|
||||
* Manually trigger an activity on a display
|
||||
* @param disp pointer to an display (NULL to use the default display)
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
*/
|
||||
void lv_disp_trig_activity(lv_disp_t * disp)
|
||||
{
|
||||
|
@ -365,7 +380,7 @@ void lv_disp_trig_activity(lv_disp_t * disp)
|
|||
|
||||
/**
|
||||
* Clean any CPU cache that is related to the display.
|
||||
* @param disp pointer to an display (NULL to use the default display)
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
*/
|
||||
void lv_disp_clean_dcache(lv_disp_t * disp)
|
||||
{
|
||||
|
@ -403,9 +418,11 @@ lv_timer_t * _lv_disp_get_refr_timer(lv_disp_t * disp)
|
|||
static void scr_load_anim_start(lv_anim_t * a)
|
||||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||
d->prev_scr = lv_scr_act();
|
||||
|
||||
lv_disp_load_scr(a->var);
|
||||
d->prev_scr = lv_scr_act();
|
||||
d->act_scr = a->var;
|
||||
|
||||
lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOAD_START, NULL);
|
||||
}
|
||||
|
||||
static void opa_scale_anim(void * obj, int32_t v)
|
||||
|
@ -427,6 +444,9 @@ static void scr_anim_ready(lv_anim_t * a)
|
|||
{
|
||||
lv_disp_t * d = lv_obj_get_disp(a->var);
|
||||
|
||||
lv_event_send(d->act_scr, LV_EVENT_SCREEN_LOADED, NULL);
|
||||
lv_event_send(d->prev_scr, LV_EVENT_SCREEN_UNLOADED, NULL);
|
||||
|
||||
if(d->prev_scr && d->del_prev) lv_obj_del(d->prev_scr);
|
||||
d->prev_scr = NULL;
|
||||
d->scr_to_load = NULL;
|
||||
|
|
|
@ -67,22 +67,21 @@ void lv_disp_load_scr(lv_obj_t * scr);
|
|||
/**
|
||||
* Return with the top layer. (Same on every screen and it is above the normal screen layer)
|
||||
* @param disp pointer to display which top layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
* @return pointer to the top layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_top(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Return with the sys. layer. (Same on every screen and it is above the normal screen and the top
|
||||
* layer)
|
||||
* @param disp pointer to display which sys. layer should be get. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
* @param disp pointer to display which sys. layer should be retrieved. (NULL to use the default screen)
|
||||
* @return pointer to the sys layer object (transparent screen sized lv_obj)
|
||||
*/
|
||||
lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Get the theme of a display
|
||||
* Set the theme of a display
|
||||
* @param disp pointer to a display
|
||||
* @return the display's theme (can be NULL)
|
||||
*/
|
||||
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th);
|
||||
|
||||
|
@ -108,7 +107,7 @@ void lv_disp_set_bg_color(lv_disp_t * disp, lv_color_t color);
|
|||
void lv_disp_set_bg_image(lv_disp_t * disp, const void * img_src);
|
||||
|
||||
/**
|
||||
* Opacity of the background
|
||||
* Set opacity of the background
|
||||
* @param disp pointer to a display
|
||||
* @param opa opacity (0..255)
|
||||
*/
|
||||
|
@ -126,20 +125,20 @@ void lv_scr_load_anim(lv_obj_t * scr, lv_scr_load_anim_t anim_type, uint32_t tim
|
|||
|
||||
/**
|
||||
* Get elapsed time since last user activity on a display (e.g. click)
|
||||
* @param disp pointer to an display (NULL to get the overall smallest inactivity)
|
||||
* @param disp pointer to a display (NULL to get the overall smallest inactivity)
|
||||
* @return elapsed ticks (milliseconds) since the last activity
|
||||
*/
|
||||
uint32_t lv_disp_get_inactive_time(const lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Manually trigger an activity on a display
|
||||
* @param disp pointer to an display (NULL to use the default display)
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
*/
|
||||
void lv_disp_trig_activity(lv_disp_t * disp);
|
||||
|
||||
/**
|
||||
* Clean any CPU cache that is related to the display.
|
||||
* @param disp pointer to an display (NULL to use the default display)
|
||||
* @param disp pointer to a display (NULL to use the default display)
|
||||
*/
|
||||
void lv_disp_clean_dcache(lv_disp_t * disp);
|
||||
|
||||
|
@ -229,7 +228,7 @@ static inline lv_coord_t lv_dpx(lv_coord_t n)
|
|||
* considering the DPI of the given display.
|
||||
* It ensures that e.g. `lv_dpx(100)` will have the same physical size regardless to the
|
||||
* DPI of the display.
|
||||
* @param obj an display whose dpi should be considered
|
||||
* @param obj a display whose dpi should be considered
|
||||
* @param n the number of pixels to scale
|
||||
* @return `n x current_dpi/160`
|
||||
*/
|
||||
|
|
|
@ -17,18 +17,19 @@
|
|||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct _lv_event_dsc_t{
|
||||
typedef struct _lv_event_dsc_t {
|
||||
lv_event_cb_t cb;
|
||||
void * user_data;
|
||||
lv_event_code_t filter :8;
|
||||
}lv_event_dsc_t;
|
||||
lv_event_code_t filter : 8;
|
||||
} lv_event_dsc_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static lv_event_dsc_t * lv_obj_get_event_dsc(const lv_obj_t * obj, uint32_t id);
|
||||
static lv_res_t event_send_core(lv_event_t * e);
|
||||
static bool event_is_bubbled(lv_event_code_t e);
|
||||
static bool event_is_bubbled(lv_event_t * e);
|
||||
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -39,9 +40,9 @@ static lv_event_t * event_head;
|
|||
* MACROS
|
||||
**********************/
|
||||
#if LV_LOG_TRACE_EVENT
|
||||
# define EVENT_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
|
||||
#define EVENT_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define EVENT_TRACE(...)
|
||||
#define EVENT_TRACE(...)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
@ -147,13 +148,15 @@ void _lv_event_mark_deleted(lv_obj_t * obj)
|
|||
}
|
||||
|
||||
|
||||
struct _lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data)
|
||||
struct _lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter,
|
||||
void * user_data)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_obj_allocate_spec_attr(obj);
|
||||
|
||||
obj->spec_attr->event_dsc_cnt++;
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
|
||||
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
|
||||
|
||||
obj->spec_attr->event_dsc[obj->spec_attr->event_dsc_cnt - 1].cb = event_cb;
|
||||
|
@ -170,14 +173,14 @@ bool lv_obj_remove_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
|
|||
|
||||
int32_t i = 0;
|
||||
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
|
||||
if(obj->spec_attr->event_dsc[i].cb == event_cb) {
|
||||
if(event_cb == NULL || obj->spec_attr->event_dsc[i].cb == event_cb) {
|
||||
/*Shift the remaining event handlers forward*/
|
||||
for(; i < (obj->spec_attr->event_dsc_cnt-1); i++) {
|
||||
obj->spec_attr->event_dsc[i].cb = obj->spec_attr->event_dsc[i+1].cb;
|
||||
obj->spec_attr->event_dsc[i].user_data = obj->spec_attr->event_dsc[i+1].user_data;
|
||||
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
|
||||
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
|
||||
}
|
||||
obj->spec_attr->event_dsc_cnt--;
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
|
||||
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
|
||||
return true;
|
||||
}
|
||||
|
@ -187,6 +190,32 @@ bool lv_obj_remove_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool lv_obj_remove_event_cb_with_user_data(lv_obj_t * obj, lv_event_cb_t event_cb, const void * user_data)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(obj->spec_attr == NULL) return false;
|
||||
|
||||
int32_t i = 0;
|
||||
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
|
||||
if((event_cb == NULL || obj->spec_attr->event_dsc[i].cb) &&
|
||||
obj->spec_attr->event_dsc[i].user_data == user_data) {
|
||||
/*Shift the remaining event handlers forward*/
|
||||
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
|
||||
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
|
||||
}
|
||||
obj->spec_attr->event_dsc_cnt--;
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
|
||||
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*No event handler found*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool lv_obj_remove_event_dsc(lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
@ -196,12 +225,12 @@ bool lv_obj_remove_event_dsc(lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc)
|
|||
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
|
||||
if(&obj->spec_attr->event_dsc[i] == event_dsc) {
|
||||
/*Shift the remaining event handlers forward*/
|
||||
for(; i < (obj->spec_attr->event_dsc_cnt-1); i++) {
|
||||
obj->spec_attr->event_dsc[i].cb = obj->spec_attr->event_dsc[i+1].cb;
|
||||
obj->spec_attr->event_dsc[i].user_data = obj->spec_attr->event_dsc[i+1].user_data;
|
||||
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
|
||||
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
|
||||
}
|
||||
obj->spec_attr->event_dsc_cnt--;
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
|
||||
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
|
||||
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
|
||||
return true;
|
||||
}
|
||||
|
@ -215,24 +244,24 @@ lv_indev_t * lv_event_get_indev(lv_event_t * e)
|
|||
{
|
||||
|
||||
if(e->code == LV_EVENT_PRESSED ||
|
||||
e->code == LV_EVENT_PRESSING ||
|
||||
e->code == LV_EVENT_PRESS_LOST ||
|
||||
e->code == LV_EVENT_SHORT_CLICKED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
e->code == LV_EVENT_CLICKED ||
|
||||
e->code == LV_EVENT_RELEASED ||
|
||||
e->code == LV_EVENT_SCROLL_BEGIN ||
|
||||
e->code == LV_EVENT_SCROLL_END ||
|
||||
e->code == LV_EVENT_SCROLL ||
|
||||
e->code == LV_EVENT_GESTURE ||
|
||||
e->code == LV_EVENT_KEY ||
|
||||
e->code == LV_EVENT_FOCUSED ||
|
||||
e->code == LV_EVENT_DEFOCUSED ||
|
||||
e->code == LV_EVENT_LEAVE)
|
||||
{
|
||||
e->code == LV_EVENT_PRESSING ||
|
||||
e->code == LV_EVENT_PRESS_LOST ||
|
||||
e->code == LV_EVENT_SHORT_CLICKED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED ||
|
||||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
|
||||
e->code == LV_EVENT_CLICKED ||
|
||||
e->code == LV_EVENT_RELEASED ||
|
||||
e->code == LV_EVENT_SCROLL_BEGIN ||
|
||||
e->code == LV_EVENT_SCROLL_END ||
|
||||
e->code == LV_EVENT_SCROLL ||
|
||||
e->code == LV_EVENT_GESTURE ||
|
||||
e->code == LV_EVENT_KEY ||
|
||||
e->code == LV_EVENT_FOCUSED ||
|
||||
e->code == LV_EVENT_DEFOCUSED ||
|
||||
e->code == LV_EVENT_LEAVE) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -240,11 +269,11 @@ lv_indev_t * lv_event_get_indev(lv_event_t * e)
|
|||
|
||||
lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_PART_BEGIN||
|
||||
e->code == LV_EVENT_DRAW_PART_END)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_PART_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_PART_END) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -253,14 +282,14 @@ lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
|
|||
const lv_area_t * lv_event_get_clip_area(lv_event_t * e)
|
||||
{
|
||||
if(e->code == LV_EVENT_DRAW_MAIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_END ||
|
||||
e->code == LV_EVENT_DRAW_POST ||
|
||||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_POST_END)
|
||||
{
|
||||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_MAIN_END ||
|
||||
e->code == LV_EVENT_DRAW_POST ||
|
||||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
|
||||
e->code == LV_EVENT_DRAW_POST_END) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -270,7 +299,8 @@ const lv_area_t * lv_event_get_old_size(lv_event_t * e)
|
|||
{
|
||||
if(e->code == LV_EVENT_SIZE_CHANGED) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -282,7 +312,8 @@ uint32_t lv_event_get_key(lv_event_t * e)
|
|||
uint32_t * k = lv_event_get_param(e);
|
||||
if(k) return *k;
|
||||
else return 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
|
@ -292,7 +323,8 @@ lv_anim_t * lv_event_get_scroll_anim(lv_event_t * e)
|
|||
{
|
||||
if(e->code == LV_EVENT_SCROLL_BEGIN) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
|
@ -303,7 +335,8 @@ void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size)
|
|||
if(e->code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t * cur_size = lv_event_get_param(e);
|
||||
*cur_size = LV_MAX(*cur_size, size);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +345,8 @@ lv_point_t * lv_event_get_self_size_info(lv_event_t * e)
|
|||
{
|
||||
if(e->code == LV_EVENT_GET_SELF_SIZE) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
|
@ -322,7 +356,8 @@ lv_hit_test_info_t * lv_event_get_hit_test_info(lv_event_t * e)
|
|||
{
|
||||
if(e->code == LV_EVENT_HIT_TEST) {
|
||||
return lv_event_get_param(e);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return 0;
|
||||
}
|
||||
|
@ -333,7 +368,8 @@ const lv_area_t * lv_event_get_cover_area(lv_event_t * e)
|
|||
if(e->code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * p = lv_event_get_param(e);
|
||||
return p->area;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
return NULL;
|
||||
}
|
||||
|
@ -344,7 +380,8 @@ void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res)
|
|||
if(e->code == LV_EVENT_COVER_CHECK) {
|
||||
lv_cover_check_info_t * p = lv_event_get_param(e);
|
||||
if(res > p->res) p->res = res; /*Save only "stronger" results*/
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Not interpreted with this event code");
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +402,7 @@ static lv_event_dsc_t * lv_obj_get_event_dsc(const lv_obj_t * obj, uint32_t id)
|
|||
|
||||
static lv_res_t event_send_core(lv_event_t * e)
|
||||
{
|
||||
EVENT_TRACE("Sending event %d to %p with %p param", e->code, e->current_target, e->param);
|
||||
EVENT_TRACE("Sending event %d to %p with %p param", e->code, (void *)e->current_target, e->param);
|
||||
|
||||
/*Call the input device's feedback callback if set*/
|
||||
lv_indev_t * indev_act = lv_indev_get_act();
|
||||
|
@ -391,39 +428,53 @@ static lv_res_t event_send_core(lv_event_t * e)
|
|||
event_dsc = lv_obj_get_event_dsc(e->current_target, i);
|
||||
}
|
||||
|
||||
if(res == LV_RES_OK && event_is_bubbled(e->code)) {
|
||||
if(lv_obj_has_flag(e->current_target, LV_OBJ_FLAG_EVENT_BUBBLE) && e->current_target->parent) {
|
||||
if(res == LV_RES_OK && e->current_target->parent && event_is_bubbled(e))
|
||||
{
|
||||
e->current_target = e->current_target->parent;
|
||||
res = event_send_core(e);
|
||||
if(res != LV_RES_OK) return LV_RES_INV;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static bool event_is_bubbled(lv_event_code_t e)
|
||||
static bool event_is_bubbled(lv_event_t * e)
|
||||
{
|
||||
switch(e) {
|
||||
case LV_EVENT_HIT_TEST:
|
||||
case LV_EVENT_COVER_CHECK:
|
||||
case LV_EVENT_REFR_EXT_DRAW_SIZE:
|
||||
case LV_EVENT_DRAW_MAIN_BEGIN:
|
||||
case LV_EVENT_DRAW_MAIN:
|
||||
case LV_EVENT_DRAW_MAIN_END:
|
||||
case LV_EVENT_DRAW_POST_BEGIN:
|
||||
case LV_EVENT_DRAW_POST:
|
||||
case LV_EVENT_DRAW_POST_END:
|
||||
case LV_EVENT_DRAW_PART_BEGIN:
|
||||
case LV_EVENT_DRAW_PART_END:
|
||||
case LV_EVENT_REFRESH:
|
||||
case LV_EVENT_DELETE:
|
||||
case LV_EVENT_CHILD_CHANGED:
|
||||
case LV_EVENT_SIZE_CHANGED:
|
||||
case LV_EVENT_STYLE_CHANGED:
|
||||
case LV_EVENT_GET_SELF_SIZE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
/*Event codes that always bubble*/
|
||||
switch(e->code) {
|
||||
case LV_EVENT_CHILD_CREATED:
|
||||
case LV_EVENT_CHILD_DELETED:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*Check other codes only if bubbling is enabled*/
|
||||
if(lv_obj_has_flag(e->current_target, LV_OBJ_FLAG_EVENT_BUBBLE) == false) return false;
|
||||
|
||||
switch(e->code) {
|
||||
case LV_EVENT_HIT_TEST:
|
||||
case LV_EVENT_COVER_CHECK:
|
||||
case LV_EVENT_REFR_EXT_DRAW_SIZE:
|
||||
case LV_EVENT_DRAW_MAIN_BEGIN:
|
||||
case LV_EVENT_DRAW_MAIN:
|
||||
case LV_EVENT_DRAW_MAIN_END:
|
||||
case LV_EVENT_DRAW_POST_BEGIN:
|
||||
case LV_EVENT_DRAW_POST:
|
||||
case LV_EVENT_DRAW_POST_END:
|
||||
case LV_EVENT_DRAW_PART_BEGIN:
|
||||
case LV_EVENT_DRAW_PART_END:
|
||||
case LV_EVENT_REFRESH:
|
||||
case LV_EVENT_DELETE:
|
||||
case LV_EVENT_CHILD_CREATED:
|
||||
case LV_EVENT_CHILD_DELETED:
|
||||
case LV_EVENT_CHILD_CHANGED:
|
||||
case LV_EVENT_SIZE_CHANGED:
|
||||
case LV_EVENT_STYLE_CHANGED:
|
||||
case LV_EVENT_GET_SELF_SIZE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,14 +72,20 @@ typedef enum {
|
|||
|
||||
/** Other events*/
|
||||
LV_EVENT_DELETE, /**< Object is being deleted*/
|
||||
LV_EVENT_CHILD_CHANGED, /**< Child was removed/added*/
|
||||
LV_EVENT_CHILD_CHANGED, /**< Child was removed, added, or its size, position were changed */
|
||||
LV_EVENT_CHILD_CREATED, /**< Child was created, always bubbles up to all parents*/
|
||||
LV_EVENT_CHILD_DELETED, /**< Child was deleted, always bubbles up to all parents*/
|
||||
LV_EVENT_SCREEN_UNLOAD_START, /**< A screen unload started, fired immediately when scr_load is called*/
|
||||
LV_EVENT_SCREEN_LOAD_START, /**< A screen load started, fired when the screen change delay is expired*/
|
||||
LV_EVENT_SCREEN_LOADED, /**< A screen was loaded*/
|
||||
LV_EVENT_SCREEN_UNLOADED, /**< A screen was unloaded*/
|
||||
LV_EVENT_SIZE_CHANGED, /**< Object coordinates/size have changed*/
|
||||
LV_EVENT_STYLE_CHANGED, /**< Object's style has changed*/
|
||||
LV_EVENT_LAYOUT_CHANGED, /**< The children position has changed due to a layout recalculation*/
|
||||
LV_EVENT_GET_SELF_SIZE, /**< Get the internal size of a widget*/
|
||||
|
||||
_LV_EVENT_LAST /** Number of default events*/
|
||||
}lv_event_code_t;
|
||||
} lv_event_code_t;
|
||||
|
||||
typedef struct _lv_event_t {
|
||||
struct _lv_obj_t * target;
|
||||
|
@ -88,8 +94,8 @@ typedef struct _lv_event_t {
|
|||
void * user_data;
|
||||
void * param;
|
||||
struct _lv_event_t * prev;
|
||||
uint8_t deleted :1;
|
||||
}lv_event_t;
|
||||
uint8_t deleted : 1;
|
||||
} lv_event_t;
|
||||
|
||||
/**
|
||||
* @brief Event callback.
|
||||
|
@ -193,8 +199,8 @@ uint32_t lv_event_register_id(void);
|
|||
|
||||
/**
|
||||
* Nested events can be called and one of them might belong to an object that is being deleted.
|
||||
* Mark this object's `event_temp_data` deleted to know that it's `lv_event_send` should return `LV_RES_INV`
|
||||
* @param obj pointer to an obejct to mark as deleted
|
||||
* Mark this object's `event_temp_data` deleted to know that its `lv_event_send` should return `LV_RES_INV`
|
||||
* @param obj pointer to an object to mark as deleted
|
||||
*/
|
||||
void _lv_event_mark_deleted(struct _lv_obj_t * obj);
|
||||
|
||||
|
@ -209,17 +215,29 @@ void _lv_event_mark_deleted(struct _lv_obj_t * obj);
|
|||
* @param user_data custom data data will be available in `event_cb`
|
||||
* @return a pointer the event descriptor. Can be used in ::lv_obj_remove_event_dsc
|
||||
*/
|
||||
struct _lv_event_dsc_t * lv_obj_add_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data);
|
||||
struct _lv_event_dsc_t * lv_obj_add_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* Remove an event handler function for an object.
|
||||
* @param obj pointer to an object
|
||||
* @param event_cb the event function to remove
|
||||
* @param event_cb the event function to remove, or `NULL` to remove the the firstly added event callback
|
||||
* @return true if any event handlers were removed
|
||||
*/
|
||||
bool lv_obj_remove_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb);
|
||||
|
||||
/**
|
||||
* Remove an event handler function with a specific user_data from an object.
|
||||
* @param obj pointer to an object
|
||||
* @param event_cb the event function to remove, or `NULL` only `user_data` matters.
|
||||
* @param event_user_data the user_data specified in ::lv_obj_add_event_cb
|
||||
* @return true if any event handlers were removed
|
||||
*/
|
||||
bool lv_obj_remove_event_cb_with_user_data(struct _lv_obj_t * obj, lv_event_cb_t event_cb,
|
||||
const void * event_user_data);
|
||||
|
||||
/**
|
||||
* DEPRACTED because doesn't work if multiple event handlers are added to an object.
|
||||
* Remove an event handler function for an object.
|
||||
* @param obj pointer to an object
|
||||
* @param event_dsc pointer to an event descriptor to remove (returned by ::lv_obj_add_event_cb)
|
||||
|
|
|
@ -79,7 +79,7 @@ void lv_group_del(lv_group_t * group)
|
|||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
_LV_LL_READ(&group->obj_ll, obj) {
|
||||
if((*obj)->spec_attr) (*obj)->spec_attr->group_p = NULL;
|
||||
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
|
||||
}
|
||||
|
||||
_lv_ll_clear(&(group->obj_ll));
|
||||
|
@ -139,6 +139,25 @@ void lv_group_add_obj(lv_group_t * group, lv_obj_t * obj)
|
|||
LV_LOG_TRACE("finished");
|
||||
}
|
||||
|
||||
void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2)
|
||||
{
|
||||
lv_group_t * g1 = lv_obj_get_group(obj1);
|
||||
lv_group_t * g2 = lv_obj_get_group(obj2);
|
||||
if(g1 != g2) return;
|
||||
if(g1 == NULL) return;
|
||||
|
||||
/*Do not add the object twice*/
|
||||
lv_obj_t ** obj_i;
|
||||
_LV_LL_READ(&g1->obj_ll, obj_i) {
|
||||
if((*obj_i) == obj1)(*obj_i) = obj2;
|
||||
else if((*obj_i) == obj2)(*obj_i) = obj1;
|
||||
}
|
||||
|
||||
if(*g1->obj_focus == obj1) lv_group_focus_obj(obj2);
|
||||
else if(*g1->obj_focus == obj2) lv_group_focus_obj(obj1);
|
||||
|
||||
}
|
||||
|
||||
void lv_group_remove_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_group_t * g = lv_obj_get_group(obj);
|
||||
|
@ -192,7 +211,7 @@ void lv_group_remove_all_objs(lv_group_t * group)
|
|||
/*Remove the objects from the group*/
|
||||
lv_obj_t ** obj;
|
||||
_LV_LL_READ(&group->obj_ll, obj) {
|
||||
if((*obj)->spec_attr) (*obj)->spec_attr->group_p = NULL;
|
||||
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
|
||||
}
|
||||
|
||||
_lv_ll_clear(&(group->obj_ll));
|
||||
|
@ -251,13 +270,7 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
|
|||
{
|
||||
lv_obj_t * act = lv_group_get_focused(group);
|
||||
if(act == NULL) return LV_RES_OK;
|
||||
|
||||
lv_res_t res;
|
||||
|
||||
res = lv_event_send(act, LV_EVENT_KEY, &c);
|
||||
if(res != LV_RES_OK) return res;
|
||||
|
||||
return res;
|
||||
return lv_event_send(act, LV_EVENT_KEY, &c);
|
||||
}
|
||||
|
||||
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
|
||||
|
@ -382,8 +395,18 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *)
|
|||
if(obj_next == NULL) continue;
|
||||
if(lv_obj_get_state(*obj_next) & LV_STATE_DISABLED) continue;
|
||||
|
||||
/*Hidden objects don't receive focus*/
|
||||
if(lv_obj_has_flag(*obj_next, LV_OBJ_FLAG_HIDDEN) == false) break;
|
||||
/*Hidden objects don't receive focus.
|
||||
*If any parent is hidden, the object is also hidden)*/
|
||||
lv_obj_t * parent = *obj_next;
|
||||
while(parent) {
|
||||
if(lv_obj_has_flag(parent, LV_OBJ_FLAG_HIDDEN)) break;
|
||||
parent = lv_obj_get_parent(parent);
|
||||
}
|
||||
|
||||
if(parent && lv_obj_has_flag(parent, LV_OBJ_FLAG_HIDDEN)) continue;
|
||||
|
||||
/*If we got her a good candidate is found*/
|
||||
break;
|
||||
}
|
||||
|
||||
if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/
|
||||
|
|
|
@ -53,7 +53,7 @@ typedef void (*lv_group_focus_cb_t)(struct _lv_group_t *);
|
|||
|
||||
/**
|
||||
* Groups can be used to logically hold objects so that they can be individually focused.
|
||||
* They are NOT for laying out objects on a screen (try `lv_cont` for that).
|
||||
* They are NOT for laying out objects on a screen (try layouts for that).
|
||||
*/
|
||||
typedef struct _lv_group_t {
|
||||
lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/
|
||||
|
@ -76,7 +76,7 @@ typedef struct _lv_group_t {
|
|||
typedef enum {
|
||||
LV_GROUP_REFOCUS_POLICY_NEXT = 0,
|
||||
LV_GROUP_REFOCUS_POLICY_PREV = 1
|
||||
}lv_group_refocus_policy_t;
|
||||
} lv_group_refocus_policy_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
@ -119,6 +119,13 @@ lv_group_t * lv_group_get_default(void);
|
|||
*/
|
||||
void lv_group_add_obj(lv_group_t * group, struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Swap 2 object in a group. The object must be in the same group
|
||||
* @param obj1 pointer to an object
|
||||
* @param obj2 pointer to an other object
|
||||
*/
|
||||
void lv_group_swap_obj(struct _lv_obj_t * obj1, struct _lv_obj_t * obj2);
|
||||
|
||||
/**
|
||||
* Remove an object from its group
|
||||
* @param obj pointer to an object to remove
|
||||
|
|
|
@ -52,9 +52,9 @@ static lv_obj_t * indev_obj_act = NULL;
|
|||
* MACROS
|
||||
**********************/
|
||||
#if LV_LOG_TRACE_INDEV
|
||||
# define INDEV_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
|
||||
#define INDEV_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define INDEV_TRACE(...)
|
||||
#define INDEV_TRACE(...)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
@ -143,29 +143,32 @@ void lv_indev_reset(lv_indev_t * indev, lv_obj_t * obj)
|
|||
if(indev) {
|
||||
indev->proc.reset_query = 1;
|
||||
if(indev_act == indev) indev_obj_act = NULL;
|
||||
if(obj == NULL || indev->proc.types.pointer.last_pressed == obj) {
|
||||
indev->proc.types.pointer.last_pressed = NULL;
|
||||
}
|
||||
if(obj == NULL || indev->proc.types.pointer.act_obj == obj) {
|
||||
indev->proc.types.pointer.act_obj = NULL;
|
||||
}
|
||||
if(obj == NULL || indev->proc.types.pointer.last_obj == obj) {
|
||||
indev->proc.types.pointer.last_obj = NULL;
|
||||
if(indev->driver->type == LV_INDEV_TYPE_POINTER || indev->driver->type == LV_INDEV_TYPE_KEYPAD) {
|
||||
if(obj == NULL || indev->proc.types.pointer.last_pressed == obj) {
|
||||
indev->proc.types.pointer.last_pressed = NULL;
|
||||
}
|
||||
if(obj == NULL || indev->proc.types.pointer.act_obj == obj) {
|
||||
indev->proc.types.pointer.act_obj = NULL;
|
||||
}
|
||||
if(obj == NULL || indev->proc.types.pointer.last_obj == obj) {
|
||||
indev->proc.types.pointer.last_obj = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_indev_t * i = lv_indev_get_next(NULL);
|
||||
while(i) {
|
||||
i->proc.reset_query = 1;
|
||||
if((i->driver->type == LV_INDEV_TYPE_POINTER || i->driver->type == LV_INDEV_TYPE_KEYPAD) &&
|
||||
(obj == NULL || i->proc.types.pointer.last_pressed == obj)) {
|
||||
i->proc.types.pointer.last_pressed = NULL;
|
||||
}
|
||||
if(obj == NULL || i->proc.types.pointer.act_obj == obj) {
|
||||
i->proc.types.pointer.act_obj = NULL;
|
||||
}
|
||||
if(obj == NULL || i->proc.types.pointer.last_obj == obj) {
|
||||
i->proc.types.pointer.last_obj = NULL;
|
||||
if(i->driver->type == LV_INDEV_TYPE_POINTER || i->driver->type == LV_INDEV_TYPE_KEYPAD) {
|
||||
if(obj == NULL || i->proc.types.pointer.last_pressed == obj) {
|
||||
i->proc.types.pointer.last_pressed = NULL;
|
||||
}
|
||||
if(obj == NULL || i->proc.types.pointer.act_obj == obj) {
|
||||
i->proc.types.pointer.act_obj = NULL;
|
||||
}
|
||||
if(obj == NULL || i->proc.types.pointer.last_obj == obj) {
|
||||
i->proc.types.pointer.last_obj = NULL;
|
||||
}
|
||||
}
|
||||
i = lv_indev_get_next(i);
|
||||
}
|
||||
|
@ -290,8 +293,9 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
|
|||
/*If the point is on this object check its children too*/
|
||||
if(lv_obj_hit_test(obj, point)) {
|
||||
int32_t i;
|
||||
for(i = lv_obj_get_child_cnt(obj) - 1; i >= 0; i--) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = child_cnt - 1; i >= 0; i--) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
found_p = lv_indev_search_obj(child, point);
|
||||
|
||||
/*If a child was found then break*/
|
||||
|
@ -325,7 +329,7 @@ lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point)
|
|||
*/
|
||||
static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
|
||||
{
|
||||
lv_disp_t *disp = i->driver->disp;
|
||||
lv_disp_t * disp = i->driver->disp;
|
||||
/*Save the raw points so they can be used again in _lv_indev_read*/
|
||||
i->proc.types.pointer.last_raw_point.x = data->point.x;
|
||||
i->proc.types.pointer.last_raw_point.y = data->point.y;
|
||||
|
@ -342,9 +346,11 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
|
||||
/*Simple sanity check*/
|
||||
if(data->point.x < 0) LV_LOG_WARN("X is %d which is smaller than zero", data->point.x);
|
||||
if(data->point.x >= lv_disp_get_hor_res(i->driver->disp)) LV_LOG_WARN("X is %d which is greater than hor. res", data->point.x);
|
||||
if(data->point.x >= lv_disp_get_hor_res(i->driver->disp)) LV_LOG_WARN("X is %d which is greater than hor. res",
|
||||
data->point.x);
|
||||
if(data->point.y < 0) LV_LOG_WARN("Y is %d which is smaller than zero", data->point.y);
|
||||
if(data->point.y >= lv_disp_get_ver_res(i->driver->disp)) LV_LOG_WARN("Y is %d which is greater than hor. res", data->point.y);
|
||||
if(data->point.y >= lv_disp_get_ver_res(i->driver->disp)) LV_LOG_WARN("Y is %d which is greater than hor. res",
|
||||
data->point.y);
|
||||
|
||||
/*Move the cursor if set and moved*/
|
||||
if(i->cursor != NULL &&
|
||||
|
@ -554,9 +560,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
i->proc.pr_timestamp = lv_tick_get();
|
||||
|
||||
if(data->key == LV_KEY_ENTER) {
|
||||
bool editable = lv_obj_is_editable(indev_obj_act);
|
||||
|
||||
if(lv_group_get_editing(g) == true || editable == false) {
|
||||
bool editable_or_scrollable = lv_obj_is_editable(indev_obj_act) ||
|
||||
lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_SCROLLABLE);
|
||||
if(lv_group_get_editing(g) == true || editable_or_scrollable == false) {
|
||||
lv_event_send(indev_obj_act, LV_EVENT_PRESSED, indev_act);
|
||||
if(indev_reset_check(&i->proc)) return;
|
||||
}
|
||||
|
@ -590,12 +596,14 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
i->proc.longpr_rep_timestamp = lv_tick_get();
|
||||
|
||||
if(data->key == LV_KEY_ENTER) {
|
||||
bool editable = lv_obj_is_editable(indev_obj_act);
|
||||
bool editable_or_scrollable = lv_obj_is_editable(indev_obj_act) ||
|
||||
lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
/*On enter long press toggle edit mode.*/
|
||||
if(editable) {
|
||||
if(editable_or_scrollable) {
|
||||
/*Don't leave edit mode if there is only one object (nowhere to navigate)*/
|
||||
if(lv_group_get_obj_count(g) > 1) {
|
||||
LV_LOG_INFO("toggling edit mode");
|
||||
lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/
|
||||
lv_obj_clear_state(indev_obj_act, LV_STATE_PRESSED); /*Remove the pressed state manually*/
|
||||
}
|
||||
|
@ -639,10 +647,11 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
LV_LOG_INFO("released");
|
||||
|
||||
if(data->key == LV_KEY_ENTER) {
|
||||
bool editable = lv_obj_is_editable(indev_obj_act);
|
||||
bool editable_or_scrollable = lv_obj_is_editable(indev_obj_act) ||
|
||||
lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
/*The button was released on a non-editable object. Just send enter*/
|
||||
if(editable == false) {
|
||||
if(editable_or_scrollable == false) {
|
||||
lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act);
|
||||
if(indev_reset_check(&i->proc)) return;
|
||||
|
||||
|
@ -668,13 +677,15 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
|
||||
|
||||
lv_group_send_data(g, LV_KEY_ENTER);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_obj_clear_state(indev_obj_act, LV_STATE_PRESSED); /*Remove the pressed state manually*/
|
||||
}
|
||||
}
|
||||
/*If the focused object is editable and now in navigate mode then on enter switch edit
|
||||
mode*/
|
||||
else if(editable && !lv_group_get_editing(g) && !i->proc.long_pr_sent) {
|
||||
else if(!i->proc.long_pr_sent) {
|
||||
LV_LOG_INFO("entering edit mode");
|
||||
lv_group_set_editing(g, true); /*Set edit mode*/
|
||||
}
|
||||
}
|
||||
|
@ -686,9 +697,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
|
||||
/*if encoder steps or simulated steps via left/right keys*/
|
||||
if(data->enc_diff != 0) {
|
||||
LV_LOG_INFO("rotated by %d", data->enc_diff);
|
||||
/*In edit mode send LEFT/RIGHT keys*/
|
||||
if(lv_group_get_editing(g)) {
|
||||
LV_LOG_INFO("rotated by %+d (edit)", data->enc_diff);
|
||||
int32_t s;
|
||||
if(data->enc_diff < 0) {
|
||||
for(s = 0; s < -data->enc_diff; s++) lv_group_send_data(g, LV_KEY_LEFT);
|
||||
|
@ -699,6 +710,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
|
|||
}
|
||||
/*In navigate mode focus on the next/prev objects*/
|
||||
else {
|
||||
LV_LOG_INFO("rotated by %+d (nav)", data->enc_diff);
|
||||
int32_t s;
|
||||
if(data->enc_diff < 0) {
|
||||
for(s = 0; s < -data->enc_diff; s++) lv_group_focus_prev(g);
|
||||
|
@ -981,66 +993,67 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev)
|
|||
static void indev_click_focus(_lv_indev_proc_t * proc)
|
||||
{
|
||||
/*Handle click focus*/
|
||||
lv_obj_t * obj_to_focus = indev_obj_act;
|
||||
if(lv_obj_has_flag(obj_to_focus, LV_OBJ_FLAG_CLICK_FOCUSABLE) &&
|
||||
proc->types.pointer.last_pressed != obj_to_focus) {
|
||||
lv_group_t * g_act = lv_obj_get_group(obj_to_focus);
|
||||
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
|
||||
if(lv_obj_has_flag(indev_obj_act, LV_OBJ_FLAG_CLICK_FOCUSABLE) == false ||
|
||||
proc->types.pointer.last_pressed == indev_obj_act)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*If both the last and act. obj. are in the same group (or no group but it's also the same)*/
|
||||
if(g_act == g_prev) {
|
||||
/*The objects are in a group*/
|
||||
if(g_act) {
|
||||
lv_group_focus_obj(obj_to_focus);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*The object are not in group*/
|
||||
else {
|
||||
if(proc->types.pointer.last_pressed) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
lv_group_t * g_act = lv_obj_get_group(indev_obj_act);
|
||||
lv_group_t * g_prev = proc->types.pointer.last_pressed ? lv_obj_get_group(proc->types.pointer.last_pressed) : NULL;
|
||||
|
||||
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*If both the last and act. obj. are in the same group (or have no group)*/
|
||||
if(g_act == g_prev) {
|
||||
/*The objects are in a group*/
|
||||
if(g_act) {
|
||||
lv_group_focus_obj(indev_obj_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*The object are not in the same group (in different group or one in not a group)*/
|
||||
/*The object are not in group*/
|
||||
else {
|
||||
/*If the prev. obj. is not in a group then defocus it.*/
|
||||
if(g_prev == NULL && proc->types.pointer.last_pressed) {
|
||||
if(proc->types.pointer.last_pressed) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*Focus on a non-group object*/
|
||||
else {
|
||||
if(proc->types.pointer.last_pressed) {
|
||||
/*If the prev. object also wasn't in a group defocus it*/
|
||||
if(g_prev == NULL) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*If the prev. object also was in a group at least "LEAVE" it instead of defocus*/
|
||||
else {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_LEAVE, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
|
||||
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
}
|
||||
/*The object are not in the same group (in different groups or one has no group)*/
|
||||
else {
|
||||
/*If the prev. obj. is not in a group then defocus it.*/
|
||||
if(g_prev == NULL && proc->types.pointer.last_pressed) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*Focus on a non-group object*/
|
||||
else {
|
||||
if(proc->types.pointer.last_pressed) {
|
||||
/*If the prev. object also wasn't in a group defocus it*/
|
||||
if(g_prev == NULL) {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_DEFOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
/*If the prev. object also was in a group at least "LEAVE" it instead of defocus*/
|
||||
else {
|
||||
lv_event_send(proc->types.pointer.last_pressed, LV_EVENT_LEAVE, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
}
|
||||
|
||||
/*Focus to the act. in its group*/
|
||||
if(g_act) {
|
||||
lv_group_focus_obj(obj_to_focus);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
else {
|
||||
lv_event_send(obj_to_focus, LV_EVENT_FOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
}
|
||||
proc->types.pointer.last_pressed = obj_to_focus;
|
||||
}
|
||||
|
||||
/*Focus to the act. in its group*/
|
||||
if(g_act) {
|
||||
lv_group_focus_obj(indev_obj_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
else {
|
||||
lv_event_send(indev_obj_act, LV_EVENT_FOCUSED, indev_act);
|
||||
if(indev_reset_check(proc)) return;
|
||||
}
|
||||
}
|
||||
proc->types.pointer.last_pressed = indev_obj_act;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,8 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo
|
|||
static void scroll_limit_diff(_lv_indev_proc_t * proc, lv_coord_t * diff_x, lv_coord_t * diff_y);
|
||||
static lv_coord_t scroll_throw_predict_y(_lv_indev_proc_t * proc);
|
||||
static lv_coord_t scroll_throw_predict_x(_lv_indev_proc_t * proc);
|
||||
static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_t scroll_start, lv_coord_t scroll_end, lv_dir_t dir);
|
||||
static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_t scroll_start, lv_coord_t scroll_end,
|
||||
lv_dir_t dir);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -68,7 +69,8 @@ void _lv_indev_scroll_handler(_lv_indev_proc_t * proc)
|
|||
lv_coord_t sr = lv_obj_get_scroll_right(scroll_obj);
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(scroll_obj);
|
||||
diff_x = elastic_diff(scroll_obj, proc->types.pointer.vect.x, sl, sr, LV_DIR_HOR);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_coord_t st = lv_obj_get_scroll_top(scroll_obj);
|
||||
lv_coord_t sb = lv_obj_get_scroll_bottom(scroll_obj);
|
||||
diff_y = elastic_diff(scroll_obj, proc->types.pointer.vect.y, st, sb, LV_DIR_VER);
|
||||
|
@ -113,12 +115,13 @@ void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc)
|
|||
/*If no snapping "throw"*/
|
||||
if(align_y == LV_SCROLL_SNAP_NONE) {
|
||||
proc->types.pointer.scroll_throw_vect.y =
|
||||
proc->types.pointer.scroll_throw_vect.y * (100 - scroll_throw) / 100;
|
||||
proc->types.pointer.scroll_throw_vect.y * (100 - scroll_throw) / 100;
|
||||
|
||||
lv_coord_t sb = lv_obj_get_scroll_bottom(scroll_obj);
|
||||
lv_coord_t st = lv_obj_get_scroll_top(scroll_obj);
|
||||
|
||||
proc->types.pointer.scroll_throw_vect.y = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.y, st, sb, LV_DIR_VER);
|
||||
proc->types.pointer.scroll_throw_vect.y = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.y, st, sb,
|
||||
LV_DIR_VER);
|
||||
|
||||
lv_obj_scroll_by(scroll_obj, 0, proc->types.pointer.scroll_throw_vect.y, LV_ANIM_OFF);
|
||||
}
|
||||
|
@ -136,12 +139,13 @@ void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc)
|
|||
/*If no snapping "throw"*/
|
||||
if(align_x == LV_SCROLL_SNAP_NONE) {
|
||||
proc->types.pointer.scroll_throw_vect.x =
|
||||
proc->types.pointer.scroll_throw_vect.x * (100 - scroll_throw) / 100;
|
||||
proc->types.pointer.scroll_throw_vect.x * (100 - scroll_throw) / 100;
|
||||
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(scroll_obj);
|
||||
lv_coord_t sr = lv_obj_get_scroll_right(scroll_obj);
|
||||
|
||||
proc->types.pointer.scroll_throw_vect.x = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.x, sl ,sr, LV_DIR_HOR);
|
||||
proc->types.pointer.scroll_throw_vect.x = elastic_diff(scroll_obj, proc->types.pointer.scroll_throw_vect.x, sl, sr,
|
||||
LV_DIR_HOR);
|
||||
|
||||
lv_obj_scroll_by(scroll_obj, proc->types.pointer.scroll_throw_vect.x, 0, LV_ANIM_OFF);
|
||||
}
|
||||
|
@ -176,7 +180,7 @@ void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc)
|
|||
if(align_x == LV_SCROLL_SNAP_NONE) {
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(scroll_obj);
|
||||
lv_coord_t sr = lv_obj_get_scroll_right(scroll_obj);
|
||||
if (sl > 0 || sr > 0) {
|
||||
if(sl > 0 || sr > 0) {
|
||||
if(sl < 0) {
|
||||
lv_obj_scroll_by(scroll_obj, sl, 0, LV_ANIM_ON);
|
||||
}
|
||||
|
@ -205,14 +209,14 @@ lv_coord_t lv_indev_scroll_throw_predict(lv_indev_t * indev, lv_dir_t dir)
|
|||
if(indev == NULL) return 0;
|
||||
lv_coord_t v;
|
||||
switch(dir) {
|
||||
case LV_DIR_VER:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.y;
|
||||
break;
|
||||
case LV_DIR_HOR:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.x;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
case LV_DIR_VER:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.y;
|
||||
break;
|
||||
case LV_DIR_HOR:
|
||||
v = indev->proc.types.pointer.scroll_throw_vect_ori.x;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
lv_coord_t scroll_throw = indev->driver->scroll_throw;
|
||||
|
@ -242,10 +246,10 @@ static lv_obj_t * find_scroll_obj(_lv_indev_proc_t * proc)
|
|||
lv_indev_t * indev_act = lv_indev_get_act();
|
||||
lv_coord_t scroll_limit = indev_act->driver->scroll_limit;
|
||||
|
||||
/*Go until find an scrollable object in the current direction
|
||||
/*Go until find a scrollable object in the current direction
|
||||
*More precisely:
|
||||
* 1. Check the pressed object and all of its ancestors and try to find an object which is scrollable
|
||||
* 2. Scrollable means it has some content out of it's area
|
||||
* 2. Scrollable means it has some content out of its area
|
||||
* 3. If an object can be scrolled into the current direction then use it ("real match"")
|
||||
* 4. If can be scrolled on the current axis (hor/ver) save it as candidate (at least show an elastic scroll effect)
|
||||
* 5. Use the last candidate. Always the "deepest" parent or the object from point 3*/
|
||||
|
@ -292,17 +296,15 @@ static lv_obj_t * find_scroll_obj(_lv_indev_proc_t * proc)
|
|||
*is propagated to this object it can show at least elastic scroll effect.
|
||||
*But if not hor/ver scrollable do not scroll it at all (so it's not a good candidate)*/
|
||||
if((st > 0 || sb > 0) &&
|
||||
((up_en && proc->types.pointer.scroll_sum.y >= scroll_limit) ||
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit)))
|
||||
{
|
||||
((up_en && proc->types.pointer.scroll_sum.y >= scroll_limit) ||
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit))) {
|
||||
obj_candidate = obj_act;
|
||||
dir_candidate = LV_DIR_VER;
|
||||
}
|
||||
|
||||
if((sl > 0 || sr > 0) &&
|
||||
((left_en && proc->types.pointer.scroll_sum.x >= scroll_limit) ||
|
||||
(right_en && proc->types.pointer.scroll_sum.x <= - scroll_limit)))
|
||||
{
|
||||
((left_en && proc->types.pointer.scroll_sum.x >= scroll_limit) ||
|
||||
(right_en && proc->types.pointer.scroll_sum.x <= - scroll_limit))) {
|
||||
obj_candidate = obj_act;
|
||||
dir_candidate = LV_DIR_HOR;
|
||||
}
|
||||
|
@ -314,10 +316,9 @@ static lv_obj_t * find_scroll_obj(_lv_indev_proc_t * proc)
|
|||
|
||||
/*If the object really can be scrolled into the current direction the use it.*/
|
||||
if((left_en && proc->types.pointer.scroll_sum.x >= scroll_limit) ||
|
||||
(right_en && proc->types.pointer.scroll_sum.x <= - scroll_limit) ||
|
||||
(up_en && proc->types.pointer.scroll_sum.y >= scroll_limit) ||
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit))
|
||||
{
|
||||
(right_en && proc->types.pointer.scroll_sum.x <= - scroll_limit) ||
|
||||
(up_en && proc->types.pointer.scroll_sum.y >= scroll_limit) ||
|
||||
(down_en && proc->types.pointer.scroll_sum.y <= - scroll_limit)) {
|
||||
proc->types.pointer.scroll_dir = hor_en ? LV_DIR_HOR : LV_DIR_VER;
|
||||
break;
|
||||
}
|
||||
|
@ -350,45 +351,45 @@ static void init_scroll_limits(_lv_indev_proc_t * proc)
|
|||
/*With STOP limit the scrolling to the perv and next snap point*/
|
||||
else {
|
||||
switch(lv_obj_get_scroll_snap_y(obj)) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, obj->coords.y1 + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, obj->coords.y1 - 1, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, obj->coords.y2, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, obj->coords.y2, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER: {
|
||||
lv_coord_t y_mid = obj->coords.y1 + lv_area_get_height(&obj->coords) / 2;
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, y_mid + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, y_mid - 1, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
proc->types.pointer.scroll_area.y1 = LV_COORD_MIN;
|
||||
proc->types.pointer.scroll_area.y2 = LV_COORD_MAX;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, obj->coords.y1 + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, obj->coords.y1 - 1, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, obj->coords.y2, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, obj->coords.y2, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER: {
|
||||
lv_coord_t y_mid = obj->coords.y1 + lv_area_get_height(&obj->coords) / 2;
|
||||
proc->types.pointer.scroll_area.y1 = find_snap_point_y(obj, y_mid + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.y2 = find_snap_point_y(obj, LV_COORD_MIN, y_mid - 1, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
proc->types.pointer.scroll_area.y1 = LV_COORD_MIN;
|
||||
proc->types.pointer.scroll_area.y2 = LV_COORD_MAX;
|
||||
break;
|
||||
}
|
||||
|
||||
switch(lv_obj_get_scroll_snap_x(obj)) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, obj->coords.x1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, obj->coords.x1, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, obj->coords.x2, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, obj->coords.x2, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER: {
|
||||
lv_coord_t x_mid = obj->coords.x1 + lv_area_get_width(&obj->coords) / 2;
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, x_mid + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, x_mid - 1, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
proc->types.pointer.scroll_area.x1 = LV_COORD_MIN;
|
||||
proc->types.pointer.scroll_area.x2 = LV_COORD_MAX;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, obj->coords.x1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, obj->coords.x1, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, obj->coords.x2, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, obj->coords.x2, 0);
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER: {
|
||||
lv_coord_t x_mid = obj->coords.x1 + lv_area_get_width(&obj->coords) / 2;
|
||||
proc->types.pointer.scroll_area.x1 = find_snap_point_x(obj, x_mid + 1, LV_COORD_MAX, 0);
|
||||
proc->types.pointer.scroll_area.x2 = find_snap_point_x(obj, LV_COORD_MIN, x_mid - 1, 0);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
proc->types.pointer.scroll_area.x1 = LV_COORD_MIN;
|
||||
proc->types.pointer.scroll_area.x2 = LV_COORD_MAX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,8 +403,8 @@ static void init_scroll_limits(_lv_indev_proc_t * proc)
|
|||
/**
|
||||
* Search for snap point in the `min` - `max` range.
|
||||
* @param obj the object on which snap point should be found
|
||||
* @param min ignore snap points smaller then this. (Absolute coordinate)
|
||||
* @param max ignore snap points greater then this. (Absolute coordinate)
|
||||
* @param min ignore snap points smaller than this. (Absolute coordinate)
|
||||
* @param max ignore snap points greater than this. (Absolute coordinate)
|
||||
* @param ofs offset to snap points. Useful the get a snap point in an imagined case
|
||||
* what if children are already moved by this value
|
||||
* @return the distance of the snap point.
|
||||
|
@ -419,27 +420,28 @@ static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coo
|
|||
lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN);
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPABLE)) {
|
||||
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPPABLE)) {
|
||||
lv_coord_t x_child = 0;
|
||||
lv_coord_t x_parent = 0;
|
||||
switch(align) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
x_child = child->coords.x1;
|
||||
x_parent = obj->coords.x1 + pad_left;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
x_child = child->coords.x2;
|
||||
x_parent = obj->coords.x2 - pad_right;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
x_child = child->coords.x1 + lv_area_get_width(&child->coords) / 2;
|
||||
x_parent = obj->coords.x1 + pad_left + (lv_area_get_width(&obj->coords) - pad_left - pad_right) / 2;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
x_child = child->coords.x1;
|
||||
x_parent = obj->coords.x1 + pad_left;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
x_child = child->coords.x2;
|
||||
x_parent = obj->coords.x2 - pad_right;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
x_child = child->coords.x1 + lv_area_get_width(&child->coords) / 2;
|
||||
x_parent = obj->coords.x1 + pad_left + (lv_area_get_width(&obj->coords) - pad_left - pad_right) / 2;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
x_child += ofs;
|
||||
|
@ -450,15 +452,15 @@ static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coo
|
|||
}
|
||||
}
|
||||
|
||||
return dist == LV_COORD_MAX ? 0: -dist;
|
||||
return dist == LV_COORD_MAX ? 0 : -dist;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for snap point in the `min` - `max` range.
|
||||
* @param obj the object on which snap point should be found
|
||||
* @param min ignore snap points smaller then this. (Absolute coordinate)
|
||||
* @param max ignore snap points greater then this. (Absolute coordinate)
|
||||
* @param ofs offset to snap points. Useful the get a snap point in an imagined case
|
||||
* @param min ignore snap points smaller than this. (Absolute coordinate)
|
||||
* @param max ignore snap points greater than this. (Absolute coordinate)
|
||||
* @param ofs offset to snap points. Useful to get a snap point in an imagined case
|
||||
* what if children are already moved by this value
|
||||
* @return the distance of the snap point.
|
||||
*/
|
||||
|
@ -473,27 +475,28 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo
|
|||
lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN);
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPABLE)) {
|
||||
if(lv_obj_has_flag(child, LV_OBJ_FLAG_SNAPPABLE)) {
|
||||
lv_coord_t y_child = 0;
|
||||
lv_coord_t y_parent = 0;
|
||||
switch(align) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
y_child = child->coords.y1;
|
||||
y_parent = obj->coords.y1 + pad_top;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
y_child = child->coords.y2;
|
||||
y_parent = obj->coords.y2 - pad_bottom;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
y_child = child->coords.y1 + lv_area_get_height(&child->coords) / 2;
|
||||
y_parent = obj->coords.y1 + pad_top + (lv_area_get_height(&obj->coords) - pad_top - pad_bottom) / 2;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
y_child = child->coords.y1;
|
||||
y_parent = obj->coords.y1 + pad_top;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
y_child = child->coords.y2;
|
||||
y_parent = obj->coords.y2 - pad_bottom;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
y_child = child->coords.y1 + lv_area_get_height(&child->coords) / 2;
|
||||
y_parent = obj->coords.y1 + pad_top + (lv_area_get_height(&obj->coords) - pad_top - pad_bottom) / 2;
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
y_child += ofs;
|
||||
|
@ -511,7 +514,7 @@ static void scroll_limit_diff(_lv_indev_proc_t * proc, lv_coord_t * diff_x, lv_c
|
|||
{
|
||||
if(diff_y) {
|
||||
if(proc->types.pointer.scroll_sum.y + *diff_y < proc->types.pointer.scroll_area.y1) {
|
||||
*diff_y = proc->types.pointer.scroll_area.y1 - proc->types.pointer.scroll_sum.y;
|
||||
*diff_y = proc->types.pointer.scroll_area.y1 - proc->types.pointer.scroll_sum.y;
|
||||
}
|
||||
|
||||
if(proc->types.pointer.scroll_sum.y + *diff_y > proc->types.pointer.scroll_area.y2) {
|
||||
|
@ -563,7 +566,8 @@ static lv_coord_t scroll_throw_predict_x(_lv_indev_proc_t * proc)
|
|||
return move;
|
||||
}
|
||||
|
||||
static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_t scroll_start, lv_coord_t scroll_end, lv_dir_t dir)
|
||||
static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_t scroll_start, lv_coord_t scroll_end,
|
||||
lv_dir_t dir)
|
||||
{
|
||||
if(lv_obj_has_flag(scroll_obj, LV_OBJ_FLAG_SCROLL_ELASTIC)) {
|
||||
/*If there is snapping in the current direction don't use the elastic factor because
|
||||
|
@ -580,36 +584,37 @@ static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_
|
|||
lv_coord_t pad_right = lv_obj_get_style_pad_right(scroll_obj, LV_PART_MAIN);
|
||||
|
||||
switch(snap) {
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_point = pad_left + (lv_area_get_width(&scroll_obj->coords) - pad_left - pad_right) / 2 + scroll_obj->coords.x1;
|
||||
act_obj_point = lv_area_get_width(&act_obj->coords) / 2 + act_obj->coords.x1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_point = scroll_obj->coords.x1 + pad_left;
|
||||
act_obj_point = act_obj->coords.x1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_point = scroll_obj->coords.x2 - pad_right;
|
||||
act_obj_point = act_obj->coords.x2;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_point = pad_left + (lv_area_get_width(&scroll_obj->coords) - pad_left - pad_right) / 2 + scroll_obj->coords.x1;
|
||||
act_obj_point = lv_area_get_width(&act_obj->coords) / 2 + act_obj->coords.x1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_point = scroll_obj->coords.x1 + pad_left;
|
||||
act_obj_point = act_obj->coords.x1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_point = scroll_obj->coords.x2 - pad_right;
|
||||
act_obj_point = act_obj->coords.x2;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(scroll_obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(scroll_obj, LV_PART_MAIN);
|
||||
|
||||
switch(snap) {
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_point = pad_top + (lv_area_get_height(&scroll_obj->coords) - pad_top - pad_bottom) / 2 + scroll_obj->coords.y1;
|
||||
act_obj_point = lv_area_get_height(&act_obj->coords) / 2 + act_obj->coords.y1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_point = scroll_obj->coords.y1 + pad_top;
|
||||
act_obj_point = act_obj->coords.y1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_point = scroll_obj->coords.y2 - pad_bottom;
|
||||
act_obj_point = act_obj->coords.y2;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_point = pad_top + (lv_area_get_height(&scroll_obj->coords) - pad_top - pad_bottom) / 2 + scroll_obj->coords.y1;
|
||||
act_obj_point = lv_area_get_height(&act_obj->coords) / 2 + act_obj->coords.y1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_point = scroll_obj->coords.y1 + pad_top;
|
||||
act_obj_point = act_obj->coords.y1;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_point = scroll_obj->coords.y2 - pad_bottom;
|
||||
act_obj_point = act_obj->coords.y2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -629,7 +634,8 @@ static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_
|
|||
if(diff > 0) diff += ELASTIC_SLOWNESS_FACTOR / 2;
|
||||
return diff / ELASTIC_SLOWNESS_FACTOR;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Scroll back to the boundary if required*/
|
||||
if(scroll_end + diff < 0) diff = - scroll_end;
|
||||
if(scroll_start - diff < 0) diff = scroll_start;
|
||||
|
|
|
@ -35,6 +35,10 @@
|
|||
#include "../gpu/lv_gpu_nxp_pxp_osa.h"
|
||||
#endif
|
||||
|
||||
#if LV_USE_GPU_SDL
|
||||
#include "../gpu/lv_gpu_sdl.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -84,6 +88,11 @@ const lv_obj_class_t lv_obj_class = {
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
bool lv_is_initialized(void)
|
||||
{
|
||||
return lv_initialized;
|
||||
}
|
||||
|
||||
void lv_init(void)
|
||||
{
|
||||
/*Do nothing if already initialized*/
|
||||
|
@ -116,6 +125,9 @@ void lv_init(void)
|
|||
for(; ;) ;
|
||||
}
|
||||
#endif
|
||||
#if LV_USE_GPU_SDL
|
||||
lv_gpu_sdl_init();
|
||||
#endif
|
||||
|
||||
_lv_obj_style_init();
|
||||
_lv_ll_init(&LV_GC_ROOT(_lv_disp_ll), sizeof(lv_disp_t));
|
||||
|
@ -133,29 +145,36 @@ void lv_init(void)
|
|||
|
||||
uint8_t * txt_u8 = (uint8_t *)txt;
|
||||
if(txt_u8[0] != 0xc3 || txt_u8[1] != 0x81 || txt_u8[2] != 0x00) {
|
||||
LV_LOG_WARN("The strings has no UTF-8 encoding. Non-ASCII characters won't be displayed.")
|
||||
LV_LOG_WARN("The strings has no UTF-8 encoding. Non-ASCII characters won't be displayed.");
|
||||
}
|
||||
|
||||
uint32_t endianess_test = 0x11223344;
|
||||
uint8_t * endianess_test_p = (uint8_t*) &endianess_test;
|
||||
uint8_t * endianess_test_p = (uint8_t *) &endianess_test;
|
||||
bool big_endian = endianess_test_p[0] == 0x11 ? true : false;
|
||||
|
||||
if(big_endian) {
|
||||
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 1, "It's a big endian system but LV_BIG_ENDIAN_SYSTEM is not enabled in lv_conf.h");
|
||||
} else {
|
||||
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 0, "It's a little endian system but LV_BIG_ENDIAN_SYSTEM is enabled in lv_conf.h");
|
||||
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 1,
|
||||
"It's a big endian system but LV_BIG_ENDIAN_SYSTEM is not enabled in lv_conf.h");
|
||||
}
|
||||
else {
|
||||
LV_ASSERT_MSG(LV_BIG_ENDIAN_SYSTEM == 0,
|
||||
"It's a little endian system but LV_BIG_ENDIAN_SYSTEM is enabled in lv_conf.h");
|
||||
}
|
||||
|
||||
#if LV_USE_ASSERT_MEM_INTEGRITY
|
||||
LV_LOG_WARN("Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower")
|
||||
LV_LOG_WARN("Memory integrity checks are enabled via LV_USE_ASSERT_MEM_INTEGRITY which makes LVGL much slower");
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_OBJ
|
||||
LV_LOG_WARN("Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower")
|
||||
LV_LOG_WARN("Object sanity checks are enabled via LV_USE_ASSERT_OBJ which makes LVGL much slower");
|
||||
#endif
|
||||
|
||||
#if LV_USE_ASSERT_STYLE
|
||||
LV_LOG_WARN("Style sanity checks are enabled that uses more RAM");
|
||||
#endif
|
||||
|
||||
#if LV_LOG_LEVEL == LV_LOG_LEVEL_TRACE
|
||||
LV_LOG_WARN("Log level is set the Trace which makes LVGL much slower")
|
||||
LV_LOG_WARN("Log level is set the Trace which makes LVGL much slower");
|
||||
#endif
|
||||
|
||||
lv_extra_init();
|
||||
|
@ -165,10 +184,13 @@ void lv_init(void)
|
|||
LV_LOG_TRACE("finished");
|
||||
}
|
||||
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM || LV_USE_GPU_SDL
|
||||
|
||||
void lv_deinit(void)
|
||||
{
|
||||
#if LV_USE_GPU_SDL
|
||||
lv_gpu_sdl_deinit();
|
||||
#endif
|
||||
_lv_gc_clear_roots();
|
||||
|
||||
lv_disp_set_default(NULL);
|
||||
|
@ -185,7 +207,7 @@ void lv_deinit(void)
|
|||
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -216,6 +238,13 @@ void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
|||
if((was_on_layout != lv_obj_is_layout_positioned(obj)) || (f & (LV_OBJ_FLAG_LAYOUT_1 | LV_OBJ_FLAG_LAYOUT_2))) {
|
||||
lv_obj_mark_layout_as_dirty(lv_obj_get_parent(obj));
|
||||
}
|
||||
|
||||
if(f & LV_OBJ_FLAG_SCROLLABLE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
||||
|
@ -223,6 +252,12 @@ void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f)
|
|||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
bool was_on_layout = lv_obj_is_layout_positioned(obj);
|
||||
if(f & LV_OBJ_FLAG_SCROLLABLE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
|
||||
obj->flags &= (~f);
|
||||
|
||||
|
@ -381,7 +416,7 @@ static void lv_obj_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||
|
||||
/*Set attributes*/
|
||||
obj->flags = LV_OBJ_FLAG_CLICKABLE;
|
||||
obj->flags |= LV_OBJ_FLAG_SNAPABLE;
|
||||
obj->flags |= LV_OBJ_FLAG_SNAPPABLE;
|
||||
if(parent) obj->flags |= LV_OBJ_FLAG_PRESS_LOCK;
|
||||
if(parent) obj->flags |= LV_OBJ_FLAG_SCROLL_CHAIN;
|
||||
obj->flags |= LV_OBJ_FLAG_CLICK_FOCUSABLE;
|
||||
|
@ -451,7 +486,7 @@ static void lv_obj_draw(lv_event_t * e)
|
|||
|
||||
if(_lv_area_is_in(info->area, &coords, r) == false) {
|
||||
info->res = LV_COVER_RES_NOT_COVER;
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if(lv_obj_get_style_bg_opa(obj, LV_PART_MAIN) < LV_OPA_MAX) {
|
||||
|
@ -493,15 +528,29 @@ static void lv_obj_draw(lv_event_t * e)
|
|||
coords.y1 -= h;
|
||||
coords.y2 += h;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_RECTANGLE;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
part_dsc.draw_area = &coords;
|
||||
part_dsc.part = LV_PART_MAIN;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
|
||||
lv_draw_rect(&coords, clip_area, &draw_dsc);
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
/*If the radius is 0 the parent's coordinates will clip anyway*/
|
||||
lv_coord_t r = lv_obj_get_style_radius(obj, LV_PART_MAIN);
|
||||
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||
lv_draw_mask_add(mp, obj + 8);
|
||||
if(r != 0) {
|
||||
lv_draw_mask_radius_param_t * mp = lv_mem_buf_get(sizeof(lv_draw_mask_radius_param_t));
|
||||
lv_draw_mask_radius_init(mp, &obj->coords, r, false);
|
||||
/*Add the mask and use `obj+8` as custom id. Don't use `obj` directly because it might be used by the user*/
|
||||
lv_draw_mask_add(mp, obj + 8);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -512,7 +561,10 @@ static void lv_obj_draw(lv_event_t * e)
|
|||
#if LV_DRAW_COMPLEX
|
||||
if(lv_obj_get_style_clip_corner(obj, LV_PART_MAIN)) {
|
||||
lv_draw_mask_radius_param_t * param = lv_draw_mask_remove_custom(obj + 8);
|
||||
lv_mem_buf_release(param);
|
||||
if(param) {
|
||||
lv_draw_mask_free_param(param);
|
||||
lv_mem_buf_release(param);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -523,6 +575,7 @@ static void lv_obj_draw(lv_event_t * e)
|
|||
draw_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.outline_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.shadow_opa = LV_OPA_TRANSP;
|
||||
draw_dsc.bg_img_opa = LV_OPA_TRANSP;
|
||||
lv_obj_init_draw_rect_dsc(obj, LV_PART_MAIN, &draw_dsc);
|
||||
|
||||
lv_coord_t w = lv_obj_get_style_transform_width(obj, LV_PART_MAIN);
|
||||
|
@ -533,7 +586,18 @@ static void lv_obj_draw(lv_event_t * e)
|
|||
coords.x2 += w;
|
||||
coords.y1 -= h;
|
||||
coords.y2 += h;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_BORDER_POST;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
part_dsc.draw_area = &coords;
|
||||
part_dsc.part = LV_PART_MAIN;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
|
||||
lv_draw_rect(&coords, clip_area, &draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -551,8 +615,25 @@ static void draw_scrollbar(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_res_t sb_res = scrollbar_init_draw_dsc(obj, &draw_dsc);
|
||||
if(sb_res != LV_RES_OK) return;
|
||||
|
||||
if(lv_area_get_size(&hor_area) > 0) lv_draw_rect(&hor_area, clip_area, &draw_dsc);
|
||||
if(lv_area_get_size(&ver_area) > 0) lv_draw_rect(&ver_area, clip_area, &draw_dsc);
|
||||
lv_obj_draw_part_dsc_t part_dsc;
|
||||
lv_obj_draw_dsc_init(&part_dsc, clip_area);
|
||||
part_dsc.class_p = MY_CLASS;
|
||||
part_dsc.type = LV_OBJ_DRAW_PART_SCROLLBAR;
|
||||
part_dsc.rect_dsc = &draw_dsc;
|
||||
part_dsc.part = LV_PART_SCROLLBAR;
|
||||
|
||||
if(lv_area_get_size(&hor_area) > 0) {
|
||||
part_dsc.draw_area = &hor_area;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
lv_draw_rect(&hor_area, clip_area, &draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
if(lv_area_get_size(&ver_area) > 0) {
|
||||
part_dsc.draw_area = &ver_area;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_dsc);
|
||||
lv_draw_rect(&ver_area, clip_area, &draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -574,7 +655,8 @@ static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc
|
|||
dsc->border_width = lv_obj_get_style_border_width(obj, LV_PART_SCROLLBAR);
|
||||
if(dsc->border_width > 0) {
|
||||
dsc->border_color = lv_obj_get_style_border_color(obj, LV_PART_SCROLLBAR);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dsc->border_opa = LV_OPA_TRANSP;
|
||||
}
|
||||
}
|
||||
|
@ -586,7 +668,8 @@ static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc
|
|||
if(dsc->shadow_width > 0) {
|
||||
dsc->shadow_spread = lv_obj_get_style_shadow_spread(obj, LV_PART_SCROLLBAR);
|
||||
dsc->shadow_color = lv_obj_get_style_shadow_color(obj, LV_PART_SCROLLBAR);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dsc->shadow_opa = LV_OPA_TRANSP;
|
||||
}
|
||||
}
|
||||
|
@ -598,10 +681,11 @@ static lv_res_t scrollbar_init_draw_dsc(lv_obj_t * obj, lv_draw_rect_dsc_t * dsc
|
|||
dsc->shadow_opa = (dsc->bg_opa * opa) >> 8;
|
||||
}
|
||||
|
||||
if(dsc->bg_opa != LV_OPA_TRANSP || dsc->border_opa != LV_OPA_TRANSP || dsc->shadow_opa != LV_OPA_TRANSP ) {
|
||||
if(dsc->bg_opa != LV_OPA_TRANSP || dsc->border_opa != LV_OPA_TRANSP || dsc->shadow_opa != LV_OPA_TRANSP) {
|
||||
dsc->radius = lv_obj_get_style_radius(obj, LV_PART_SCROLLBAR);
|
||||
return LV_RES_OK;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return LV_RES_INV;
|
||||
}
|
||||
#else
|
||||
|
@ -657,6 +741,34 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
if(res != LV_RES_OK) return;
|
||||
}
|
||||
}
|
||||
else if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLLABLE) && !lv_obj_is_editable(obj)) {
|
||||
/*scroll by keypad or encoder*/
|
||||
lv_anim_enable_t anim_enable = LV_ANIM_OFF;
|
||||
lv_coord_t sl = lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t sr = lv_obj_get_scroll_right(obj);
|
||||
char c = *((char *)lv_event_get_param(e));
|
||||
if(c == LV_KEY_DOWN) {
|
||||
/*use scroll_to_x/y functions to enforce scroll limits*/
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) + lv_obj_get_height(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_UP) {
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) - lv_obj_get_height(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_RIGHT) {
|
||||
/*If the object can't be scrolled horizontally then scroll it vertically*/
|
||||
if(!((lv_obj_get_scroll_dir(obj) & LV_DIR_HOR) && (sl > 0 || sr > 0)))
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) + lv_obj_get_height(obj) / 4, anim_enable);
|
||||
else
|
||||
lv_obj_scroll_to_x(obj, lv_obj_get_scroll_x(obj) + lv_obj_get_width(obj) / 4, anim_enable);
|
||||
}
|
||||
else if(c == LV_KEY_LEFT) {
|
||||
/*If the object can't be scrolled horizontally then scroll it vertically*/
|
||||
if(!((lv_obj_get_scroll_dir(obj) & LV_DIR_HOR) && (sl > 0 || sr > 0)))
|
||||
lv_obj_scroll_to_y(obj, lv_obj_get_scroll_y(obj) - lv_obj_get_height(obj) / 4, anim_enable);
|
||||
else
|
||||
lv_obj_scroll_to_x(obj, lv_obj_get_scroll_x(obj) - lv_obj_get_width(obj) / 4, anim_enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_FOCUSED) {
|
||||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS)) {
|
||||
|
@ -689,6 +801,12 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
}
|
||||
else if(code == LV_EVENT_SCROLL_END) {
|
||||
lv_obj_clear_state(obj, LV_STATE_SCROLLED);
|
||||
if(lv_obj_get_scrollbar_mode(obj) == LV_SCROLLBAR_MODE_ACTIVE) {
|
||||
lv_area_t hor_area, ver_area;
|
||||
lv_obj_get_scrollbar_area(obj, &hor_area, &ver_area);
|
||||
lv_obj_invalidate_area(obj, &hor_area);
|
||||
lv_obj_invalidate_area(obj, &ver_area);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_DEFOCUSED) {
|
||||
lv_obj_clear_state(obj, LV_STATE_FOCUSED | LV_STATE_EDITED | LV_STATE_FOCUS_KEY);
|
||||
|
@ -701,8 +819,9 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
}
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
lv_obj_mark_layout_as_dirty(child);
|
||||
}
|
||||
}
|
||||
|
@ -715,11 +834,6 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_SCROLL_END) {
|
||||
if(lv_obj_get_scrollbar_mode(obj) == LV_SCROLLBAR_MODE_ACTIVE) {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
}
|
||||
else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_coord_t * s = lv_event_get_param(e);
|
||||
lv_coord_t d = lv_obj_calculate_ext_draw_size(obj, LV_PART_MAIN);
|
||||
|
@ -790,7 +904,7 @@ static void lv_obj_set_state(lv_obj_t * obj, lv_state_t new_state)
|
|||
}
|
||||
}
|
||||
|
||||
for(i = 0;i < tsi; i++) {
|
||||
for(i = 0; i < tsi; i++) {
|
||||
lv_part_t part_act = lv_obj_style_get_selector_part(ts[i].selector);
|
||||
_lv_obj_style_create_transition(obj, part_act, prev_state, new_state, &ts[i]);
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ enum {
|
|||
LV_PART_INDICATOR = 0x020000, /**< Indicator, e.g. for slider, bar, switch, or the tick box of the checkbox*/
|
||||
LV_PART_KNOB = 0x030000, /**< Like handle to grab to adjust the value*/
|
||||
LV_PART_SELECTED = 0x040000, /**< Indicate the currently selected option or section*/
|
||||
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. tabel cells)*/
|
||||
LV_PART_ITEMS = 0x050000, /**< Used if the widget has multiple similar elements (e.g. table cells)*/
|
||||
LV_PART_TICKS = 0x060000, /**< Ticks on scale e.g. for a chart or meter*/
|
||||
LV_PART_CURSOR = 0x070000, /**< Mark a specific place e.g. for text area's cursor or on a chart*/
|
||||
|
||||
|
@ -87,37 +87,46 @@ typedef uint32_t lv_part_t;
|
|||
* OR-ed values are possible
|
||||
*/
|
||||
enum {
|
||||
LV_OBJ_FLAG_HIDDEN = (1 << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
|
||||
LV_OBJ_FLAG_CLICKABLE = (1 << 1), /**< Make the object clickable by the input devices*/
|
||||
LV_OBJ_FLAG_CLICK_FOCUSABLE = (1 << 2), /**< Add focused state to the object when clicked*/
|
||||
LV_OBJ_FLAG_CHECKABLE = (1 << 3), /**< Toggle checked state when the object is clicked*/
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1 << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC = (1 << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1 << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1 << 7), /**< Allow scrolling only one snapable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN = (1 << 8), /**< Allow propagating the scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1 << 9), /**< Automatically scroll object to make it visible when focused*/
|
||||
LV_OBJ_FLAG_SNAPABLE = (1 << 10), /**< If scroll snap is enabled on the parent it can snap to this object*/
|
||||
LV_OBJ_FLAG_PRESS_LOCK = (1 << 11), /**< Keep the object pressed even if the press slid from the object*/
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE = (1 << 12), /**< Propagate the events to the parent too*/
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE = (1 << 13), /**< Propagate the gestures to the parent*/
|
||||
LV_OBJ_FLAG_ADV_HITTEST = (1 << 14), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1 << 15), /**< Make the object position-able by the layouts*/
|
||||
LV_OBJ_FLAG_FLOATING = (1 << 16), /**< Do not scroll the object when the parent scrolls and ignore layout*/
|
||||
LV_OBJ_FLAG_HIDDEN = (1L << 0), /**< Make the object hidden. (Like it wasn't there at all)*/
|
||||
LV_OBJ_FLAG_CLICKABLE = (1L << 1), /**< Make the object clickable by the input devices*/
|
||||
LV_OBJ_FLAG_CLICK_FOCUSABLE = (1L << 2), /**< Add focused state to the object when clicked*/
|
||||
LV_OBJ_FLAG_CHECKABLE = (1L << 3), /**< Toggle checked state when the object is clicked*/
|
||||
LV_OBJ_FLAG_SCROLLABLE = (1L << 4), /**< Make the object scrollable*/
|
||||
LV_OBJ_FLAG_SCROLL_ELASTIC = (1L << 5), /**< Allow scrolling inside but with slower speed*/
|
||||
LV_OBJ_FLAG_SCROLL_MOMENTUM = (1L << 6), /**< Make the object scroll further when "thrown"*/
|
||||
LV_OBJ_FLAG_SCROLL_ONE = (1L << 7), /**< Allow scrolling only one snappable children*/
|
||||
LV_OBJ_FLAG_SCROLL_CHAIN = (1L << 8), /**< Allow propagating the scroll to a parent*/
|
||||
LV_OBJ_FLAG_SCROLL_ON_FOCUS = (1L << 9), /**< Automatically scroll object to make it visible when focused*/
|
||||
LV_OBJ_FLAG_SNAPPABLE = (1L << 10), /**< If scroll snap is enabled on the parent it can snap to this object*/
|
||||
LV_OBJ_FLAG_PRESS_LOCK = (1L << 11), /**< Keep the object pressed even if the press slid from the object*/
|
||||
LV_OBJ_FLAG_EVENT_BUBBLE = (1L << 12), /**< Propagate the events to the parent too*/
|
||||
LV_OBJ_FLAG_GESTURE_BUBBLE = (1L << 13), /**< Propagate the gestures to the parent*/
|
||||
LV_OBJ_FLAG_ADV_HITTEST = (1L << 14), /**< Allow performing more accurate hit (click) test. E.g. consider rounded corners.*/
|
||||
LV_OBJ_FLAG_IGNORE_LAYOUT = (1L << 15), /**< Make the object position-able by the layouts*/
|
||||
LV_OBJ_FLAG_FLOATING = (1L << 16), /**< Do not scroll the object when the parent scrolls and ignore layout*/
|
||||
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1 << 23), /** Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1 << 24), /** Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_1 = (1L << 23), /**< Custom flag, free to use by layouts*/
|
||||
LV_OBJ_FLAG_LAYOUT_2 = (1L << 24), /**< Custom flag, free to use by layouts*/
|
||||
|
||||
LV_OBJ_FLAG_WIDGET_1 = (1 << 25), /** Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_WIDGET_2 = (1 << 26), /** Custom flag, free to use by widget*/
|
||||
|
||||
LV_OBJ_FLAG_USER_1 = (1 << 27), /** Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_2 = (1 << 28), /** Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_3 = (1 << 29), /** Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_4 = (1 << 30), /** Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_WIDGET_1 = (1L << 25), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_WIDGET_2 = (1L << 26), /**< Custom flag, free to use by widget*/
|
||||
LV_OBJ_FLAG_USER_1 = (1L << 27), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_2 = (1L << 28), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_3 = (1L << 29), /**< Custom flag, free to use by user*/
|
||||
LV_OBJ_FLAG_USER_4 = (1L << 30), /**< Custom flag, free to use by user*/
|
||||
};
|
||||
typedef uint32_t lv_obj_flag_t;
|
||||
|
||||
/**
|
||||
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_obj_class`
|
||||
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
|
||||
*/
|
||||
typedef enum {
|
||||
LV_OBJ_DRAW_PART_RECTANGLE, /**< The main rectangle*/
|
||||
LV_OBJ_DRAW_PART_BORDER_POST,/**< The border if style_border_post = true*/
|
||||
LV_OBJ_DRAW_PART_SCROLLBAR, /**< The scrollbar*/
|
||||
} lv_obj_draw_part_type_t;
|
||||
|
||||
#include "lv_obj_tree.h"
|
||||
#include "lv_obj_pos.h"
|
||||
#include "lv_obj_scroll.h"
|
||||
|
@ -141,18 +150,18 @@ typedef struct {
|
|||
uint32_t child_cnt; /**< Number of children*/
|
||||
lv_group_t * group_p;
|
||||
|
||||
struct _lv_event_dsc_t * event_dsc; /**< Dynamically allocated event callback and user data array*/
|
||||
lv_point_t scroll; /**< The current X/Y scroll offset*/
|
||||
struct _lv_event_dsc_t * event_dsc; /**< Dynamically allocated event callback and user data array*/
|
||||
lv_point_t scroll; /**< The current X/Y scroll offset*/
|
||||
|
||||
lv_coord_t ext_click_pad; /**< Extra click padding in all direction*/
|
||||
lv_coord_t ext_click_pad; /**< Extra click padding in all direction*/
|
||||
lv_coord_t ext_draw_size; /**< EXTend the size in every direction for drawing.*/
|
||||
|
||||
lv_scrollbar_mode_t scrollbar_mode :2; /**< How to display scrollbars*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snapable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snapable children horizontally*/
|
||||
lv_dir_t scroll_dir :4; /**< The allowed scroll direction(s)*/
|
||||
uint8_t event_dsc_cnt; /**< Number of event callabcks stored in `event_cb` array*/
|
||||
}_lv_obj_spec_attr_t;
|
||||
lv_scrollbar_mode_t scrollbar_mode : 2; /**< How to display scrollbars*/
|
||||
lv_scroll_snap_t scroll_snap_x : 2; /**< Where to align the snappable children horizontally*/
|
||||
lv_scroll_snap_t scroll_snap_y : 2; /**< Where to align the snappable children vertically*/
|
||||
lv_dir_t scroll_dir : 4; /**< The allowed scroll direction(s)*/
|
||||
uint8_t event_dsc_cnt; /**< Number of event callbacks stored in `event_dsc` array*/
|
||||
} _lv_obj_spec_attr_t;
|
||||
|
||||
typedef struct _lv_obj_t {
|
||||
const lv_obj_class_t * class_p;
|
||||
|
@ -165,13 +174,13 @@ typedef struct _lv_obj_t {
|
|||
lv_area_t coords;
|
||||
lv_obj_flag_t flags;
|
||||
lv_state_t state;
|
||||
uint16_t layout_inv :1;
|
||||
uint16_t scr_layout_inv :1;
|
||||
uint16_t skip_trans :1;
|
||||
uint16_t style_cnt :6;
|
||||
uint16_t h_layout :1;
|
||||
uint16_t w_layout :1;
|
||||
}lv_obj_t;
|
||||
uint16_t layout_inv : 1;
|
||||
uint16_t scr_layout_inv : 1;
|
||||
uint16_t skip_trans : 1;
|
||||
uint16_t style_cnt : 6;
|
||||
uint16_t h_layout : 1;
|
||||
uint16_t w_layout : 1;
|
||||
} lv_obj_t;
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -184,7 +193,7 @@ typedef struct _lv_obj_t {
|
|||
*/
|
||||
void lv_init(void);
|
||||
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM
|
||||
#if LV_ENABLE_GC || !LV_MEM_CUSTOM || LV_USE_GPU_SDL
|
||||
|
||||
/**
|
||||
* Deinit the 'lv' library
|
||||
|
@ -194,10 +203,15 @@ void lv_deinit(void);
|
|||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns whether the 'lv' library is currently initialized
|
||||
*/
|
||||
bool lv_is_initialized(void);
|
||||
|
||||
/**
|
||||
* Create a base object (a rectangle)
|
||||
* @param parent pointer to a parent object. If NULL then a screen will be created.
|
||||
* @return pointer to the new object
|
||||
* @return pointer to the new object
|
||||
*/
|
||||
lv_obj_t * lv_obj_create(lv_obj_t * parent);
|
||||
|
||||
|
@ -314,10 +328,10 @@ static inline void * lv_obj_get_user_data(lv_obj_t * obj)
|
|||
void lv_obj_allocate_spec_attr(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get object's and its ancestors type. Put their name in `type_buf` starting with the current type.
|
||||
* E.g. buf.type[0]="lv_btn", buf.type[1]="lv_cont", buf.type[2]="lv_obj"
|
||||
* @param obj pointer to an object which type should be get
|
||||
* @param buf pointer to an `lv_obj_type_t` buffer to store the types
|
||||
* Check the type of obj.
|
||||
* @param obj pointer to an object
|
||||
* @param class_p a class to check (e.g. `lv_slider_class`)
|
||||
* @return true: `class_p` is the `obj` class.
|
||||
*/
|
||||
bool lv_obj_check_type(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
||||
|
||||
|
@ -332,15 +346,14 @@ bool lv_obj_has_class(const lv_obj_t * obj, const lv_obj_class_t * class_p);
|
|||
|
||||
/**
|
||||
* Get the class (type) of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the class (type) of the object
|
||||
* @param obj pointer to an object
|
||||
* @return the class (type) of the object
|
||||
*/
|
||||
const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Check if any object is still "alive", and part of the hierarchy
|
||||
* Check if any object is still "alive".
|
||||
* @param obj pointer to an object
|
||||
* @param obj_type type of the object. (e.g. "lv_btn")
|
||||
* @return true: valid
|
||||
*/
|
||||
bool lv_obj_is_valid(const lv_obj_t * obj);
|
||||
|
@ -365,16 +378,16 @@ static inline lv_coord_t lv_obj_dpx(const lv_obj_t * obj, lv_coord_t n)
|
|||
|
||||
#if LV_USE_ASSERT_OBJ
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) \
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?");
|
||||
LV_ASSERT_MSG(obj_p != NULL, "The object is NULL"); \
|
||||
LV_ASSERT_MSG(lv_obj_has_class(obj_p, obj_class) == true, "Incompatible object type."); \
|
||||
LV_ASSERT_MSG(lv_obj_is_valid(obj_p) == true, "The object is invalid, deleted or corrupted?");
|
||||
|
||||
# else
|
||||
# define LV_ASSERT_OBJ(obj_p, obj_class) do{}while(0)
|
||||
#endif
|
||||
|
||||
#if LV_USE_LOG && LV_LOG_TRACE_OBJ_CREATE
|
||||
# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE( __VA_ARGS__)
|
||||
# define LV_TRACE_OBJ_CREATE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define LV_TRACE_OBJ_CREATE(...)
|
||||
#endif
|
||||
|
|
|
@ -42,7 +42,7 @@ static uint32_t get_instance_size(const lv_obj_class_t * class_p);
|
|||
|
||||
lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * parent)
|
||||
{
|
||||
LV_TRACE_OBJ_CREATE("Creating object with %p class on %p parent", class_p, parent);
|
||||
LV_TRACE_OBJ_CREATE("Creating object with %p class on %p parent", (void *)class_p, (void *)parent);
|
||||
uint32_t s = get_instance_size(class_p);
|
||||
lv_obj_t * obj = lv_mem_alloc(s);
|
||||
if(obj == NULL) return NULL;
|
||||
|
@ -63,7 +63,8 @@ lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * pa
|
|||
disp->screens = lv_mem_alloc(sizeof(lv_obj_t *));
|
||||
disp->screens[0] = obj;
|
||||
disp->screen_cnt = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
disp->screen_cnt++;
|
||||
disp->screens = lv_mem_realloc(disp->screens, sizeof(lv_obj_t *) * disp->screen_cnt);
|
||||
disp->screens[disp->screen_cnt - 1] = obj;
|
||||
|
@ -87,9 +88,11 @@ lv_obj_t * lv_obj_class_create_obj(const lv_obj_class_t * class_p, lv_obj_t * pa
|
|||
parent->spec_attr->children = lv_mem_alloc(sizeof(lv_obj_t *));
|
||||
parent->spec_attr->children[0] = obj;
|
||||
parent->spec_attr->child_cnt = 1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
parent->spec_attr->child_cnt++;
|
||||
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, sizeof(lv_obj_t *) * parent->spec_attr->child_cnt);
|
||||
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children,
|
||||
sizeof(lv_obj_t *) * parent->spec_attr->child_cnt);
|
||||
parent->spec_attr->children[parent->spec_attr->child_cnt - 1] = obj;
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +123,7 @@ void lv_obj_class_init_obj(lv_obj_t * obj)
|
|||
/*Call the ancestor's event handler to the parent to notify it about the new child.
|
||||
*Also triggers layout update*/
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CREATED, obj);
|
||||
|
||||
/*Invalidate the area if not screen created*/
|
||||
lv_obj_invalidate(obj);
|
||||
|
|
|
@ -33,13 +33,13 @@ typedef enum {
|
|||
LV_OBJ_CLASS_EDITABLE_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
|
||||
LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
LV_OBJ_CLASS_EDITABLE_FALSE,
|
||||
}lv_obj_class_editable_t;
|
||||
} lv_obj_class_editable_t;
|
||||
|
||||
typedef enum {
|
||||
LV_OBJ_CLASS_GROUP_DEF_INHERIT, /**< Check the base class. Must have 0 value to let zero initialized class inherit*/
|
||||
LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
LV_OBJ_CLASS_GROUP_DEF_FALSE,
|
||||
}lv_obj_class_group_def_t;
|
||||
} lv_obj_class_group_def_t;
|
||||
|
||||
typedef void (*lv_obj_class_event_cb_t)(struct _lv_obj_class_t * class_p, struct _lv_event_t * e);
|
||||
/**
|
||||
|
@ -53,13 +53,14 @@ typedef struct _lv_obj_class_t {
|
|||
#if LV_USE_USER_DATA
|
||||
void * user_data;
|
||||
#endif
|
||||
void (*event_cb)(const struct _lv_obj_class_t * class_p, struct _lv_event_t * e); /**< Widget type specific event function*/
|
||||
void (*event_cb)(const struct _lv_obj_class_t * class_p,
|
||||
struct _lv_event_t * e); /**< Widget type specific event function*/
|
||||
lv_coord_t width_def;
|
||||
lv_coord_t height_def;
|
||||
uint32_t editable : 2; /**< Value from ::lv_obj_class_editable_t*/
|
||||
uint32_t group_def : 2; /**< Value from ::lv_obj_class_group_def_t*/
|
||||
uint32_t instance_size : 16;
|
||||
}lv_obj_class_t;
|
||||
} lv_obj_class_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
|
|
@ -84,7 +84,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t
|
|||
draw_dsc->outline_opa = lv_obj_get_style_outline_opa(obj, part);
|
||||
if(draw_dsc->outline_opa > LV_OPA_MIN) {
|
||||
draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part);
|
||||
draw_dsc->outline_color = lv_obj_get_style_outline_color(obj, part);
|
||||
draw_dsc->outline_color = lv_obj_get_style_outline_color_filtered(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +95,11 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t
|
|||
draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part);
|
||||
if(draw_dsc->bg_img_opa > LV_OPA_MIN) {
|
||||
if(lv_img_src_get_type(draw_dsc->bg_img_src) == LV_IMG_SRC_SYMBOL) {
|
||||
draw_dsc->bg_img_symbol_font= lv_obj_get_style_text_font(obj, part);
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_text_color(obj, part);
|
||||
} else {
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part);
|
||||
draw_dsc->bg_img_symbol_font = lv_obj_get_style_text_font(obj, part);
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_text_color_filtered(obj, part);
|
||||
}
|
||||
else {
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor_filtered(obj, part);
|
||||
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
|
||||
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t
|
|||
draw_dsc->outline_opa = lv_obj_get_style_outline_opa(obj, part);
|
||||
if(draw_dsc->outline_opa > LV_OPA_MIN) {
|
||||
draw_dsc->outline_pad = lv_obj_get_style_outline_pad(obj, part);
|
||||
draw_dsc->outline_color = lv_obj_get_style_outline_color(obj, part);
|
||||
draw_dsc->outline_color = lv_obj_get_style_outline_color_filtered(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,13 +168,14 @@ void lv_obj_init_draw_rect_dsc(lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t
|
|||
draw_dsc->bg_img_opa = lv_obj_get_style_bg_img_opa(obj, part);
|
||||
if(draw_dsc->bg_img_opa > LV_OPA_MIN) {
|
||||
if(lv_img_src_get_type(draw_dsc->bg_img_src) == LV_IMG_SRC_SYMBOL) {
|
||||
draw_dsc->bg_img_symbol_font= lv_obj_get_style_text_font(obj, part);
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_text_color(obj, part);
|
||||
} else {
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor(obj, part);
|
||||
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
|
||||
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
|
||||
}
|
||||
draw_dsc->bg_img_symbol_font = lv_obj_get_style_text_font(obj, part);
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_text_color_filtered(obj, part);
|
||||
}
|
||||
else {
|
||||
draw_dsc->bg_img_recolor = lv_obj_get_style_bg_img_recolor_filtered(obj, part);
|
||||
draw_dsc->bg_img_recolor_opa = lv_obj_get_style_bg_img_recolor_opa(obj, part);
|
||||
draw_dsc->bg_img_tiled = lv_obj_get_style_bg_img_tiled(obj, part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -206,10 +208,6 @@ void lv_obj_init_draw_label_dsc(lv_obj_t * obj, uint32_t part, lv_draw_label_dsc
|
|||
#endif
|
||||
|
||||
draw_dsc->align = lv_obj_get_style_text_align(obj, part);
|
||||
if(draw_dsc->align == LV_TEXT_ALIGN_AUTO) {
|
||||
if(draw_dsc->bidi_dir == LV_BASE_DIR_RTL) draw_dsc->align = LV_TEXT_ALIGN_RIGHT;
|
||||
else draw_dsc->align = LV_TEXT_ALIGN_LEFT;
|
||||
}
|
||||
}
|
||||
|
||||
void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc)
|
||||
|
@ -230,7 +228,7 @@ void lv_obj_init_draw_img_dsc(lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t *
|
|||
|
||||
draw_dsc->recolor_opa = lv_obj_get_style_img_recolor_opa(obj, part);
|
||||
if(draw_dsc->recolor_opa > 0) {
|
||||
draw_dsc->recolor = lv_obj_get_style_img_recolor(obj, part);
|
||||
draw_dsc->recolor = lv_obj_get_style_img_recolor_filtered(obj, part);
|
||||
}
|
||||
#if LV_DRAW_COMPLEX
|
||||
draw_dsc->blend_mode = lv_obj_get_style_blend_mode(obj, part);
|
||||
|
@ -251,7 +249,7 @@ void lv_obj_init_draw_line_dsc(lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t
|
|||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_line_color(obj, part);
|
||||
draw_dsc->color = lv_obj_get_style_line_color_filtered(obj, part);
|
||||
|
||||
draw_dsc->dash_width = lv_obj_get_style_line_dash_width(obj, part);
|
||||
if(draw_dsc->dash_width) {
|
||||
|
@ -280,7 +278,7 @@ void lv_obj_init_draw_arc_dsc(lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t *
|
|||
}
|
||||
if(draw_dsc->opa <= LV_OPA_MIN) return;
|
||||
|
||||
draw_dsc->color = lv_obj_get_style_arc_color(obj, part);
|
||||
draw_dsc->color = lv_obj_get_style_arc_color_filtered(obj, part);
|
||||
draw_dsc->img_src = lv_obj_get_style_arc_img_src(obj, part);
|
||||
|
||||
draw_dsc->rounded = lv_obj_get_style_arc_rounded(obj, part);
|
||||
|
@ -330,6 +328,12 @@ void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_a
|
|||
dsc->clip_area = clip_area;
|
||||
}
|
||||
|
||||
bool lv_obj_draw_part_check_type(lv_obj_draw_part_dsc_t * dsc, const lv_obj_class_t * class_p, uint32_t type)
|
||||
{
|
||||
if(dsc->class_p == class_p && dsc->type == type) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
void lv_obj_refresh_ext_draw_size(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
|
|
@ -24,32 +24,41 @@ extern "C" {
|
|||
**********************/
|
||||
|
||||
struct _lv_obj_t;
|
||||
struct _lv_obj_class_t;
|
||||
|
||||
/** Cover check results.*/
|
||||
typedef enum {
|
||||
LV_COVER_RES_COVER = 0,
|
||||
LV_COVER_RES_NOT_COVER = 1,
|
||||
LV_COVER_RES_MASKED = 2,
|
||||
}lv_cover_res_t;
|
||||
} lv_cover_res_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
const lv_area_t * clip_area; /**< The current clip area, required if you need to draw something in the event*/
|
||||
const struct _lv_obj_class_t * class_p; /**< The class that sent the event */
|
||||
uint32_t type; /**< The type if part being draw. Element of `lv_<name>_draw_part_type_t` */
|
||||
lv_area_t * draw_area; /**< The area of the part being drawn*/
|
||||
lv_draw_rect_dsc_t * rect_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for rectangle-like parts*/
|
||||
lv_draw_label_dsc_t * label_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for text-like parts*/
|
||||
lv_draw_line_dsc_t * line_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for line-like parts*/
|
||||
lv_draw_img_dsc_t * img_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for image-like parts*/
|
||||
lv_draw_arc_dsc_t * arc_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for arc-like parts*/
|
||||
const lv_point_t * p1; /**< A point calculated during drawing. E.g. a point of chart or the center of an arc.*/
|
||||
lv_draw_rect_dsc_t *
|
||||
rect_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for rectangle-like parts*/
|
||||
lv_draw_label_dsc_t *
|
||||
label_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for text-like parts*/
|
||||
lv_draw_line_dsc_t *
|
||||
line_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for line-like parts*/
|
||||
lv_draw_img_dsc_t *
|
||||
img_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for image-like parts*/
|
||||
lv_draw_arc_dsc_t *
|
||||
arc_dsc; /**< A draw descriptor that can be modified to changed what LVGL will draw. Set only for arc-like parts*/
|
||||
const lv_point_t *
|
||||
p1; /**< A point calculated during drawing. E.g. a point of chart or the center of an arc.*/
|
||||
const lv_point_t * p2; /**< A point calculated during drawing. E.g. a point of chart.*/
|
||||
char text[16]; /**< A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.*/
|
||||
char * text; /**< A text calculated during drawing. Can be modified. E.g. tick labels on a chart axis.*/
|
||||
uint32_t text_length; /**< Size of the text buffer containing null-terminated text string calculated during drawing.*/
|
||||
uint32_t part; /**< The current part for which the event is sent*/
|
||||
uint32_t id; /**< The index of the part. E.g. a button's index on button matrix or table cell index.*/
|
||||
lv_coord_t radius; /**< E.g. the radius of an arc (not the corner radius).*/
|
||||
int32_t value; /**< A value calculated during drawing. E.g. Chart's tick line value.*/
|
||||
const void * sub_part_ptr; /**< A pointer the identifies something in the part. E.g. chart series. */
|
||||
}lv_obj_draw_part_dsc_t;
|
||||
} lv_obj_draw_part_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
@ -59,8 +68,8 @@ typedef struct
|
|||
* Initialize a rectangle draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object. E.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor the initialize.
|
||||
* If an `..._opa` filed is set to `LV_OPA_TRANSP` the related properties won't be initialized.
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* If an `..._opa` field is set to `LV_OPA_TRANSP` the related properties won't be initialized.
|
||||
* Should be initialized with `lv_draw_rect_dsc_init(draw_dsc)`.
|
||||
* @note Only the relevant fields will be set.
|
||||
* E.g. if `border width == 0` the other border properties won't be evaluated.
|
||||
|
@ -71,8 +80,8 @@ void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_re
|
|||
* Initialize a label draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object. E.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor the initialize.
|
||||
* If the `opa` filed is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized.
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* If the `opa` field is set to or the property is equal to `LV_OPA_TRANSP` the rest won't be initialized.
|
||||
* Should be initialized with `lv_draw_label_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc);
|
||||
|
@ -81,7 +90,7 @@ void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_l
|
|||
* Initialize an image draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object. E.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor the initialize.
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_image_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc);
|
||||
|
@ -91,7 +100,7 @@ void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_img
|
|||
* Initialize a line draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object. E.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor the initialize.
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_line_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_line_dsc_t * draw_dsc);
|
||||
|
@ -100,7 +109,7 @@ void lv_obj_init_draw_line_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_li
|
|||
* Initialize an arc draw descriptor from an object's styles in its current state
|
||||
* @param obj pointer to an object
|
||||
* @param part part of the object. E.g. `LV_PART_MAIN`, `LV_PART_SCROLLBAR`, `LV_PART_KNOB`, etc
|
||||
* @param draw_dsc the descriptor the initialize.
|
||||
* @param draw_dsc the descriptor to initialize.
|
||||
* Should be initialized with `lv_draw_arc_dsc_init(draw_dsc)`.
|
||||
*/
|
||||
void lv_obj_init_draw_arc_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_arc_dsc_t * draw_dsc);
|
||||
|
@ -120,6 +129,15 @@ lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part)
|
|||
*/
|
||||
void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area);
|
||||
|
||||
/**
|
||||
* Check the type obj a part draw descriptor
|
||||
* @param dsc the descriptor (normally the event parameter)
|
||||
* @param class_p pointer to class to which `type` is related
|
||||
* @param type element of `lv_<name>_draw_part_type_t`
|
||||
* @return true if ::dsc is related to ::class_p and ::type
|
||||
*/
|
||||
bool lv_obj_draw_part_check_type(lv_obj_draw_part_dsc_t * dsc, const struct _lv_obj_class_t * class_p, uint32_t type);
|
||||
|
||||
/**
|
||||
* Send a 'LV_EVENT_REFR_EXT_DRAW_SIZE' Call the ancestor's event handler to the object to refresh the value of the extended draw size.
|
||||
* The result will be saved in `obj`.
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void calc_auto_size(lv_obj_t * obj, lv_coord_t * w_out, lv_coord_t * h_out);
|
||||
static lv_coord_t calc_content_width(lv_obj_t * obj);
|
||||
static lv_coord_t calc_content_height(lv_obj_t * obj);
|
||||
static void layout_update_core(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
|
@ -50,9 +51,6 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
|||
void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
if(lv_obj_is_layout_positioned(obj)) {
|
||||
return;
|
||||
}
|
||||
|
||||
lv_res_t res_x;
|
||||
lv_style_value_t v_x;
|
||||
|
@ -66,9 +64,6 @@ void lv_obj_set_x(lv_obj_t * obj, lv_coord_t x)
|
|||
|
||||
void lv_obj_set_y(lv_obj_t * obj, lv_coord_t y)
|
||||
{
|
||||
if(lv_obj_is_layout_positioned(obj)) {
|
||||
return;
|
||||
}
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_res_t res_y;
|
||||
|
@ -91,51 +86,69 @@ bool lv_obj_refr_size(lv_obj_t * obj)
|
|||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(parent == NULL) return false;
|
||||
|
||||
lv_coord_t w;
|
||||
lv_coord_t sl_ori = lv_obj_get_scroll_left(obj);
|
||||
bool w_content = false;
|
||||
bool w_is_content = false;
|
||||
bool w_is_pct = false;
|
||||
|
||||
lv_coord_t w;
|
||||
if(obj->w_layout) {
|
||||
w = lv_obj_get_width(obj);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
w = lv_obj_get_style_width(obj, LV_PART_MAIN);
|
||||
w_content = w == LV_SIZE_CONTENT ? true : false;
|
||||
|
||||
/*Be sure the object is not scrolled when it has auto size*/
|
||||
if(w_content) {
|
||||
lv_obj_scroll_to_x(obj, 0, LV_ANIM_OFF);
|
||||
calc_auto_size(obj, &w, NULL);
|
||||
}
|
||||
|
||||
/*Calculate the sizes in percentage*/
|
||||
bool pct_w = LV_COORD_IS_PCT(w) ? true : false;
|
||||
|
||||
w_is_content = w == LV_SIZE_CONTENT ? true : false;
|
||||
w_is_pct = LV_COORD_IS_PCT(w) ? true : false;
|
||||
lv_coord_t parent_w = lv_obj_get_content_width(parent);
|
||||
if(pct_w) w = (LV_COORD_GET_PCT(w) * parent_w) / 100;
|
||||
|
||||
if(w_is_content) {
|
||||
w = calc_content_width(obj);
|
||||
}
|
||||
else if(w_is_pct) {
|
||||
/*If parent has content size and the child has pct size
|
||||
*a circular dependency will occur. To solve it keep child size at zero */
|
||||
if(parent->w_layout == 0 && lv_obj_get_style_width(parent, 0) == LV_SIZE_CONTENT) {
|
||||
lv_coord_t border_w = lv_obj_get_style_border_width(obj, 0);
|
||||
w = lv_obj_get_style_pad_left(obj, 0) + border_w;
|
||||
w += lv_obj_get_style_pad_right(obj, 0) + border_w;
|
||||
}
|
||||
else {
|
||||
w = (LV_COORD_GET_PCT(w) * parent_w) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
lv_coord_t minw = lv_obj_get_style_min_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t maxw = lv_obj_get_style_max_width(obj, LV_PART_MAIN);
|
||||
w = lv_clamp_width(w, minw, maxw, parent_w);
|
||||
}
|
||||
|
||||
lv_coord_t h;
|
||||
lv_coord_t st_ori = lv_obj_get_scroll_top(obj);
|
||||
bool h_content = false;
|
||||
lv_coord_t h;
|
||||
bool h_is_content = false;
|
||||
bool h_is_pct = false;
|
||||
if(obj->h_layout) {
|
||||
h = lv_obj_get_height(obj);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
h = lv_obj_get_style_height(obj, LV_PART_MAIN);
|
||||
h_content = h == LV_SIZE_CONTENT ? true : false;
|
||||
|
||||
/*Be sure the object is not scrolled when it has auto size*/
|
||||
if(h_content) {
|
||||
lv_obj_scroll_to_y(obj, 0, LV_ANIM_OFF);
|
||||
calc_auto_size(obj, NULL, &h);
|
||||
}
|
||||
|
||||
/*Calculate the sizes in percentage*/
|
||||
bool pct_h = LV_COORD_IS_PCT(h) ? true : false;
|
||||
h_is_content = h == LV_SIZE_CONTENT ? true : false;
|
||||
h_is_pct = LV_COORD_IS_PCT(h) ? true : false;
|
||||
lv_coord_t parent_h = lv_obj_get_content_height(parent);
|
||||
if(pct_h) h = (LV_COORD_GET_PCT(h) * parent_h) / 100;
|
||||
|
||||
if(h_is_content) {
|
||||
h = calc_content_height(obj);
|
||||
}
|
||||
else if(h_is_pct) {
|
||||
/*If parent has content size and the child has pct size
|
||||
*a circular dependency will occur. To solve it keep child size at zero */
|
||||
if(parent->h_layout == 0 && lv_obj_get_style_height(parent, 0) == LV_SIZE_CONTENT) {
|
||||
lv_coord_t border_w = lv_obj_get_style_border_width(obj, 0);
|
||||
h = lv_obj_get_style_pad_top(obj, 0) + border_w;
|
||||
h += lv_obj_get_style_pad_bottom(obj, 0) + border_w;
|
||||
}
|
||||
else {
|
||||
h = (LV_COORD_GET_PCT(h) * parent_h) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
lv_coord_t minh = lv_obj_get_style_min_height(obj, LV_PART_MAIN);
|
||||
lv_coord_t maxh = lv_obj_get_style_max_height(obj, LV_PART_MAIN);
|
||||
|
@ -143,7 +156,7 @@ bool lv_obj_refr_size(lv_obj_t * obj)
|
|||
}
|
||||
|
||||
/*calc_auto_size set the scroll x/y to 0 so revert the original value*/
|
||||
if(w_content || h_content) {
|
||||
if(w_is_content || h_is_content) {
|
||||
lv_obj_scroll_to(obj, sl_ori, st_ori, LV_ANIM_OFF);
|
||||
}
|
||||
|
||||
|
@ -193,10 +206,6 @@ bool lv_obj_refr_size(lv_obj_t * obj)
|
|||
bool on2 = _lv_area_is_in(&obj->coords, &parent_fit_area, 0);
|
||||
if(on1 || (!on1 && on2)) lv_obj_scrollbar_invalidate(parent);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -277,7 +286,7 @@ void lv_obj_mark_layout_as_dirty(lv_obj_t * obj)
|
|||
{
|
||||
obj->layout_inv = 1;
|
||||
|
||||
/*Mark the screen as dirty too to mark that there is an something to do on this screen*/
|
||||
/*Mark the screen as dirty too to mark that there is something to do on this screen*/
|
||||
lv_obj_t * scr = lv_obj_get_screen(obj);
|
||||
scr->scr_layout_inv = 1;
|
||||
|
||||
|
@ -290,7 +299,7 @@ void lv_obj_update_layout(const lv_obj_t * obj)
|
|||
{
|
||||
static bool mutex = false;
|
||||
if(mutex) {
|
||||
LV_LOG_TRACE("Already running, returning")
|
||||
LV_LOG_TRACE("Already running, returning");
|
||||
return;
|
||||
}
|
||||
mutex = true;
|
||||
|
@ -299,10 +308,10 @@ void lv_obj_update_layout(const lv_obj_t * obj)
|
|||
|
||||
/*Repeat until there where layout invalidations*/
|
||||
while(scr->scr_layout_inv) {
|
||||
LV_LOG_INFO("Layout update begin")
|
||||
LV_LOG_INFO("Layout update begin");
|
||||
scr->scr_layout_inv = 0;
|
||||
layout_update_core(scr);
|
||||
LV_LOG_TRACE("Layout update end")
|
||||
LV_LOG_TRACE("Layout update end");
|
||||
}
|
||||
|
||||
mutex = false;
|
||||
|
@ -357,110 +366,115 @@ void lv_obj_align_to(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv
|
|||
}
|
||||
|
||||
switch(align) {
|
||||
case LV_ALIGN_CENTER:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
x = bleft;
|
||||
y = btop;
|
||||
break;
|
||||
case LV_ALIGN_TOP_MID:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = btop;
|
||||
break;
|
||||
case LV_ALIGN_CENTER:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
x = bleft;
|
||||
y = btop;
|
||||
break;
|
||||
case LV_ALIGN_TOP_MID:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = btop;
|
||||
break;
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
x = bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_MID:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
x = bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_MID:
|
||||
x = lv_obj_get_content_width(base) / 2 - lv_obj_get_width(obj) / 2 + bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_BOTTOM_RIGHT:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_RIGHT:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = lv_obj_get_content_height(base) - lv_obj_get_height(obj) + btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
x = bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
x = bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_RIGHT_MID:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
case LV_ALIGN_RIGHT_MID:
|
||||
x = lv_obj_get_content_width(base) - lv_obj_get_width(obj) + bleft;
|
||||
y = lv_obj_get_content_height(base) / 2 - lv_obj_get_height(obj) / 2 + btop;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
x = 0;
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_OUT_TOP_LEFT:
|
||||
x = 0;
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_MID:
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_OUT_TOP_MID:
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = -lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||
x = 0;
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||
x = 0;
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_TOP:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = 0;
|
||||
break;
|
||||
case LV_ALIGN_OUT_LEFT_TOP:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = 0;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_MID:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
case LV_ALIGN_OUT_LEFT_MID:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||
x = -lv_obj_get_width(obj);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||
x = lv_obj_get_width(base);
|
||||
y = 0;
|
||||
break;
|
||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||
x = lv_obj_get_width(base);
|
||||
y = 0;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_MID:
|
||||
x = lv_obj_get_width(base);
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
case LV_ALIGN_OUT_RIGHT_MID:
|
||||
x = lv_obj_get_width(base);
|
||||
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||
break;
|
||||
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
x = lv_obj_get_width(base);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||
x = lv_obj_get_width(base);
|
||||
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||
break;
|
||||
}
|
||||
|
||||
x += x_ofs + base->coords.x1 - parent->coords.x1 + lv_obj_get_scroll_left(parent) - pleft;
|
||||
if(lv_obj_get_style_base_dir(parent, LV_PART_MAIN) == LV_BASE_DIR_RTL) {
|
||||
x += x_ofs + base->coords.x1 - parent->coords.x1 + lv_obj_get_scroll_right(parent) - pleft;
|
||||
}
|
||||
else {
|
||||
x += x_ofs + base->coords.x1 - parent->coords.x1 + lv_obj_get_scroll_left(parent) - pleft;
|
||||
}
|
||||
y += y_ofs + base->coords.y1 - parent->coords.y1 + lv_obj_get_scroll_top(parent) - ptop;
|
||||
lv_obj_set_style_align(obj, LV_ALIGN_TOP_LEFT, 0);
|
||||
lv_obj_set_pos(obj, x, y);
|
||||
|
@ -577,14 +591,14 @@ void lv_obj_get_content_coords(const lv_obj_t * obj, lv_area_t * area)
|
|||
lv_coord_t lv_obj_get_self_width(const lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {0, LV_COORD_MIN};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
lv_event_send((lv_obj_t *)obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
return p.x;
|
||||
}
|
||||
|
||||
lv_coord_t lv_obj_get_self_height(const lv_obj_t * obj)
|
||||
{
|
||||
lv_point_t p = {LV_COORD_MIN, 0};
|
||||
lv_event_send((lv_obj_t * )obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
lv_event_send((lv_obj_t *)obj, LV_EVENT_GET_SELF_SIZE, &p);
|
||||
return p.y;
|
||||
}
|
||||
|
||||
|
@ -642,36 +656,36 @@ void lv_obj_refr_pos(lv_obj_t * obj)
|
|||
else {
|
||||
|
||||
switch(align) {
|
||||
case LV_ALIGN_TOP_MID:
|
||||
x += pw / 2 - w / 2;
|
||||
break;
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
x += pw - w;
|
||||
break;
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_MID:
|
||||
x += pw / 2 - w / 2;
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_RIGHT:
|
||||
x += pw - w;
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_RIGHT_MID:
|
||||
x += pw - w;
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
case LV_ALIGN_CENTER:
|
||||
x += pw / 2 - w / 2;
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LV_ALIGN_TOP_MID:
|
||||
x += pw / 2 - w / 2;
|
||||
break;
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
x += pw - w;
|
||||
break;
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_MID:
|
||||
x += pw / 2 - w / 2;
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_BOTTOM_RIGHT:
|
||||
x += pw - w;
|
||||
y += ph - h;
|
||||
break;
|
||||
case LV_ALIGN_RIGHT_MID:
|
||||
x += pw - w;
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
case LV_ALIGN_CENTER:
|
||||
x += pw / 2 - w / 2;
|
||||
y += ph / 2 - h / 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
lv_obj_move_to(obj, x, y);
|
||||
}
|
||||
|
@ -689,7 +703,8 @@ void lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
|||
if(lv_obj_has_flag(obj, LV_OBJ_FLAG_FLOATING)) {
|
||||
x += pad_left + parent->coords.x1;
|
||||
y += pad_top + parent->coords.y1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
x += pad_left + parent->coords.x1 - lv_obj_get_scroll_x(parent);
|
||||
y += pad_top + parent->coords.y1 - lv_obj_get_scroll_y(parent);
|
||||
}
|
||||
|
@ -752,8 +767,9 @@ void lv_obj_move_to(lv_obj_t * obj, lv_coord_t x, lv_coord_t y)
|
|||
void lv_obj_move_children_by(lv_obj_t * obj, lv_coord_t x_diff, lv_coord_t y_diff, bool ignore_floating)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(ignore_floating && lv_obj_has_flag(child, LV_OBJ_FLAG_FLOATING)) continue;
|
||||
child->coords.x1 += x_diff;
|
||||
child->coords.y1 += y_diff;
|
||||
|
@ -803,8 +819,7 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
|
|||
if(obj_scr != lv_disp_get_scr_act(disp) &&
|
||||
obj_scr != lv_disp_get_scr_prev(disp) &&
|
||||
obj_scr != lv_disp_get_layer_top(disp) &&
|
||||
obj_scr != lv_disp_get_layer_sys(disp))
|
||||
{
|
||||
obj_scr != lv_disp_get_layer_sys(disp)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -827,7 +842,8 @@ bool lv_obj_area_is_visible(const lv_obj_t * obj, lv_area_t * area)
|
|||
while(par != NULL) {
|
||||
is_common = _lv_area_intersect(area, area, &par->coords);
|
||||
if(is_common == false) return false; /*If no common parts with parent break;*/
|
||||
if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return false; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
if(lv_obj_has_flag(par, LV_OBJ_FLAG_HIDDEN)) return
|
||||
false; /*If the parent is hidden then the child is hidden and won't be drawn*/
|
||||
|
||||
par = lv_obj_get_parent(par);
|
||||
}
|
||||
|
@ -908,34 +924,145 @@ lv_coord_t lv_clamp_height(lv_coord_t height, lv_coord_t min_height, lv_coord_t
|
|||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Calculate the "auto size". It's `auto_size = max(children_size, self_size)`
|
||||
* @param obj pointer to an object
|
||||
* @param w_out store the width here. NULL to not calculate width
|
||||
* @param h_out store the height here. NULL to not calculate height
|
||||
*/
|
||||
static void calc_auto_size(lv_obj_t * obj, lv_coord_t * w_out, lv_coord_t * h_out)
|
||||
static lv_coord_t calc_content_width(lv_obj_t * obj)
|
||||
{
|
||||
if(!w_out && !h_out) return;
|
||||
/*Get the bounding box of the children*/
|
||||
if(w_out) {
|
||||
lv_coord_t scroll_right = lv_obj_get_scroll_right(obj);
|
||||
lv_coord_t scroll_left = lv_obj_get_scroll_left(obj);
|
||||
*w_out = lv_obj_get_width(obj) + scroll_right + scroll_left;
|
||||
lv_obj_scroll_to_x(obj, 0, LV_ANIM_OFF);
|
||||
|
||||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_right = lv_obj_get_style_pad_right(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN) + border_width;
|
||||
|
||||
lv_coord_t self_w;
|
||||
self_w = lv_obj_get_self_width(obj) + pad_left + pad_right;
|
||||
|
||||
lv_coord_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
/*With RTL find the left most coordinate*/
|
||||
if(lv_obj_get_style_base_dir(obj, LV_PART_MAIN) == LV_BASE_DIR_RTL) {
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
if(!lv_obj_is_layout_positioned(child)) {
|
||||
lv_align_t align = lv_obj_get_style_align(child, 0);
|
||||
switch(align) {
|
||||
case LV_ALIGN_DEFAULT:
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
case LV_ALIGN_BOTTOM_RIGHT:
|
||||
case LV_ALIGN_RIGHT_MID:
|
||||
/*Normal right aligns. Other are ignored due to possible circular dependencies*/
|
||||
child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if x=0 and use the width of the object.
|
||||
* With x!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_width(&child->coords));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, obj->coords.x2 - child->coords.x1 + 1);
|
||||
}
|
||||
}
|
||||
if(child_res != LV_COORD_MIN) {
|
||||
child_res += pad_left;
|
||||
}
|
||||
}
|
||||
/*Else find the right most coordinate*/
|
||||
else {
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
if(!lv_obj_is_layout_positioned(child)) {
|
||||
lv_align_t align = lv_obj_get_style_align(child, 0);
|
||||
switch(align) {
|
||||
case LV_ALIGN_DEFAULT:
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
case LV_ALIGN_BOTTOM_LEFT:
|
||||
case LV_ALIGN_LEFT_MID:
|
||||
/*Normal left aligns.*/
|
||||
child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if x=0 and use the width of the object.
|
||||
* With x!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_width(&child->coords));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, child->coords.x2 - obj->coords.x1 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(child_res != LV_COORD_MIN) {
|
||||
child_res += pad_right;
|
||||
}
|
||||
}
|
||||
|
||||
if(h_out) {
|
||||
lv_coord_t scroll_bottom = lv_obj_get_scroll_bottom(obj);
|
||||
lv_coord_t scroll_top = lv_obj_get_scroll_top(obj);
|
||||
*h_out = lv_obj_get_height(obj) + scroll_bottom + scroll_top;
|
||||
if(child_res == LV_COORD_MIN) return self_w;
|
||||
else return LV_MAX(child_res, self_w);
|
||||
}
|
||||
|
||||
static lv_coord_t calc_content_height(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_scroll_to_y(obj, 0, LV_ANIM_OFF);
|
||||
|
||||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pad_bottom = lv_obj_get_style_pad_bottom(obj, LV_PART_MAIN) + border_width;
|
||||
|
||||
lv_coord_t self_h;
|
||||
self_h = lv_obj_get_self_height(obj) + pad_top + pad_bottom;
|
||||
|
||||
lv_coord_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
|
||||
|
||||
if(!lv_obj_is_layout_positioned(child)) {
|
||||
lv_align_t align = lv_obj_get_style_align(child, 0);
|
||||
switch(align) {
|
||||
case LV_ALIGN_DEFAULT:
|
||||
case LV_ALIGN_TOP_RIGHT:
|
||||
case LV_ALIGN_TOP_MID:
|
||||
case LV_ALIGN_TOP_LEFT:
|
||||
/*Normal top aligns. */
|
||||
child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1);
|
||||
break;
|
||||
default:
|
||||
/* Consider other cases only if y=0 and use the height of the object.
|
||||
* With y!=0 circular dependency could occur. */
|
||||
if(lv_obj_get_style_y(child, 0) == 0) {
|
||||
child_res = LV_MAX(child_res, lv_area_get_height(&child->coords));
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
child_res = LV_MAX(child_res, child->coords.y2 - obj->coords.y1 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if(child_res != LV_COORD_MIN) {
|
||||
child_res += pad_bottom;
|
||||
return LV_MAX(child_res, self_h);
|
||||
} else {
|
||||
return self_h;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void layout_update_core(lv_obj_t * obj)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
layout_update_core(child);
|
||||
}
|
||||
|
||||
|
@ -946,11 +1073,11 @@ static void layout_update_core(lv_obj_t * obj)
|
|||
lv_obj_refr_size(obj);
|
||||
lv_obj_refr_pos(obj);
|
||||
|
||||
if(lv_obj_get_child_cnt(obj) > 0) {
|
||||
if(child_cnt > 0) {
|
||||
uint32_t layout_id = lv_obj_get_style_layout(obj, LV_PART_MAIN);
|
||||
if(layout_id > 0 && layout_id <= layout_cnt) {
|
||||
void * user_data = LV_GC_ROOT(_lv_layout_list)[layout_id -1].user_data;
|
||||
LV_GC_ROOT(_lv_layout_list)[layout_id -1].cb(obj, user_data);
|
||||
void * user_data = LV_GC_ROOT(_lv_layout_list)[layout_id - 1].user_data;
|
||||
LV_GC_ROOT(_lv_layout_list)[layout_id - 1].cb(obj, user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef void (*lv_layout_update_cb_t)(struct _lv_obj_t *, void * user_data);
|
|||
typedef struct {
|
||||
lv_layout_update_cb_t cb;
|
||||
void * user_data;
|
||||
}lv_layout_dsc_t;
|
||||
} lv_layout_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
@ -176,7 +176,8 @@ void lv_obj_align(struct _lv_obj_t * obj, lv_align_t align, lv_coord_t x_ofs, lv
|
|||
* @param y_ofs y coordinate offset after alignment
|
||||
* @note if the position or size of `base` changes `obj` needs to be aligned manually again
|
||||
*/
|
||||
void lv_obj_align_to(struct _lv_obj_t * obj, const struct _lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs, lv_coord_t y_ofs);
|
||||
void lv_obj_align_to(struct _lv_obj_t * obj, const struct _lv_obj_t * base, lv_align_t align, lv_coord_t x_ofs,
|
||||
lv_coord_t y_ofs);
|
||||
|
||||
/**
|
||||
* Align an object to the center on its parent.
|
||||
|
@ -200,6 +201,8 @@ void lv_obj_get_coords(const struct _lv_obj_t * obj, lv_area_t * coords);
|
|||
* Get the x coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the left side of its parent plus the parent's left padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the left padding of the parent, and not on the left edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
|
@ -210,6 +213,8 @@ lv_coord_t lv_obj_get_x(const struct _lv_obj_t * obj);
|
|||
* Get the x2 coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the right side of its parent plus the parent's right padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the right padding of the parent, and not on the right edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
|
@ -220,6 +225,8 @@ lv_coord_t lv_obj_get_x2(const struct _lv_obj_t * obj);
|
|||
* Get the y coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the top side of its parent plus the parent's top padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the top padding of the parent, and not on the top edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
|
@ -230,6 +237,8 @@ lv_coord_t lv_obj_get_y(const struct _lv_obj_t * obj);
|
|||
* Get the y2 coordinate of object.
|
||||
* @param obj pointer to an object
|
||||
* @return distance of `obj` from the bottom side of its parent plus the parent's bottom padding
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @note Zero return value means the object is on the bottom padding of the parent, and not on the bottom edge.
|
||||
* @note Scrolling of the parent doesn't change the returned value.
|
||||
* @note The returned value is always the distance from the parent even if `obj` is positioned by a layout.
|
||||
|
@ -239,6 +248,8 @@ lv_coord_t lv_obj_get_y2(const struct _lv_obj_t * obj);
|
|||
/**
|
||||
* Get the width of an object
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the width in pixels
|
||||
*/
|
||||
lv_coord_t lv_obj_get_width(const struct _lv_obj_t * obj);
|
||||
|
@ -246,6 +257,8 @@ lv_coord_t lv_obj_get_width(const struct _lv_obj_t * obj);
|
|||
/**
|
||||
* Get the height of an object
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the height in pixels
|
||||
*/
|
||||
lv_coord_t lv_obj_get_height(const struct _lv_obj_t * obj);
|
||||
|
@ -253,13 +266,17 @@ lv_coord_t lv_obj_get_height(const struct _lv_obj_t * obj);
|
|||
/**
|
||||
* Get the width reduced by the left and right padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the width which still fits into its parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
lv_coord_t lv_obj_get_content_width(const struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the height reduced by the top an bottom padding and the border width.
|
||||
* Get the height reduced by the top and bottom padding and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @return the height which still fits into the parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
lv_coord_t lv_obj_get_content_height(const struct _lv_obj_t * obj);
|
||||
|
@ -267,6 +284,8 @@ lv_coord_t lv_obj_get_content_height(const struct _lv_obj_t * obj);
|
|||
/**
|
||||
* Get the area reduced by the paddings and the border width.
|
||||
* @param obj pointer to an object
|
||||
* @note The position of the object is recalculated only on the next redraw. To force coordinate recalculation
|
||||
* call `lv_obj_update_layout(obj)`.
|
||||
* @param area the area which still fits into the parent without causing overflow (making the parent scrollable)
|
||||
*/
|
||||
void lv_obj_get_content_coords(const struct _lv_obj_t * obj, lv_area_t * area);
|
||||
|
@ -361,7 +380,7 @@ bool lv_obj_hit_test(struct _lv_obj_t * obj, const lv_point_t * point);
|
|||
* @param min_width the minimal width
|
||||
* @param max_width the maximal width
|
||||
* @param ref_width the reference width used when min/max width is in percentage
|
||||
* @return the clampled width
|
||||
* @return the clamped width
|
||||
*/
|
||||
lv_coord_t lv_clamp_width(lv_coord_t width, lv_coord_t min_width, lv_coord_t max_width, lv_coord_t ref_width);
|
||||
|
||||
|
@ -371,7 +390,7 @@ lv_coord_t lv_clamp_width(lv_coord_t width, lv_coord_t min_width, lv_coord_t max
|
|||
* @param min_height the minimal height
|
||||
* @param max_height the maximal height
|
||||
* @param ref_height the reference height used when min/max height is in percentage
|
||||
* @return the clampled height
|
||||
* @return the clamped height
|
||||
*/
|
||||
lv_coord_t lv_clamp_height(lv_coord_t height, lv_coord_t min_height, lv_coord_t max_height, lv_coord_t ref_height);
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ static void scroll_by_raw(lv_obj_t * obj, lv_coord_t x, lv_coord_t y);
|
|||
static void scroll_x_anim(void * obj, int32_t v);
|
||||
static void scroll_y_anim(void * obj, int32_t v);
|
||||
static void scroll_anim_ready_cb(lv_anim_t * a);
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value, lv_anim_enable_t anim_en);
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value,
|
||||
lv_anim_enable_t anim_en);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -137,8 +138,9 @@ lv_coord_t lv_obj_get_scroll_bottom(lv_obj_t * obj)
|
|||
|
||||
lv_coord_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
child_res = LV_MAX(child_res, child->coords.y2);
|
||||
}
|
||||
|
@ -177,9 +179,10 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
|
|||
|
||||
uint32_t i;
|
||||
lv_coord_t x1 = LV_COORD_MAX;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
x1 = LV_MIN(x1, child->coords.x1);
|
||||
|
||||
}
|
||||
|
@ -187,7 +190,8 @@ lv_coord_t lv_obj_get_scroll_left(lv_obj_t * obj)
|
|||
if(x1 != LV_COORD_MAX) {
|
||||
child_res = x1;
|
||||
child_res = (obj->coords.x1 + pad_left + border_width) - child_res;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
child_res = LV_COORD_MIN;
|
||||
}
|
||||
|
||||
|
@ -212,8 +216,9 @@ lv_coord_t lv_obj_get_scroll_right(lv_obj_t * obj)
|
|||
/*With other base direction (LTR) scrolling to the right is normal so find the right most coordinate*/
|
||||
lv_coord_t child_res = LV_COORD_MIN;
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
if(lv_obj_has_flag_any(child, LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) continue;
|
||||
child_res = LV_MAX(child_res, child->coords.x2);
|
||||
}
|
||||
|
@ -282,13 +287,14 @@ void lv_obj_scroll_by(lv_obj_t * obj, lv_coord_t x, lv_coord_t y, lv_anim_enable
|
|||
lv_anim_set_values(&a, -sy, -sy + y);
|
||||
lv_anim_set_exec_cb(&a, scroll_y_anim);
|
||||
lv_anim_set_path_cb(&a, lv_anim_path_ease_out);
|
||||
|
||||
|
||||
lv_res_t res;
|
||||
res = lv_event_send(obj, LV_EVENT_SCROLL_BEGIN, &a);
|
||||
if(res != LV_RES_OK) return;
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Remove pending animations*/
|
||||
bool y_del = lv_anim_del(obj, scroll_y_anim);
|
||||
bool x_del = lv_anim_del(obj, scroll_x_anim);
|
||||
|
@ -320,7 +326,8 @@ void lv_obj_scroll_to_x(lv_obj_t * obj, lv_coord_t x, lv_anim_enable_t anim_en)
|
|||
|
||||
if(x > scroll_max) x = scroll_max;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(x > 0) x = 0;
|
||||
if(x < 0) {
|
||||
lv_coord_t scroll_max = lv_obj_get_scroll_left(obj) + lv_obj_get_scroll_right(obj);
|
||||
|
@ -426,23 +433,25 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
|||
|
||||
bool ver_draw = false;
|
||||
if((dir & LV_DIR_VER) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_VER))) {
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (st > 0 || sb > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_VER))) {
|
||||
ver_draw = true;
|
||||
}
|
||||
|
||||
|
||||
bool hor_draw = false;
|
||||
if((dir & LV_DIR_HOR) &&
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_HOR))) {
|
||||
((sm == LV_SCROLLBAR_MODE_ON) ||
|
||||
(sm == LV_SCROLLBAR_MODE_AUTO && (sl > 0 || sr > 0)) ||
|
||||
(sm == LV_SCROLLBAR_MODE_ACTIVE && lv_indev_get_scroll_dir(indev) == LV_DIR_HOR))) {
|
||||
hor_draw = true;
|
||||
}
|
||||
|
||||
if(!hor_draw && !ver_draw) return;
|
||||
|
||||
bool rtl = lv_obj_get_style_base_dir(obj, LV_PART_SCROLLBAR) == LV_BASE_DIR_RTL ? true : false;
|
||||
|
||||
lv_coord_t end_space = lv_obj_get_style_pad_top(obj, LV_PART_SCROLLBAR);
|
||||
lv_coord_t side_space = lv_obj_get_style_pad_right(obj, LV_PART_SCROLLBAR);
|
||||
lv_coord_t tickness = lv_obj_get_style_width(obj, LV_PART_SCROLLBAR);
|
||||
|
@ -462,35 +471,39 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
|||
/*Draw horizontal scrollbar if the mode is ON or can be scrolled in this direction*/
|
||||
lv_coord_t content_h = obj_h + st + sb;
|
||||
if(ver_draw && content_h) {
|
||||
ver_area->y1 = obj->coords.y1;
|
||||
ver_area->y2 = obj->coords.y2;
|
||||
ver_area->x2 = obj->coords.x2 - side_space;
|
||||
ver_area->x1 =ver_area->x2 - tickness;
|
||||
ver_area->y1 = obj->coords.y1;
|
||||
ver_area->y2 = obj->coords.y2;
|
||||
if(rtl) {
|
||||
ver_area->x1 = obj->coords.x1 + side_space;
|
||||
ver_area->x2 = ver_area->x1 + tickness - 1;
|
||||
}
|
||||
else {
|
||||
ver_area->x2 = obj->coords.x2 - side_space;
|
||||
ver_area->x1 = ver_area->x2 - tickness + 1;
|
||||
}
|
||||
|
||||
lv_coord_t sb_h = ((obj_h - end_space * 2 - hor_req_space) * obj_h) / content_h;
|
||||
sb_h = LV_MAX(sb_h, SCROLLBAR_MIN_SIZE);
|
||||
rem = (obj_h - end_space * 2 - hor_req_space) - sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
rem = (obj_h - end_space * 2 - hor_req_space) -
|
||||
sb_h; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
lv_coord_t scroll_h = content_h - obj_h; /*The size of the content which can be really scrolled*/
|
||||
if(scroll_h <= 0) {
|
||||
ver_area->y1 = obj->coords.y1 + end_space;
|
||||
ver_area->y2 = obj->coords.y2 - end_space - hor_req_space - 1;
|
||||
ver_area->x2 = obj->coords.x2 - side_space;
|
||||
ver_area->x1 =ver_area->x2 - tickness + 1;
|
||||
} else {
|
||||
ver_area->y1 = obj->coords.y1 + end_space;
|
||||
ver_area->y2 = obj->coords.y2 - end_space - hor_req_space - 1;
|
||||
}
|
||||
else {
|
||||
lv_coord_t sb_y = (rem * sb) / scroll_h;
|
||||
sb_y = rem - sb_y;
|
||||
|
||||
ver_area->y1 = obj->coords.y1 + sb_y + end_space;
|
||||
ver_area->y2 =ver_area->y1 + sb_h - 1;
|
||||
ver_area->x2 = obj->coords.x2 - side_space;
|
||||
ver_area->x1 =ver_area->x2 - tickness;
|
||||
ver_area->y1 = obj->coords.y1 + sb_y + end_space;
|
||||
ver_area->y2 = ver_area->y1 + sb_h - 1;
|
||||
if(ver_area->y1 < obj->coords.y1 + end_space) {
|
||||
ver_area->y1 = obj->coords.y1 + end_space;
|
||||
if(ver_area->y1 + SCROLLBAR_MIN_SIZE >ver_area->y2)ver_area->y2 =ver_area->y1 + SCROLLBAR_MIN_SIZE;
|
||||
ver_area->y1 = obj->coords.y1 + end_space;
|
||||
if(ver_area->y1 + SCROLLBAR_MIN_SIZE > ver_area->y2)ver_area->y2 = ver_area->y1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
if(ver_area->y2 > obj->coords.y2 - hor_req_space - end_space) {
|
||||
ver_area->y2 = obj->coords.y2 - hor_req_space - end_space;
|
||||
if(ver_area->y2 - SCROLLBAR_MIN_SIZE <ver_area->y1)ver_area->y1 =ver_area->y2 - SCROLLBAR_MIN_SIZE;
|
||||
ver_area->y2 = obj->coords.y2 - hor_req_space - end_space;
|
||||
if(ver_area->y2 - SCROLLBAR_MIN_SIZE < ver_area->y1)ver_area->y1 = ver_area->y2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,34 +512,52 @@ void lv_obj_get_scrollbar_area(lv_obj_t * obj, lv_area_t * hor_area, lv_area_t *
|
|||
lv_coord_t content_w = obj_w + sl + sr;
|
||||
if(hor_draw && content_w) {
|
||||
hor_area->y2 = obj->coords.y2 - side_space;
|
||||
hor_area->y1 = hor_area->y2 - tickness;
|
||||
hor_area->y1 = hor_area->y2 - tickness + 1;
|
||||
hor_area->x1 = obj->coords.x1;
|
||||
hor_area->x2 = obj->coords.x2;
|
||||
|
||||
lv_coord_t sb_w = ((obj_w - end_space * 2 - ver_reg_space) * obj_w) / content_w;
|
||||
sb_w = LV_MAX(sb_w, SCROLLBAR_MIN_SIZE);
|
||||
rem = (obj_w - end_space * 2 - ver_reg_space) - sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
rem = (obj_w - end_space * 2 - ver_reg_space) -
|
||||
sb_w; /*Remaining size from the scrollbar track that is not the scrollbar itself*/
|
||||
lv_coord_t scroll_w = content_w - obj_w; /*The size of the content which can be really scrolled*/
|
||||
if(scroll_w <= 0) {
|
||||
hor_area->y2 = obj->coords.y2 - side_space;
|
||||
hor_area->y1 = hor_area->y2 - tickness + 1;
|
||||
hor_area->x1 = obj->coords.x1 + end_space;
|
||||
hor_area->x2 = obj->coords.x2 - end_space - ver_reg_space - 1;
|
||||
} else {
|
||||
if(rtl) {
|
||||
hor_area->x1 = obj->coords.x1 + end_space + ver_reg_space - 1;
|
||||
hor_area->x2 = obj->coords.x2 - end_space;
|
||||
}
|
||||
else {
|
||||
hor_area->x1 = obj->coords.x1 + end_space;
|
||||
hor_area->x2 = obj->coords.x2 - end_space - ver_reg_space - 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
lv_coord_t sb_x = (rem * sr) / scroll_w;
|
||||
sb_x = rem - sb_x;
|
||||
|
||||
hor_area->x1 = obj->coords.x1 + sb_x + end_space;
|
||||
hor_area->x2 = hor_area->x1 + sb_w - 1;
|
||||
hor_area->y2 = obj->coords.y2 - side_space;
|
||||
hor_area->y1 = hor_area->y2 - tickness;
|
||||
if(hor_area->x1 < obj->coords.x1 + end_space) {
|
||||
hor_area->x1 = obj->coords.x1 + end_space;
|
||||
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
|
||||
if(rtl) {
|
||||
hor_area->x1 = obj->coords.x1 + sb_x + end_space + ver_reg_space;
|
||||
hor_area->x2 = hor_area->x1 + sb_w - 1;
|
||||
if(hor_area->x1 < obj->coords.x1 + end_space + ver_reg_space) {
|
||||
hor_area->x1 = obj->coords.x1 + end_space + ver_reg_space;
|
||||
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
if(hor_area->x2 > obj->coords.x2 - end_space) {
|
||||
hor_area->x2 = obj->coords.x2 - end_space;
|
||||
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
if(hor_area->x2 > obj->coords.x2 - ver_reg_space - end_space) {
|
||||
hor_area->x2 = obj->coords.x2 - ver_reg_space - end_space;
|
||||
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
|
||||
else {
|
||||
hor_area->x1 = obj->coords.x1 + sb_x + end_space;
|
||||
hor_area->x2 = hor_area->x1 + sb_w - 1;
|
||||
if(hor_area->x1 < obj->coords.x1 + end_space) {
|
||||
hor_area->x1 = obj->coords.x1 + end_space;
|
||||
if(hor_area->x1 + SCROLLBAR_MIN_SIZE > hor_area->x2) hor_area->x2 = hor_area->x1 + SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
if(hor_area->x2 > obj->coords.x2 - ver_reg_space - end_space) {
|
||||
hor_area->x2 = obj->coords.x2 - ver_reg_space - end_space;
|
||||
if(hor_area->x2 - SCROLLBAR_MIN_SIZE < hor_area->x1) hor_area->x1 = hor_area->x2 - SCROLLBAR_MIN_SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -566,7 +597,8 @@ void lv_obj_readjust_scroll(lv_obj_t * obj, lv_anim_enable_t anim_en)
|
|||
sr = LV_MIN(sl, -sr);
|
||||
lv_obj_scroll_by(obj, sr, 0, anim_en);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Be sure the right side is not remains scrolled in*/
|
||||
if(sl < 0 && sr > 0) {
|
||||
sr = LV_MIN(sr, -sl);
|
||||
|
@ -610,9 +642,12 @@ static void scroll_anim_ready_cb(lv_anim_t * a)
|
|||
lv_event_send(a->var, LV_EVENT_SCROLL_END, NULL);
|
||||
}
|
||||
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value, lv_anim_enable_t anim_en)
|
||||
static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_point_t * scroll_value,
|
||||
lv_anim_enable_t anim_en)
|
||||
{
|
||||
lv_obj_t * parent = lv_obj_get_parent(child);
|
||||
if(!lv_obj_has_flag(parent, LV_OBJ_FLAG_SCROLLABLE)) return;
|
||||
|
||||
lv_dir_t scroll_dir = lv_obj_get_scroll_dir(parent);
|
||||
lv_coord_t snap_goal = 0;
|
||||
lv_coord_t act = 0;
|
||||
|
@ -623,12 +658,13 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
|
|||
if(snap_y != LV_SCROLL_SNAP_NONE) area_tmp = &child->coords;
|
||||
else area_tmp = area;
|
||||
|
||||
lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN);
|
||||
lv_coord_t pbottom = lv_obj_get_style_pad_bottom(parent, LV_PART_MAIN);
|
||||
lv_coord_t border_width = lv_obj_get_style_border_width(parent, LV_PART_MAIN);
|
||||
lv_coord_t ptop = lv_obj_get_style_pad_top(parent, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pbottom = lv_obj_get_style_pad_bottom(parent, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t top_diff = parent->coords.y1 + ptop - area_tmp->y1 - scroll_value->y;
|
||||
lv_coord_t bottom_diff = -(parent->coords.y2 - pbottom - area_tmp->y2 - scroll_value->y);
|
||||
lv_coord_t parent_h = lv_obj_get_height(parent) - ptop - pbottom;
|
||||
if((top_diff > 0 && bottom_diff > 0)) y_scroll = 0;
|
||||
if((top_diff >= 0 && bottom_diff >= 0)) y_scroll = 0;
|
||||
else if(top_diff > 0) {
|
||||
y_scroll = top_diff;
|
||||
/*Do not let scrolling in*/
|
||||
|
@ -643,21 +679,21 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
|
|||
}
|
||||
|
||||
switch(snap_y) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.y1 + ptop;
|
||||
act = area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.y2 - pbottom;
|
||||
act = area_tmp->y2 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.y1 + ptop + parent_h / 2;
|
||||
act = lv_area_get_height(area_tmp) / 2 + area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.y1 + ptop;
|
||||
act = area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.y2 - pbottom;
|
||||
act = area_tmp->y2 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.y1 + ptop + parent_h / 2;
|
||||
act = lv_area_get_height(area_tmp) / 2 + area_tmp->y1 + y_scroll;
|
||||
y_scroll += snap_goal - act;
|
||||
break;
|
||||
}
|
||||
|
||||
lv_coord_t x_scroll = 0;
|
||||
|
@ -665,11 +701,11 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
|
|||
if(snap_x != LV_SCROLL_SNAP_NONE) area_tmp = &child->coords;
|
||||
else area_tmp = area;
|
||||
|
||||
lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_PART_MAIN);
|
||||
lv_coord_t pright = lv_obj_get_style_pad_right(parent, LV_PART_MAIN);
|
||||
lv_coord_t pleft = lv_obj_get_style_pad_left(parent, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pright = lv_obj_get_style_pad_right(parent, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t left_diff = parent->coords.x1 + pleft - area_tmp->x1 - scroll_value->x;
|
||||
lv_coord_t right_diff = -(parent->coords.x2 - pright - area_tmp->x2- scroll_value->x);
|
||||
if((left_diff > 0 && right_diff > 0)) x_scroll = 0;
|
||||
lv_coord_t right_diff = -(parent->coords.x2 - pright - area_tmp->x2 - scroll_value->x);
|
||||
if((left_diff >= 0 && right_diff >= 0)) x_scroll = 0;
|
||||
else if(left_diff > 0) {
|
||||
x_scroll = left_diff;
|
||||
/*Do not let scrolling in*/
|
||||
|
@ -685,21 +721,21 @@ static void scroll_area_into_view(const lv_area_t * area, lv_obj_t * child, lv_p
|
|||
|
||||
lv_coord_t parent_w = lv_obj_get_width(parent) - pleft - pright;
|
||||
switch(snap_x) {
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.x1 + pleft;
|
||||
act = area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.x2 - pright;
|
||||
act = area_tmp->x2 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.x1 + pleft + parent_w / 2;
|
||||
act = lv_area_get_width(area_tmp) / 2 + area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_START:
|
||||
snap_goal = parent->coords.x1 + pleft;
|
||||
act = area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_END:
|
||||
snap_goal = parent->coords.x2 - pright;
|
||||
act = area_tmp->x2 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
case LV_SCROLL_SNAP_CENTER:
|
||||
snap_goal = parent->coords.x1 + pleft + parent_w / 2;
|
||||
act = lv_area_get_width(area_tmp) / 2 + area_tmp->x1 + x_scroll;
|
||||
x_scroll += snap_goal - act;
|
||||
break;
|
||||
}
|
||||
|
||||
/*Remove any pending scroll animations.*/
|
||||
|
|
|
@ -37,7 +37,7 @@ enum {
|
|||
typedef uint8_t lv_scrollbar_mode_t;
|
||||
|
||||
|
||||
/** Scroll span align options. Tells where to align the snapable children when scroll stops.*/
|
||||
/** Scroll span align options. Tells where to align the snappable children when scroll stops.*/
|
||||
enum {
|
||||
LV_SCROLL_SNAP_NONE, /**< Do not align, leave where it is*/
|
||||
LV_SCROLL_SNAP_START, /**< Align to the left/top*/
|
||||
|
@ -172,9 +172,9 @@ lv_coord_t lv_obj_get_scroll_right(struct _lv_obj_t * obj);
|
|||
|
||||
/**
|
||||
* Get the X and Y coordinates where the scrolling will end for this object if a scrolling animation is in progress.
|
||||
* In no scrolling animation give the current `x` or `y` scroll position.
|
||||
* If no scrolling animation, give the current `x` or `y` scroll position.
|
||||
* @param obj pointer to an object
|
||||
* @param end poinr to point to store the result
|
||||
* @param end pointer to store the result
|
||||
*/
|
||||
void lv_obj_get_scroll_end(struct _lv_obj_t * obj, lv_point_t * end);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef enum {
|
|||
CACHE_UNSET = 2,
|
||||
CACHE_255 = 3,
|
||||
CACHE_NEED_CHECK = 4,
|
||||
}cache_t;
|
||||
} cache_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
@ -117,8 +117,7 @@ void lv_obj_remove_style(lv_obj_t * obj, lv_style_t * style, lv_style_selector_t
|
|||
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
|
||||
if((state != LV_STATE_ANY && state_act != state) ||
|
||||
(part != LV_PART_ANY && part_act != part) ||
|
||||
(style != NULL && style != obj->styles[i].style))
|
||||
{
|
||||
(style != NULL && style != obj->styles[i].style)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
@ -175,11 +174,17 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
|
|||
|
||||
lv_part_t part = lv_obj_style_get_selector_part(selector);
|
||||
|
||||
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_LAYOUT_REFR))) {
|
||||
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL);
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
if(prop & LV_STYLE_PROP_LAYOUT_REFR) {
|
||||
if(part == LV_PART_ANY ||
|
||||
part == LV_PART_MAIN ||
|
||||
lv_obj_get_style_height(obj, 0) == LV_SIZE_CONTENT ||
|
||||
lv_obj_get_style_width(obj, 0) == LV_SIZE_CONTENT) {
|
||||
lv_event_send(obj, LV_EVENT_STYLE_CHANGED, NULL);
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
}
|
||||
}
|
||||
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY || (prop & LV_STYLE_PROP_PARENT_LAYOUT_REFR))) {
|
||||
if((part == LV_PART_ANY || part == LV_PART_MAIN) && (prop == LV_STYLE_PROP_ANY ||
|
||||
(prop & LV_STYLE_PROP_PARENT_LAYOUT_REFR))) {
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
if(parent) lv_obj_mark_layout_as_dirty(parent);
|
||||
}
|
||||
|
@ -190,8 +195,7 @@ void lv_obj_refresh_style(lv_obj_t * obj, lv_style_selector_t selector, lv_style
|
|||
lv_obj_invalidate(obj);
|
||||
|
||||
if(prop == LV_STYLE_PROP_ANY ||
|
||||
((prop & LV_STYLE_PROP_INHERIT) && ((prop & LV_STYLE_PROP_EXT_DRAW) || (prop & LV_STYLE_PROP_LAYOUT_REFR))))
|
||||
{
|
||||
((prop & LV_STYLE_PROP_INHERIT) && ((prop & LV_STYLE_PROP_EXT_DRAW) || (prop & LV_STYLE_PROP_LAYOUT_REFR)))) {
|
||||
if(part != LV_PART_SCROLLBAR) {
|
||||
refresh_children_style(obj);
|
||||
}
|
||||
|
@ -233,14 +237,16 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_
|
|||
while(cls) {
|
||||
if(prop == LV_STYLE_WIDTH) {
|
||||
if(cls->width_def != 0) break;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(cls->height_def != 0) break;
|
||||
}
|
||||
cls = cls->base_class;
|
||||
}
|
||||
|
||||
value_act.num = prop == LV_STYLE_WIDTH ? cls->width_def : cls->height_def;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
value_act = lv_style_prop_get_default(prop);
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +254,8 @@ lv_style_value_t lv_obj_get_style_prop(const lv_obj_t * obj, lv_part_t part, lv_
|
|||
return value_act;
|
||||
}
|
||||
|
||||
void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value,
|
||||
lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_t * style = get_local_style(obj, selector);
|
||||
lv_style_set_prop(style, prop, value);
|
||||
|
@ -256,13 +263,13 @@ void lv_obj_set_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_
|
|||
}
|
||||
|
||||
|
||||
lv_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value, lv_style_selector_t selector)
|
||||
lv_res_t lv_obj_get_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
|
||||
lv_style_selector_t selector)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; i < obj->style_cnt; i++) {
|
||||
if(obj->styles[i].is_local &&
|
||||
obj->styles[i].selector == selector)
|
||||
{
|
||||
obj->styles[i].selector == selector) {
|
||||
return lv_style_get_prop(obj->styles[i].style, prop, value);
|
||||
}
|
||||
}
|
||||
|
@ -289,7 +296,8 @@ bool lv_obj_remove_local_style_prop(lv_obj_t * obj, lv_style_prop_t prop, lv_sty
|
|||
return lv_style_remove_prop(obj->styles[i].style, prop);
|
||||
}
|
||||
|
||||
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr_dsc)
|
||||
void _lv_obj_style_create_transition(lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state,
|
||||
const _lv_obj_style_transition_dsc_t * tr_dsc)
|
||||
{
|
||||
trans_t * tr;
|
||||
|
||||
|
@ -357,8 +365,7 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
|
|||
if(obj->styles[i].is_trans) continue;
|
||||
|
||||
lv_state_t state_act = lv_obj_style_get_selector_state(obj->styles[i].selector);
|
||||
lv_part_t part_act = lv_obj_style_get_selector_part(obj->styles[i].selector);
|
||||
/*The style is valid for a stat but not the other*/
|
||||
/*The style is valid for a state but not the other*/
|
||||
bool valid1 = state_act & (~state1) ? false : true;
|
||||
bool valid2 = state_act & (~state2) ? false : true;
|
||||
if(valid1 != valid2) {
|
||||
|
@ -382,15 +389,11 @@ _lv_style_state_cmp_t _lv_obj_style_state_compare(lv_obj_t * obj, lv_state_t sta
|
|||
else if(lv_style_get_prop(style, LV_STYLE_MIN_HEIGHT, &v)) layout_diff = true;
|
||||
else if(lv_style_get_prop(style, LV_STYLE_MAX_HEIGHT, &v)) layout_diff = true;
|
||||
else if(lv_style_get_prop(style, LV_STYLE_BORDER_WIDTH, &v)) layout_diff = true;
|
||||
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ANGLE, &v)) layout_diff = true;
|
||||
else if(lv_style_get_prop(style, LV_STYLE_TRANSFORM_ZOOM, &v)) layout_diff = true;
|
||||
|
||||
if(layout_diff) {
|
||||
if(part_act == LV_PART_MAIN) {
|
||||
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
}
|
||||
else {
|
||||
res = _LV_STYLE_STATE_CMP_DIFF_DRAW_PAD;
|
||||
continue;
|
||||
}
|
||||
return _LV_STYLE_STATE_CMP_DIFF_LAYOUT;
|
||||
}
|
||||
|
||||
/*Check for draw pad changes*/
|
||||
|
@ -449,6 +452,15 @@ lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector)
|
|||
return selector & 0xFF0000;
|
||||
}
|
||||
|
||||
|
||||
lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt)
|
||||
{
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, part);
|
||||
lv_base_dir_t base_dir = lv_obj_get_style_base_dir(obj, part);
|
||||
lv_bidi_calculate_align(&align, &base_dir, txt);
|
||||
return align;
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -466,8 +478,7 @@ static lv_style_t * get_local_style(lv_obj_t * obj, lv_style_selector_t selecto
|
|||
uint32_t i;
|
||||
for(i = 0; i < obj->style_cnt; i++) {
|
||||
if(obj->styles[i].is_local &&
|
||||
obj->styles[i].selector == selector)
|
||||
{
|
||||
obj->styles[i].selector == selector) {
|
||||
return obj->styles[i].style;
|
||||
}
|
||||
}
|
||||
|
@ -613,8 +624,9 @@ static void report_style_change_core(void * style, lv_obj_t * obj)
|
|||
}
|
||||
}
|
||||
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
report_style_change_core(style, lv_obj_get_child(obj, i));
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
report_style_change_core(style, obj->spec_attr->children[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -626,8 +638,9 @@ static void report_style_change_core(void * style, lv_obj_t * obj)
|
|||
static void refresh_children_style(lv_obj_t * obj)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
lv_obj_invalidate(child);
|
||||
lv_event_send(child, LV_EVENT_STYLE_CHANGED, NULL);
|
||||
lv_obj_invalidate(child);
|
||||
|
@ -687,7 +700,7 @@ static void trans_anim_cb(void * _tr, int32_t v)
|
|||
if(obj->styles[i].is_trans == 0 || obj->styles[i].selector != tr->selector) continue;
|
||||
|
||||
lv_style_value_t value_final;
|
||||
switch (tr->prop) {
|
||||
switch(tr->prop) {
|
||||
|
||||
case LV_STYLE_BORDER_SIDE:
|
||||
case LV_STYLE_BORDER_POST:
|
||||
|
@ -727,12 +740,13 @@ static void trans_anim_cb(void * _tr, int32_t v)
|
|||
lv_style_value_t old_value;
|
||||
bool refr = true;
|
||||
if(lv_style_get_prop(obj->styles[i].style, tr->prop, &old_value)) {
|
||||
if(value_final.ptr == old_value.ptr && value_final.color.full == old_value.color.full && value_final.num == old_value.num) {
|
||||
if(value_final.ptr == old_value.ptr && value_final.color.full == old_value.color.full &&
|
||||
value_final.num == old_value.num) {
|
||||
refr = false;
|
||||
}
|
||||
}
|
||||
lv_style_set_prop(obj->styles[i].style, tr->prop, value_final);
|
||||
if (refr) lv_obj_refresh_style(tr->obj, tr->selector, tr->prop);
|
||||
if(refr) lv_obj_refresh_style(tr->obj, tr->selector, tr->prop);
|
||||
break;
|
||||
|
||||
}
|
||||
|
|
|
@ -38,10 +38,10 @@ typedef uint32_t lv_style_selector_t;
|
|||
|
||||
typedef struct {
|
||||
lv_style_t * style;
|
||||
uint32_t selector :24;
|
||||
uint32_t is_local :1;
|
||||
uint32_t is_trans :1;
|
||||
}_lv_obj_style_t;
|
||||
uint32_t selector : 24;
|
||||
uint32_t is_local : 1;
|
||||
uint32_t is_trans : 1;
|
||||
} _lv_obj_style_t;
|
||||
|
||||
typedef struct {
|
||||
uint16_t time;
|
||||
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
#if LV_USE_USER_DATA
|
||||
void * user_data;
|
||||
#endif
|
||||
}_lv_obj_style_transition_dsc_t;
|
||||
} _lv_obj_style_transition_dsc_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
|
@ -138,9 +138,11 @@ lv_style_value_t lv_obj_get_style_prop(const struct _lv_obj_t * obj, lv_part_t p
|
|||
* @param prop the property
|
||||
* @param value value of the property. The correct element should be set according to the type of the property
|
||||
*/
|
||||
void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t value,
|
||||
lv_style_selector_t selector);
|
||||
|
||||
lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value, lv_style_selector_t selector);
|
||||
lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_value_t * value,
|
||||
lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Remove a local style property from a part of an object with a given state.
|
||||
|
@ -153,14 +155,15 @@ lv_res_t lv_obj_get_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t pro
|
|||
bool lv_obj_remove_local_style_prop(struct _lv_obj_t * obj, lv_style_prop_t prop, lv_style_selector_t selector);
|
||||
|
||||
/**
|
||||
* Used internally to create a style tarnsition
|
||||
* Used internally to create a style transition
|
||||
* @param obj
|
||||
* @param part
|
||||
* @param prev_state
|
||||
* @param new_state
|
||||
* @param tr
|
||||
*/
|
||||
void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_part_t part, lv_state_t prev_state, lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr);
|
||||
void _lv_obj_style_create_transition(struct _lv_obj_t * obj, lv_part_t part, lv_state_t prev_state,
|
||||
lv_state_t new_state, const _lv_obj_style_transition_dsc_t * tr);
|
||||
|
||||
/**
|
||||
* Used internally to compare the appearance of an object in 2 states
|
||||
|
@ -193,33 +196,50 @@ lv_part_t lv_obj_style_get_selector_part(lv_style_selector_t selector);
|
|||
|
||||
#include "lv_obj_style_gen.h"
|
||||
|
||||
static inline void lv_obj_set_style_pad_all(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
|
||||
static inline void lv_obj_set_style_pad_all(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_left(obj, value, selector);
|
||||
lv_obj_set_style_pad_right(obj, value, selector);
|
||||
lv_obj_set_style_pad_top(obj, value, selector);
|
||||
lv_obj_set_style_pad_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
|
||||
static inline void lv_obj_set_style_pad_hor(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_left(obj, value, selector);
|
||||
lv_obj_set_style_pad_right(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
|
||||
static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_top(obj, value, selector);
|
||||
lv_obj_set_style_pad_bottom(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
|
||||
static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_pad_row(obj, value, selector);
|
||||
lv_obj_set_style_pad_column(obj, value, selector);
|
||||
}
|
||||
|
||||
static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) {
|
||||
static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_obj_set_style_width(obj, value, selector);
|
||||
lv_obj_set_style_height(obj, value, selector);
|
||||
}
|
||||
|
||||
lv_text_align_t lv_obj_calculate_style_text_align(const struct _lv_obj_t * obj, lv_part_t part, const char * txt);
|
||||
|
||||
static inline lv_coord_t lv_obj_get_x_aligned(const struct _lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_x(obj, LV_PART_MAIN);
|
||||
}
|
||||
|
||||
static inline lv_coord_t lv_obj_get_y_aligned(const struct _lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_y(obj, LV_PART_MAIN);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
|
|
@ -631,7 +631,7 @@ void lv_obj_set_style_line_dash_gap(struct _lv_obj_t * obj, lv_coord_t value, lv
|
|||
lv_obj_set_local_style_prop(obj, LV_STYLE_LINE_DASH_GAP, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
|
@ -671,7 +671,7 @@ void lv_obj_set_style_arc_width(struct _lv_obj_t * obj, lv_coord_t value, lv_sty
|
|||
lv_obj_set_local_style_prop(obj, LV_STYLE_ARC_WIDTH, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
|
|
|
@ -472,10 +472,10 @@ static inline lv_coord_t lv_obj_get_style_line_dash_gap(const struct _lv_obj_t *
|
|||
return (lv_coord_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_coord_t lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline bool lv_obj_get_style_line_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_LINE_ROUNDED);
|
||||
return (lv_coord_t)v.num;
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_line_color(const struct _lv_obj_t * obj, uint32_t part)
|
||||
|
@ -502,10 +502,10 @@ static inline lv_coord_t lv_obj_get_style_arc_width(const struct _lv_obj_t * obj
|
|||
return (lv_coord_t)v.num;
|
||||
}
|
||||
|
||||
static inline lv_coord_t lv_obj_get_style_arc_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
static inline bool lv_obj_get_style_arc_rounded(const struct _lv_obj_t * obj, uint32_t part)
|
||||
{
|
||||
lv_style_value_t v = lv_obj_get_style_prop(obj, part, LV_STYLE_ARC_ROUNDED);
|
||||
return (lv_coord_t)v.num;
|
||||
return (bool)v.num;
|
||||
}
|
||||
|
||||
static inline lv_color_t lv_obj_get_style_arc_color(const struct _lv_obj_t * obj, uint32_t part)
|
||||
|
@ -611,12 +611,12 @@ void lv_obj_set_style_shadow_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_styl
|
|||
void lv_obj_set_style_line_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_dash_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_dash_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_color_filtered(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_line_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_width(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_rounded(struct _lv_obj_t * obj, bool value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_color(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_color_filtered(struct _lv_obj_t * obj, lv_color_t value, lv_style_selector_t selector);
|
||||
void lv_obj_set_style_arc_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector);
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lv_obj.h"
|
||||
#include "lv_indev.h"
|
||||
#include "../misc/lv_anim.h"
|
||||
|
@ -17,10 +19,6 @@
|
|||
*********************/
|
||||
#define MY_CLASS &lv_obj_class
|
||||
|
||||
#if defined(LV_USER_DATA_FREE_INCLUDE)
|
||||
#include LV_USER_DATA_FREE_INCLUDE
|
||||
#endif /*LV_USE_USER_DATA_FREE*/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -46,7 +44,7 @@ static lv_obj_tree_walk_res_t walk_core(lv_obj_t * obj, lv_obj_tree_walk_cb_t cb
|
|||
|
||||
void lv_obj_del(lv_obj_t * obj)
|
||||
{
|
||||
LV_LOG_TRACE("begin (delete %p)", obj)
|
||||
LV_LOG_TRACE("begin (delete %p)", (void *)obj);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
|
@ -70,21 +68,22 @@ void lv_obj_del(lv_obj_t * obj)
|
|||
lv_obj_readjust_scroll(par, LV_ANIM_OFF);
|
||||
lv_obj_scrollbar_invalidate(par);
|
||||
lv_event_send(par, LV_EVENT_CHILD_CHANGED, NULL);
|
||||
lv_event_send(par, LV_EVENT_CHILD_DELETED, NULL);
|
||||
}
|
||||
|
||||
/*Handle if the active screen was deleted*/
|
||||
if(act_scr_del) {
|
||||
LV_LOG_WARN("the active screen was deleted")
|
||||
if(act_scr_del) {
|
||||
LV_LOG_WARN("the active screen was deleted");
|
||||
disp->act_scr = NULL;
|
||||
}
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
LV_LOG_TRACE("finished (delete %p)", obj)
|
||||
LV_LOG_TRACE("finished (delete %p)", (void *)obj);
|
||||
}
|
||||
|
||||
void lv_obj_clean(lv_obj_t * obj)
|
||||
{
|
||||
LV_LOG_TRACE("begin (delete %p)", obj)
|
||||
LV_LOG_TRACE("begin (delete %p)", (void *)obj);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
@ -103,7 +102,19 @@ void lv_obj_clean(lv_obj_t * obj)
|
|||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
|
||||
LV_LOG_TRACE("finished (delete %p)", obj)
|
||||
LV_LOG_TRACE("finished (delete %p)", (void *)obj);
|
||||
}
|
||||
|
||||
void lv_obj_del_delayed(lv_obj_t * obj, uint32_t delay_ms)
|
||||
{
|
||||
lv_anim_t a;
|
||||
lv_anim_init(&a);
|
||||
lv_anim_set_var(&a, obj);
|
||||
lv_anim_set_exec_cb(&a, NULL);
|
||||
lv_anim_set_time(&a, 1);
|
||||
lv_anim_set_delay(&a, delay_ms);
|
||||
lv_anim_set_ready_cb(&a, lv_obj_del_anim_ready_cb);
|
||||
lv_anim_start(&a);
|
||||
}
|
||||
|
||||
void lv_obj_del_anim_ready_cb(lv_anim_t * a)
|
||||
|
@ -137,90 +148,101 @@ void lv_obj_set_parent(lv_obj_t * obj, lv_obj_t * parent)
|
|||
lv_obj_allocate_spec_attr(parent);
|
||||
|
||||
lv_obj_t * old_parent = obj->parent;
|
||||
lv_point_t old_pos;
|
||||
old_pos.y = lv_obj_get_y(obj);
|
||||
|
||||
lv_base_dir_t new_base_dir = lv_obj_get_style_base_dir(parent, LV_PART_MAIN);
|
||||
|
||||
if(new_base_dir != LV_BASE_DIR_RTL) old_pos.x = lv_obj_get_x(obj);
|
||||
else old_pos.x = old_parent->coords.x2 - obj->coords.x2;
|
||||
|
||||
/*Remove the object from the old parent's child list*/
|
||||
int32_t i;
|
||||
for(i = lv_obj_get_child_id(obj); i <= (int32_t)lv_obj_get_child_cnt(old_parent) - 2; i++) {
|
||||
old_parent->spec_attr->children[i] = old_parent->spec_attr->children[i+1];
|
||||
for(i = lv_obj_get_index(obj); i <= (int32_t)lv_obj_get_child_cnt(old_parent) - 2; i++) {
|
||||
old_parent->spec_attr->children[i] = old_parent->spec_attr->children[i + 1];
|
||||
}
|
||||
old_parent->spec_attr->child_cnt--;
|
||||
if(old_parent->spec_attr->child_cnt) {
|
||||
old_parent->spec_attr->children = lv_mem_realloc(old_parent->spec_attr->children, old_parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
} else {
|
||||
old_parent->spec_attr->children = lv_mem_realloc(old_parent->spec_attr->children,
|
||||
old_parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
}
|
||||
else {
|
||||
lv_mem_free(old_parent->spec_attr->children);
|
||||
old_parent->spec_attr->children = NULL;
|
||||
}
|
||||
|
||||
/*Add the child to the new parent as the last (newest child)*/
|
||||
parent->spec_attr->child_cnt++;
|
||||
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children, parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
parent->spec_attr->children = lv_mem_realloc(parent->spec_attr->children,
|
||||
parent->spec_attr->child_cnt * (sizeof(lv_obj_t *)));
|
||||
parent->spec_attr->children[lv_obj_get_child_cnt(parent) - 1] = obj;
|
||||
|
||||
obj->parent = parent;
|
||||
|
||||
if(new_base_dir != LV_BASE_DIR_RTL) {
|
||||
lv_obj_set_pos(obj, old_pos.x, old_pos.y);
|
||||
}
|
||||
else {
|
||||
/*Align to the right in case of RTL base dir*/
|
||||
lv_coord_t new_x = lv_obj_get_width(parent) - old_pos.x - lv_obj_get_width(obj);
|
||||
lv_obj_set_pos(obj, new_x, old_pos.y);
|
||||
}
|
||||
|
||||
/*Notify the original parent because one of its children is lost*/
|
||||
lv_event_send(old_parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_event_send(old_parent, LV_EVENT_CHILD_DELETED, NULL);
|
||||
|
||||
/*Notify the new parent about the child*/
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CREATED, NULL);
|
||||
|
||||
lv_obj_mark_layout_as_dirty(obj);
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_obj_move_foreground(lv_obj_t * obj)
|
||||
void lv_obj_move_to_index(lv_obj_t * obj, int32_t index)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
const int32_t old_index = lv_obj_get_index(obj);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
|
||||
lv_obj_invalidate(parent);
|
||||
if(index < 0) return;
|
||||
if(index >= (int32_t) lv_obj_get_child_cnt(parent)) return;
|
||||
if(index == old_index) return;
|
||||
|
||||
uint32_t i;
|
||||
for(i = lv_obj_get_child_id(obj); i < lv_obj_get_child_cnt(parent) - 1; i++) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i + 1];
|
||||
int32_t i = old_index;
|
||||
if(index < old_index) {
|
||||
while(i > index) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i - 1];
|
||||
i--;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while(i < index) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i + 1];
|
||||
i++;
|
||||
}
|
||||
}
|
||||
parent->spec_attr->children[lv_obj_get_child_cnt(parent) - 1] = obj;
|
||||
|
||||
/*Notify the new parent about the child*/
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
|
||||
parent->spec_attr->children[index] = obj;
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, NULL);
|
||||
lv_obj_invalidate(parent);
|
||||
}
|
||||
|
||||
void lv_obj_move_background(lv_obj_t * obj)
|
||||
void lv_obj_swap(lv_obj_t * obj1, lv_obj_t * obj2)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_OBJ(obj1, MY_CLASS);
|
||||
LV_ASSERT_OBJ(obj2, MY_CLASS);
|
||||
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj);
|
||||
lv_obj_t * parent = lv_obj_get_parent(obj1);
|
||||
lv_obj_t * parent2 = lv_obj_get_parent(obj2);
|
||||
|
||||
uint_fast32_t index1 = lv_obj_get_index(obj1);
|
||||
uint_fast32_t index2 = lv_obj_get_index(obj2);
|
||||
|
||||
lv_event_send(parent2, LV_EVENT_CHILD_DELETED, obj2);
|
||||
lv_event_send(parent, LV_EVENT_CHILD_DELETED, obj1);
|
||||
|
||||
parent->spec_attr->children[index1] = obj2;
|
||||
parent2->spec_attr->children[index2] = obj1;
|
||||
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj2);
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CREATED, obj2);
|
||||
lv_event_send(parent2, LV_EVENT_CHILD_CHANGED, obj1);
|
||||
lv_event_send(parent2, LV_EVENT_CHILD_CREATED, obj1);
|
||||
|
||||
lv_obj_invalidate(parent);
|
||||
|
||||
int32_t i;
|
||||
for(i = lv_obj_get_child_id(obj); i > 0; i--) {
|
||||
parent->spec_attr->children[i] = parent->spec_attr->children[i-1];
|
||||
if(parent != parent2) {
|
||||
lv_obj_invalidate(parent2);
|
||||
}
|
||||
parent->spec_attr->children[0] = obj;
|
||||
|
||||
/*Notify the new parent about the child*/
|
||||
lv_event_send(parent, LV_EVENT_CHILD_CHANGED, obj);
|
||||
|
||||
lv_obj_invalidate(parent);
|
||||
lv_group_swap_obj(obj1, obj2);
|
||||
}
|
||||
|
||||
lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
||||
|
@ -232,10 +254,10 @@ lv_obj_t * lv_obj_get_screen(const lv_obj_t * obj)
|
|||
|
||||
do {
|
||||
act_par = par;
|
||||
par = lv_obj_get_parent(act_par);
|
||||
par = lv_obj_get_parent(act_par);
|
||||
} while(par != NULL);
|
||||
|
||||
return (lv_obj_t*)act_par;
|
||||
return (lv_obj_t *)act_par;
|
||||
}
|
||||
|
||||
lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
||||
|
@ -255,7 +277,7 @@ lv_disp_t * lv_obj_get_disp(const lv_obj_t * obj)
|
|||
}
|
||||
}
|
||||
|
||||
LV_LOG_WARN("No screen found")
|
||||
LV_LOG_WARN("No screen found");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -278,7 +300,8 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, int32_t id)
|
|||
id = obj->spec_attr->child_cnt + id;
|
||||
if(id < 0) return NULL;
|
||||
idu = (uint32_t) id;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
idu = id;
|
||||
}
|
||||
|
||||
|
@ -293,7 +316,7 @@ uint32_t lv_obj_get_child_cnt(const lv_obj_t * obj)
|
|||
return obj->spec_attr->child_cnt;
|
||||
}
|
||||
|
||||
uint32_t lv_obj_get_child_id(const lv_obj_t * obj)
|
||||
uint32_t lv_obj_get_index(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
|
@ -308,7 +331,6 @@ uint32_t lv_obj_get_child_id(const lv_obj_t * obj)
|
|||
return 0xFFFFFFFF; /*Shouldn't happen*/
|
||||
}
|
||||
|
||||
|
||||
void lv_obj_tree_walk(lv_obj_t * start_obj, lv_obj_tree_walk_cb_t cb, void * user_data)
|
||||
{
|
||||
walk_core(start_obj, cb, user_data);
|
||||
|
@ -377,13 +399,14 @@ static void obj_del_core(lv_obj_t * obj)
|
|||
}
|
||||
/*Remove the object from the child list of its parent*/
|
||||
else {
|
||||
uint32_t id = lv_obj_get_child_id(obj);
|
||||
uint32_t id = lv_obj_get_index(obj);
|
||||
uint32_t i;
|
||||
for(i = id; i < obj->parent->spec_attr->child_cnt - 1; i++) {
|
||||
obj->parent->spec_attr->children[i] = obj->parent->spec_attr->children[i + 1];
|
||||
}
|
||||
obj->parent->spec_attr->child_cnt--;
|
||||
obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children, obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *));
|
||||
obj->parent->spec_attr->children = lv_mem_realloc(obj->parent->spec_attr->children,
|
||||
obj->parent->spec_attr->child_cnt * sizeof(lv_obj_t *));
|
||||
}
|
||||
|
||||
/*Free the object itself*/
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef lv_obj_tree_walk_res_t (*lv_obj_tree_walk_cb_t)(struct _lv_obj_t *, void
|
|||
**********************/
|
||||
|
||||
/**
|
||||
* Delete an object and all of it's children.
|
||||
* Delete an object and all of its children.
|
||||
* Also remove the objects from their group and remove all animations (if any).
|
||||
* Send `LV_EVENT_DELETED` to deleted objects.
|
||||
* @param obj pointer to an object
|
||||
|
@ -56,6 +56,13 @@ void lv_obj_del(struct _lv_obj_t * obj);
|
|||
*/
|
||||
void lv_obj_clean(struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Delete an object after some delay
|
||||
* @param obj pointer to an object
|
||||
* @param delay_ms time to wait before delete in milliseconds
|
||||
*/
|
||||
void lv_obj_del_delayed(struct _lv_obj_t * obj, uint32_t delay_ms);
|
||||
|
||||
/**
|
||||
* A function to be easily used in animation ready callback to delete an object when the animation is ready
|
||||
* @param a pointer to the animation
|
||||
|
@ -79,32 +86,34 @@ void lv_obj_del_async(struct _lv_obj_t * obj);
|
|||
void lv_obj_set_parent(struct _lv_obj_t * obj, struct _lv_obj_t * parent);
|
||||
|
||||
/**
|
||||
* Move the object to the foreground.
|
||||
* It will look like if it was created as the last child of its parent.
|
||||
* It also means it can cover any of the siblings.
|
||||
* @param obj pointer to an object
|
||||
* Swap the positions of two objects.
|
||||
* When used in listboxes, it can be used to sort the listbox items.
|
||||
* @param obj1 pointer to the first object
|
||||
* @param obj2 pointer to the second object
|
||||
*/
|
||||
void lv_obj_move_foreground(struct _lv_obj_t * obj);
|
||||
void lv_obj_swap(struct _lv_obj_t * obj1, struct _lv_obj_t * obj2);
|
||||
|
||||
/**
|
||||
* Move the object to the background.
|
||||
* It will look like if it was created as the first child of its parent.
|
||||
* It also means any of the siblings can cover the object.
|
||||
* @param obj pointer to an object
|
||||
* moves the object to the given index in its parent.
|
||||
* When used in listboxes, it can be used to sort the listbox items.
|
||||
* @param obj pointer to the object to be moved.
|
||||
* @param index new index in parent.
|
||||
* @note to move to the foreground: lv_obj_move_to_index(obj, 0)
|
||||
* @note to move forward (up): lv_obj_move_to_index(obj, lv_obj_get_index(obj) - 1)
|
||||
*/
|
||||
void lv_obj_move_background(struct _lv_obj_t * obj);
|
||||
void lv_obj_move_to_index(struct _lv_obj_t * obj, int32_t index);
|
||||
|
||||
/**
|
||||
* Get the screen of an object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the obejct's screen
|
||||
* @return pointer to the object's screen
|
||||
*/
|
||||
struct _lv_obj_t * lv_obj_get_screen(const struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the display of the object
|
||||
* @param obj pointer to an object
|
||||
* @return pointer to the obejct's display
|
||||
* @return pointer to the object's display
|
||||
*/
|
||||
lv_disp_t * lv_obj_get_disp(const struct _lv_obj_t * obj);
|
||||
|
||||
|
@ -137,11 +146,11 @@ uint32_t lv_obj_get_child_cnt(const struct _lv_obj_t * obj);
|
|||
|
||||
/**
|
||||
* Get the index of a child.
|
||||
* @param obj pointer to an obejct
|
||||
* @param obj pointer to an object
|
||||
* @return the child index of the object.
|
||||
* E.g. 0: the oldest (firstly created child)
|
||||
*/
|
||||
uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj);
|
||||
uint32_t lv_obj_get_index(const struct _lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Iterate through all children of any object.
|
||||
|
|
|
@ -57,9 +57,9 @@ static lv_disp_t * disp_refr; /*Display being refreshed*/
|
|||
* MACROS
|
||||
**********************/
|
||||
#if LV_LOG_TRACE_DISP_REFR
|
||||
# define TRACE_REFR(...) LV_LOG_TRACE( __VA_ARGS__)
|
||||
#define REFR_TRACE(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define TRACE_REFR(...)
|
||||
#define REFR_TRACE(...)
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
|
@ -181,10 +181,10 @@ void _lv_refr_set_disp_refreshing(lv_disp_t * disp)
|
|||
*/
|
||||
void _lv_disp_refr_timer(lv_timer_t * tmr)
|
||||
{
|
||||
TRACE_REFR("begin");
|
||||
REFR_TRACE("begin");
|
||||
|
||||
uint32_t start = lv_tick_get();
|
||||
uint32_t elaps = 0;
|
||||
volatile uint32_t elaps = 0;
|
||||
|
||||
disp_refr = tmr->user_data;
|
||||
|
||||
|
@ -207,7 +207,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
if(disp_refr->act_scr == NULL) {
|
||||
disp_refr->inv_p = 0;
|
||||
LV_LOG_WARN("there is no active screen");
|
||||
TRACE_REFR("finished");
|
||||
REFR_TRACE("finished");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -236,6 +236,10 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
lv_mem_buf_free_all();
|
||||
_lv_font_clean_up_fmt_txt();
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
_lv_draw_mask_cleanup();
|
||||
#endif
|
||||
|
||||
#if LV_USE_PERF_MONITOR && LV_USE_LABEL
|
||||
static lv_obj_t * perf_label = NULL;
|
||||
if(perf_label == NULL) {
|
||||
|
@ -249,7 +253,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
lv_obj_set_style_pad_right(perf_label, 3, 0);
|
||||
lv_obj_set_style_text_align(perf_label, LV_TEXT_ALIGN_RIGHT, 0);
|
||||
lv_label_set_text(perf_label, "?");
|
||||
lv_obj_align(perf_label, LV_ALIGN_BOTTOM_RIGHT, 0, 0);
|
||||
lv_obj_align(perf_label, LV_USE_PERF_MONITOR_POS, 0, 0);
|
||||
}
|
||||
|
||||
static uint32_t perf_last_time = 0;
|
||||
|
@ -264,7 +268,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
else {
|
||||
perf_last_time = lv_tick_get();
|
||||
uint32_t fps_limit = 1000 / disp_refr->refr_timer->period;
|
||||
uint32_t fps;
|
||||
unsigned int fps;
|
||||
|
||||
if(elaps_sum == 0) elaps_sum = 1;
|
||||
if(frame_cnt == 0) fps = fps_limit;
|
||||
|
@ -275,8 +279,8 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
|
||||
fps_sum_all += fps;
|
||||
fps_sum_cnt ++;
|
||||
uint32_t cpu = 100 - lv_timer_get_idle();
|
||||
lv_label_set_text_fmt(perf_label, "%d FPS\n%d%% CPU", fps, cpu);
|
||||
unsigned int cpu = 100 - lv_timer_get_idle();
|
||||
lv_label_set_text_fmt(perf_label, "%u FPS\n%u%% CPU", fps, cpu);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -292,7 +296,7 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
lv_obj_set_style_pad_left(mem_label, 3, 0);
|
||||
lv_obj_set_style_pad_right(mem_label, 3, 0);
|
||||
lv_label_set_text(mem_label, "?");
|
||||
lv_obj_align(mem_label, LV_ALIGN_BOTTOM_LEFT, 0, 0);
|
||||
lv_obj_align(mem_label, LV_USE_MEM_MONITOR_POS, 0, 0);
|
||||
}
|
||||
|
||||
static uint32_t mem_last_time = 0;
|
||||
|
@ -303,11 +307,13 @@ void _lv_disp_refr_timer(lv_timer_t * tmr)
|
|||
uint32_t used_size = mon.total_size - mon.free_size;;
|
||||
uint32_t used_kb = used_size / 1024;
|
||||
uint32_t used_kb_tenth = (used_size - (used_kb * 1024)) / 102;
|
||||
lv_label_set_text_fmt(mem_label, "%d.%d kB used (%d %%)\n%d%% frag.", used_kb, used_kb_tenth, mon.used_pct, mon.frag_pct);
|
||||
lv_label_set_text_fmt(mem_label, "%" LV_PRIu32 ".%" LV_PRIu32 " kB used (%d %%)\n" \
|
||||
"%d%% frag.", used_kb, used_kb_tenth, mon.used_pct,
|
||||
mon.frag_pct);
|
||||
}
|
||||
#endif
|
||||
|
||||
TRACE_REFR("finished");
|
||||
REFR_TRACE("finished");
|
||||
}
|
||||
|
||||
#if LV_USE_PERF_MONITOR
|
||||
|
@ -417,7 +423,7 @@ static void lv_refr_area(const lv_area_t * area_p)
|
|||
lv_coord_t w = lv_area_get_width(area_p);
|
||||
lv_coord_t h = lv_area_get_height(area_p);
|
||||
lv_coord_t y2 = area_p->y2 >= lv_disp_get_ver_res(disp_refr) ?
|
||||
lv_disp_get_ver_res(disp_refr) - 1 : area_p->y2;
|
||||
lv_disp_get_ver_res(disp_refr) - 1 : area_p->y2;
|
||||
|
||||
int32_t max_row = (uint32_t)draw_buf->size / w;
|
||||
|
||||
|
@ -452,31 +458,43 @@ static void lv_refr_area(const lv_area_t * area_p)
|
|||
}
|
||||
}
|
||||
|
||||
/*Always use the full row*/
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_last = 0;
|
||||
for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
|
||||
/*Calc. the next y coordinates of draw_buf*/
|
||||
draw_buf->area.x1 = area_p->x1;
|
||||
draw_buf->area.x2 = area_p->x2;
|
||||
draw_buf->area.y1 = row;
|
||||
draw_buf->area.y2 = row + max_row - 1;
|
||||
if(draw_buf->area.y2 > y2) draw_buf->area.y2 = y2;
|
||||
row_last = draw_buf->area.y2;
|
||||
if(y2 == row_last) disp_refr->driver->draw_buf->last_part = 1;
|
||||
/*In direct mode draw directly on the absolute coordinates of the buffer*/
|
||||
if(disp_refr->driver->direct_mode) {
|
||||
draw_buf->area.x1 = 0;
|
||||
draw_buf->area.x2 = lv_disp_get_hor_res(disp_refr) - 1;
|
||||
draw_buf->area.y1 = 0;
|
||||
draw_buf->area.y2 = lv_disp_get_ver_res(disp_refr) - 1;
|
||||
disp_refr->driver->draw_buf->last_part = disp_refr->driver->draw_buf->last_area;
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
/*Else assume the buffer starts at the given area*/
|
||||
else {
|
||||
/*Always use the full row*/
|
||||
lv_coord_t row;
|
||||
lv_coord_t row_last = 0;
|
||||
for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
|
||||
/*Calc. the next y coordinates of draw_buf*/
|
||||
draw_buf->area.x1 = area_p->x1;
|
||||
draw_buf->area.x2 = area_p->x2;
|
||||
draw_buf->area.y1 = row;
|
||||
draw_buf->area.y2 = row + max_row - 1;
|
||||
if(draw_buf->area.y2 > y2) draw_buf->area.y2 = y2;
|
||||
row_last = draw_buf->area.y2;
|
||||
if(y2 == row_last) disp_refr->driver->draw_buf->last_part = 1;
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(y2 != row_last) {
|
||||
/*Calc. the next y coordinates of draw_buf*/
|
||||
draw_buf->area.x1 = area_p->x1;
|
||||
draw_buf->area.x2 = area_p->x2;
|
||||
draw_buf->area.y1 = row;
|
||||
draw_buf->area.y2 = y2;
|
||||
/*If the last y coordinates are not handled yet ...*/
|
||||
if(y2 != row_last) {
|
||||
/*Calc. the next y coordinates of draw_buf*/
|
||||
draw_buf->area.x1 = area_p->x1;
|
||||
draw_buf->area.x2 = area_p->x2;
|
||||
draw_buf->area.y1 = row;
|
||||
draw_buf->area.y2 = y2;
|
||||
|
||||
disp_refr->driver->draw_buf->last_part = 1;
|
||||
lv_refr_area_part(area_p);
|
||||
disp_refr->driver->draw_buf->last_part = 1;
|
||||
lv_refr_area_part(area_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,8 +506,12 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
|||
{
|
||||
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp_refr);
|
||||
|
||||
while(draw_buf->flushing) {
|
||||
if(disp_refr->driver->wait_cb) disp_refr->driver->wait_cb(disp_refr->driver);
|
||||
/* Below the `area_p` area will be redrawn into the draw buffer.
|
||||
* In single buffered mode wait here until the buffer is freed.*/
|
||||
if(draw_buf->buf1 && !draw_buf->buf2) {
|
||||
while(draw_buf->flushing) {
|
||||
if(disp_refr->driver->wait_cb) disp_refr->driver->wait_cb(disp_refr->driver);
|
||||
}
|
||||
}
|
||||
|
||||
lv_obj_t * top_act_scr = NULL;
|
||||
|
@ -508,7 +530,9 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
|||
|
||||
/*Draw a display background if there is no top object*/
|
||||
if(top_act_scr == NULL && top_prev_scr == NULL) {
|
||||
if(disp_refr->bg_img) {
|
||||
if(disp_refr->bg_fn) {
|
||||
disp_refr->bg_fn(&start_mask);
|
||||
} else if(disp_refr->bg_img) {
|
||||
lv_draw_img_dsc_t dsc;
|
||||
lv_draw_img_dsc_init(&dsc);
|
||||
dsc.opa = disp_refr->bg_opa;
|
||||
|
@ -521,7 +545,7 @@ static void lv_refr_area_part(const lv_area_t * area_p)
|
|||
lv_draw_img(&a, &start_mask, disp_refr->bg_img, &dsc);
|
||||
}
|
||||
else {
|
||||
LV_LOG_WARN("Can't draw the background image")
|
||||
LV_LOG_WARN("Can't draw the background image");
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -580,8 +604,9 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj)
|
|||
if(info.res == LV_COVER_RES_MASKED) return NULL;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
found_p = lv_refr_get_top_obj(area_p, child);
|
||||
|
||||
/*If a children is ok then break*/
|
||||
|
@ -627,20 +652,22 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p)
|
|||
while(par != NULL) {
|
||||
bool go = false;
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(par); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(par, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(par);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = par->spec_attr->children[i];
|
||||
if(!go) {
|
||||
if(child == border_p) go = true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Refresh the objects*/
|
||||
lv_refr_obj(child, mask_p);
|
||||
}
|
||||
}
|
||||
|
||||
/*Call the post draw draw function of the parents of the to object*/
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_BEGIN, (void*)mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST, (void*)mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_END, (void*)mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_BEGIN, (void *)mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST, (void *)mask_p);
|
||||
lv_event_send(par, LV_EVENT_DRAW_POST_END, (void *)mask_p);
|
||||
|
||||
/*The new border will be the last parents,
|
||||
*so the 'younger' brothers of parent will be refreshed*/
|
||||
|
@ -699,8 +726,9 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
|||
lv_area_t mask_child; /*Mask from obj and its child*/
|
||||
lv_area_t child_area;
|
||||
uint32_t i;
|
||||
for(i = 0; i < lv_obj_get_child_cnt(obj); i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = obj->spec_attr->children[i];
|
||||
lv_obj_get_coords(child, &child_area);
|
||||
ext_size = _lv_obj_get_ext_draw_size(child);
|
||||
child_area.x1 -= ext_size;
|
||||
|
@ -726,7 +754,8 @@ static void lv_refr_obj(lv_obj_t * obj, const lv_area_t * mask_ori_p)
|
|||
}
|
||||
}
|
||||
|
||||
static void draw_buf_rotate_180(lv_disp_drv_t *drv, lv_area_t *area, lv_color_t *color_p) {
|
||||
static void draw_buf_rotate_180(lv_disp_drv_t * drv, lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
lv_coord_t area_w = lv_area_get_width(area);
|
||||
lv_coord_t area_h = lv_area_get_height(area);
|
||||
uint32_t total = area_w * area_h;
|
||||
|
@ -749,7 +778,9 @@ static void draw_buf_rotate_180(lv_disp_drv_t *drv, lv_area_t *area, lv_color_t
|
|||
area->x1 = drv->hor_res - tmp_coord - 1;
|
||||
}
|
||||
|
||||
static LV_ATTRIBUTE_FAST_MEM void draw_buf_rotate_90(bool invert_i, lv_coord_t area_w, lv_coord_t area_h, lv_color_t *orig_color_p, lv_color_t *rot_buf) {
|
||||
static LV_ATTRIBUTE_FAST_MEM void draw_buf_rotate_90(bool invert_i, lv_coord_t area_w, lv_coord_t area_h,
|
||||
lv_color_t * orig_color_p, lv_color_t * rot_buf)
|
||||
{
|
||||
|
||||
uint32_t invert = (area_w * area_h) - 1;
|
||||
uint32_t initial_i = ((area_w - 1) * area_h);
|
||||
|
@ -770,7 +801,8 @@ static LV_ATTRIBUTE_FAST_MEM void draw_buf_rotate_90(bool invert_i, lv_coord_t a
|
|||
/**
|
||||
* Helper function for draw_buf_rotate_90_sqr. Given a list of four numbers, rotate the entire list to the left.
|
||||
*/
|
||||
static inline void draw_buf_rotate4(lv_color_t *a, lv_color_t *b, lv_color_t * c, lv_color_t * d) {
|
||||
static inline void draw_buf_rotate4(lv_color_t * a, lv_color_t * b, lv_color_t * c, lv_color_t * d)
|
||||
{
|
||||
lv_color_t tmp;
|
||||
tmp = *a;
|
||||
*a = *b;
|
||||
|
@ -783,9 +815,10 @@ static inline void draw_buf_rotate4(lv_color_t *a, lv_color_t *b, lv_color_t * c
|
|||
* Rotate a square image 90/270 degrees in place.
|
||||
* @note inspired by https://stackoverflow.com/a/43694906
|
||||
*/
|
||||
static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color_p) {
|
||||
for(lv_coord_t i = 0; i < w/2; i++) {
|
||||
for(lv_coord_t j = 0; j < (w + 1)/2; j++) {
|
||||
static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color_p)
|
||||
{
|
||||
for(lv_coord_t i = 0; i < w / 2; i++) {
|
||||
for(lv_coord_t j = 0; j < (w + 1) / 2; j++) {
|
||||
lv_coord_t inv_i = (w - 1) - i;
|
||||
lv_coord_t inv_j = (w - 1) - j;
|
||||
if(is_270) {
|
||||
|
@ -795,7 +828,8 @@ static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color
|
|||
&color_p[inv_i * w + inv_j],
|
||||
&color_p[j * w + inv_i]
|
||||
);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
draw_buf_rotate4(
|
||||
&color_p[i * w + j],
|
||||
&color_p[j * w + inv_i],
|
||||
|
@ -811,7 +845,8 @@ static void draw_buf_rotate_90_sqr(bool is_270, lv_coord_t w, lv_color_t * color
|
|||
/**
|
||||
* Rotate the draw_buf to the display's native orientation.
|
||||
*/
|
||||
static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
|
||||
static void draw_buf_rotate(lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
lv_disp_drv_t * drv = disp_refr->driver;
|
||||
if(disp_refr->driver->full_refresh && drv->sw_rotate) {
|
||||
LV_LOG_ERROR("cannot rotate a full refreshed display!");
|
||||
|
@ -820,14 +855,15 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
|
|||
if(drv->rotated == LV_DISP_ROT_180) {
|
||||
draw_buf_rotate_180(drv, area, color_p);
|
||||
call_flush_cb(drv, area, color_p);
|
||||
} else if(drv->rotated == LV_DISP_ROT_90 || drv->rotated == LV_DISP_ROT_270) {
|
||||
}
|
||||
else if(drv->rotated == LV_DISP_ROT_90 || drv->rotated == LV_DISP_ROT_270) {
|
||||
/*Allocate a temporary buffer to store rotated image*/
|
||||
lv_color_t * rot_buf = NULL;
|
||||
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp_refr);
|
||||
lv_coord_t area_w = lv_area_get_width(area);
|
||||
lv_coord_t area_h = lv_area_get_height(area);
|
||||
/*Determine the maximum number of rows that can be rotated at a time*/
|
||||
lv_coord_t max_row = LV_MIN((lv_coord_t)((LV_DISP_ROT_MAX_BUF/sizeof(lv_color_t)) / area_w), area_h);
|
||||
lv_coord_t max_row = LV_MIN((lv_coord_t)((LV_DISP_ROT_MAX_BUF / sizeof(lv_color_t)) / area_w), area_h);
|
||||
lv_coord_t init_y_off;
|
||||
init_y_off = area->y1;
|
||||
if(drv->rotated == LV_DISP_ROT_90) {
|
||||
|
@ -838,11 +874,11 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
|
|||
area->y1 = area->x1;
|
||||
area->y2 = area->y1 + area_w - 1;
|
||||
}
|
||||
draw_buf->flushing = 0;
|
||||
|
||||
/*Rotate the screen in chunks, flushing after each one*/
|
||||
lv_coord_t row = 0;
|
||||
while(row < area_h) {
|
||||
lv_coord_t height = LV_MIN(max_row, area_h-row);
|
||||
lv_coord_t height = LV_MIN(max_row, area_h - row);
|
||||
draw_buf->flushing = 1;
|
||||
if((row == 0) && (area_h >= area_w)) {
|
||||
/*Rotate the initial area as a square*/
|
||||
|
@ -871,6 +907,16 @@ static void draw_buf_rotate(lv_area_t *area, lv_color_t *color_p) {
|
|||
area->x1 = area->x2 - height + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* The original part (chunk of the current area) were split into more parts here.
|
||||
* Set the original last_part flag on the last part of rotation. */
|
||||
if(row + height >= area_h && draw_buf->last_area && draw_buf->last_part) {
|
||||
draw_buf->flushing_last = 1;
|
||||
}
|
||||
else {
|
||||
draw_buf->flushing_last = 0;
|
||||
}
|
||||
|
||||
/*Flush the completed area to the display*/
|
||||
call_flush_cb(drv, area, rot_buf == NULL ? color_p : rot_buf);
|
||||
/*FIXME: Rotation forces legacy behavior where rendering and flushing are done serially*/
|
||||
|
@ -893,20 +939,29 @@ static void draw_buf_flush(void)
|
|||
lv_disp_draw_buf_t * draw_buf = lv_disp_get_draw_buf(disp_refr);
|
||||
lv_color_t * color_p = draw_buf->buf_act;
|
||||
|
||||
/*Flush the rendered content to the display*/
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
if(disp->driver->gpu_wait_cb) disp->driver->gpu_wait_cb(disp->driver);
|
||||
|
||||
/* In double buffered mode wait until the other buffer is freed
|
||||
* and driver is ready to receive the new buffer */
|
||||
if(draw_buf->buf1 && draw_buf->buf2) {
|
||||
while(draw_buf->flushing) {
|
||||
if(disp_refr->driver->wait_cb) disp_refr->driver->wait_cb(disp_refr->driver);
|
||||
}
|
||||
}
|
||||
|
||||
draw_buf->flushing = 1;
|
||||
|
||||
if(disp_refr->driver->draw_buf->last_area && disp_refr->driver->draw_buf->last_part) draw_buf->flushing_last = 1;
|
||||
else draw_buf->flushing_last = 0;
|
||||
|
||||
/*Flush the rendered content to the display*/
|
||||
lv_disp_t * disp = _lv_refr_get_disp_refreshing();
|
||||
if(disp->driver->gpu_wait_cb) disp->driver->gpu_wait_cb(disp->driver);
|
||||
|
||||
if(disp->driver->flush_cb) {
|
||||
/*Rotate the buffer to the display's native orientation if necessary*/
|
||||
if(disp->driver->rotated != LV_DISP_ROT_NONE && disp->driver->sw_rotate) {
|
||||
draw_buf_rotate(&draw_buf->area, draw_buf->buf_act);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
call_flush_cb(disp->driver, &draw_buf->area, color_p);
|
||||
}
|
||||
}
|
||||
|
@ -920,6 +975,15 @@ static void draw_buf_flush(void)
|
|||
|
||||
static void call_flush_cb(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_p)
|
||||
{
|
||||
TRACE_REFR("Calling flush_cb on (%d;%d)(%d;%d) area with %p image pointer", area->x1, area->y1, area->x2, area->y2, color_p);
|
||||
drv->flush_cb(drv, area, color_p);
|
||||
REFR_TRACE("Calling flush_cb on (%d;%d)(%d;%d) area with %p image pointer", area->x1, area->y1, area->x2, area->y2,
|
||||
(void *)color_p);
|
||||
|
||||
lv_area_t offset_area = {
|
||||
.x1 = area->x1 + drv->offset_x,
|
||||
.y1 = area->y1 + drv->offset_y,
|
||||
.x2 = area->x2 + drv->offset_x,
|
||||
.y2 = area->y2 + drv->offset_y
|
||||
};
|
||||
|
||||
drv->flush_cb(drv, &offset_area, color_p);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ static void apply_theme(lv_theme_t * th, lv_obj_t * obj);
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
|
||||
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj)
|
||||
{
|
||||
lv_disp_t * disp = obj ? lv_obj_get_disp(obj) : lv_disp_get_default();
|
||||
return lv_disp_get_theme(disp);
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct _lv_theme_t {
|
|||
* @param obj pointer to object
|
||||
* @return the theme of the object's display (can be NULL)
|
||||
*/
|
||||
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj);
|
||||
lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Apply the active theme on an object
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define SPLIT_RADIUS_LIMIT 10 /*With radius greater then this the arc will drawn in quarters. A quarter is drawn only if there is arc in it*/
|
||||
#define SPLIT_RADIUS_LIMIT 10 /*With radius greater than this the arc will drawn in quarters. A quarter is drawn only if there is arc in it*/
|
||||
#define SPLIT_ANGLE_GAP_LIMIT 60 /*With small gaps in the arc don't bother with splitting because there is nothing to skip.*/
|
||||
|
||||
/**********************
|
||||
|
@ -40,11 +40,11 @@ typedef struct {
|
|||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if LV_DRAW_COMPLEX
|
||||
static void draw_quarter_0(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_1(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_2(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_3(quarter_draw_dsc_t * q);
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness, lv_area_t * res_area);
|
||||
static void draw_quarter_0(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_1(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_2(quarter_draw_dsc_t * q);
|
||||
static void draw_quarter_3(quarter_draw_dsc_t * q);
|
||||
static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t thickness, lv_area_t * res_area);
|
||||
#endif /*LV_DRAW_COMPLEX*/
|
||||
|
||||
/**********************
|
||||
|
@ -85,7 +85,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
cir_dsc.bg_opa = LV_OPA_TRANSP;
|
||||
cir_dsc.bg_img_src = dsc->img_src;
|
||||
cir_dsc.bg_img_opa = dsc->opa;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
cir_dsc.bg_opa = dsc->opa;
|
||||
cir_dsc.bg_color = dsc->color;
|
||||
}
|
||||
|
@ -104,9 +105,12 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
area_in.y2 -= dsc->width;
|
||||
|
||||
/*Create inner the mask*/
|
||||
int16_t mask_in_id = LV_MASK_ID_INV;
|
||||
lv_draw_mask_radius_param_t mask_in_param;
|
||||
lv_draw_mask_radius_init(&mask_in_param, &area_in, LV_RADIUS_CIRCLE, true);
|
||||
int16_t mask_in_id = lv_draw_mask_add(&mask_in_param, NULL);
|
||||
if(lv_area_get_width(&area_in) > 0 && lv_area_get_height(&area_in) > 0) {
|
||||
lv_draw_mask_radius_init(&mask_in_param, &area_in, LV_RADIUS_CIRCLE, true);
|
||||
mask_in_id = lv_draw_mask_add(&mask_in_param, NULL);
|
||||
}
|
||||
|
||||
lv_draw_mask_radius_param_t mask_out_param;
|
||||
lv_draw_mask_radius_init(&mask_out_param, &area_out, LV_RADIUS_CIRCLE, false);
|
||||
|
@ -118,7 +122,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
lv_draw_rect(&area_out, clip_area, &cir_dsc);
|
||||
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
lv_draw_mask_remove_id(mask_in_id);
|
||||
if(mask_in_id != LV_MASK_ID_INV) lv_draw_mask_remove_id(mask_in_id);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -159,9 +163,14 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
else {
|
||||
lv_draw_rect(&area_out, clip_area, &cir_dsc);
|
||||
}
|
||||
|
||||
lv_draw_mask_free_param(&mask_angle_param);
|
||||
lv_draw_mask_free_param(&mask_out_param);
|
||||
lv_draw_mask_free_param(&mask_in_param);
|
||||
|
||||
lv_draw_mask_remove_id(mask_angle_id);
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
lv_draw_mask_remove_id(mask_in_id);
|
||||
if(mask_in_id != LV_MASK_ID_INV) lv_draw_mask_remove_id(mask_in_id);
|
||||
|
||||
if(dsc->rounded) {
|
||||
|
||||
|
@ -180,6 +189,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
|
||||
lv_draw_rect(&area_out, &clip_area2, &cir_dsc);
|
||||
lv_draw_mask_remove_id(mask_end_id);
|
||||
lv_draw_mask_free_param(&mask_end_param);
|
||||
}
|
||||
|
||||
get_rounded_area(end_angle, radius, width, &round_area);
|
||||
|
@ -193,6 +203,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
|
||||
lv_draw_rect(&area_out, &clip_area2, &cir_dsc);
|
||||
lv_draw_mask_remove_id(mask_end_id);
|
||||
lv_draw_mask_free_param(&mask_end_param);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -207,14 +218,31 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
#endif /*LV_DRAW_COMPLEX*/
|
||||
}
|
||||
|
||||
void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, lv_coord_t w, bool rounded, lv_area_t * area)
|
||||
void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
lv_coord_t w, bool rounded, lv_area_t * area)
|
||||
{
|
||||
lv_coord_t rout = radius;
|
||||
|
||||
/*Special case: full arc invalidation */
|
||||
if(end_angle == start_angle + 360) {
|
||||
area->x1 = x - rout;
|
||||
area->y1 = y - rout;
|
||||
area->x2 = x + rout;
|
||||
area->y2 = y + rout;
|
||||
return;
|
||||
}
|
||||
|
||||
if(start_angle > 360) start_angle -= 360;
|
||||
if(end_angle > 360) end_angle -= 360;
|
||||
|
||||
lv_coord_t rin = radius - w;
|
||||
lv_coord_t extra_area = rounded ? w : 0;
|
||||
lv_coord_t extra_area = rounded ? w / 2 + 1 : 0;
|
||||
uint8_t start_quarter = start_angle / 90;
|
||||
uint8_t end_quarter = end_angle / 90;
|
||||
|
||||
/*360 deg still counts as quarter 3 (360 / 90 would be 4)*/
|
||||
if(start_quarter == 4) start_quarter = 3;
|
||||
if(end_quarter == 4) end_quarter = 3;
|
||||
|
||||
if(start_quarter == end_quarter && start_angle <= end_angle) {
|
||||
if(start_quarter == 0) {
|
||||
|
@ -249,7 +277,7 @@ void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t
|
|||
else if(start_quarter == 0 && end_quarter == 1) {
|
||||
area->x1 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y + ((LV_MIN(lv_trigo_sin(end_angle),
|
||||
lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
lv_trigo_sin(start_angle)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(start_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + rout + extra_area;
|
||||
}
|
||||
|
@ -257,7 +285,7 @@ void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t
|
|||
area->x1 = x - rout - extra_area;
|
||||
area->y1 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + ((LV_MAX(lv_trigo_sin(start_angle + 90),
|
||||
lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
lv_trigo_sin(end_angle + 90)) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
else if(start_quarter == 2 && end_quarter == 3) {
|
||||
|
@ -265,11 +293,11 @@ void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t
|
|||
area->y1 = y - rout - extra_area;
|
||||
area->x2 = x + ((lv_trigo_sin(end_angle + 90) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
area->y2 = y + (LV_MAX(lv_trigo_sin(end_angle) * rin,
|
||||
lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
lv_trigo_sin(start_angle) * rin) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
}
|
||||
else if(start_quarter == 3 && end_quarter == 0) {
|
||||
area->x1 = x + ((LV_MIN(lv_trigo_sin(end_angle + 90),
|
||||
lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
lv_trigo_sin(start_angle + 90)) * rin) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->y1 = y + ((lv_trigo_sin(start_angle) * rout) >> LV_TRIGO_SHIFT) - extra_area;
|
||||
area->x2 = x + rout + extra_area;
|
||||
area->y2 = y + ((lv_trigo_sin(end_angle) * rout) >> LV_TRIGO_SHIFT) + extra_area;
|
||||
|
|
|
@ -62,7 +62,8 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uin
|
|||
* @param rounded true: the arc is rounded
|
||||
* @param area store the area to invalidate here
|
||||
*/
|
||||
void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, lv_coord_t w, bool rounded, lv_area_t * area);
|
||||
void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle,
|
||||
lv_coord_t w, bool rounded, lv_area_t * area);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
lv_color_t color, lv_opa_t opa,
|
||||
const lv_opa_t * mask, lv_draw_mask_res_t mask_res);
|
||||
|
@ -64,7 +65,9 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
|||
|
||||
static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
static inline lv_color_t color_blend_true_color_multiply(lv_color_t fg, lv_color_t bg, lv_opa_t opa);
|
||||
#endif
|
||||
#endif //LV_USE_GPU_SDL_RENDER
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -73,22 +76,21 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
|||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#if LV_COLOR_SCREEN_TRANSP == 0
|
||||
#define FILL_NORMAL_MASK_PX(color) \
|
||||
if(*mask == LV_OPA_COVER) *disp_buf_first = color; \
|
||||
else *disp_buf_first = lv_color_mix(color, *disp_buf_first, *mask); \
|
||||
mask++; \
|
||||
disp_buf_first++;
|
||||
|
||||
#define FILL_NORMAL_MASK_PX(out_x, color) \
|
||||
if(*mask_tmp_x) { \
|
||||
if(*mask_tmp_x == LV_OPA_COVER) disp_buf_first[out_x] = color; \
|
||||
else disp_buf_first[out_x] = lv_color_mix(color, disp_buf_first[out_x], *mask_tmp_x); \
|
||||
} \
|
||||
mask_tmp_x++;
|
||||
|
||||
#define FILL_NORMAL_MASK_PX_SCR_TRANSP(out_x, color) \
|
||||
if(*mask_tmp_x) { \
|
||||
if(*mask_tmp_x == LV_OPA_COVER) disp_buf_first[out_x] = color; \
|
||||
else if(disp->driver->screen_transp) lv_color_mix_with_alpha(disp_buf_first[out_x], disp_buf_first[out_x].ch.alpha, \
|
||||
color, *mask_tmp_x, &disp_buf_first[out_x], &disp_buf_first[out_x].ch.alpha); \
|
||||
else disp_buf_first[out_x] = lv_color_mix(color, disp_buf_first[out_x], *mask_tmp_x); \
|
||||
} \
|
||||
mask_tmp_x++;
|
||||
#else
|
||||
#define FILL_NORMAL_MASK_PX(color) \
|
||||
if(*mask == LV_OPA_COVER) *disp_buf_first = color; \
|
||||
else if(disp->driver->screen_transp) lv_color_mix_with_alpha(*disp_buf_first, disp_buf_first->ch.alpha, color, *mask, disp_buf_first, &disp_buf_first->ch.alpha); \
|
||||
else *disp_buf_first = lv_color_mix(color, *disp_buf_first, *mask); \
|
||||
mask++; \
|
||||
disp_buf_first++;
|
||||
#endif
|
||||
|
||||
#define MAP_NORMAL_MASK_PX(x) \
|
||||
if(*mask_tmp_x) { \
|
||||
|
@ -101,7 +103,7 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
|||
if(*mask_tmp_x) { \
|
||||
if(*mask_tmp_x == LV_OPA_COVER) disp_buf_first[x] = map_buf_first[x]; \
|
||||
else if(disp->driver->screen_transp) lv_color_mix_with_alpha(disp_buf_first[x], disp_buf_first[x].ch.alpha, \
|
||||
map_buf_first[x], *mask_tmp_x, &disp_buf_first[x], &disp_buf_first[x].ch.alpha); \
|
||||
map_buf_first[x], *mask_tmp_x, &disp_buf_first[x], &disp_buf_first[x].ch.alpha); \
|
||||
else disp_buf_first[x] = lv_color_mix(map_buf_first[x], disp_buf_first[x], *mask_tmp_x); \
|
||||
} \
|
||||
mask_tmp_x++;
|
||||
|
@ -110,6 +112,7 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
/**
|
||||
* Fill and area in the display buffer.
|
||||
* @param clip_area clip the fill to this area (absolute coordinates)
|
||||
|
@ -141,16 +144,11 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_fill(const lv_area_t * clip_area, const lv_
|
|||
/*Get clipped fill area which is the real draw area.
|
||||
*It is always the same or inside `fill_area`*/
|
||||
lv_area_t draw_area;
|
||||
bool is_common;
|
||||
is_common = _lv_area_intersect(&draw_area, clip_area, fill_area);
|
||||
if(!is_common) return;
|
||||
if(!_lv_area_intersect(&draw_area, clip_area, fill_area)) return;
|
||||
|
||||
/*Now `draw_area` has absolute coordinates.
|
||||
*Make it relative to `disp_area` to simplify draw to `disp_buf`*/
|
||||
draw_area.x1 -= disp_area->x1;
|
||||
draw_area.y1 -= disp_area->y1;
|
||||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
*Make it relative to `disp_area` to simplify the drawing to `disp_buf`*/
|
||||
lv_area_move(&draw_area, -disp_area->x1, -disp_area->y1);
|
||||
|
||||
/*Round the values in the mask if anti-aliasing is disabled*/
|
||||
if(mask && disp->driver->antialiasing == 0 && mask) {
|
||||
|
@ -216,8 +214,7 @@ LV_ATTRIBUTE_FAST_MEM void _lv_blend_map(const lv_area_t * clip_area, const lv_a
|
|||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
/*Round the values in the mask if anti-aliasing is disabled*/
|
||||
if(mask && disp->driver->antialiasing == 0)
|
||||
{
|
||||
if(mask && disp->driver->antialiasing == 0) {
|
||||
int32_t mask_w = lv_area_get_width(&draw_area);
|
||||
int32_t i;
|
||||
for(i = 0; i < mask_w; i++) mask[i] = mask[i] > 128 ? LV_OPA_COVER : LV_OPA_TRANSP;
|
||||
|
@ -272,7 +269,7 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
|||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
if(mask_tmp[x]) {
|
||||
disp->driver->set_px_cb(disp->driver, (void *)disp_buf, disp_w, x, y, color,
|
||||
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
}
|
||||
}
|
||||
mask_tmp += draw_area_w;
|
||||
|
@ -280,6 +277,7 @@ static void fill_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
|||
}
|
||||
}
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
/**
|
||||
* Fill an area with a color
|
||||
* @param disp_area the current display area (destination area)
|
||||
|
@ -326,7 +324,6 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
|
|||
if(lv_gpu_nxp_vglite_fill(disp_buf, disp_w, lv_area_get_height(disp_area), draw_area, color, opa) == LV_RES_OK) {
|
||||
return;
|
||||
}
|
||||
/*Fall down to SW render in case of error*/
|
||||
}
|
||||
#elif LV_USE_GPU_STM32_DMA2D
|
||||
if(lv_area_get_size(draw_area) >= 240) {
|
||||
|
@ -392,79 +389,71 @@ LV_ATTRIBUTE_FAST_MEM static void fill_normal(const lv_area_t * disp_area, lv_co
|
|||
}
|
||||
/*Masked*/
|
||||
else {
|
||||
/*Buffer the result color to avoid recalculating the same color*/
|
||||
lv_color_t last_dest_color;
|
||||
lv_color_t last_res_color;
|
||||
lv_opa_t last_mask = LV_OPA_TRANSP;
|
||||
last_dest_color.full = disp_buf_first[0].full;
|
||||
last_res_color.full = disp_buf_first[0].full;
|
||||
|
||||
int32_t x_end4 = draw_area_w - 4;
|
||||
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
uint32_t c32 = color.full + ((uint32_t)color.full << 16);
|
||||
#endif
|
||||
|
||||
/*Only the mask matters*/
|
||||
if(opa > LV_OPA_MAX) {
|
||||
for(y = 0; y < draw_area_h; y++) {
|
||||
const lv_opa_t * mask_tmp_x = mask;
|
||||
#if 0
|
||||
for(x = 0; x < draw_area_w; x++) {
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color)
|
||||
#else
|
||||
FILL_NORMAL_MASK_PX(x, color)
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
for(x = 0; x < draw_area_w && ((lv_uintptr_t)mask_tmp_x & 0x3); x++) {
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color)
|
||||
#else
|
||||
FILL_NORMAL_MASK_PX(x, color)
|
||||
#endif
|
||||
for(x = 0; x < draw_area_w && ((lv_uintptr_t)(mask) & 0x3); x++) {
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
}
|
||||
|
||||
uint32_t * mask32 = (uint32_t *)mask_tmp_x;
|
||||
for(; x <= x_end4; x += 4) {
|
||||
if(*mask32) {
|
||||
if((*mask32) == 0xFFFFFFFF) {
|
||||
disp_buf_first[x] = color;
|
||||
disp_buf_first[x + 1] = color;
|
||||
disp_buf_first[x + 2] = color;
|
||||
disp_buf_first[x + 3] = color;
|
||||
uint32_t mask32 = *((uint32_t *)mask);
|
||||
if(mask32 == 0xFFFFFFFF) {
|
||||
#if LV_COLOR_DEPTH == 16
|
||||
if((lv_uintptr_t)disp_buf_first & 0x3) {
|
||||
*(disp_buf_first + 0) = color;
|
||||
uint32_t * d = (uint32_t *)(disp_buf_first + 1);
|
||||
*d = c32;
|
||||
*(disp_buf_first + 3) = color;
|
||||
}
|
||||
else {
|
||||
mask_tmp_x = (const lv_opa_t *)mask32;
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color)
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 1, color)
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 2, color)
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x + 3, color)
|
||||
#else
|
||||
FILL_NORMAL_MASK_PX(x, color)
|
||||
FILL_NORMAL_MASK_PX(x + 1, color)
|
||||
FILL_NORMAL_MASK_PX(x + 2, color)
|
||||
FILL_NORMAL_MASK_PX(x + 3, color)
|
||||
#endif
|
||||
uint32_t * d = (uint32_t *)disp_buf_first;
|
||||
*d = c32;
|
||||
*(d + 1) = c32;
|
||||
}
|
||||
#else
|
||||
disp_buf_first[0] = color;
|
||||
disp_buf_first[1] = color;
|
||||
disp_buf_first[2] = color;
|
||||
disp_buf_first[3] = color;
|
||||
#endif
|
||||
disp_buf_first += 4;
|
||||
mask += 4;
|
||||
}
|
||||
else if(mask32) {
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
}
|
||||
else {
|
||||
mask += 4;
|
||||
disp_buf_first += 4;
|
||||
}
|
||||
mask32++;
|
||||
}
|
||||
|
||||
mask_tmp_x = (const lv_opa_t *)mask32;
|
||||
for(; x < draw_area_w ; x++) {
|
||||
#if LV_COLOR_SCREEN_TRANSP
|
||||
FILL_NORMAL_MASK_PX_SCR_TRANSP(x, color)
|
||||
#else
|
||||
FILL_NORMAL_MASK_PX(x, color)
|
||||
#endif
|
||||
FILL_NORMAL_MASK_PX(color)
|
||||
}
|
||||
#endif
|
||||
disp_buf_first += disp_w;
|
||||
mask += draw_area_w;
|
||||
disp_buf_first += (disp_w - draw_area_w);
|
||||
}
|
||||
}
|
||||
/*Handle opa and mask values too*/
|
||||
else {
|
||||
/*Buffer the result color to avoid recalculating the same color*/
|
||||
lv_color_t last_dest_color;
|
||||
lv_color_t last_res_color;
|
||||
lv_opa_t last_mask = LV_OPA_TRANSP;
|
||||
last_dest_color.full = disp_buf_first[0].full;
|
||||
last_res_color.full = disp_buf_first[0].full;
|
||||
lv_opa_t opa_tmp = LV_OPA_TRANSP;
|
||||
|
||||
for(y = draw_area->y1; y <= draw_area->y2; y++) {
|
||||
const lv_opa_t * mask_tmp_x = mask;
|
||||
for(x = 0; x < draw_area_w; x++) {
|
||||
|
@ -530,6 +519,9 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
|||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
case LV_BLEND_MODE_MULTIPLY:
|
||||
blend_fp = color_blend_true_color_multiply;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
|
@ -588,6 +580,7 @@ static void fill_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, co
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif // LV_USE_GPU_SDL_RENDER
|
||||
|
||||
static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, const lv_area_t * draw_area,
|
||||
const lv_area_t * map_area, const lv_color_t * map_buf, lv_opa_t opa,
|
||||
|
@ -631,7 +624,7 @@ static void map_set_px(const lv_area_t * disp_area, lv_color_t * disp_buf, cons
|
|||
for(x = draw_area->x1; x <= draw_area->x2; x++) {
|
||||
if(mask_tmp[x]) {
|
||||
disp->driver->set_px_cb(disp->driver, (void *)disp_buf, disp_w, x, y, map_buf_tmp[x],
|
||||
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
(uint32_t)((uint32_t)opa * mask_tmp[x]) >> 8);
|
||||
}
|
||||
}
|
||||
mask_tmp += draw_area_w;
|
||||
|
@ -701,8 +694,8 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
|||
blit.src_stride = lv_area_get_width(map_area) * sizeof(lv_color_t);
|
||||
blit.src_area.x1 = (draw_area->x1 - (map_area->x1 - disp_area->x1));
|
||||
blit.src_area.y1 = (draw_area->y1 - (map_area->y1 - disp_area->y1));
|
||||
blit.src_area.x2 = blit.src_area.x1 + draw_area_w - 1;
|
||||
blit.src_area.y2 = blit.src_area.y1 + draw_area_h - 1;
|
||||
blit.src_area.x2 = blit.src_area.x1 + draw_area_w;
|
||||
blit.src_area.y2 = blit.src_area.y1 + draw_area_h;
|
||||
|
||||
blit.dst = disp_buf;
|
||||
blit.dst_width = lv_area_get_width(disp_area);
|
||||
|
@ -710,8 +703,8 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
|||
blit.dst_stride = lv_area_get_width(disp_area) * sizeof(lv_color_t);
|
||||
blit.dst_area.x1 = draw_area->x1;
|
||||
blit.dst_area.y1 = draw_area->y1;
|
||||
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w - 1;
|
||||
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h - 1;
|
||||
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w;
|
||||
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h;
|
||||
|
||||
blit.opa = opa;
|
||||
|
||||
|
@ -751,8 +744,8 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
|||
blit.src_stride = lv_area_get_width(map_area) * sizeof(lv_color_t);
|
||||
blit.src_area.x1 = (draw_area->x1 - (map_area->x1 - disp_area->x1));
|
||||
blit.src_area.y1 = (draw_area->y1 - (map_area->y1 - disp_area->y1));
|
||||
blit.src_area.x2 = blit.src_area.x1 + draw_area_w - 1;
|
||||
blit.src_area.y2 = blit.src_area.y1 + draw_area_h - 1;
|
||||
blit.src_area.x2 = blit.src_area.x1 + draw_area_w;
|
||||
blit.src_area.y2 = blit.src_area.y1 + draw_area_h;
|
||||
|
||||
blit.dst = disp_buf;
|
||||
blit.dst_width = lv_area_get_width(disp_area);
|
||||
|
@ -760,8 +753,8 @@ LV_ATTRIBUTE_FAST_MEM static void map_normal(const lv_area_t * disp_area, lv_col
|
|||
blit.dst_stride = lv_area_get_width(disp_area) * sizeof(lv_color_t);
|
||||
blit.dst_area.x1 = draw_area->x1;
|
||||
blit.dst_area.y1 = draw_area->y1;
|
||||
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w - 1;
|
||||
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h - 1;
|
||||
blit.dst_area.x2 = blit.dst_area.x1 + draw_area_w;
|
||||
blit.dst_area.y2 = blit.dst_area.y1 + draw_area_h;
|
||||
|
||||
blit.opa = opa;
|
||||
|
||||
|
@ -915,6 +908,9 @@ static void map_blended(const lv_area_t * disp_area, lv_color_t * disp_buf, con
|
|||
case LV_BLEND_MODE_SUBTRACTIVE:
|
||||
blend_fp = color_blend_true_color_subtractive;
|
||||
break;
|
||||
case LV_BLEND_MODE_MULTIPLY:
|
||||
blend_fp = color_blend_true_color_multiply;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("fill_blended: unsupported blend mode");
|
||||
return;
|
||||
|
@ -1015,7 +1011,6 @@ static inline lv_color_t color_blend_true_color_additive(lv_color_t fg, lv_color
|
|||
|
||||
static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_color_t bg, lv_opa_t opa)
|
||||
{
|
||||
|
||||
if(opa <= LV_OPA_MIN) return bg;
|
||||
|
||||
int32_t tmp;
|
||||
|
@ -1039,4 +1034,30 @@ static inline lv_color_t color_blend_true_color_subtractive(lv_color_t fg, lv_co
|
|||
|
||||
return lv_color_mix(fg, bg, opa);
|
||||
}
|
||||
|
||||
static inline lv_color_t color_blend_true_color_multiply(lv_color_t fg, lv_color_t bg, lv_opa_t opa)
|
||||
{
|
||||
if(opa <= LV_OPA_MIN) return bg;
|
||||
|
||||
#if LV_COLOR_DEPTH == 32
|
||||
fg.ch.red = (fg.ch.red * bg.ch.red) >> 8;
|
||||
fg.ch.green = (fg.ch.green * bg.ch.green) >> 8;
|
||||
fg.ch.blue = (fg.ch.blue * bg.ch.blue) >> 8;
|
||||
#elif LV_COLOR_DEPTH == 16
|
||||
fg.ch.red = (fg.ch.red * bg.ch.red) >> 5;
|
||||
fg.ch.blue = (fg.ch.blue * bg.ch.blue) >> 5;
|
||||
LV_COLOR_SET_G(fg, (LV_COLOR_GET_G(fg) * LV_COLOR_GET_G(bg)) >> 6);
|
||||
#elif LV_COLOR_DEPTH == 8
|
||||
fg.ch.red = (fg.ch.red * bg.ch.red) >> 3;
|
||||
fg.ch.green = (fg.ch.green * bg.ch.green) >> 3;
|
||||
fg.ch.blue = (fg.ch.blue * bg.ch.blue) >> 2;
|
||||
#endif
|
||||
|
||||
if(opa == LV_OPA_COVER) return fg;
|
||||
|
||||
return lv_color_mix(fg, bg, opa);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // LV_USE_GPU_SDL_RENDER
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
|
||||
const void * src,
|
||||
const lv_draw_img_dsc_t * draw_dsc);
|
||||
|
@ -41,6 +42,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
|
||||
static void show_error(const lv_area_t * coords, const lv_area_t * clip_area, const char * msg);
|
||||
static void draw_cleanup(_lv_img_cache_entry_t * cache);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -63,6 +65,7 @@ void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc)
|
|||
dsc->antialias = LV_COLOR_DEPTH > 8 ? 1 : 0;
|
||||
}
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
/**
|
||||
* Draw an image
|
||||
* @param coords the coordinates of the image
|
||||
|
@ -89,6 +92,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void *
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif //LV_USE_GPU_SDL_RENDER
|
||||
|
||||
/**
|
||||
* Get the pixel size of a color format in bits
|
||||
|
@ -229,6 +233,7 @@ lv_img_src_t lv_img_src_get_type(const void * src)
|
|||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * clip_area,
|
||||
const void * src,
|
||||
const lv_draw_img_dsc_t * draw_dsc)
|
||||
|
@ -289,7 +294,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
|||
int32_t width = lv_area_get_width(&mask_com);
|
||||
|
||||
uint8_t * buf = lv_mem_buf_get(lv_area_get_width(&mask_com) *
|
||||
LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
|
||||
LV_IMG_PX_SIZE_ALPHA_BYTE); /*+1 because of the possible alpha byte*/
|
||||
|
||||
lv_area_t line;
|
||||
lv_area_copy(&line, &mask_com);
|
||||
|
@ -326,11 +331,11 @@ LV_ATTRIBUTE_FAST_MEM static lv_res_t lv_img_draw_core(const lv_area_t * coords,
|
|||
|
||||
/**
|
||||
* Draw a color map to the display (image)
|
||||
* @param cords_p coordinates the color map
|
||||
* @param mask_p the map will drawn only on this area (truncated to draw_buf area)
|
||||
* @param map_area coordinates the color map
|
||||
* @param clip_area the map will drawn only on this area (truncated to draw_buf area)
|
||||
* @param map_p pointer to a lv_color_t array
|
||||
* @param draw_dsc pointer to an initialized `lv_draw_img_dsc_t` variable
|
||||
* @param chroma_keyed true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param chroma_key true: enable transparency of LV_IMG_LV_COLOR_TRANSP color pixels
|
||||
* @param alpha_byte true: extra alpha byte is inserted for every pixel
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area,
|
||||
|
@ -353,10 +358,10 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
draw_area.x2 -= disp_area->x1;
|
||||
draw_area.y2 -= disp_area->y1;
|
||||
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
bool mask_any = lv_draw_mask_is_any(clip_area);
|
||||
|
||||
/*The simplest case just copy the pixels into the draw_buf*/
|
||||
if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE &&
|
||||
if(!mask_any && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE &&
|
||||
chroma_key == false && alpha_byte == false && draw_dsc->recolor_opa == LV_OPA_TRANSP) {
|
||||
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
|
||||
draw_dsc->blend_mode);
|
||||
|
@ -364,14 +369,14 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
|
||||
#if LV_USE_GPU_NXP_PXP
|
||||
/*Simple case without masking and transformations*/
|
||||
else if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
|
||||
else if(!mask_any && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
|
||||
chroma_key == true && draw_dsc->recolor_opa == LV_OPA_TRANSP) { /*copy with color keying (+ alpha)*/
|
||||
lv_gpu_nxp_pxp_enable_color_key();
|
||||
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
|
||||
draw_dsc->blend_mode);
|
||||
lv_gpu_nxp_pxp_disable_color_key();
|
||||
}
|
||||
else if(other_mask_cnt == 0 && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
|
||||
else if(!mask_any && draw_dsc->angle == 0 && draw_dsc->zoom == LV_IMG_ZOOM_NONE && alpha_byte == false &&
|
||||
chroma_key == false && draw_dsc->recolor_opa != LV_OPA_TRANSP) { /*copy with recolor (+ alpha)*/
|
||||
lv_gpu_nxp_pxp_enable_recolor(draw_dsc->recolor, draw_dsc->recolor_opa);
|
||||
_lv_blend_map(clip_area, map_area, (lv_color_t *)map_p, NULL, LV_DRAW_MASK_RES_FULL_COVER, draw_dsc->opa,
|
||||
|
@ -381,7 +386,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
#endif
|
||||
/*In the other cases every pixel need to be checked one-by-one*/
|
||||
else {
|
||||
//#if LV_DRAW_COMPLEX
|
||||
//#if LV_DRAW_COMPLEX
|
||||
/*The pixel size in byte is different if an alpha byte is added too*/
|
||||
uint8_t px_size_byte = alpha_byte ? LV_IMG_PX_SIZE_ALPHA_BYTE : sizeof(lv_color_t);
|
||||
|
||||
|
@ -397,18 +402,18 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
|
||||
const uint8_t * map_px;
|
||||
|
||||
lv_area_t blend_area;
|
||||
blend_area.x1 = draw_area.x1 + disp_area->x1;
|
||||
blend_area.x2 = blend_area.x1 + lv_area_get_width(&draw_area) - 1;
|
||||
blend_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
blend_area.y2 = blend_area.y1;
|
||||
|
||||
lv_coord_t draw_area_h = lv_area_get_height(&draw_area);
|
||||
lv_coord_t draw_area_w = lv_area_get_width(&draw_area);
|
||||
|
||||
lv_area_t blend_area;
|
||||
blend_area.x1 = draw_area.x1 + disp_area->x1;
|
||||
blend_area.x2 = blend_area.x1 + draw_area_w - 1;
|
||||
blend_area.y1 = disp_area->y1 + draw_area.y1;
|
||||
blend_area.y2 = blend_area.y1;
|
||||
|
||||
bool transform = draw_dsc->angle != 0 || draw_dsc->zoom != LV_IMG_ZOOM_NONE ? true : false;
|
||||
/*Simple ARGB image. Handle it as special case because it's very common*/
|
||||
if(other_mask_cnt == 0 && !transform && !chroma_key && draw_dsc->recolor_opa == LV_OPA_TRANSP && alpha_byte) {
|
||||
if(!mask_any && !transform && !chroma_key && draw_dsc->recolor_opa == LV_OPA_TRANSP && alpha_byte) {
|
||||
#if LV_USE_GPU_STM32_DMA2D && LV_COLOR_DEPTH == 32
|
||||
/*Blend ARGB images directly*/
|
||||
if(lv_area_get_size(&draw_area) > 240) {
|
||||
|
@ -447,7 +452,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
}
|
||||
|
||||
map_buf_tmp += map_w * px_size_byte;
|
||||
if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) {
|
||||
if(px_i + draw_area_w < mask_buf_size) {
|
||||
blend_area.y2 ++;
|
||||
}
|
||||
else {
|
||||
|
@ -509,7 +514,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
draw_dsc->zoom != LV_IMG_ZOOM_NONE) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
|
||||
|
||||
/*Prepare the `mask_buf`if there are other masks*/
|
||||
if(other_mask_cnt) {
|
||||
if(mask_any) {
|
||||
lv_memset_ff(mask_buf, mask_buf_size);
|
||||
}
|
||||
|
||||
|
@ -589,12 +594,13 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
}
|
||||
#if LV_DRAW_COMPLEX
|
||||
/*Apply the masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
if(mask_any) {
|
||||
lv_draw_mask_res_t mask_res_sub;
|
||||
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + draw_buf->area.x1, y + draw_area.y1 + draw_buf->area.y1,
|
||||
lv_area_get_width(&draw_area));
|
||||
mask_res_sub = lv_draw_mask_apply(mask_buf + px_i_start, draw_area.x1 + draw_buf->area.x1,
|
||||
y + draw_area.y1 + draw_buf->area.y1,
|
||||
draw_area_w);
|
||||
if(mask_res_sub == LV_DRAW_MASK_RES_TRANSP) {
|
||||
lv_memset_00(mask_buf + px_i_start, lv_area_get_width(&draw_area));
|
||||
lv_memset_00(mask_buf + px_i_start, draw_area_w);
|
||||
mask_res = LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
else if(mask_res_sub == LV_DRAW_MASK_RES_CHANGED) {
|
||||
|
@ -604,7 +610,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
#endif
|
||||
|
||||
map_buf_tmp += map_w * px_size_byte;
|
||||
if(px_i + lv_area_get_width(&draw_area) < mask_buf_size) {
|
||||
if(px_i + draw_area_w < mask_buf_size) {
|
||||
blend_area.y2 ++;
|
||||
}
|
||||
else {
|
||||
|
@ -619,7 +625,7 @@ LV_ATTRIBUTE_FAST_MEM static void lv_draw_map(const lv_area_t * map_area, const
|
|||
draw_dsc->zoom != LV_IMG_ZOOM_NONE) ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
|
||||
|
||||
/*Prepare the `mask_buf`if there are other masks*/
|
||||
if(other_mask_cnt) {
|
||||
if(mask_any) {
|
||||
lv_memset_ff(mask_buf, mask_buf_size);
|
||||
}
|
||||
}
|
||||
|
@ -658,3 +664,5 @@ static void draw_cleanup(_lv_img_cache_entry_t * cache)
|
|||
LV_UNUSED(cache);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //LV_USE_GPU_SDL_RENDER
|
|
@ -13,6 +13,9 @@
|
|||
#include "../misc/lv_bidi.h"
|
||||
#include "../misc/lv_assert.h"
|
||||
|
||||
#if LV_USE_GPU_SDL
|
||||
#include "../gpu/lv_gpu_sdl.h"
|
||||
#endif
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -32,13 +35,18 @@ typedef uint8_t cmd_state_t;
|
|||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g,
|
||||
const lv_area_t * clip_area,
|
||||
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
|
||||
#if LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX
|
||||
static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_dsc_t * g, const lv_area_t * clip_area,
|
||||
const uint8_t * map_p, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode);
|
||||
#endif
|
||||
#endif /*LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX*/
|
||||
#endif /*LV_USE_EXTERNAL_RENDERER*/
|
||||
|
||||
static uint8_t hex_char_to_num(char hex);
|
||||
|
||||
/**********************
|
||||
|
@ -121,13 +129,18 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
int32_t w;
|
||||
|
||||
/*No need to waste processor time if string is empty*/
|
||||
if (txt == NULL || txt[0] == '\0')
|
||||
if(txt == NULL || txt[0] == '\0')
|
||||
return;
|
||||
|
||||
lv_area_t clipped_area;
|
||||
bool clip_ok = _lv_area_intersect(&clipped_area, coords, mask);
|
||||
if(!clip_ok) return;
|
||||
|
||||
lv_text_align_t align = dsc->align;
|
||||
lv_base_dir_t base_dir = dsc->bidi_dir;
|
||||
|
||||
lv_bidi_calculate_align(&align, &base_dir, txt);
|
||||
|
||||
if((dsc->flag & LV_TEXT_FLAG_EXPAND) == 0) {
|
||||
/*Normally use the label's width as width*/
|
||||
w = lv_area_get_width(coords);
|
||||
|
@ -136,7 +149,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
/*If EXAPND is enabled then not limit the text's width to the object's width*/
|
||||
lv_point_t p;
|
||||
lv_txt_get_size(&p, txt, dsc->font, dsc->letter_space, dsc->line_space, LV_COORD_MAX,
|
||||
dsc->flag);
|
||||
dsc->flag);
|
||||
w = p.x;
|
||||
}
|
||||
|
||||
|
@ -193,14 +206,14 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
}
|
||||
|
||||
/*Align to middle*/
|
||||
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
|
||||
pos.x += (lv_area_get_width(coords) - line_width) / 2;
|
||||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||
line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
}
|
||||
|
@ -244,7 +257,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
i = 0;
|
||||
#if LV_USE_BIDI
|
||||
char * bidi_txt = lv_mem_buf_get(line_end - line_start + 1);
|
||||
_lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0);
|
||||
_lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, base_dir, NULL, 0);
|
||||
#else
|
||||
const char * bidi_txt = txt + line_start;
|
||||
#endif
|
||||
|
@ -255,7 +268,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
#if LV_USE_BIDI
|
||||
logical_char_pos = _lv_txt_encoded_get_char_id(txt, line_start);
|
||||
uint32_t t = _lv_txt_encoded_get_char_id(bidi_txt, i);
|
||||
logical_char_pos += _lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, dsc->bidi_dir, t, NULL);
|
||||
logical_char_pos += _lv_bidi_get_logical_pos(bidi_txt, NULL, line_end - line_start, base_dir, t, NULL);
|
||||
#else
|
||||
logical_char_pos = _lv_txt_encoded_get_char_id(txt, line_start + i);
|
||||
#endif
|
||||
|
@ -359,7 +372,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
|
||||
pos.x = coords->x1;
|
||||
/*Align to middle*/
|
||||
if(dsc->align == LV_TEXT_ALIGN_CENTER) {
|
||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||
line_width =
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
|
||||
|
@ -367,7 +380,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
|
||||
}
|
||||
/*Align to the right*/
|
||||
else if(dsc->align == LV_TEXT_ALIGN_RIGHT) {
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||
line_width =
|
||||
lv_txt_get_width(&txt[line_start], line_end - line_start, font, dsc->letter_space, dsc->flag);
|
||||
pos.x += lv_area_get_width(coords) - line_width;
|
||||
|
@ -382,6 +395,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_label(const lv_area_t * coords, const lv_area
|
|||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
||||
#if LV_USE_EXTERNAL_RENDERER == 0
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
@ -414,9 +428,9 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_letter(const lv_point_t * pos_p, const lv_are
|
|||
/*Add warning if the dsc is not found
|
||||
*but do not print warning for non printable ASCII chars (e.g. '\n')*/
|
||||
if(letter >= 0x20 &&
|
||||
letter != 0xf8ff && /*LV_SYMBOL_DUMMY*/
|
||||
letter != 0x200c) { /*ZERO WIDTH NON-JOINER*/
|
||||
LV_LOG_WARN("lv_draw_letter: glyph dsc. not found for U+%X", letter);
|
||||
letter != 0xf8ff && /*LV_SYMBOL_DUMMY*/
|
||||
letter != 0x200c) { /*ZERO WIDTH NON-JOINER*/
|
||||
LV_LOG_WARN("lv_draw_letter: glyph dsc. not found for U+%X", (unsigned int)letter);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -443,11 +457,12 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_letter(const lv_point_t * pos_p, const lv_are
|
|||
|
||||
if(font_p->subpx) {
|
||||
#if LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX
|
||||
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode);
|
||||
draw_letter_subpx(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode);
|
||||
#else
|
||||
LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h");
|
||||
LV_LOG_WARN("Can't draw sub-pixel rendered letter because LV_USE_FONT_SUBPX == 0 in lv_conf.h");
|
||||
#endif
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
draw_letter_normal(pos_x, pos_y, &g, clip_area, map_p, color, opa, blend_mode);
|
||||
}
|
||||
}
|
||||
|
@ -534,7 +549,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
|
|||
fill_area.y1 = row_start + pos_y;
|
||||
fill_area.y2 = fill_area.y1;
|
||||
#if LV_DRAW_COMPLEX
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
bool mask_any = lv_draw_mask_is_any(&fill_area);
|
||||
#endif
|
||||
|
||||
uint32_t col_bit_max = 8 - bpp;
|
||||
|
@ -572,7 +587,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_letter_normal(lv_coord_t pos_x, lv_coord_
|
|||
|
||||
#if LV_DRAW_COMPLEX
|
||||
/*Apply masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
if(mask_any) {
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, fill_area.x1, fill_area.y2,
|
||||
lv_area_get_width(&fill_area));
|
||||
if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
|
||||
|
@ -690,8 +705,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
|||
/*If the letter is partially out of mask the move there on draw_buf*/
|
||||
disp_buf_buf_tmp += (row_start * disp_buf_width) + col_start / 3;
|
||||
|
||||
uint8_t other_mask_cnt = lv_draw_mask_get_cnt();
|
||||
|
||||
bool mask_any = lv_draw_mask_is_any(&map_area);
|
||||
uint8_t font_rgb[3];
|
||||
|
||||
#if LV_COLOR_16_SWAP == 0
|
||||
|
@ -779,7 +793,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
|||
}
|
||||
|
||||
/*Apply masks if any*/
|
||||
if(other_mask_cnt) {
|
||||
if(mask_any) {
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf + mask_p_start, map_area.x1, map_area.y2,
|
||||
lv_area_get_width(&map_area));
|
||||
if(mask_res == LV_DRAW_MASK_RES_TRANSP) {
|
||||
|
@ -816,8 +830,9 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_
|
|||
lv_mem_buf_release(mask_buf);
|
||||
lv_mem_buf_release(color_buf);
|
||||
}
|
||||
#endif
|
||||
#endif /*LV_DRAW_COMPLEX && LV_USE_FONT_SUBPX*/
|
||||
|
||||
#endif /*LV_USE_EXTERNAL_RENDERER*/
|
||||
/**
|
||||
* Convert a hexadecimal characters to a number (0..15)
|
||||
* @param hex Pointer to a hexadecimal character (0..9, A..F)
|
||||
|
@ -860,3 +875,4 @@ static uint8_t hex_char_to_num(char hex)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ typedef struct {
|
|||
lv_coord_t ofs_y;
|
||||
lv_opa_t opa;
|
||||
lv_base_dir_t bidi_dir;
|
||||
lv_text_align_t align;
|
||||
lv_text_flag_t flag;
|
||||
lv_text_align_t align :2;
|
||||
lv_text_decor_t decor : 3;
|
||||
lv_blend_mode_t blend_mode: 3;
|
||||
} lv_draw_label_dsc_t;
|
||||
|
|
|
@ -34,7 +34,6 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
|
|||
LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2,
|
||||
const lv_area_t * clip,
|
||||
const lv_draw_line_dsc_t * dsc);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
@ -117,6 +116,7 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_line(const lv_point_t * point1, const lv_poin
|
|||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2,
|
||||
const lv_area_t * clip,
|
||||
const lv_draw_line_dsc_t * dsc)
|
||||
|
@ -127,11 +127,7 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
|
|||
int32_t w_half0 = w >> 1;
|
||||
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
|
||||
bool simple_mode = true;
|
||||
if(lv_draw_mask_get_cnt()) simple_mode = false;
|
||||
else if(dashed) simple_mode = false;
|
||||
|
||||
lv_area_t draw_area;
|
||||
draw_area.x1 = LV_MIN(point1->x, point2->x);
|
||||
|
@ -139,6 +135,11 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
|
|||
draw_area.y1 = point1->y - w_half1;
|
||||
draw_area.y2 = point1->y + w_half0;
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
bool simple_mode = true;
|
||||
if(lv_draw_mask_is_any(&draw_area)) simple_mode = false;
|
||||
else if(dashed) simple_mode = false;
|
||||
|
||||
/*If there is no mask then simply draw a rectangle*/
|
||||
if(simple_mode) {
|
||||
_lv_blend_fill(clip, &draw_area,
|
||||
|
@ -181,7 +182,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_hor(const lv_point_t * point1, const
|
|||
int32_t h;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
lv_memset_ff(mask_buf, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, draw_buf->area.x1 + draw_area.x1, draw_buf->area.y1 + h, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, draw_buf->area.x1 + draw_area.x1, draw_buf->area.y1 + h,
|
||||
draw_area_w);
|
||||
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_TRANSP) {
|
||||
|
@ -227,18 +229,17 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
|
|||
int32_t w_half0 = w >> 1;
|
||||
int32_t w_half1 = w_half0 + (w & 0x1); /*Compensate rounding error*/
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
|
||||
bool simple_mode = true;
|
||||
if(lv_draw_mask_get_cnt()) simple_mode = false;
|
||||
else if(dashed) simple_mode = false;
|
||||
|
||||
lv_area_t draw_area;
|
||||
draw_area.x1 = point1->x - w_half1;
|
||||
draw_area.x2 = point1->x + w_half0;
|
||||
draw_area.y1 = LV_MIN(point1->y, point2->y);
|
||||
draw_area.y2 = LV_MAX(point1->y, point2->y) - 1;
|
||||
|
||||
bool dashed = dsc->dash_gap && dsc->dash_width ? true : false;
|
||||
bool simple_mode = true;
|
||||
if(lv_draw_mask_is_any(&draw_area)) simple_mode = false;
|
||||
else if(dashed) simple_mode = false;
|
||||
|
||||
/*If there is no mask then simply draw a rectangle*/
|
||||
if(simple_mode) {
|
||||
_lv_blend_fill(clip, &draw_area,
|
||||
|
@ -285,7 +286,8 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_ver(const lv_point_t * point1, const
|
|||
int32_t h;
|
||||
for(h = draw_area.y1; h <= draw_area.y2; h++) {
|
||||
lv_memset_ff(mask_buf, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, draw_buf->area.x1 + draw_area.x1, draw_buf->area.y1 + h, draw_area_w);
|
||||
lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, draw_buf->area.x1 + draw_area.x1, draw_buf->area.y1 + h,
|
||||
draw_area_w);
|
||||
|
||||
if(dashed) {
|
||||
if(mask_res != LV_DRAW_MASK_RES_TRANSP) {
|
||||
|
@ -474,6 +476,10 @@ LV_ATTRIBUTE_FAST_MEM static void draw_line_skew(const lv_point_t * point1, cons
|
|||
|
||||
lv_mem_buf_release(mask_buf);
|
||||
|
||||
lv_draw_mask_free_param(&mask_left_param);
|
||||
lv_draw_mask_free_param(&mask_right_param);
|
||||
if(mask_top_id != LV_MASK_ID_INV) lv_draw_mask_free_param(&mask_top_param);
|
||||
if(mask_bottom_id != LV_MASK_ID_INV) lv_draw_mask_free_param(&mask_bottom_param);
|
||||
lv_draw_mask_remove_id(mask_left_id);
|
||||
lv_draw_mask_remove_id(mask_right_id);
|
||||
lv_draw_mask_remove_id(mask_top_id);
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct {
|
|||
lv_blend_mode_t blend_mode : 2;
|
||||
uint8_t round_start : 1;
|
||||
uint8_t round_end : 1;
|
||||
uint8_t raw_end : 1; /*Do not bother with perpendicular line ending is it's not visible for any reason*/
|
||||
uint8_t raw_end : 1; /*Do not bother with perpendicular line ending if it's not visible for any reason*/
|
||||
} lv_draw_line_dsc_t;
|
||||
|
||||
/**********************
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
|
||||
#include "lv_draw_mask.h"
|
||||
#if LV_DRAW_COMPLEX
|
||||
#include "../misc/lv_math.h"
|
||||
|
@ -18,6 +16,8 @@
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define CIRCLE_CACHE_LIFE_MAX 1000
|
||||
#define CIRCLE_CACHE_AGING(life, r) life = LV_MIN(life + (r < 16 ? 1 : (r >> 4)), 1000)
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -49,8 +49,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
|
|||
lv_coord_t len,
|
||||
lv_draw_mask_line_param_t * p);
|
||||
|
||||
static void circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius);
|
||||
static bool circ_cont(lv_point_t * c);
|
||||
static void circ_next(lv_point_t * c, lv_coord_t * tmp);
|
||||
static void circ_calc_aa4(_lv_draw_mask_radius_circle_dsc_t * c, lv_coord_t radius);
|
||||
static lv_opa_t * get_next_line(_lv_draw_mask_radius_circle_dsc_t * c, lv_coord_t y, lv_coord_t * len,
|
||||
lv_coord_t * x_start);
|
||||
LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_t mask_new);
|
||||
LV_ATTRIBUTE_FAST_MEM static inline void sqrt_approx(lv_sqrt_res_t * q, lv_sqrt_res_t * ref, uint32_t x);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -121,6 +126,39 @@ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf,
|
|||
return changed ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the specified buffers on a line. Used internally by the library's drawing routines.
|
||||
* @param mask_buf store the result mask here. Has to be `len` byte long. Should be initialized with `0xFF`.
|
||||
* @param abs_x absolute X coordinate where the line to calculate start
|
||||
* @param abs_y absolute Y coordinate where the line to calculate start
|
||||
* @param len length of the line to calculate (in pixel count)
|
||||
* @param ids ID array of added buffers
|
||||
* @param ids_count number of ID array
|
||||
* @return One of these values:
|
||||
* - `LV_DRAW_MASK_RES_FULL_TRANSP`: the whole line is transparent. `mask_buf` is not set to zero
|
||||
* - `LV_DRAW_MASK_RES_FULL_COVER`: the whole line is fully visible. `mask_buf` is unchanged
|
||||
* - `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
|
||||
lv_coord_t len, const int16_t *ids, int16_t ids_count)
|
||||
{
|
||||
bool changed = false;
|
||||
_lv_draw_mask_common_dsc_t * dsc;
|
||||
|
||||
for (int i = 0; i < ids_count; i++) {
|
||||
int16_t id = ids[i];
|
||||
if (id == LV_MASK_ID_INV) continue;
|
||||
dsc = LV_GC_ROOT(_lv_draw_mask_list[id]).param;
|
||||
if (!dsc) continue;
|
||||
lv_draw_mask_res_t res = LV_DRAW_MASK_RES_FULL_COVER;
|
||||
res = dsc->cb(mask_buf, abs_x, abs_y, len, dsc);
|
||||
if(res == LV_DRAW_MASK_RES_TRANSP) return LV_DRAW_MASK_RES_TRANSP;
|
||||
else if(res == LV_DRAW_MASK_RES_CHANGED) changed = true;
|
||||
}
|
||||
|
||||
return changed ? LV_DRAW_MASK_RES_CHANGED : LV_DRAW_MASK_RES_FULL_COVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a mask with a given ID
|
||||
* @param id the ID of the mask. Returned by `lv_draw_mask_add`
|
||||
|
@ -129,7 +167,7 @@ LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf,
|
|||
*/
|
||||
void * lv_draw_mask_remove_id(int16_t id)
|
||||
{
|
||||
void * p = NULL;
|
||||
_lv_draw_mask_common_dsc_t * p = NULL;
|
||||
|
||||
if(id != LV_MASK_ID_INV) {
|
||||
p = LV_GC_ROOT(_lv_draw_mask_list[id]).param;
|
||||
|
@ -148,18 +186,52 @@ void * lv_draw_mask_remove_id(int16_t id)
|
|||
*/
|
||||
void * lv_draw_mask_remove_custom(void * custom_id)
|
||||
{
|
||||
void * p = NULL;
|
||||
_lv_draw_mask_common_dsc_t * p = NULL;
|
||||
uint8_t i;
|
||||
for(i = 0; i < _LV_MASK_MAX_NUM; i++) {
|
||||
if(LV_GC_ROOT(_lv_draw_mask_list[i]).custom_id == custom_id) {
|
||||
p = LV_GC_ROOT(_lv_draw_mask_list[i]).param;
|
||||
LV_GC_ROOT(_lv_draw_mask_list[i]).param = NULL;
|
||||
LV_GC_ROOT(_lv_draw_mask_list[i]).custom_id = NULL;
|
||||
lv_draw_mask_remove_id(i);
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the data from the parameter.
|
||||
* It's called inside `lv_draw_mask_remove_id` and `lv_draw_mask_remove_custom`
|
||||
* Needs to be called only in special cases when the mask is not added by `lv_draw_mask_add`
|
||||
* and not removed by `lv_draw_mask_remove_id` or `lv_draw_mask_remove_custom`
|
||||
* @param p pointer to a mask parameter
|
||||
*/
|
||||
void lv_draw_mask_free_param(void * p)
|
||||
{
|
||||
_lv_draw_mask_common_dsc_t * pdsc = p;
|
||||
if(pdsc->type == LV_DRAW_MASK_TYPE_RADIUS) {
|
||||
lv_draw_mask_radius_param_t * radius_p = (lv_draw_mask_radius_param_t *) p;
|
||||
if(radius_p->circle) {
|
||||
if(radius_p->circle->life < 0) {
|
||||
lv_mem_free(radius_p->circle->cir_opa);
|
||||
lv_mem_free(radius_p->circle);
|
||||
}
|
||||
else {
|
||||
radius_p->circle->used_cnt--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _lv_draw_mask_cleanup(void)
|
||||
{
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_CIRCLE_CACHE_SIZE; i++) {
|
||||
if(LV_GC_ROOT(_lv_circle_cache[i]).buf) {
|
||||
lv_mem_free(LV_GC_ROOT(_lv_circle_cache[i]).buf);
|
||||
}
|
||||
lv_memset_00(&LV_GC_ROOT(_lv_circle_cache[i]), sizeof(LV_GC_ROOT(_lv_circle_cache[i])));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count the currently added masks
|
||||
* @return number of active masks
|
||||
|
@ -174,6 +246,32 @@ LV_ATTRIBUTE_FAST_MEM uint8_t lv_draw_mask_get_cnt(void)
|
|||
return cnt;
|
||||
}
|
||||
|
||||
bool lv_draw_mask_is_any(const lv_area_t * a)
|
||||
{
|
||||
if(a == NULL) return LV_GC_ROOT(_lv_draw_mask_list[0]).param ? true : false;
|
||||
|
||||
uint8_t i;
|
||||
for(i = 0; i < _LV_MASK_MAX_NUM; i++) {
|
||||
_lv_draw_mask_common_dsc_t * comm_param = LV_GC_ROOT(_lv_draw_mask_list[i]).param;
|
||||
if(comm_param == NULL) continue;
|
||||
if(comm_param->type == LV_DRAW_MASK_TYPE_RADIUS) {
|
||||
lv_draw_mask_radius_param_t * radius_param = LV_GC_ROOT(_lv_draw_mask_list[i]).param;
|
||||
if(radius_param->cfg.outer) {
|
||||
if(!_lv_area_is_out(a, &radius_param->cfg.rect, radius_param->cfg.radius)) return true;
|
||||
}
|
||||
else {
|
||||
if(!_lv_area_is_in(a, &radius_param->cfg.rect, radius_param->cfg.radius)) return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*Initialize a line mask from two points.
|
||||
* @param param pointer to a `lv_draw_mask_param_t` to initialize
|
||||
|
@ -228,12 +326,12 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
|
|||
int32_t m;
|
||||
|
||||
if(dx) {
|
||||
m = (1 << 20) / dx; /*m is multiplier to normalize y (upscaled by 1024)*/
|
||||
m = (1L << 20) / dx; /*m is multiplier to normalize y (upscaled by 1024)*/
|
||||
param->yx_steep = (m * dy) >> 10;
|
||||
}
|
||||
|
||||
if(dy) {
|
||||
m = (1 << 20) / dy; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
m = (1L << 20) / dy; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
param->xy_steep = (m * dx) >> 10;
|
||||
}
|
||||
param->steep = param->yx_steep;
|
||||
|
@ -243,12 +341,12 @@ void lv_draw_mask_line_points_init(lv_draw_mask_line_param_t * param, lv_coord_t
|
|||
int32_t m;
|
||||
|
||||
if(dy) {
|
||||
m = (1 << 20) / dy; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
m = (1L << 20) / dy; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
param->xy_steep = (m * dx) >> 10;
|
||||
}
|
||||
|
||||
if(dx) {
|
||||
m = (1 << 20) / dx; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
m = (1L << 20) / dx; /*m is multiplier to normalize x (upscaled by 1024)*/
|
||||
param->yx_steep = (m * dy) >> 10;
|
||||
}
|
||||
param->steep = param->xy_steep;
|
||||
|
@ -373,6 +471,7 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
|
|||
{
|
||||
lv_coord_t w = lv_area_get_width(rect);
|
||||
lv_coord_t h = lv_area_get_height(rect);
|
||||
if(radius < 0) radius = 0;
|
||||
int32_t short_side = LV_MIN(w, h);
|
||||
if(radius > short_side >> 1) radius = short_side >> 1;
|
||||
|
||||
|
@ -381,9 +480,48 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area
|
|||
param->cfg.outer = inv ? 1 : 0;
|
||||
param->dsc.cb = (lv_draw_mask_xcb_t)lv_draw_mask_radius;
|
||||
param->dsc.type = LV_DRAW_MASK_TYPE_RADIUS;
|
||||
param->y_prev = INT32_MIN;
|
||||
param->y_prev_x.f = 0;
|
||||
param->y_prev_x.i = 0;
|
||||
|
||||
if(radius == 0) {
|
||||
param->circle = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t i;
|
||||
|
||||
/*Try to reuse a circle cache entry*/
|
||||
for(i = 0; i < LV_CIRCLE_CACHE_SIZE; i++) {
|
||||
if(LV_GC_ROOT(_lv_circle_cache[i]).radius == radius) {
|
||||
LV_GC_ROOT(_lv_circle_cache[i]).used_cnt++;
|
||||
CIRCLE_CACHE_AGING(LV_GC_ROOT(_lv_circle_cache[i]).life, radius);
|
||||
param->circle = &LV_GC_ROOT(_lv_circle_cache[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*If not found find a free entry with lowest life*/
|
||||
_lv_draw_mask_radius_circle_dsc_t * entry = NULL;
|
||||
for(i = 0; i < LV_CIRCLE_CACHE_SIZE; i++) {
|
||||
if(LV_GC_ROOT(_lv_circle_cache[i]).used_cnt == 0) {
|
||||
if(!entry) entry = &LV_GC_ROOT(_lv_circle_cache[i]);
|
||||
else if(LV_GC_ROOT(_lv_circle_cache[i]).life < entry->life) entry = &LV_GC_ROOT(_lv_circle_cache[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(!entry) {
|
||||
entry = lv_mem_alloc(sizeof(_lv_draw_mask_radius_circle_dsc_t));
|
||||
LV_ASSERT_MALLOC(entry);
|
||||
lv_memset_00(entry, sizeof(_lv_draw_mask_radius_circle_dsc_t));
|
||||
entry->life = -1;
|
||||
}
|
||||
else {
|
||||
entry->used_cnt++;
|
||||
entry->life = 0;
|
||||
CIRCLE_CACHE_AGING(entry->life, radius);
|
||||
}
|
||||
|
||||
param->circle = entry;
|
||||
|
||||
circ_calc_aa4(param->circle, radius);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -515,7 +653,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_flat(lv_opa_t * mask_b
|
|||
}
|
||||
}
|
||||
|
||||
/*At the end of the mask if the limit line is smaller then the mask's y.
|
||||
/*At the end of the mask if the limit line is smaller than the mask's y.
|
||||
*Then the mask is in the "good" area*/
|
||||
y_at_x = (int32_t)((int32_t)p->yx_steep * (abs_x + len)) >> 10;
|
||||
if(p->yx_steep > 0) {
|
||||
|
@ -608,7 +746,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
|
|||
{
|
||||
int32_t k;
|
||||
int32_t x_at_y;
|
||||
/*At the beginning of the mask if the limit line is greater then the mask's y.
|
||||
/*At the beginning of the mask if the limit line is greater than the mask's y.
|
||||
*Then the mask is in the "wrong" area*/
|
||||
x_at_y = (int32_t)((int32_t)p->xy_steep * abs_y) >> 10;
|
||||
if(p->xy_steep > 0) x_at_y++;
|
||||
|
@ -621,7 +759,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t line_mask_steep(lv_opa_t * mask_
|
|||
}
|
||||
}
|
||||
|
||||
/*At the end of the mask if the limit line is smaller then the mask's y.
|
||||
/*At the end of the mask if the limit line is smaller than the mask's y.
|
||||
*Then the mask is in the "good" area*/
|
||||
x_at_y = (int32_t)((int32_t)p->xy_steep * (abs_y)) >> 10;
|
||||
if(x_at_y > abs_x + len) {
|
||||
|
@ -881,6 +1019,8 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_angle(lv_opa_t * ma
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * mask_buf, lv_coord_t abs_x,
|
||||
lv_coord_t abs_y, lv_coord_t len,
|
||||
lv_draw_mask_radius_param_t * p)
|
||||
|
@ -891,7 +1031,7 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
|
|||
lv_area_copy(&rect, &p->cfg.rect);
|
||||
|
||||
if(outer == false) {
|
||||
if(abs_y < rect.y1 || abs_y > rect.y2) {
|
||||
if((abs_y < rect.y1 || abs_y > rect.y2)) {
|
||||
return LV_DRAW_MASK_RES_TRANSP;
|
||||
}
|
||||
}
|
||||
|
@ -932,6 +1072,13 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
|
|||
}
|
||||
return LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
// printf("exec: x:%d.. %d, y:%d: r:%d, %s\n", abs_x, abs_x + len - 1, abs_y, p->cfg.radius, p->cfg.outer ? "inv" : "norm");
|
||||
|
||||
|
||||
// if( abs_x == 276 && abs_x + len - 1 == 479 && abs_y == 63 && p->cfg.radius == 5 && p->cfg.outer == 1) {
|
||||
// char x = 0;
|
||||
// }
|
||||
//exec: x:276.. 479, y:63: r:5, inv)
|
||||
|
||||
int32_t k = rect.x1 - abs_x; /*First relevant coordinate on the of the mask*/
|
||||
int32_t w = lv_area_get_width(&rect);
|
||||
|
@ -939,194 +1086,53 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_radius(lv_opa_t * m
|
|||
abs_x -= rect.x1;
|
||||
abs_y -= rect.y1;
|
||||
|
||||
uint32_t r2 = p->cfg.radius * p->cfg.radius;
|
||||
lv_coord_t aa_len;
|
||||
lv_coord_t x_start;
|
||||
lv_coord_t cir_y;
|
||||
if(abs_y < radius) {
|
||||
cir_y = radius - abs_y - 1;
|
||||
}
|
||||
else {
|
||||
cir_y = abs_y - (h - radius);
|
||||
}
|
||||
lv_opa_t * aa_opa = get_next_line(p->circle, cir_y, &aa_len, &x_start);
|
||||
lv_coord_t cir_x_right = k + w - radius + x_start;
|
||||
lv_coord_t cir_x_left = k + radius - x_start - 1;
|
||||
lv_coord_t i;
|
||||
|
||||
/*Handle corner areas*/
|
||||
if(abs_y < radius || abs_y > h - radius - 1) {
|
||||
|
||||
uint32_t sqrt_mask;
|
||||
if(radius <= 32) sqrt_mask = 0x200;
|
||||
if(radius <= 256) sqrt_mask = 0x800;
|
||||
else sqrt_mask = 0x8000;
|
||||
|
||||
lv_sqrt_res_t x0;
|
||||
lv_sqrt_res_t x1;
|
||||
/*y = 0 should mean the top of the circle*/
|
||||
int32_t y;
|
||||
if(abs_y < radius) {
|
||||
y = radius - abs_y;
|
||||
|
||||
/*Get the x intersection points for `abs_y` and `abs_y-1`
|
||||
*Use the circle's equation x = sqrt(r^2 - y^2)
|
||||
*Try to use the values from the previous run*/
|
||||
if(y == p->y_prev) {
|
||||
x0.f = p->y_prev_x.f;
|
||||
x0.i = p->y_prev_x.i;
|
||||
if(outer == false) {
|
||||
for(i = 0; i < aa_len; i++) {
|
||||
lv_opa_t opa = aa_opa[aa_len - i - 1];
|
||||
if(cir_x_right + i >= 0 && cir_x_right + i < len) {
|
||||
mask_buf[cir_x_right + i] = mask_mix(opa, mask_buf[cir_x_right + i]);
|
||||
}
|
||||
else {
|
||||
lv_sqrt(r2 - (y * y), &x0, sqrt_mask);
|
||||
}
|
||||
lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask);
|
||||
p->y_prev = y - 1;
|
||||
p->y_prev_x.f = x1.f;
|
||||
p->y_prev_x.i = x1.i;
|
||||
}
|
||||
else {
|
||||
y = radius - (h - abs_y) + 1;
|
||||
|
||||
/*Get the x intersection points for `abs_y` and `abs_y-1`
|
||||
*Use the circle's equation x = sqrt(r^2 - y^2)
|
||||
*Try to use the values from the previous run*/
|
||||
if((y - 1) == p->y_prev) {
|
||||
x1.f = p->y_prev_x.f;
|
||||
x1.i = p->y_prev_x.i;
|
||||
}
|
||||
else {
|
||||
lv_sqrt(r2 - ((y - 1) * (y - 1)), &x1, sqrt_mask);
|
||||
}
|
||||
|
||||
lv_sqrt(r2 - (y * y), &x0, sqrt_mask);
|
||||
p->y_prev = y;
|
||||
p->y_prev_x.f = x0.f;
|
||||
p->y_prev_x.i = x0.i;
|
||||
}
|
||||
|
||||
/*If x1 is on the next round coordinate (e.g. x0: 3.5, x1:4.0)
|
||||
*then treat x1 as x1: 3.99 to handle them as they were on the same pixel*/
|
||||
if(x0.i == x1.i - 1 && x1.f == 0) {
|
||||
x1.i--;
|
||||
x1.f = 0xFF;
|
||||
}
|
||||
|
||||
/*If the two x intersections are on the same x then just get average of the fractions*/
|
||||
if(x0.i == x1.i) {
|
||||
lv_opa_t m = (x0.f + x1.f) >> 1;
|
||||
if(outer) m = 255 - m;
|
||||
int32_t ofs = radius - x0.i - 1;
|
||||
|
||||
/*Left corner*/
|
||||
int32_t kl = k + ofs;
|
||||
|
||||
if(kl >= 0 && kl < len) {
|
||||
mask_buf[kl] = mask_mix(mask_buf[kl], m);
|
||||
}
|
||||
|
||||
/*Right corner*/
|
||||
int32_t kr = k + (w - ofs - 1);
|
||||
if(kr >= 0 && kr < len) {
|
||||
mask_buf[kr] = mask_mix(mask_buf[kr], m);
|
||||
}
|
||||
|
||||
/*Clear the unused parts*/
|
||||
if(outer == false) {
|
||||
kr++;
|
||||
if(kl > len) {
|
||||
return LV_DRAW_MASK_RES_TRANSP;
|
||||
}
|
||||
if(kl >= 0) {
|
||||
lv_memset_00(&mask_buf[0], kl);
|
||||
}
|
||||
if(kr < 0) {
|
||||
return LV_DRAW_MASK_RES_TRANSP;
|
||||
}
|
||||
if(kr <= len) {
|
||||
lv_memset_00(&mask_buf[kr], len - kr);
|
||||
}
|
||||
}
|
||||
else {
|
||||
kl++;
|
||||
int32_t first = kl;
|
||||
if(first < 0) first = 0;
|
||||
|
||||
int32_t len_tmp = kr - first;
|
||||
if(len_tmp + first > len) len_tmp = len - first;
|
||||
if(first < len && len_tmp >= 0) {
|
||||
lv_memset_00(&mask_buf[first], len_tmp);
|
||||
}
|
||||
if(cir_x_left - i >= 0 && cir_x_left - i < len) {
|
||||
mask_buf[cir_x_left - i] = mask_mix(opa, mask_buf[cir_x_left - i]);
|
||||
}
|
||||
}
|
||||
/*Multiple pixels are affected. Get y intersection of the pixels*/
|
||||
else {
|
||||
int32_t ofs = radius - (x0.i + 1);
|
||||
int32_t kl = k + ofs;
|
||||
int32_t kr = k + (w - ofs - 1);
|
||||
|
||||
if(outer) {
|
||||
int32_t first = kl + 1;
|
||||
if(first < 0) first = 0;
|
||||
/*Clean the right side*/
|
||||
cir_x_right = LV_CLAMP(0, cir_x_right + i, len);
|
||||
lv_memset_00(&mask_buf[cir_x_right], len - cir_x_right);
|
||||
|
||||
int32_t len_tmp = kr - first;
|
||||
if(len_tmp + first > len) len_tmp = len - first;
|
||||
if(first < len && len_tmp >= 0) {
|
||||
lv_memset_00(&mask_buf[first], len_tmp);
|
||||
}
|
||||
/*Clean the left side*/
|
||||
cir_x_left = LV_CLAMP(0, cir_x_left - aa_len + 1, len);
|
||||
lv_memset_00(&mask_buf[0], cir_x_left);
|
||||
}
|
||||
else {
|
||||
for(i = 0; i < aa_len; i++) {
|
||||
lv_opa_t opa = 255 - (aa_opa[aa_len - 1 - i]);
|
||||
if(cir_x_right + i >= 0 && cir_x_right + i < len) {
|
||||
mask_buf[cir_x_right + i] = mask_mix(opa, mask_buf[cir_x_right + i]);
|
||||
}
|
||||
|
||||
uint32_t i = x0.i + 1;
|
||||
lv_opa_t m;
|
||||
lv_sqrt_res_t y_prev;
|
||||
lv_sqrt_res_t y_next;
|
||||
|
||||
lv_sqrt(r2 - (x0.i * x0.i), &y_prev, sqrt_mask);
|
||||
|
||||
if(y_prev.f == 0) {
|
||||
y_prev.i--;
|
||||
y_prev.f = 0xFF;
|
||||
}
|
||||
|
||||
/*The first y intersection is special as it might be in the previous line*/
|
||||
if(y_prev.i >= y) {
|
||||
lv_sqrt(r2 - (i * i), &y_next, sqrt_mask);
|
||||
m = 255 - (((255 - x0.f) * (255 - y_next.f)) >> 9);
|
||||
|
||||
if(outer) m = 255 - m;
|
||||
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
|
||||
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
|
||||
kl--;
|
||||
kr++;
|
||||
y_prev.f = y_next.f;
|
||||
i++;
|
||||
}
|
||||
|
||||
/*Set all points which are crossed by the circle*/
|
||||
for(; i <= x1.i; i++) {
|
||||
/*These values are very close to each other. It's enough to approximate sqrt
|
||||
*The non-approximated version is lv_sqrt(r2 - (i * i), &y_next, sqrt_mask);*/
|
||||
sqrt_approx(&y_next, &y_prev, r2 - (i * i));
|
||||
|
||||
m = (y_prev.f + y_next.f) >> 1;
|
||||
if(outer) m = 255 - m;
|
||||
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
|
||||
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
|
||||
kl--;
|
||||
kr++;
|
||||
y_prev.f = y_next.f;
|
||||
}
|
||||
|
||||
/*If the last pixel was left in its middle therefore
|
||||
* the circle still has parts on the next one*/
|
||||
if(y_prev.f) {
|
||||
m = (y_prev.f * x1.f) >> 9;
|
||||
if(outer) m = 255 - m;
|
||||
if(kl >= 0 && kl < len) mask_buf[kl] = mask_mix(mask_buf[kl], m);
|
||||
if(kr >= 0 && kr < len) mask_buf[kr] = mask_mix(mask_buf[kr], m);
|
||||
kl--;
|
||||
kr++;
|
||||
}
|
||||
|
||||
if(outer == 0) {
|
||||
kl++;
|
||||
if(kl > len) {
|
||||
return LV_DRAW_MASK_RES_TRANSP;
|
||||
}
|
||||
if(kl >= 0) lv_memset_00(&mask_buf[0], kl);
|
||||
|
||||
if(kr < 0) {
|
||||
return LV_DRAW_MASK_RES_TRANSP;
|
||||
}
|
||||
if(kr < len) lv_memset_00(&mask_buf[kr], len - kr);
|
||||
if(cir_x_left - i >= 0 && cir_x_left - i < len) {
|
||||
mask_buf[cir_x_left - i] = mask_mix(opa, mask_buf[cir_x_left - i]);
|
||||
}
|
||||
}
|
||||
|
||||
lv_coord_t clr_start = LV_CLAMP(0, cir_x_left + 1, len);
|
||||
lv_coord_t clr_len = LV_CLAMP(0, cir_x_right - clr_start, len - clr_start);
|
||||
lv_memset_00(&mask_buf[clr_start], clr_len);
|
||||
}
|
||||
|
||||
return LV_DRAW_MASK_RES_CHANGED;
|
||||
|
@ -1212,6 +1218,204 @@ LV_ATTRIBUTE_FAST_MEM static lv_draw_mask_res_t lv_draw_mask_map(lv_opa_t * mask
|
|||
return LV_DRAW_MASK_RES_CHANGED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the circle drawing
|
||||
* @param c pointer to a point. The coordinates will be calculated here
|
||||
* @param tmp point to a variable. It will store temporary data
|
||||
* @param radius radius of the circle
|
||||
*/
|
||||
static void circ_init(lv_point_t * c, lv_coord_t * tmp, lv_coord_t radius)
|
||||
{
|
||||
c->x = radius;
|
||||
c->y = 0;
|
||||
*tmp = 1 - radius;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the circle drawing is ready or not
|
||||
* @param c same as in circ_init
|
||||
* @return true if the circle is not ready yet
|
||||
*/
|
||||
static bool circ_cont(lv_point_t * c)
|
||||
{
|
||||
return c->y <= c->x ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next point from the circle
|
||||
* @param c same as in circ_init. The next point stored here.
|
||||
* @param tmp same as in circ_init.
|
||||
*/
|
||||
static void circ_next(lv_point_t * c, lv_coord_t * tmp)
|
||||
{
|
||||
|
||||
if(*tmp <= 0) {
|
||||
(*tmp) += 2 * c->y + 3; /*Change in decision criterion for y -> y+1*/
|
||||
}
|
||||
else {
|
||||
(*tmp) += 2 * (c->y - c->x) + 5; /*Change for y -> y+1, x -> x-1*/
|
||||
c->x--;
|
||||
}
|
||||
c->y++;
|
||||
}
|
||||
|
||||
static void circ_calc_aa4(_lv_draw_mask_radius_circle_dsc_t * c, lv_coord_t radius)
|
||||
{
|
||||
if(radius == 0) return;
|
||||
c->radius = radius;
|
||||
|
||||
/*Allocate buffers*/
|
||||
if(c->buf) lv_mem_free(c->buf);
|
||||
|
||||
c->buf = lv_mem_alloc(radius * 6 + 6); /*Use uint16_t for opa_start_on_y and x_start_on_y*/
|
||||
LV_ASSERT_MALLOC(c->buf);
|
||||
c->cir_opa = c->buf;
|
||||
c->opa_start_on_y = (uint16_t *)(c->buf + 2 * radius + 2);
|
||||
c->x_start_on_y = (uint16_t *)(c->buf + 4 * radius + 4);
|
||||
|
||||
/*Special case, handle manually*/
|
||||
if(radius == 1) {
|
||||
c->cir_opa[0] = 180;
|
||||
c->opa_start_on_y[0] = 0;
|
||||
c->opa_start_on_y[1] = 1;
|
||||
c->x_start_on_y[0] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
lv_coord_t * cir_x = lv_mem_buf_get((radius + 1) * 2 * 2 * sizeof(lv_coord_t));
|
||||
lv_coord_t * cir_y = &cir_x[(radius + 1) * 2];
|
||||
|
||||
uint32_t y_8th_cnt = 0;
|
||||
lv_point_t cp;
|
||||
lv_coord_t tmp;
|
||||
circ_init(&cp, &tmp, radius * 4); /*Upscale by 4*/
|
||||
int32_t i;
|
||||
|
||||
uint32_t x_int[4];
|
||||
uint32_t x_fract[4];
|
||||
lv_coord_t cir_size = 0;
|
||||
x_int[0] = cp.x >> 2;
|
||||
x_fract[0] = 0;
|
||||
|
||||
/*Calculate an 1/8 circle*/
|
||||
while(circ_cont(&cp)) {
|
||||
/*Calculate 4 point of the circle */
|
||||
for(i = 0; i < 4; i++) {
|
||||
circ_next(&cp, &tmp);
|
||||
if(circ_cont(&cp) == false) break;
|
||||
x_int[i] = cp.x >> 2;
|
||||
x_fract[i] = cp.x & 0x3;
|
||||
}
|
||||
if(i != 4) break;
|
||||
|
||||
/*All lines on the same x when downscaled*/
|
||||
if(x_int[0] == x_int[3]) {
|
||||
cir_x[cir_size] = x_int[0];
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = x_fract[0] + x_fract[1] + x_fract[2] + x_fract[3];
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
}
|
||||
/*Second line on new x when downscaled*/
|
||||
else if(x_int[0] != x_int[1]) {
|
||||
cir_x[cir_size] = x_int[0];
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = x_fract[0];
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
|
||||
cir_x[cir_size] = x_int[0] - 1;
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = 1 * 4 + x_fract[1] + x_fract[2] + x_fract[3];;
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
}
|
||||
/*Third line on new x when downscaled*/
|
||||
else if(x_int[0] != x_int[2]) {
|
||||
cir_x[cir_size] = x_int[0];
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = x_fract[0] + x_fract[1];
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
|
||||
cir_x[cir_size] = x_int[0] - 1;
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = 2 * 4 + x_fract[2] + x_fract[3];;
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
}
|
||||
/*Forth line on new x when downscaled*/
|
||||
else {
|
||||
cir_x[cir_size] = x_int[0];
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = x_fract[0] + x_fract[1] + x_fract[2];
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
|
||||
cir_x[cir_size] = x_int[0] - 1;
|
||||
cir_y[cir_size] = y_8th_cnt;
|
||||
c->cir_opa[cir_size] = 3 * 4 + x_fract[3];;
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
}
|
||||
|
||||
y_8th_cnt++;
|
||||
}
|
||||
|
||||
/*The point on the 1/8 circle is special, calculate it manually*/
|
||||
int32_t mid = radius * 723;
|
||||
int32_t mid_int = mid >> 10;
|
||||
if(cir_x[cir_size - 1] != mid_int || cir_y[cir_size - 1] != mid_int) {
|
||||
int32_t tmp_val = mid - (mid_int << 10);
|
||||
if(tmp_val <= 512) {
|
||||
tmp_val = tmp_val * tmp_val * 2;
|
||||
tmp_val = tmp_val >> (10 + 6);
|
||||
}
|
||||
else {
|
||||
tmp_val = 1024 - tmp_val;
|
||||
tmp_val = tmp_val * tmp_val * 2;
|
||||
tmp_val = tmp_val >> (10 + 6);
|
||||
tmp_val = 15 - tmp_val;
|
||||
}
|
||||
|
||||
cir_x[cir_size] = mid_int;
|
||||
cir_y[cir_size] = mid_int;
|
||||
c->cir_opa[cir_size] = tmp_val;
|
||||
c->cir_opa[cir_size] *= 16;
|
||||
cir_size++;
|
||||
}
|
||||
|
||||
/*Build the second octet by mirroring the first*/
|
||||
for(i = cir_size - 2; i >= 0; i--, cir_size++) {
|
||||
cir_x[cir_size] = cir_y[i];
|
||||
cir_y[cir_size] = cir_x[i];
|
||||
c->cir_opa[cir_size] = c->cir_opa[i];
|
||||
}
|
||||
|
||||
lv_coord_t y = 0;
|
||||
i = 0;
|
||||
c->opa_start_on_y[0] = 0;
|
||||
while(i < cir_size) {
|
||||
c->opa_start_on_y[y] = i;
|
||||
c->x_start_on_y[y] = cir_x[i];
|
||||
for(; cir_y[i] == y && i < (int32_t)cir_size; i++) {
|
||||
c->x_start_on_y[y] = LV_MIN(c->x_start_on_y[y], cir_x[i]);
|
||||
}
|
||||
y++;
|
||||
}
|
||||
|
||||
lv_mem_buf_release(cir_x);
|
||||
}
|
||||
|
||||
static lv_opa_t * get_next_line(_lv_draw_mask_radius_circle_dsc_t * c, lv_coord_t y, lv_coord_t * len,
|
||||
lv_coord_t * x_start)
|
||||
{
|
||||
*len = c->opa_start_on_y[y + 1] - c->opa_start_on_y[y];
|
||||
*x_start = c->x_start_on_y[y];
|
||||
return &c->cir_opa[c->opa_start_on_y[y]];
|
||||
}
|
||||
|
||||
|
||||
LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_t mask_new)
|
||||
{
|
||||
if(mask_new >= LV_OPA_MAX) return mask_act;
|
||||
|
@ -1220,24 +1424,5 @@ LV_ATTRIBUTE_FAST_MEM static inline lv_opa_t mask_mix(lv_opa_t mask_act, lv_opa_
|
|||
return LV_UDIV255(mask_act * mask_new);// >> 8);
|
||||
}
|
||||
|
||||
/**
|
||||
* Approximate the sqrt near to an already calculated value
|
||||
* @param q store the result here
|
||||
* @param ref the reference point (already calculated sqrt)
|
||||
* @param x the value which sqrt should be approximated
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM static inline void sqrt_approx(lv_sqrt_res_t * q, lv_sqrt_res_t * ref, uint32_t x)
|
||||
{
|
||||
x = x << 8; /*Upscale for extra precision*/
|
||||
|
||||
uint32_t raw = (ref->i << 4) + (ref->f >> 4);
|
||||
uint32_t raw2 = raw * raw;
|
||||
|
||||
int32_t d = x - raw2;
|
||||
d = (int32_t)d / (int32_t)(2 * raw) + raw;
|
||||
|
||||
q->i = d >> 4;
|
||||
q->f = (d & 0xF) << 4;
|
||||
}
|
||||
|
||||
#endif /*LV_DRAW_COMPLEX*/
|
||||
|
|
|
@ -55,9 +55,17 @@ typedef _lv_draw_mask_saved_t _lv_draw_mask_saved_arr_t[_LV_MASK_MAX_NUM];
|
|||
|
||||
|
||||
#if LV_DRAW_COMPLEX == 0
|
||||
static inline uint8_t lv_draw_mask_get_cnt(void) {
|
||||
static inline uint8_t lv_draw_mask_get_cnt(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline bool lv_draw_mask_is_any(const lv_area_t * a)
|
||||
{
|
||||
LV_UNUSED(a);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
|
@ -147,6 +155,18 @@ typedef struct {
|
|||
uint16_t delta_deg;
|
||||
} lv_draw_mask_angle_param_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t * buf;
|
||||
lv_opa_t * cir_opa; /*Opacity of values on the circumference of an 1/4 circle*/
|
||||
uint16_t * x_start_on_y; /*The x coordinate of the circle for each y value*/
|
||||
uint16_t * opa_start_on_y; /*The index of `cir_opa` for each y value*/
|
||||
int32_t life; /*How many times the entry way used*/
|
||||
uint32_t used_cnt; /*Like a semaphore to count the referencing masks*/
|
||||
lv_coord_t radius; /*The radius of the entry*/
|
||||
} _lv_draw_mask_radius_circle_dsc_t;
|
||||
|
||||
typedef _lv_draw_mask_radius_circle_dsc_t _lv_draw_mask_radius_circle_dsc_arr_t[LV_CIRCLE_CACHE_SIZE];
|
||||
|
||||
typedef struct {
|
||||
/*The first element must be the common descriptor*/
|
||||
_lv_draw_mask_common_dsc_t dsc;
|
||||
|
@ -157,9 +177,8 @@ typedef struct {
|
|||
/*Invert the mask. 0: Keep the pixels inside.*/
|
||||
uint8_t outer: 1;
|
||||
} cfg;
|
||||
int32_t y_prev;
|
||||
lv_sqrt_res_t y_prev_x;
|
||||
|
||||
_lv_draw_mask_radius_circle_dsc_t * circle;
|
||||
} lv_draw_mask_radius_param_t;
|
||||
|
||||
|
||||
|
@ -217,6 +236,22 @@ int16_t lv_draw_mask_add(void * param, void * custom_id);
|
|||
LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
|
||||
lv_coord_t len);
|
||||
|
||||
/**
|
||||
* Apply the specified buffers on a line. Used internally by the library's drawing routines.
|
||||
* @param mask_buf store the result mask here. Has to be `len` byte long. Should be initialized with `0xFF`.
|
||||
* @param abs_x absolute X coordinate where the line to calculate start
|
||||
* @param abs_y absolute Y coordinate where the line to calculate start
|
||||
* @param len length of the line to calculate (in pixel count)
|
||||
* @param ids ID array of added buffers
|
||||
* @param ids_count number of ID array
|
||||
* @return One of these values:
|
||||
* - `LV_DRAW_MASK_RES_FULL_TRANSP`: the whole line is transparent. `mask_buf` is not set to zero
|
||||
* - `LV_DRAW_MASK_RES_FULL_COVER`: the whole line is fully visible. `mask_buf` is unchanged
|
||||
* - `LV_DRAW_MASK_RES_CHANGED`: `mask_buf` has changed, it shows the desired opacity of each pixel in the given line
|
||||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM lv_draw_mask_res_t lv_draw_mask_apply_ids(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y,
|
||||
lv_coord_t len, const int16_t *ids, int16_t ids_count);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
|
@ -235,6 +270,21 @@ void * lv_draw_mask_remove_id(int16_t id);
|
|||
*/
|
||||
void * lv_draw_mask_remove_custom(void * custom_id);
|
||||
|
||||
/**
|
||||
* Free the data from the parameter.
|
||||
* It's called inside `lv_draw_mask_remove_id` and `lv_draw_mask_remove_custom`
|
||||
* Needs to be called only in special cases when the mask is not added by `lv_draw_mask_add`
|
||||
* and not removed by `lv_draw_mask_remove_id` or `lv_draw_mask_remove_custom`
|
||||
* @param p pointer to a mask parameter
|
||||
*/
|
||||
void lv_draw_mask_free_param(void * p);
|
||||
|
||||
/**
|
||||
* Called by LVGL the rendering of a screen is ready to clean up
|
||||
* the temporal (cache) data of the masks
|
||||
*/
|
||||
void _lv_draw_mask_cleanup(void);
|
||||
|
||||
//! @cond Doxygen_Suppress
|
||||
|
||||
/**
|
||||
|
@ -243,6 +293,14 @@ void * lv_draw_mask_remove_custom(void * custom_id);
|
|||
*/
|
||||
LV_ATTRIBUTE_FAST_MEM uint8_t lv_draw_mask_get_cnt(void);
|
||||
|
||||
|
||||
/**
|
||||
* Check if there is any added draw mask
|
||||
* @param a an area to test for affecting masks.
|
||||
* @return true: there is t least 1 draw mask; false: there are no draw masks
|
||||
*/
|
||||
bool lv_draw_mask_is_any(const lv_area_t * a);
|
||||
|
||||
//! @endcond
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,7 +37,7 @@ typedef struct {
|
|||
uint8_t bg_main_color_stop;
|
||||
uint8_t bg_grad_color_stop;
|
||||
lv_opa_t bg_opa;
|
||||
lv_grad_dir_t bg_grad_dir :3;
|
||||
lv_grad_dir_t bg_grad_dir : 3;
|
||||
|
||||
/*Background img*/
|
||||
const void * bg_img_src;
|
||||
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
lv_coord_t border_width;
|
||||
lv_opa_t border_opa;
|
||||
uint8_t border_post : 1; /*There is a border it will be drawn later.*/
|
||||
lv_border_side_t border_side :5;
|
||||
lv_border_side_t border_side : 5;
|
||||
|
||||
/*Outline*/
|
||||
lv_color_t outline_color;
|
||||
|
@ -80,10 +80,10 @@ LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc);
|
|||
/**
|
||||
* Draw a rectangle
|
||||
* @param coords the coordinates of the rectangle
|
||||
* @param mask the rectangle will be drawn only in this mask
|
||||
* @param clip the rectangle will be drawn only in this area
|
||||
* @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
|
||||
*/
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc);
|
||||
void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, const lv_draw_rect_dsc_t * dsc);
|
||||
|
||||
/**
|
||||
* Draw a pixel
|
||||
|
|
|
@ -367,7 +367,7 @@ void lv_img_buf_free(lv_img_dsc_t * dsc)
|
|||
{
|
||||
if(dsc != NULL) {
|
||||
if(dsc->data != NULL)
|
||||
lv_mem_free((void*)dsc->data);
|
||||
lv_mem_free((void *)dsc->data);
|
||||
|
||||
lv_mem_free(dsc);
|
||||
}
|
||||
|
@ -483,10 +483,10 @@ void _lv_img_buf_get_transformed_area(lv_area_t * res, lv_coord_t w, lv_coord_t
|
|||
return;
|
||||
}
|
||||
|
||||
res->x1 = (((-pivot->x) * zoom) >> 8) - 1;
|
||||
res->y1 = (((-pivot->y) * zoom) >> 8) - 1;
|
||||
res->x2 = (((w - pivot->x) * zoom) >> 8) + 2;
|
||||
res->y2 = (((h - pivot->y) * zoom) >> 8) + 2;
|
||||
res->x1 = (((int32_t)(-pivot->x) * zoom) >> 8) - 1;
|
||||
res->y1 = (((int32_t)(-pivot->y) * zoom) >> 8) - 1;
|
||||
res->x2 = (((int32_t)(w - pivot->x) * zoom) >> 8) + 2;
|
||||
res->y2 = (((int32_t)(h - pivot->y) * zoom) >> 8) + 2;
|
||||
|
||||
if(angle == 0) {
|
||||
res->x1 += pivot->x;
|
||||
|
@ -710,7 +710,7 @@ bool _lv_img_buf_transform_anti_alias(lv_img_transform_dsc_t * dsc)
|
|||
lv_memcpy_small(&c01, &src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn], sizeof(lv_color_t));
|
||||
lv_memcpy_small(&c10, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn], sizeof(lv_color_t));
|
||||
lv_memcpy_small(&c11, &src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size * xn],
|
||||
sizeof(lv_color_t));
|
||||
sizeof(lv_color_t));
|
||||
if(dsc->tmp.has_alpha) {
|
||||
a10 = src_u8[dsc->tmp.pxi + dsc->tmp.px_size * xn + dsc->tmp.px_size - 1];
|
||||
a01 = src_u8[dsc->tmp.pxi + dsc->cfg.src_w * dsc->tmp.px_size * yn + dsc->tmp.px_size - 1];
|
||||
|
|
|
@ -82,7 +82,15 @@ void _lv_img_decoder_init(void)
|
|||
*/
|
||||
lv_res_t lv_img_decoder_get_info(const void * src, lv_img_header_t * header)
|
||||
{
|
||||
lv_memset_00(header, sizeof(lv_img_header_t));
|
||||
lv_memset_00(header, sizeof(lv_img_header_t));
|
||||
|
||||
if(src == NULL) return LV_RES_INV;
|
||||
|
||||
lv_img_src_t src_type = lv_img_src_get_type(src);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
const lv_img_dsc_t * img_dsc = src;
|
||||
if(img_dsc->data == NULL) return LV_RES_INV;
|
||||
}
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
lv_img_decoder_t * d;
|
||||
|
@ -100,8 +108,15 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
|||
{
|
||||
lv_memset_00(dsc, sizeof(lv_img_decoder_dsc_t));
|
||||
|
||||
if(src == NULL) return LV_RES_INV;
|
||||
lv_img_src_t src_type = lv_img_src_get_type(src);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
const lv_img_dsc_t * img_dsc = src;
|
||||
if(img_dsc->data == NULL) return LV_RES_INV;
|
||||
}
|
||||
|
||||
dsc->color = color;
|
||||
dsc->src_type = lv_img_src_get_type(src);
|
||||
dsc->src_type = src_type;
|
||||
dsc->frame_id = frame_id;
|
||||
|
||||
if(dsc->src_type == LV_IMG_SRC_FILE) {
|
||||
|
@ -144,7 +159,7 @@ lv_res_t lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, lv_co
|
|||
}
|
||||
|
||||
if(dsc->src_type == LV_IMG_SRC_FILE)
|
||||
lv_mem_free((void*)dsc->src);
|
||||
lv_mem_free((void *)dsc->src);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -176,7 +191,7 @@ void lv_img_decoder_close(lv_img_decoder_dsc_t * dsc)
|
|||
if(dsc->decoder->close_cb) dsc->decoder->close_cb(dsc->decoder, dsc);
|
||||
|
||||
if(dsc->src_type == LV_IMG_SRC_FILE) {
|
||||
lv_mem_free((void*)dsc->src);
|
||||
lv_mem_free((void *)dsc->src);
|
||||
dsc->src = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +272,7 @@ void lv_img_decoder_set_close_cb(lv_img_decoder_t * decoder, lv_img_decoder_clos
|
|||
*/
|
||||
lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header)
|
||||
{
|
||||
(void)decoder; /*Unused*/
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
lv_img_src_t src_type = lv_img_src_get_type(src);
|
||||
if(src_type == LV_IMG_SRC_VARIABLE) {
|
||||
|
@ -420,7 +435,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||
/*Free the potentially allocated memories*/
|
||||
lv_img_decoder_built_in_close(decoder, dsc);
|
||||
|
||||
LV_LOG_WARN("Image decoder open: unknown color format")
|
||||
LV_LOG_WARN("Image decoder open: unknown color format");
|
||||
return LV_RES_INV;
|
||||
}
|
||||
}
|
||||
|
@ -439,7 +454,7 @@ lv_res_t lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder
|
|||
lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc, lv_coord_t x,
|
||||
lv_coord_t y, lv_coord_t len, uint8_t * buf)
|
||||
{
|
||||
(void)decoder; /*Unused*/
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
lv_res_t res = LV_RES_INV;
|
||||
|
||||
|
@ -474,7 +489,7 @@ lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, lv_img_de
|
|||
*/
|
||||
void lv_img_decoder_built_in_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc)
|
||||
{
|
||||
(void)decoder; /*Unused*/
|
||||
LV_UNUSED(decoder); /*Unused*/
|
||||
|
||||
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
|
||||
if(user_data) {
|
||||
|
@ -579,7 +594,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l
|
|||
|
||||
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
|
||||
uint8_t * fs_buf = lv_mem_buf_get(w);
|
||||
if (fs_buf == NULL) return LV_RES_INV;
|
||||
if(fs_buf == NULL) return LV_RES_INV;
|
||||
|
||||
const uint8_t * data_tmp = NULL;
|
||||
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
|
@ -648,7 +663,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc,
|
|||
lv_img_decoder_built_in_data_t * user_data = dsc->user_data;
|
||||
|
||||
uint8_t * fs_buf = lv_mem_buf_get(w);
|
||||
if (fs_buf == NULL) return LV_RES_INV;
|
||||
if(fs_buf == NULL) return LV_RES_INV;
|
||||
const uint8_t * data_tmp = NULL;
|
||||
if(dsc->src_type == LV_IMG_SRC_VARIABLE) {
|
||||
const lv_img_dsc_t * img_dsc = dsc->src;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
# Extra components
|
||||
|
||||
This directory contains extra (optional) components to lvgl.
|
||||
It's a good place for contributions as there are less strict expectations about the completeness and flexibility of the components here.
|
||||
|
||||
In other words, if you have created a complex widget from other widgets, or modified an existing widget with special events, styles or animations, or have a new feature that could work as a plugin to lvgl feel free to the share it here.
|
||||
|
||||
## How to contribute
|
||||
- Create a [Pull request](https://docs.lvgl.io/8.0/CONTRIBUTING.html#pull-request) with your new content
|
||||
- Please and follow the [Coding style](https://github.com/lvgl/lvgl/blob/master/docs/CODING_STYLE.md) of LVGL
|
||||
- Add setter/getter functions in pair
|
||||
- Update [lv_conf_template.h](https://github.com/lvgl/lvgl/blob/master/lv_conf_template.h)
|
||||
- Add description in the [docs](https://github.com/lvgl/lvgl/tree/master/docs)
|
||||
- Add [examples](https://github.com/lvgl/lvgl/tree/master/examples)
|
||||
- Update the [changelog](https://github.com/lvgl/lvgl/tree/master/docs/CHANGELOG.md)
|
||||
- Add yourself to the [Contributors](#contributors) section below.
|
||||
|
||||
## Ideas
|
||||
Here some ideas as inspiration feel free to contribute with ideas too.
|
||||
- New [Calendar headers](https://github.com/lvgl/lvgl/tree/master/src/extra/widgets/calendar)
|
||||
- Color picker with RGB and or HSV bars
|
||||
- Ruler, horizontal or vertical with major and minor ticks and labels
|
||||
- New [List items types](https://github.com/lvgl/lvgl/tree/master/src/extra/widgets/list)
|
||||
- [Preloaders](https://www.google.com/search?q=preloader&sxsrf=ALeKk01ddA4YB0WEgLLN1bZNSm8YER7pkg:1623080551559&source=lnms&tbm=isch&sa=X&ved=2ahUKEwiwoN6d7oXxAhVuw4sKHVedBB4Q_AUoAXoECAEQAw&biw=952&bih=940)
|
||||
- Drop-down list with a container to which an content can be added
|
||||
- 9 patch button: Similar to [lv_imgbtn](https://docs.lvgl.io/8.0/widgets/extra/imgbtn.html) but 9 images for 4 corner, 4 sides and the center
|
||||
|
||||
## Contributors
|
||||
- lv_animimg: @ZhaoQiang-b45475
|
||||
- lv_span: @guoweilkd
|
|
@ -21,10 +21,10 @@ typedef struct {
|
|||
lv_flex_align_t main_place;
|
||||
lv_flex_align_t cross_place;
|
||||
lv_flex_align_t track_place;
|
||||
uint8_t row :1;
|
||||
uint8_t wrap :1;
|
||||
uint8_t rev :1;
|
||||
}flex_t;
|
||||
uint8_t row : 1;
|
||||
uint8_t wrap : 1;
|
||||
uint8_t rev : 1;
|
||||
} flex_t;
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t * item;
|
||||
|
@ -32,8 +32,8 @@ typedef struct {
|
|||
lv_coord_t max_size;
|
||||
lv_coord_t final_size;
|
||||
uint32_t grow_value;
|
||||
uint32_t clamped :1;
|
||||
}grow_dsc_t;
|
||||
uint32_t clamped : 1;
|
||||
} grow_dsc_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t track_cross_size;
|
||||
|
@ -42,8 +42,8 @@ typedef struct {
|
|||
uint32_t item_cnt;
|
||||
grow_dsc_t * grow_dsc;
|
||||
uint32_t grow_item_cnt;
|
||||
uint32_t grow_dsc_calc :1;
|
||||
}track_t;
|
||||
uint32_t grow_dsc_calc : 1;
|
||||
} track_t;
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -54,9 +54,12 @@ typedef struct {
|
|||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void flex_update(lv_obj_t * cont, void * user_data);
|
||||
static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id, lv_coord_t item_gap, lv_coord_t max_main_size, track_t * t);
|
||||
static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t);
|
||||
static void place_content(lv_flex_align_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt, lv_coord_t * start_pos, lv_coord_t * gap);
|
||||
static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id, lv_coord_t item_gap,
|
||||
lv_coord_t max_main_size, track_t * t);
|
||||
static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x,
|
||||
lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t);
|
||||
static void place_content(lv_flex_align_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt,
|
||||
lv_coord_t * start_pos, lv_coord_t * gap);
|
||||
static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id);
|
||||
|
||||
/**********************
|
||||
|
@ -102,7 +105,8 @@ void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow)
|
|||
lv_obj_set_style_layout(obj, LV_LAYOUT_FLEX, 0);
|
||||
}
|
||||
|
||||
void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place, lv_flex_align_t track_place)
|
||||
void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place,
|
||||
lv_flex_align_t track_place)
|
||||
{
|
||||
lv_obj_set_style_flex_main_place(obj, main_place, 0);
|
||||
lv_obj_set_style_flex_cross_place(obj, cross_place, 0);
|
||||
|
@ -152,7 +156,7 @@ void lv_style_set_flex_track_place(lv_style_t * style, lv_flex_align_t value)
|
|||
void lv_style_set_flex_grow(lv_style_t * style, uint8_t value)
|
||||
{
|
||||
lv_style_value_t v = {
|
||||
.num = (int32_t)value
|
||||
.num = (int32_t)value
|
||||
};
|
||||
lv_style_set_prop(style, LV_STYLE_FLEX_GROW, v);
|
||||
}
|
||||
|
@ -204,7 +208,7 @@ void lv_obj_set_style_flex_grow(lv_obj_t * obj, uint8_t value, lv_style_selector
|
|||
|
||||
static void flex_update(lv_obj_t * cont, void * user_data)
|
||||
{
|
||||
LV_LOG_INFO("update %p container", cont);
|
||||
LV_LOG_INFO("update %p container", (void *)cont);
|
||||
LV_UNUSED(user_data);
|
||||
|
||||
flex_t f;
|
||||
|
@ -217,12 +221,16 @@ static void flex_update(lv_obj_t * cont, void * user_data)
|
|||
f.track_place = lv_obj_get_style_flex_track_place(cont, LV_PART_MAIN);
|
||||
|
||||
bool rtl = lv_obj_get_style_base_dir(cont, LV_PART_MAIN) == LV_BASE_DIR_RTL ? true : false;
|
||||
lv_coord_t track_gap = !f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
|
||||
lv_coord_t item_gap = f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont, LV_PART_MAIN);
|
||||
lv_coord_t track_gap = !f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont,
|
||||
LV_PART_MAIN);
|
||||
lv_coord_t item_gap = f.row ? lv_obj_get_style_pad_column(cont, LV_PART_MAIN) : lv_obj_get_style_pad_row(cont,
|
||||
LV_PART_MAIN);
|
||||
lv_coord_t max_main_size = (f.row ? lv_obj_get_content_width(cont) : lv_obj_get_content_height(cont));
|
||||
lv_coord_t border_widt = lv_obj_get_style_border_width(cont, LV_PART_MAIN);
|
||||
lv_coord_t abs_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont, LV_PART_MAIN) + border_widt - lv_obj_get_scroll_y(cont);
|
||||
lv_coord_t abs_x = cont->coords.x1 + lv_obj_get_style_pad_left(cont, LV_PART_MAIN) + border_widt - lv_obj_get_scroll_x(cont);
|
||||
lv_coord_t border_width = lv_obj_get_style_border_width(cont, LV_PART_MAIN);
|
||||
lv_coord_t abs_y = cont->coords.y1 + lv_obj_get_style_pad_top(cont,
|
||||
LV_PART_MAIN) + border_width - lv_obj_get_scroll_y(cont);
|
||||
lv_coord_t abs_x = cont->coords.x1 + lv_obj_get_style_pad_left(cont,
|
||||
LV_PART_MAIN) + border_width - lv_obj_get_scroll_x(cont);
|
||||
|
||||
lv_flex_align_t track_cross_place = f.track_place;
|
||||
lv_coord_t * cross_pos = (f.row ? &abs_y : &abs_x);
|
||||
|
@ -232,8 +240,7 @@ static void flex_update(lv_obj_t * cont, void * user_data)
|
|||
|
||||
/*Content sized objects should squeezed the gap between the children, therefore any alignment will look like `START`*/
|
||||
if((f.row && h_set == LV_SIZE_CONTENT && cont->h_layout == 0) ||
|
||||
(!f.row && w_set == LV_SIZE_CONTENT && cont->w_layout == 0))
|
||||
{
|
||||
(!f.row && w_set == LV_SIZE_CONTENT && cont->w_layout == 0)) {
|
||||
track_cross_place = LV_FLEX_ALIGN_START;
|
||||
}
|
||||
|
||||
|
@ -270,7 +277,7 @@ static void flex_update(lv_obj_t * cont, void * user_data)
|
|||
track_first_item = f.rev ? cont->spec_attr->child_cnt - 1 : 0;
|
||||
|
||||
if(rtl && !f.row) {
|
||||
*cross_pos += total_track_cross_size;
|
||||
*cross_pos += total_track_cross_size;
|
||||
}
|
||||
|
||||
while(track_first_item < (int32_t)cont->spec_attr->child_cnt && track_first_item >= 0) {
|
||||
|
@ -288,7 +295,8 @@ static void flex_update(lv_obj_t * cont, void * user_data)
|
|||
t.grow_dsc = NULL;
|
||||
if(rtl && !f.row) {
|
||||
*cross_pos -= gap + track_gap;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
*cross_pos += t.track_cross_size + gap + track_gap;
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +314,8 @@ static void flex_update(lv_obj_t * cont, void * user_data)
|
|||
/**
|
||||
* Find the last item of a track
|
||||
*/
|
||||
static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
|
||||
static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id, lv_coord_t max_main_size,
|
||||
lv_coord_t item_gap, track_t * t)
|
||||
{
|
||||
lv_coord_t w_set = lv_obj_get_style_width(cont, LV_PART_MAIN);
|
||||
lv_coord_t h_set = lv_obj_get_style_height(cont, LV_PART_MAIN);
|
||||
|
@ -318,7 +327,6 @@ static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id
|
|||
lv_coord_t(*get_main_size)(const lv_obj_t *) = (f->row ? lv_obj_get_width : lv_obj_get_height);
|
||||
lv_coord_t(*get_cross_size)(const lv_obj_t *) = (!f->row ? lv_obj_get_width : lv_obj_get_height);
|
||||
|
||||
lv_coord_t grow_sum = 0;
|
||||
t->track_main_size = 0;
|
||||
t->track_fix_main_size = 0;
|
||||
t->grow_item_cnt = 0;
|
||||
|
@ -335,7 +343,6 @@ static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id
|
|||
if(!lv_obj_has_flag_any(item, LV_OBJ_FLAG_IGNORE_LAYOUT | LV_OBJ_FLAG_HIDDEN | LV_OBJ_FLAG_FLOATING)) {
|
||||
uint8_t grow_value = lv_obj_get_style_flex_grow(item, LV_PART_MAIN);
|
||||
if(grow_value) {
|
||||
grow_sum += grow_value;
|
||||
t->grow_item_cnt++;
|
||||
t->track_fix_main_size += item_gap;
|
||||
if(t->grow_dsc_calc) {
|
||||
|
@ -348,13 +355,16 @@ static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id
|
|||
lv_mem_buf_release(t->grow_dsc);
|
||||
}
|
||||
new_dsc[t->grow_item_cnt - 1].item = item;
|
||||
new_dsc[t->grow_item_cnt - 1].min_size = f->row ? lv_obj_get_style_min_width(item, LV_PART_MAIN) : lv_obj_get_style_min_height(item, LV_PART_MAIN);
|
||||
new_dsc[t->grow_item_cnt - 1].max_size = f->row ? lv_obj_get_style_max_width(item, LV_PART_MAIN) : lv_obj_get_style_max_height(item, LV_PART_MAIN);
|
||||
new_dsc[t->grow_item_cnt - 1].min_size = f->row ? lv_obj_get_style_min_width(item,
|
||||
LV_PART_MAIN) : lv_obj_get_style_min_height(item, LV_PART_MAIN);
|
||||
new_dsc[t->grow_item_cnt - 1].max_size = f->row ? lv_obj_get_style_max_width(item,
|
||||
LV_PART_MAIN) : lv_obj_get_style_max_height(item, LV_PART_MAIN);
|
||||
new_dsc[t->grow_item_cnt - 1].grow_value = grow_value;
|
||||
new_dsc[t->grow_item_cnt - 1].clamped = 0;
|
||||
t->grow_dsc = new_dsc;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_coord_t item_size = get_main_size(item);
|
||||
if(f->wrap && t->track_fix_main_size + item_size > max_main_size) break;
|
||||
t->track_fix_main_size += item_size + item_gap;
|
||||
|
@ -392,7 +402,8 @@ static int32_t find_track_end(lv_obj_t * cont, flex_t * f, int32_t item_start_id
|
|||
/**
|
||||
* Position the children in the same track
|
||||
*/
|
||||
static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
|
||||
static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, int32_t item_last_id, lv_coord_t abs_x,
|
||||
lv_coord_t abs_y, lv_coord_t max_main_size, lv_coord_t item_gap, track_t * t)
|
||||
{
|
||||
void (*area_set_main_size)(lv_area_t *, lv_coord_t) = (f->row ? lv_area_set_width : lv_area_set_height);
|
||||
lv_coord_t (*area_get_main_size)(const lv_area_t *) = (f->row ? lv_area_get_width : lv_area_get_height);
|
||||
|
@ -408,7 +419,8 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i
|
|||
for(i = 0; i < t->grow_item_cnt; i++) {
|
||||
if(t->grow_dsc[i].clamped == 0) {
|
||||
grow_value_sum += t->grow_dsc[i].grow_value;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
grow_max_size -= t->grow_dsc[i].final_size;
|
||||
}
|
||||
}
|
||||
|
@ -470,23 +482,24 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i
|
|||
lv_event_send(lv_obj_get_parent(item), LV_EVENT_CHILD_CHANGED, item);
|
||||
lv_obj_invalidate(item);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
item->w_layout = 0;
|
||||
item->h_layout = 0;
|
||||
}
|
||||
|
||||
lv_coord_t cross_pos = 0;
|
||||
switch(f->cross_place) {
|
||||
case LV_FLEX_ALIGN_CENTER:
|
||||
/*Round up the cross size to avoid rounding error when dividing by 2
|
||||
*The issue comes up e,g, with column direction with center cross direction if an element's width changes*/
|
||||
cross_pos = (((t->track_cross_size + 1) & (~1)) - area_get_cross_size(&item->coords)) / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_END:
|
||||
cross_pos = t->track_cross_size - area_get_cross_size(&item->coords);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case LV_FLEX_ALIGN_CENTER:
|
||||
/*Round up the cross size to avoid rounding error when dividing by 2
|
||||
*The issue comes up e,g, with column direction with center cross direction if an element's width changes*/
|
||||
cross_pos = (((t->track_cross_size + 1) & (~1)) - area_get_cross_size(&item->coords)) / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_END:
|
||||
cross_pos = t->track_cross_size - area_get_cross_size(&item->coords);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(f->row && rtl) main_pos -= area_get_main_size(&item->coords);
|
||||
|
@ -525,7 +538,8 @@ static void children_repos(lv_obj_t * cont, flex_t * f, int32_t item_first_id, i
|
|||
/**
|
||||
* Tell a start coordinate and gap for a placement type.
|
||||
*/
|
||||
static void place_content(lv_flex_align_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt, lv_coord_t * start_pos, lv_coord_t * gap)
|
||||
static void place_content(lv_flex_align_t place, lv_coord_t max_size, lv_coord_t content_size, lv_coord_t item_cnt,
|
||||
lv_coord_t * start_pos, lv_coord_t * gap)
|
||||
{
|
||||
if(item_cnt <= 1) {
|
||||
switch(place) {
|
||||
|
@ -540,27 +554,27 @@ static void place_content(lv_flex_align_t place, lv_coord_t max_size, lv_coord_t
|
|||
}
|
||||
|
||||
switch(place) {
|
||||
case LV_FLEX_ALIGN_CENTER:
|
||||
*gap = 0;
|
||||
*start_pos += (max_size - content_size) / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_END:
|
||||
*gap = 0;
|
||||
*start_pos += max_size - content_size;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_BETWEEN:
|
||||
*gap = (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt - 1);
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_AROUND:
|
||||
*gap += (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt);
|
||||
*start_pos += *gap / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_EVENLY:
|
||||
*gap = (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt + 1);
|
||||
*start_pos += *gap;
|
||||
break;
|
||||
default:
|
||||
*gap = 0;
|
||||
case LV_FLEX_ALIGN_CENTER:
|
||||
*gap = 0;
|
||||
*start_pos += (max_size - content_size) / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_END:
|
||||
*gap = 0;
|
||||
*start_pos += max_size - content_size;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_BETWEEN:
|
||||
*gap = (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt - 1);
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_AROUND:
|
||||
*gap += (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt);
|
||||
*start_pos += *gap / 2;
|
||||
break;
|
||||
case LV_FLEX_ALIGN_SPACE_EVENLY:
|
||||
*gap = (lv_coord_t)(max_size - content_size) / (lv_coord_t)(item_cnt + 1);
|
||||
*start_pos += *gap;
|
||||
break;
|
||||
default:
|
||||
*gap = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +584,8 @@ static lv_obj_t * get_next_item(lv_obj_t * cont, bool rev, int32_t * item_id)
|
|||
(*item_id)--;
|
||||
if(*item_id >= 0) return cont->spec_attr->children[*item_id];
|
||||
else return NULL;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
(*item_id)++;
|
||||
if((*item_id) < (int32_t)cont->spec_attr->child_cnt) return cont->spec_attr->children[*item_id];
|
||||
else return NULL;
|
||||
|
|
|
@ -41,7 +41,7 @@ typedef enum {
|
|||
LV_FLEX_ALIGN_SPACE_EVENLY,
|
||||
LV_FLEX_ALIGN_SPACE_AROUND,
|
||||
LV_FLEX_ALIGN_SPACE_BETWEEN,
|
||||
}lv_flex_align_t;
|
||||
} lv_flex_align_t;
|
||||
|
||||
typedef enum {
|
||||
LV_FLEX_FLOW_ROW = 0x00,
|
||||
|
@ -52,7 +52,7 @@ typedef enum {
|
|||
LV_FLEX_FLOW_COLUMN_WRAP = LV_FLEX_FLOW_COLUMN | _LV_FLEX_WRAP,
|
||||
LV_FLEX_FLOW_COLUMN_REVERSE = LV_FLEX_FLOW_COLUMN | _LV_FLEX_REVERSE,
|
||||
LV_FLEX_FLOW_COLUMN_WRAP_REVERSE = LV_FLEX_FLOW_COLUMN | _LV_FLEX_WRAP | _LV_FLEX_REVERSE,
|
||||
}lv_flex_flow_t;
|
||||
} lv_flex_flow_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
|
@ -69,7 +69,7 @@ extern lv_style_prop_t LV_STYLE_FLEX_GROW;
|
|||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize a felx layout the default values
|
||||
* Initialize a flex layout the default values
|
||||
* @param flex pointer to a flex layout descriptor
|
||||
*/
|
||||
void lv_flex_init(void);
|
||||
|
@ -82,13 +82,14 @@ void lv_flex_init(void);
|
|||
void lv_obj_set_flex_flow(lv_obj_t * obj, lv_flex_flow_t flow);
|
||||
|
||||
/**
|
||||
* Set how to place (where to align) the items an tracks
|
||||
* Set how to place (where to align) the items and tracks
|
||||
* @param flex pointer: to a flex layout descriptor
|
||||
* @param main_place where to place the items on main axis (in their track). Any value of `lv_flex_align_t`.
|
||||
* @param cross_place where to place the item in their track on the cross axis. `LV_FLEX_ALIGN_START/END/CENTER`
|
||||
* @param track_place where to place the tracks in the cross direction. Any value of `lv_flex_align_t`.
|
||||
*/
|
||||
void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place, lv_flex_align_t track_cross_place);
|
||||
void lv_obj_set_flex_align(lv_obj_t * obj, lv_flex_align_t main_place, lv_flex_align_t cross_place,
|
||||
lv_flex_align_t track_cross_place);
|
||||
|
||||
/**
|
||||
* Sets the width or height (on main axis) to grow the object in order fill the free space
|
||||
|
|
|
@ -27,7 +27,7 @@ typedef struct {
|
|||
uint32_t col;
|
||||
uint32_t row;
|
||||
lv_point_t grid_abs;
|
||||
}item_repos_hint_t;
|
||||
} item_repos_hint_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t * x;
|
||||
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
uint32_t row_num;
|
||||
lv_coord_t grid_w;
|
||||
lv_coord_t grid_h;
|
||||
}_lv_grid_calc_t;
|
||||
} _lv_grid_calc_t;
|
||||
|
||||
|
||||
/**********************
|
||||
|
@ -54,19 +54,50 @@ static void calc_free(_lv_grid_calc_t * calc);
|
|||
static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c);
|
||||
static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c);
|
||||
static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t * hint);
|
||||
static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t align, lv_coord_t gap, uint32_t track_num, lv_coord_t * size_array, lv_coord_t * pos_array, bool reverse);
|
||||
static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t align, lv_coord_t gap, uint32_t track_num,
|
||||
lv_coord_t * size_array, lv_coord_t * pos_array, bool reverse);
|
||||
static uint32_t count_tracks(const lv_coord_t * templ);
|
||||
|
||||
static inline const lv_coord_t * get_col_dsc(lv_obj_t * obj) {return lv_obj_get_style_grid_column_dsc_array(obj, 0); }
|
||||
static inline const lv_coord_t * get_row_dsc(lv_obj_t * obj) {return lv_obj_get_style_grid_row_dsc_array(obj, 0); }
|
||||
static inline uint8_t get_col_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_pos(obj, 0); }
|
||||
static inline uint8_t get_row_pos(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_pos(obj, 0); }
|
||||
static inline uint8_t get_col_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_column_span(obj, 0); }
|
||||
static inline uint8_t get_row_span(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_row_span(obj, 0); }
|
||||
static inline uint8_t get_cell_col_align(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_x_align(obj, 0); }
|
||||
static inline uint8_t get_cell_row_align(lv_obj_t * obj) {return lv_obj_get_style_grid_cell_y_align(obj, 0); }
|
||||
static inline uint8_t get_grid_col_align(lv_obj_t * obj) {return lv_obj_get_style_grid_column_align(obj, 0); }
|
||||
static inline uint8_t get_grid_row_align(lv_obj_t * obj) {return lv_obj_get_style_grid_row_align(obj, 0); }
|
||||
static inline const lv_coord_t * get_col_dsc(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_column_dsc_array(obj, 0);
|
||||
}
|
||||
static inline const lv_coord_t * get_row_dsc(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_row_dsc_array(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_col_pos(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_column_pos(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_row_pos(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_row_pos(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_col_span(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_column_span(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_row_span(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_row_span(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_cell_col_align(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_x_align(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_cell_row_align(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_cell_y_align(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_grid_col_align(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_column_align(obj, 0);
|
||||
}
|
||||
static inline uint8_t get_grid_row_align(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_style_grid_row_align(obj, 0);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
|
@ -128,7 +159,7 @@ void lv_obj_set_grid_align(lv_obj_t * obj, lv_grid_align_t column_align, lv_grid
|
|||
}
|
||||
|
||||
void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_align_t x_align, uint8_t col_pos, uint8_t col_span,
|
||||
lv_grid_align_t y_align, uint8_t row_pos, uint8_t row_span)
|
||||
lv_grid_align_t y_align, uint8_t row_pos, uint8_t row_span)
|
||||
|
||||
{
|
||||
lv_obj_set_style_grid_cell_column_pos(obj, col_pos, 0);
|
||||
|
@ -228,7 +259,7 @@ void lv_obj_set_style_grid_row_dsc_array(lv_obj_t * obj, const lv_coord_t value[
|
|||
lv_style_value_t v = {
|
||||
.ptr = (const void *)value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector);
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_ROW_DSC_ARRAY, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_column_dsc_array(lv_obj_t * obj, const lv_coord_t value[], lv_style_selector_t selector)
|
||||
|
@ -262,7 +293,7 @@ void lv_obj_set_style_grid_cell_column_pos(lv_obj_t * obj, lv_coord_t value, lv_
|
|||
lv_style_value_t v = {
|
||||
.num = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_CELL_COLUMN_POS, v, selector);
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_POS, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
|
@ -270,7 +301,7 @@ void lv_obj_set_style_grid_cell_column_span(lv_obj_t * obj, lv_coord_t value, lv
|
|||
lv_style_value_t v = {
|
||||
.num = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_CELL_COLUMN_SPAN, v, selector);
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_COLUMN_SPAN, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
|
@ -278,7 +309,7 @@ void lv_obj_set_style_grid_cell_row_pos(lv_obj_t * obj, lv_coord_t value, lv_sty
|
|||
lv_style_value_t v = {
|
||||
.num = value
|
||||
};
|
||||
lv_obj_set_local_style_prop(obj,LV_STYLE_GRID_CELL_ROW_POS, v, selector);
|
||||
lv_obj_set_local_style_prop(obj, LV_STYLE_GRID_CELL_ROW_POS, v, selector);
|
||||
}
|
||||
|
||||
void lv_obj_set_style_grid_cell_row_span(lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector)
|
||||
|
@ -312,7 +343,7 @@ void lv_obj_set_style_grid_cell_y_align(lv_obj_t * obj, lv_coord_t value, lv_sty
|
|||
|
||||
static void grid_update(lv_obj_t * cont, void * user_data)
|
||||
{
|
||||
LV_LOG_INFO("update %p container", cont);
|
||||
LV_LOG_INFO("update %p container", (void *)cont);
|
||||
LV_UNUSED(user_data);
|
||||
|
||||
const lv_coord_t * col_templ = get_col_dsc(cont);
|
||||
|
@ -376,11 +407,13 @@ static void calc(lv_obj_t * cont, _lv_grid_calc_t * calc_out)
|
|||
lv_coord_t h_set = lv_obj_get_style_height(cont, LV_PART_MAIN);
|
||||
bool auto_w = (w_set == LV_SIZE_CONTENT && !cont->w_layout) ? true : false;
|
||||
lv_coord_t cont_w = lv_obj_get_content_width(cont);
|
||||
calc_out->grid_w = grid_align(cont_w, auto_w, get_grid_col_align(cont), col_gap, calc_out->col_num, calc_out->w, calc_out->x, rev);
|
||||
calc_out->grid_w = grid_align(cont_w, auto_w, get_grid_col_align(cont), col_gap, calc_out->col_num, calc_out->w,
|
||||
calc_out->x, rev);
|
||||
|
||||
bool auto_h = (h_set == LV_SIZE_CONTENT && !cont->h_layout) ? true : false;
|
||||
lv_coord_t cont_h = lv_obj_get_content_height(cont);
|
||||
calc_out->grid_h = grid_align(cont_h, auto_h, get_grid_row_align(cont), row_gap, calc_out->row_num, calc_out->h, calc_out->y, false);
|
||||
calc_out->grid_h = grid_align(cont_h, auto_h, get_grid_row_align(cont), row_gap, calc_out->row_num, calc_out->h,
|
||||
calc_out->y, false);
|
||||
|
||||
LV_ASSERT_MEM_INTEGRITY();
|
||||
}
|
||||
|
@ -437,7 +470,7 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
|
|||
if(IS_FR(x)) {
|
||||
col_fr_cnt += GET_FR(x);
|
||||
}
|
||||
else if (IS_CONTENT(x)) {
|
||||
else if(IS_CONTENT(x)) {
|
||||
grid_w += c->w[i];
|
||||
}
|
||||
else {
|
||||
|
@ -465,7 +498,7 @@ static void calc_cols(lv_obj_t * cont, _lv_grid_calc_t * c)
|
|||
|
||||
/*To avoid rounding errors set the last FR track to the remaining size */
|
||||
if(last_fr_i >= 0) {
|
||||
c->w[last_fr_i] = free_w - ((free_w * (col_fr_cnt - last_fr_x)) / col_fr_cnt);
|
||||
c->w[last_fr_i] = free_w - ((free_w * (col_fr_cnt - last_fr_x)) / col_fr_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,9 +538,11 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
|
|||
lv_coord_t x = row_templ[i];
|
||||
if(IS_FR(x)) {
|
||||
row_fr_cnt += GET_FR(x);
|
||||
} else if (IS_CONTENT(x)) {
|
||||
}
|
||||
else if(IS_CONTENT(x)) {
|
||||
grid_h += c->h[i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
c->h[i] = x;
|
||||
grid_h += x;
|
||||
}
|
||||
|
@ -531,7 +566,7 @@ static void calc_rows(lv_obj_t * cont, _lv_grid_calc_t * c)
|
|||
|
||||
/*To avoid rounding errors set the last FR track to the remaining size */
|
||||
if(last_fr_i >= 0) {
|
||||
c->h[last_fr_i] = free_h - ((free_h * (row_fr_cnt - last_fr_x)) / row_fr_cnt);
|
||||
c->h[last_fr_i] = free_h - ((free_h * (row_fr_cnt - last_fr_x)) / row_fr_cnt);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -666,14 +701,16 @@ static void item_repos(lv_obj_t * item, _lv_grid_calc_t * c, item_repos_hint_t *
|
|||
* @param pos_array write the positions of the tracks here
|
||||
* @return the total size of the grid
|
||||
*/
|
||||
static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t align, lv_coord_t gap, uint32_t track_num, lv_coord_t * size_array, lv_coord_t * pos_array, bool reverse)
|
||||
static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t align, lv_coord_t gap, uint32_t track_num,
|
||||
lv_coord_t * size_array, lv_coord_t * pos_array, bool reverse)
|
||||
{
|
||||
lv_coord_t grid_size = 0;
|
||||
uint32_t i;
|
||||
|
||||
if(auto_size) {
|
||||
pos_array[0] = 0;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*With spaced alignment gap will be calculated from the remaining space*/
|
||||
if(align == LV_GRID_ALIGN_SPACE_AROUND || align == LV_GRID_ALIGN_SPACE_BETWEEN || align == LV_GRID_ALIGN_SPACE_EVENLY) {
|
||||
gap = 0;
|
||||
|
@ -688,27 +725,27 @@ static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t alig
|
|||
|
||||
/*Calculate the position of the first item and set gap is necessary*/
|
||||
switch(align) {
|
||||
case LV_GRID_ALIGN_START:
|
||||
pos_array[0] = 0;
|
||||
break;
|
||||
case LV_GRID_ALIGN_CENTER:
|
||||
pos_array[0] = (cont_size - grid_size) / 2;
|
||||
break;
|
||||
case LV_GRID_ALIGN_END:
|
||||
pos_array[0] = cont_size - grid_size;
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_BETWEEN:
|
||||
pos_array[0] = 0;
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num - 1);
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_AROUND:
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num);
|
||||
pos_array[0] = gap / 2;
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_EVENLY:
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num + 1);
|
||||
pos_array[0] = gap;
|
||||
break;
|
||||
case LV_GRID_ALIGN_START:
|
||||
pos_array[0] = 0;
|
||||
break;
|
||||
case LV_GRID_ALIGN_CENTER:
|
||||
pos_array[0] = (cont_size - grid_size) / 2;
|
||||
break;
|
||||
case LV_GRID_ALIGN_END:
|
||||
pos_array[0] = cont_size - grid_size;
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_BETWEEN:
|
||||
pos_array[0] = 0;
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num - 1);
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_AROUND:
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num);
|
||||
pos_array[0] = gap / 2;
|
||||
break;
|
||||
case LV_GRID_ALIGN_SPACE_EVENLY:
|
||||
gap = (lv_coord_t)(cont_size - grid_size) / (lv_coord_t)(track_num + 1);
|
||||
pos_array[0] = gap;
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -734,7 +771,7 @@ static lv_coord_t grid_align(lv_coord_t cont_size, bool auto_size, uint8_t alig
|
|||
static uint32_t count_tracks(const lv_coord_t * templ)
|
||||
{
|
||||
uint32_t i;
|
||||
for(i = 0; templ[i] != LV_COORD_MAX; i++);
|
||||
for(i = 0; templ[i] != LV_GRID_TEMPLATE_LAST; i++);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef enum {
|
|||
LV_GRID_ALIGN_SPACE_EVENLY,
|
||||
LV_GRID_ALIGN_SPACE_AROUND,
|
||||
LV_GRID_ALIGN_SPACE_BETWEEN,
|
||||
}lv_grid_align_t;
|
||||
} lv_grid_align_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL VARIABLES
|
||||
|
@ -78,15 +78,15 @@ void lv_obj_set_grid_align(lv_obj_t * obj, lv_grid_align_t column_align, lv_grid
|
|||
/**
|
||||
* Set the cell of an object. The object's parent needs to have grid layout, else nothing will happen
|
||||
* @param obj pointer to an object
|
||||
* @param hor_place the vertical alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
|
||||
* @param column_align the vertical alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
|
||||
* @param col_pos column ID
|
||||
* @param col_span number of columns to take (>= 1)
|
||||
* @param ver_place the horizontal alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
|
||||
* @param row_align the horizontal alignment in the cell. `LV_GRID_START/END/CENTER/STRETCH`
|
||||
* @param row_pos row ID
|
||||
* @param row_span number of rows to take (>= 1)
|
||||
*/
|
||||
void lv_obj_set_grid_cell(lv_obj_t * obj, lv_grid_align_t column_align, uint8_t col_pos, uint8_t col_span,
|
||||
lv_grid_align_t row_align, uint8_t row_pos, uint8_t row_span);
|
||||
lv_grid_align_t row_align, uint8_t row_pos, uint8_t row_span);
|
||||
|
||||
/**
|
||||
* Just a wrapper to `LV_GRID_FR` for bindings.
|
||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
|||
* MACROS
|
||||
**********************/
|
||||
#if LV_USE_LOG && LV_LOG_TRACE_LAYOUT
|
||||
# define LV_TRACE_LAYOUT(...) LV_LOG_TRACE( __VA_ARGS__)
|
||||
# define LV_TRACE_LAYOUT(...) LV_LOG_TRACE(__VA_ARGS__)
|
||||
#else
|
||||
# define LV_TRACE_LAYOUT(...)
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,276 @@
|
|||
/**
|
||||
* @file lv_fs_fatfs.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
|
||||
#if LV_USE_FS_FATFS != '\0'
|
||||
#include "ff.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void fs_init(void);
|
||||
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path);
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn);
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
void lv_fs_fatfs_init(void)
|
||||
{
|
||||
/*----------------------------------------------------
|
||||
* Initialize your storage device and File System
|
||||
* -------------------------------------------------*/
|
||||
fs_init();
|
||||
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/*Add a simple drive to open images*/
|
||||
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = LV_USE_FS_FATFS;
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/*Initialize your Storage device and File system.*/
|
||||
static void fs_init(void)
|
||||
{
|
||||
/*Initialize the SD card and FatFS itself.
|
||||
*Better to do it in your code to keep this library untouched for easy updating*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return pointer to FIL struct or NULL in case of fail
|
||||
*/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
uint8_t flags = 0;
|
||||
|
||||
if(mode == LV_FS_MODE_WR) flags = FA_WRITE | FA_OPEN_ALWAYS;
|
||||
else if(mode == LV_FS_MODE_RD) flags = FA_READ;
|
||||
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) flags = FA_READ | FA_WRITE | FA_OPEN_ALWAYS;
|
||||
|
||||
FIL * f = lv_mem_alloc(sizeof(FIL));
|
||||
if(f == NULL) return NULL;
|
||||
|
||||
FRESULT res = f_open(f, path, flags);
|
||||
if(res == FR_OK) {
|
||||
return f;
|
||||
} else {
|
||||
lv_mem_free(f);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FIL variable. (opened with fs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
f_close(file_p);
|
||||
lv_mem_free(file_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FIL variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
FRESULT res = f_read(file_p, buf, btr, (UINT *)br);
|
||||
if(res == FR_OK) return LV_FS_RES_OK;
|
||||
else return LV_FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FIL variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
FRESULT res = f_write(file_p, buf, btw, (UINT *)bw);
|
||||
if(res == FR_OK) return LV_FS_RES_OK;
|
||||
else return LV_FS_RES_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FIL variable. (opened with fs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @param whence only LV_SEEK_SET is supported
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
switch (whence) {
|
||||
case LV_FS_SEEK_SET:
|
||||
f_lseek(file_p, pos);
|
||||
break;
|
||||
case LV_FS_SEEK_CUR:
|
||||
f_lseek(file_p, f_tell(file_p) + pos);
|
||||
break;
|
||||
case LV_FS_SEEK_END:
|
||||
f_lseek(file_p, f_size(file_p) + pos);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FIL variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*pos_p = f_tell(file_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize a 'DIR' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to an initialized 'DIR' variable
|
||||
*/
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
DIR * d = lv_mem_alloc(sizeof(DIR));
|
||||
if(d == NULL) return NULL;
|
||||
|
||||
FRESULT res = f_opendir(d, path);
|
||||
if(res != FR_OK) {
|
||||
lv_mem_free(d);
|
||||
d = NULL;
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename from a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
FRESULT res;
|
||||
FILINFO fno;
|
||||
fn[0] = '\0';
|
||||
|
||||
do {
|
||||
res = f_readdir(dir_p, &fno);
|
||||
if(res != FR_OK) return LV_FS_RES_UNKNOWN;
|
||||
|
||||
if(fno.fattrib & AM_DIR) {
|
||||
fn[0] = '/';
|
||||
strcpy(&fn[1], fno.fname);
|
||||
}
|
||||
else strcpy(fn, fno.fname);
|
||||
|
||||
} while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0);
|
||||
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
f_closedir(dir_p);
|
||||
lv_mem_free(dir_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FS_FATFS*/
|
|
@ -0,0 +1,313 @@
|
|||
/**
|
||||
* @file lv_fs_posix.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_FS_POSIX != '\0'
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#ifndef WIN32
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path);
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn);
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register a driver for the File system interface
|
||||
*/
|
||||
void lv_fs_posix_init(void)
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/*Add a simple drive to open images*/
|
||||
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = LV_USE_FS_POSIX;
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return a file handle or -1 in case of fail
|
||||
*/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
uint32_t flags = 0;
|
||||
if(mode == LV_FS_MODE_WR) flags = O_WRONLY;
|
||||
else if(mode == LV_FS_MODE_RD) flags = O_RDONLY;
|
||||
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) flags = O_RDWR;
|
||||
|
||||
#ifdef LV_FS_POSIX_PATH
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
sprintf(buf, LV_FS_POSIX_PATH "%s", path);
|
||||
|
||||
int f = open(buf, flags);
|
||||
#else
|
||||
int f = open(path, flags);
|
||||
#endif
|
||||
if(f < 0) return NULL;
|
||||
|
||||
return (void *)(lv_uintptr_t)f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p a file handle. (opened with fs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
close((lv_uintptr_t)file_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p a file handle variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*br = read((lv_uintptr_t)file_p, buf, btr);
|
||||
return (int32_t)*br < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p a file handle variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*bw = write((lv_uintptr_t)file_p, buf, btw);
|
||||
return (int32_t)*bw < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p a file handle variable. (opened with fs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
lseek((lv_uintptr_t)file_p, pos, whence);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p a file handle variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*pos_p = lseek((lv_uintptr_t)file_p, 0, SEEK_CUR);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
static char next_fn[256];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize a 'fs_read_dir_t' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
*/
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
#ifndef WIN32
|
||||
# ifdef LV_FS_POSIX_PATH
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
sprintf(buf, LV_FS_POSIX_PATH "%s", path);
|
||||
return opendir(buf);
|
||||
# else
|
||||
return opendir(path);
|
||||
# endif
|
||||
#else
|
||||
HANDLE d = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATA fdata;
|
||||
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
# ifdef LV_FS_POSIX_PATH
|
||||
sprintf(buf, LV_FS_POSIX_PATH "%s\\*", path);
|
||||
# else
|
||||
sprintf(buf, "%s\\*", path);
|
||||
# endif
|
||||
|
||||
strcpy(next_fn, "");
|
||||
d = FindFirstFile(buf, &fdata);
|
||||
do {
|
||||
if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) {
|
||||
continue;
|
||||
} else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
} else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(FindNextFileA(d, &fdata));
|
||||
|
||||
return d;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename from a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
#ifndef WIN32
|
||||
struct dirent *entry;
|
||||
do {
|
||||
entry = readdir(dir_p);
|
||||
if(entry) {
|
||||
if(entry->d_type == DT_DIR) sprintf(fn, "/%s", entry->d_name);
|
||||
else strcpy(fn, entry->d_name);
|
||||
} else {
|
||||
strcpy(fn, "");
|
||||
}
|
||||
} while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0);
|
||||
#else
|
||||
strcpy(fn, next_fn);
|
||||
|
||||
strcpy(next_fn, "");
|
||||
WIN32_FIND_DATA fdata;
|
||||
|
||||
if(FindNextFile(dir_p, &fdata) == false) return LV_FS_RES_OK;
|
||||
do {
|
||||
if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) {
|
||||
continue;
|
||||
} else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
} else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(FindNextFile(dir_p, &fdata));
|
||||
|
||||
#endif
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
#ifndef WIN32
|
||||
closedir(dir_p);
|
||||
#else
|
||||
FindClose(dir_p);
|
||||
#endif
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FS_POSIX*/
|
|
@ -0,0 +1,310 @@
|
|||
/**
|
||||
* @file lv_fs_stdio.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_FS_STDIO != '\0'
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef WIN32
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path);
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn);
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register a driver for the File system interface
|
||||
*/
|
||||
void lv_fs_stdio_init(void)
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/*Add a simple drive to open images*/
|
||||
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = LV_USE_FS_STDIO;
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return pointer to FIL struct or NULL in case of fail
|
||||
*/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
const char * flags = "";
|
||||
|
||||
if(mode == LV_FS_MODE_WR) flags = "wb";
|
||||
else if(mode == LV_FS_MODE_RD) flags = "rb";
|
||||
else if(mode == (LV_FS_MODE_WR | LV_FS_MODE_RD)) flags = "rb+";
|
||||
|
||||
#ifdef LV_FS_STDIO_PATH
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
|
||||
char buf[256];
|
||||
sprintf(buf, LV_FS_STDIO_PATH "%s", path);
|
||||
|
||||
return fopen(buf, flags);
|
||||
#else
|
||||
return fopen(path, flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
fclose(file_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*br = fread(buf, 1, btr, file_p);
|
||||
return (int32_t)*br < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*bw = fwrite(buf, 1, btw, file_p);
|
||||
return (int32_t)*bw < 0 ? LV_FS_RES_UNKNOWN : LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
fseek(file_p, pos, whence);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
*pos_p = ftell(file_p);
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
static char next_fn[256];
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize a 'DIR' or 'HANDLE' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
*/
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
#ifndef WIN32
|
||||
# ifdef LV_FS_STDIO_PATH
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
sprintf(buf, LV_FS_STDIO_PATH "%s", path);
|
||||
return opendir(buf);
|
||||
# else
|
||||
return opendir(path);
|
||||
# endif
|
||||
#else
|
||||
HANDLE d = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATA fdata;
|
||||
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
# ifdef LV_FS_STDIO_PATH
|
||||
sprintf(buf, LV_FS_STDIO_PATH "%s\\*", path);
|
||||
# else
|
||||
sprintf(buf, "%s\\*", path);
|
||||
# endif
|
||||
|
||||
strcpy(next_fn, "");
|
||||
d = FindFirstFile(buf, &fdata);
|
||||
do {
|
||||
if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) {
|
||||
continue;
|
||||
} else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
} else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(FindNextFileA(d, &fdata));
|
||||
|
||||
return d;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename form a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
#ifndef WIN32
|
||||
struct dirent *entry;
|
||||
do {
|
||||
entry = readdir(dir_p);
|
||||
if(entry) {
|
||||
if(entry->d_type == DT_DIR) sprintf(fn, "/%s", entry->d_name);
|
||||
else strcpy(fn, entry->d_name);
|
||||
} else {
|
||||
strcpy(fn, "");
|
||||
}
|
||||
} while(strcmp(fn, "/.") == 0 || strcmp(fn, "/..") == 0);
|
||||
#else
|
||||
strcpy(fn, next_fn);
|
||||
|
||||
strcpy(next_fn, "");
|
||||
WIN32_FIND_DATA fdata;
|
||||
|
||||
if(FindNextFile(dir_p, &fdata) == false) return LV_FS_RES_OK;
|
||||
do {
|
||||
if (strcmp(fdata.cFileName, ".") == 0 || strcmp(fdata.cFileName, "..") == 0) {
|
||||
continue;
|
||||
} else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
} else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while(FindNextFile(dir_p, &fdata));
|
||||
|
||||
#endif
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
#ifndef WIN32
|
||||
closedir(dir_p);
|
||||
#else
|
||||
FindClose(dir_p);
|
||||
#endif
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FS_STDIO*/
|
|
@ -0,0 +1,451 @@
|
|||
/**
|
||||
* @file lv_fs_win32.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lvgl.h"
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
static bool is_dots_name(const char * name);
|
||||
static lv_fs_res_t fs_error_from_win32(DWORD error);
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode);
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p);
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br);
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw);
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence);
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p);
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path);
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn);
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Register a driver for the File system interface
|
||||
*/
|
||||
void lv_fs_win32_init(void)
|
||||
{
|
||||
/*---------------------------------------------------
|
||||
* Register the file system interface in LittlevGL
|
||||
*--------------------------------------------------*/
|
||||
|
||||
/*Add a simple drive to open images*/
|
||||
static lv_fs_drv_t fs_drv; /*A driver descriptor*/
|
||||
lv_fs_drv_init(&fs_drv);
|
||||
|
||||
/*Set up fields...*/
|
||||
fs_drv.letter = LV_USE_FS_WIN32;
|
||||
fs_drv.open_cb = fs_open;
|
||||
fs_drv.close_cb = fs_close;
|
||||
fs_drv.read_cb = fs_read;
|
||||
fs_drv.write_cb = fs_write;
|
||||
fs_drv.seek_cb = fs_seek;
|
||||
fs_drv.tell_cb = fs_tell;
|
||||
|
||||
fs_drv.dir_close_cb = fs_dir_close;
|
||||
fs_drv.dir_open_cb = fs_dir_open;
|
||||
fs_drv.dir_read_cb = fs_dir_read;
|
||||
|
||||
lv_fs_drv_register(&fs_drv);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Check the dots name
|
||||
* @param name file or dir name
|
||||
* @return true if the name is dots name
|
||||
*/
|
||||
static bool is_dots_name(const char * name)
|
||||
{
|
||||
return name[0] == '.' && (!name[1] || (name[1] == '.' && !name[2]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Win32 error code to error from lv_fs_res_t enum
|
||||
* @param error Win32 error code
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_error_from_win32(DWORD error)
|
||||
{
|
||||
lv_fs_res_t res;
|
||||
|
||||
switch (error) {
|
||||
case ERROR_SUCCESS:
|
||||
res = LV_FS_RES_OK;
|
||||
break;
|
||||
case ERROR_BAD_UNIT:
|
||||
case ERROR_NOT_READY:
|
||||
case ERROR_CRC:
|
||||
case ERROR_SEEK:
|
||||
case ERROR_NOT_DOS_DISK:
|
||||
case ERROR_WRITE_FAULT:
|
||||
case ERROR_READ_FAULT:
|
||||
case ERROR_GEN_FAILURE:
|
||||
case ERROR_WRONG_DISK:
|
||||
res = LV_FS_RES_HW_ERR;
|
||||
break;
|
||||
case ERROR_INVALID_HANDLE:
|
||||
case ERROR_INVALID_TARGET_HANDLE:
|
||||
res = LV_FS_RES_FS_ERR;
|
||||
break;
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
case ERROR_PATH_NOT_FOUND:
|
||||
case ERROR_INVALID_DRIVE:
|
||||
case ERROR_NO_MORE_FILES:
|
||||
case ERROR_SECTOR_NOT_FOUND:
|
||||
case ERROR_BAD_NETPATH:
|
||||
case ERROR_BAD_NET_NAME:
|
||||
case ERROR_BAD_PATHNAME:
|
||||
case ERROR_FILENAME_EXCED_RANGE:
|
||||
res = LV_FS_RES_NOT_EX;
|
||||
break;
|
||||
case ERROR_DISK_FULL:
|
||||
res = LV_FS_RES_FULL;
|
||||
break;
|
||||
case ERROR_SHARING_VIOLATION:
|
||||
case ERROR_LOCK_VIOLATION:
|
||||
case ERROR_DRIVE_LOCKED:
|
||||
res = LV_FS_RES_LOCKED;
|
||||
break;
|
||||
case ERROR_ACCESS_DENIED:
|
||||
case ERROR_CURRENT_DIRECTORY:
|
||||
case ERROR_WRITE_PROTECT:
|
||||
case ERROR_NETWORK_ACCESS_DENIED:
|
||||
case ERROR_CANNOT_MAKE:
|
||||
case ERROR_FAIL_I24:
|
||||
case ERROR_SEEK_ON_DEVICE:
|
||||
case ERROR_NOT_LOCKED:
|
||||
case ERROR_LOCK_FAILED:
|
||||
res = LV_FS_RES_DENIED;
|
||||
break;
|
||||
case ERROR_BUSY:
|
||||
res = LV_FS_RES_BUSY;
|
||||
break;
|
||||
case ERROR_TIMEOUT:
|
||||
res = LV_FS_RES_TOUT;
|
||||
break;
|
||||
case ERROR_NOT_SAME_DEVICE:
|
||||
case ERROR_DIRECT_ACCESS_HANDLE:
|
||||
res = LV_FS_RES_NOT_IMP;
|
||||
break;
|
||||
case ERROR_TOO_MANY_OPEN_FILES:
|
||||
case ERROR_ARENA_TRASHED:
|
||||
case ERROR_NOT_ENOUGH_MEMORY:
|
||||
case ERROR_INVALID_BLOCK:
|
||||
case ERROR_OUT_OF_PAPER:
|
||||
case ERROR_SHARING_BUFFER_EXCEEDED:
|
||||
case ERROR_NOT_ENOUGH_QUOTA:
|
||||
res = LV_FS_RES_OUT_OF_MEM;
|
||||
break;
|
||||
case ERROR_INVALID_FUNCTION:
|
||||
case ERROR_INVALID_ACCESS:
|
||||
case ERROR_INVALID_DATA:
|
||||
case ERROR_BAD_COMMAND:
|
||||
case ERROR_BAD_LENGTH:
|
||||
case ERROR_INVALID_PARAMETER:
|
||||
case ERROR_NEGATIVE_SEEK:
|
||||
res = LV_FS_RES_INV_PARAM;
|
||||
break;
|
||||
default:
|
||||
res = LV_FS_RES_UNKNOWN;
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to the file beginning with the driver letter (e.g. S:/folder/file.txt)
|
||||
* @param mode read: FS_MODE_RD, write: FS_MODE_WR, both: FS_MODE_RD | FS_MODE_WR
|
||||
* @return pointer to FIL struct or NULL in case of fail
|
||||
*/
|
||||
static void * fs_open(lv_fs_drv_t * drv, const char * path, lv_fs_mode_t mode)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
DWORD desired_access = 0;
|
||||
|
||||
if (mode & LV_FS_MODE_RD) {
|
||||
desired_access |= GENERIC_READ;
|
||||
}
|
||||
|
||||
if (mode & LV_FS_MODE_WR) {
|
||||
desired_access |= GENERIC_WRITE;
|
||||
}
|
||||
|
||||
#ifdef LV_FS_WIN32_PATH
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
|
||||
char buf[MAX_PATH];
|
||||
sprintf(buf, LV_FS_WIN32_PATH "%s", path);
|
||||
#endif
|
||||
|
||||
return (void*)CreateFileA(
|
||||
#ifdef LV_FS_WIN32_PATH
|
||||
buf,
|
||||
#else
|
||||
path,
|
||||
#endif
|
||||
desired_access,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_close(lv_fs_drv_t * drv, void * file_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return CloseHandle((HANDLE)file_p)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Read data from an opened file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param buf pointer to a memory block where to store the read data
|
||||
* @param btr number of Bytes To Read
|
||||
* @param br the real number of read bytes (Byte Read)
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_read(lv_fs_drv_t * drv, void * file_p, void * buf, uint32_t btr, uint32_t * br)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return ReadFile((HANDLE)file_p, buf, btr, (LPDWORD)br, NULL)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Write into a file
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable
|
||||
* @param buf pointer to a buffer with the bytes to write
|
||||
* @param btr Bytes To Write
|
||||
* @param br the number of real written bytes (Bytes Written). NULL if unused.
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_write(lv_fs_drv_t * drv, void * file_p, const void * buf, uint32_t btw, uint32_t * bw)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return WriteFile((HANDLE)file_p, buf, btw, (LPDWORD)bw, NULL)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the read write pointer. Also expand the file size if necessary.
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable. (opened with fs_open )
|
||||
* @param pos the new position of read write pointer
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_seek(lv_fs_drv_t * drv, void * file_p, uint32_t pos, lv_fs_whence_t whence)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
DWORD move_method = (DWORD)-1;
|
||||
if (whence == LV_FS_SEEK_SET) {
|
||||
move_method = FILE_BEGIN;
|
||||
}
|
||||
else if(whence == LV_FS_SEEK_CUR) {
|
||||
move_method = FILE_CURRENT;
|
||||
}
|
||||
else if(whence == LV_FS_SEEK_END) {
|
||||
move_method = FILE_END;
|
||||
}
|
||||
|
||||
LARGE_INTEGER distance_to_move;
|
||||
distance_to_move.QuadPart = pos;
|
||||
return SetFilePointerEx((HANDLE)file_p, distance_to_move, NULL, move_method)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the position of the read write pointer
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param file_p pointer to a FILE variable.
|
||||
* @param pos_p pointer to to store the result
|
||||
* @return LV_FS_RES_OK: no error, the file is read
|
||||
* any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_tell(lv_fs_drv_t * drv, void * file_p, uint32_t * pos_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
if (!pos_p) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
}
|
||||
|
||||
LARGE_INTEGER file_pointer;
|
||||
file_pointer.QuadPart = 0;
|
||||
|
||||
LARGE_INTEGER distance_to_move;
|
||||
distance_to_move.QuadPart = 0;
|
||||
if (SetFilePointerEx(
|
||||
(HANDLE)file_p,
|
||||
distance_to_move,
|
||||
&file_pointer,
|
||||
FILE_CURRENT)) {
|
||||
if (file_pointer.QuadPart > LONG_MAX) {
|
||||
return LV_FS_RES_INV_PARAM;
|
||||
}
|
||||
else {
|
||||
*pos_p = file_pointer.LowPart;
|
||||
return LV_FS_RES_OK;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return fs_error_from_win32(GetLastError());
|
||||
}
|
||||
}
|
||||
|
||||
static char next_fn[256];
|
||||
static lv_fs_res_t next_error = LV_FS_RES_OK;
|
||||
|
||||
/**
|
||||
* Initialize a 'DIR' or 'HANDLE' variable for directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param path path to a directory
|
||||
* @return pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
*/
|
||||
static void * fs_dir_open(lv_fs_drv_t * drv, const char * path)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
HANDLE d = INVALID_HANDLE_VALUE;
|
||||
WIN32_FIND_DATAA fdata;
|
||||
|
||||
/*Make the path relative to the current directory (the projects root folder)*/
|
||||
char buf[256];
|
||||
#ifdef LV_FS_WIN32_PATH
|
||||
sprintf(buf, LV_FS_WIN32_PATH "%s\\*", path);
|
||||
#else
|
||||
sprintf(buf, "%s\\*", path);
|
||||
#endif
|
||||
|
||||
strcpy(next_fn, "");
|
||||
d = FindFirstFileA(buf, &fdata);
|
||||
do {
|
||||
if (is_dots_name(fdata.cFileName)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
}
|
||||
else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} while (FindNextFileA(d, &fdata));
|
||||
|
||||
next_error = fs_error_from_win32(GetLastError());
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the next filename from a directory.
|
||||
* The name of the directories will begin with '/'
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @param fn pointer to a buffer to store the filename
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_read(lv_fs_drv_t * drv, void * dir_p, char * fn)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
|
||||
strcpy(fn, next_fn);
|
||||
lv_fs_res_t current_error = next_error;
|
||||
next_error = LV_FS_RES_OK;
|
||||
|
||||
strcpy(next_fn, "");
|
||||
WIN32_FIND_DATAA fdata;
|
||||
|
||||
while (FindNextFileA(dir_p, &fdata)) {
|
||||
if (is_dots_name(fdata.cFileName)) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
if (fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
sprintf(next_fn, "/%s", fdata.cFileName);
|
||||
}
|
||||
else {
|
||||
sprintf(next_fn, "%s", fdata.cFileName);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (next_fn[0] == '\0') {
|
||||
next_error = fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
return current_error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the directory reading
|
||||
* @param drv pointer to a driver where this function belongs
|
||||
* @param dir_p pointer to an initialized 'DIR' or 'HANDLE' variable
|
||||
* @return LV_FS_RES_OK or any error from lv_fs_res_t enum
|
||||
*/
|
||||
static lv_fs_res_t fs_dir_close(lv_fs_drv_t * drv, void * dir_p)
|
||||
{
|
||||
LV_UNUSED(drv);
|
||||
return FindClose((HANDLE)dir_p)
|
||||
? LV_FS_RES_OK
|
||||
: fs_error_from_win32(GetLastError());
|
||||
}
|
||||
|
||||
#endif /*LV_USE_FS_WIN32*/
|
|
@ -0,0 +1,55 @@
|
|||
/**
|
||||
* @file lv_fsdrv.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_FSDRV_H
|
||||
#define LV_FSDRV_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../../../lv_conf_internal.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
#if LV_USE_FS_FATFS != '\0'
|
||||
void lv_fs_fatfs_init(void);
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_STDIO != '\0'
|
||||
void lv_fs_stdio_init(void);
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_POSIX != '\0'
|
||||
void lv_fs_posix_init(void);
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
void lv_fs_win32_init(void);
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /*LV_FSDRV_H*/
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* @file lv_libs.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_LIBS_H
|
||||
#define LV_LIBS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
// TODO Tasmota
|
||||
// #include "bmp/lv_bmp.h"
|
||||
// #include "fsdrv/lv_fsdrv.h"
|
||||
// #include "png/lv_png.h"
|
||||
// #include "gif/lv_gif.h"
|
||||
// #include "qrcode/lv_qrcode.h"
|
||||
// #include "sjpg/lv_sjpg.h"
|
||||
// #include "freetype/lv_freetype.h"
|
||||
// #include "rlottie/lv_rlottie.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_LAYOUTS_H*/
|
|
@ -41,6 +41,40 @@ void lv_extra_init(void)
|
|||
#if LV_USE_GRID
|
||||
lv_grid_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_FATFS != '\0'
|
||||
lv_fs_fatfs_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_STDIO != '\0'
|
||||
lv_fs_stdio_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_POSIX != '\0'
|
||||
lv_fs_posix_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FS_WIN32 != '\0'
|
||||
lv_fs_win32_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_PNG
|
||||
lv_png_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_SJPG
|
||||
lv_split_jpeg_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_BMP
|
||||
lv_bmp_init();
|
||||
#endif
|
||||
|
||||
#if LV_USE_FREETYPE
|
||||
/*Init freetype library
|
||||
*Cache max 64 faces and 1 size*/
|
||||
lv_freetype_init(0, 0, LV_FREETYPE_CACHE_SIZE);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* @file lv_others.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OTHERS_H
|
||||
#define LV_OTHERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "snapshot/lv_snapshot.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OTHERS_H*/
|
|
@ -0,0 +1,228 @@
|
|||
/**
|
||||
* @file lv_snapshot.c
|
||||
*
|
||||
*/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_snapshot.h"
|
||||
#if LV_USE_SNAPSHOT
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "../../../core/lv_disp.h"
|
||||
#include "../../../core/lv_refr.h"
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
/** Get the buffer needed for object snapshot image.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
*
|
||||
* @return the buffer size needed in bytes
|
||||
*/
|
||||
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_img_cf_t cf)
|
||||
{
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
lv_obj_update_layout(obj);
|
||||
|
||||
/*Width and height determine snapshot image size.*/
|
||||
lv_coord_t w = lv_obj_get_width(obj);
|
||||
lv_coord_t h = lv_obj_get_height(obj);
|
||||
lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj);
|
||||
w += ext_size * 2;
|
||||
h += ext_size * 2;
|
||||
|
||||
uint8_t px_size = lv_img_cf_get_px_size(cf);
|
||||
return w * h * ((px_size + 7) >> 3);
|
||||
}
|
||||
|
||||
/** Take snapshot for object with its children, save image info to provided buffer.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @param dsc image descriptor to store the image result.
|
||||
* @param buf the buffer to store image data.
|
||||
* @param buff_size provided buffer size in bytes.
|
||||
*
|
||||
* @return LV_RES_OK on success, LV_RES_INV on error.
|
||||
*/
|
||||
lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size)
|
||||
{
|
||||
LV_ASSERT(dsc);
|
||||
LV_ASSERT(buf);
|
||||
|
||||
switch(cf) {
|
||||
case LV_IMG_CF_TRUE_COLOR_ALPHA:
|
||||
case LV_IMG_CF_ALPHA_1BIT:
|
||||
case LV_IMG_CF_ALPHA_2BIT:
|
||||
case LV_IMG_CF_ALPHA_4BIT:
|
||||
case LV_IMG_CF_ALPHA_8BIT:
|
||||
break;
|
||||
default:
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
if(lv_snapshot_buf_size_needed(obj, cf) > buff_size)
|
||||
return LV_RES_INV;
|
||||
|
||||
/*Width and height determine snapshot image size.*/
|
||||
lv_coord_t w = lv_obj_get_width(obj);
|
||||
lv_coord_t h = lv_obj_get_height(obj);
|
||||
lv_coord_t ext_size = _lv_obj_get_ext_draw_size(obj);
|
||||
w += ext_size * 2;
|
||||
h += ext_size * 2;
|
||||
|
||||
/*Backup obj original info.*/
|
||||
lv_obj_t * parent_old = lv_obj_get_parent(obj);
|
||||
lv_area_t coords_bkp;
|
||||
lv_area_copy(&coords_bkp, &obj->coords);
|
||||
|
||||
lv_memset(buf, 0x00, buff_size);
|
||||
lv_memset_00(dsc, sizeof(lv_img_dsc_t));
|
||||
|
||||
/*We are safe to use stack for below variables since disp will be
|
||||
* unregistered when function returns. */
|
||||
lv_disp_t * disp;
|
||||
lv_disp_drv_t driver;
|
||||
lv_disp_draw_buf_t draw_buf;
|
||||
|
||||
lv_disp_draw_buf_init(&draw_buf, buf, NULL, w * h);
|
||||
|
||||
lv_disp_drv_init(&driver);
|
||||
driver.draw_buf = &draw_buf;
|
||||
driver.hor_res = w;
|
||||
driver.ver_res = h;
|
||||
lv_disp_drv_use_generic_set_px_cb(&driver, cf);
|
||||
|
||||
disp = lv_disp_drv_register(&driver);
|
||||
if(disp == NULL) {
|
||||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
/*Make background transparent */
|
||||
lv_disp_set_bg_opa(disp, LV_OPA_TRANSP);
|
||||
|
||||
/*Move obj to newly created disp and refresh it. */
|
||||
lv_obj_t * screen = lv_disp_get_scr_act(disp);
|
||||
lv_obj_remove_style_all(screen);
|
||||
lv_obj_allocate_spec_attr(screen);
|
||||
screen->spec_attr->child_cnt = 1;
|
||||
screen->spec_attr->children = &obj;
|
||||
|
||||
obj->parent = screen;
|
||||
|
||||
disp->inv_p = 0;
|
||||
|
||||
obj->coords.x2 = w - ext_size - 1;
|
||||
obj->coords.x1 = ext_size;
|
||||
obj->coords.y2 = h - ext_size - 1;
|
||||
obj->coords.y1 = ext_size;
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/*Don't call lv_refr_now to avoid animation disruption */
|
||||
_lv_disp_refr_timer(disp->refr_timer);
|
||||
|
||||
/*Restore obj original parameters and clean up*/
|
||||
obj->parent = parent_old;
|
||||
screen->spec_attr->child_cnt = 0;
|
||||
screen->spec_attr->children = NULL;
|
||||
|
||||
lv_disp_remove(disp);
|
||||
|
||||
lv_area_copy(&obj->coords, &coords_bkp);
|
||||
|
||||
dsc->data = buf;
|
||||
dsc->header.w = lv_area_get_width(&draw_buf.area);
|
||||
dsc->header.h = lv_area_get_height(&draw_buf.area);
|
||||
dsc->header.cf = cf;
|
||||
return LV_RES_OK;
|
||||
}
|
||||
|
||||
/** Take snapshot for object with its children, alloc the memory needed.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
*
|
||||
* @return a pointer to a image descriptor, or NULL if failed.
|
||||
*/
|
||||
lv_img_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_img_cf_t cf)
|
||||
{
|
||||
uint32_t buff_size = lv_snapshot_buf_size_needed(obj, cf);
|
||||
|
||||
void * buf = lv_mem_alloc(buff_size);
|
||||
if(buf == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_img_dsc_t * dsc = lv_mem_alloc(sizeof(lv_img_dsc_t));
|
||||
if(dsc == NULL) {
|
||||
lv_mem_free(buf);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(lv_snapshot_take_to_buf(obj, cf, dsc, buf, buff_size) == LV_RES_INV) {
|
||||
lv_mem_free(buf);
|
||||
lv_mem_free(dsc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return dsc;
|
||||
}
|
||||
|
||||
/** Free the snapshot image returned by @ref lv_snapshot_take
|
||||
*
|
||||
* It will firstly free the data image takes, then the image descriptor.
|
||||
*
|
||||
* @param dsc The image descriptor generated by lv_snapshot_take.
|
||||
*
|
||||
*/
|
||||
void lv_snapshot_free(lv_img_dsc_t * dsc)
|
||||
{
|
||||
if(!dsc)
|
||||
return;
|
||||
|
||||
if(dsc->data)
|
||||
lv_mem_free((void *)dsc->data);
|
||||
|
||||
lv_mem_free(dsc);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_SNAPSHOT*/
|
|
@ -0,0 +1,84 @@
|
|||
/**
|
||||
* @file lv_snapshot.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_SNAPSHOT_H
|
||||
#define LV_SNAPSHOT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../../lv_conf_internal.h"
|
||||
#include "../../../core/lv_obj.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
#if LV_USE_SNAPSHOT
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/** Take snapshot for object with its children.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
*
|
||||
* @return a pointer to a image descriptor, or NULL if failed.
|
||||
*/
|
||||
lv_img_dsc_t * lv_snapshot_take(lv_obj_t * obj, lv_img_cf_t cf);
|
||||
|
||||
/** Free the snapshot image returned by @ref lv_snapshot_take
|
||||
*
|
||||
* It will firstly free the data image takes, then the image descriptor.
|
||||
*
|
||||
* @param dsc The image descriptor generated by lv_snapshot_take.
|
||||
*
|
||||
*/
|
||||
void lv_snapshot_free(lv_img_dsc_t * dsc);
|
||||
|
||||
/** Get the buffer needed for object snapshot image.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
*
|
||||
* @return the buffer size needed in bytes
|
||||
*/
|
||||
uint32_t lv_snapshot_buf_size_needed(lv_obj_t * obj, lv_img_cf_t cf);
|
||||
|
||||
/** Take snapshot for object with its children, save image info to provided buffer.
|
||||
*
|
||||
* @param obj The object to generate snapshot.
|
||||
* @param cf color format for generated image.
|
||||
* @param dsc image descriptor to store the image result.
|
||||
* @param buff the buffer to store image data.
|
||||
* @param buff_size provided buffer size in bytes.
|
||||
*
|
||||
* @return LV_RES_OK on success, LV_RES_INV on error.
|
||||
*/
|
||||
lv_res_t lv_snapshot_take_to_buf(lv_obj_t * obj, lv_img_cf_t cf, lv_img_dsc_t * dsc, void * buf, uint32_t buff_size);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
#endif /*LV_USE_SNAPSHOT*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -201,12 +201,12 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_WIN
|
||||
/*Header*/
|
||||
if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->light, 0);
|
||||
return;
|
||||
}
|
||||
/*Content*/
|
||||
else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->light, 0);
|
||||
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
|
||||
return;
|
||||
|
@ -406,8 +406,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_LED
|
||||
else if(lv_obj_check_type(obj, &lv_led_class)) {
|
||||
lv_obj_add_style(obj, &styles->light, 0);
|
||||
}
|
||||
lv_obj_add_style(obj, &styles->light, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file lv_theme_defau.c
|
||||
* @file lv_theme_default.c
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
#define DARK_COLOR_TEXT lv_palette_lighten(LV_PALETTE_GREY, 5)
|
||||
#define DARK_COLOR_GREY lv_color_hex(0x2f3237)
|
||||
|
||||
#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITON_TIME
|
||||
#define TRANSITION_TIME LV_THEME_DEFAULT_TRANSITION_TIME
|
||||
#define BORDER_WIDTH lv_disp_dpx(theme.disp, 2)
|
||||
#define OUTLINE_WIDTH lv_disp_dpx(theme.disp, 3)
|
||||
|
||||
|
@ -74,6 +74,7 @@ typedef struct {
|
|||
lv_style_t transition_delayed;
|
||||
lv_style_t transition_normal;
|
||||
lv_style_t anim;
|
||||
lv_style_t anim_fast;
|
||||
|
||||
/*Parts*/
|
||||
lv_style_t knob;
|
||||
|
@ -117,7 +118,7 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
lv_style_t calendar_bg, calendar_day;
|
||||
lv_style_t calendar_btnm_bg, calendar_btnm_day, calendar_header;
|
||||
#endif
|
||||
|
||||
#if LV_USE_COLORWHEEL
|
||||
|
@ -125,7 +126,7 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
#if LV_USE_MSGBOX
|
||||
lv_style_t msgbox_bg, msgbox_btn_bg;
|
||||
lv_style_t msgbox_bg, msgbox_btn_bg, msgbox_backdrop_bg;
|
||||
#endif
|
||||
|
||||
#if LV_USE_KEYBOARD
|
||||
|
@ -146,14 +147,14 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
lv_theme_t base;
|
||||
uint8_t light :1;
|
||||
}my_theme_t;
|
||||
uint8_t light : 1;
|
||||
} my_theme_t;
|
||||
|
||||
typedef enum {
|
||||
DISP_SMALL = 3,
|
||||
DISP_MEDIUM = 2,
|
||||
DISP_LARGE = 1,
|
||||
}disp_size_t;
|
||||
} disp_size_t;
|
||||
|
||||
/**********************
|
||||
* STATIC PROTOTYPES
|
||||
|
@ -199,12 +200,12 @@ static lv_color_t grey_filter_cb(const lv_color_filter_dsc_t * f, lv_color_t col
|
|||
static void style_init(void)
|
||||
{
|
||||
static const lv_style_prop_t trans_props[] = {
|
||||
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
|
||||
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
|
||||
LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X,
|
||||
LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE,
|
||||
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC,
|
||||
0
|
||||
LV_STYLE_BG_OPA, LV_STYLE_BG_COLOR,
|
||||
LV_STYLE_TRANSFORM_WIDTH, LV_STYLE_TRANSFORM_HEIGHT,
|
||||
LV_STYLE_TRANSLATE_Y, LV_STYLE_TRANSLATE_X,
|
||||
LV_STYLE_TRANSFORM_ZOOM, LV_STYLE_TRANSFORM_ANGLE,
|
||||
LV_STYLE_COLOR_FILTER_OPA, LV_STYLE_COLOR_FILTER_DSC,
|
||||
0
|
||||
};
|
||||
|
||||
color_scr = theme.flags & MODE_DARK ? DARK_COLOR_SCR : LIGHT_COLOR_SCR;
|
||||
|
@ -225,7 +226,8 @@ static void style_init(void)
|
|||
lv_style_set_transition(&styles->transition_normal, &trans_normal); /*Go back to default state with delay*/
|
||||
|
||||
style_init_reset(&styles->scrollbar);
|
||||
lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_bg_color(&styles->scrollbar, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY,
|
||||
2) : lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_radius(&styles->scrollbar, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_pad_right(&styles->scrollbar, lv_disp_dpx(theme.disp, 7));
|
||||
lv_style_set_pad_top(&styles->scrollbar, lv_disp_dpx(theme.disp, 7));
|
||||
|
@ -269,13 +271,15 @@ static void style_init(void)
|
|||
lv_style_set_outline_opa(&styles->outline_secondary, LV_OPA_50);
|
||||
|
||||
style_init_reset(&styles->btn);
|
||||
lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp, 16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)));
|
||||
lv_style_set_radius(&styles->btn, (disp_size == DISP_LARGE ? lv_disp_dpx(theme.disp,
|
||||
16) : disp_size == DISP_MEDIUM ? lv_disp_dpx(theme.disp, 12) : lv_disp_dpx(theme.disp, 8)));
|
||||
lv_style_set_bg_opa(&styles->btn, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->btn, color_grey);
|
||||
if(!(theme.flags & MODE_DARK)) {
|
||||
lv_style_set_shadow_color(&styles->btn, lv_palette_lighten(LV_PALETTE_GREY, 3));
|
||||
lv_style_set_shadow_width(&styles->btn, 1);
|
||||
lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, 4));
|
||||
lv_style_set_shadow_color(&styles->btn, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_shadow_width(&styles->btn, LV_DPX(3));
|
||||
lv_style_set_shadow_opa(&styles->btn, LV_OPA_50);
|
||||
lv_style_set_shadow_ofs_y(&styles->btn, lv_disp_dpx(theme.disp, LV_DPX(4)));
|
||||
}
|
||||
lv_style_set_text_color(&styles->btn, color_text);
|
||||
lv_style_set_pad_hor(&styles->btn, PAD_DEF);
|
||||
|
@ -299,6 +303,7 @@ static void style_init(void)
|
|||
|
||||
style_init_reset(&styles->clip_corner);
|
||||
lv_style_set_clip_corner(&styles->clip_corner, true);
|
||||
lv_style_set_border_post(&styles->clip_corner, true);
|
||||
|
||||
style_init_reset(&styles->pad_normal);
|
||||
lv_style_set_pad_all(&styles->pad_normal, PAD_DEF);
|
||||
|
@ -380,6 +385,9 @@ static void style_init(void)
|
|||
style_init_reset(&styles->anim);
|
||||
lv_style_set_anim_time(&styles->anim, 200);
|
||||
|
||||
style_init_reset(&styles->anim_fast);
|
||||
lv_style_set_anim_time(&styles->anim_fast, 120);
|
||||
|
||||
#if LV_USE_ARC
|
||||
style_init_reset(&styles->arc_indic);
|
||||
lv_style_set_arc_color(&styles->arc_indic, color_grey);
|
||||
|
@ -434,7 +442,7 @@ static void style_init(void)
|
|||
lv_style_set_pad_column(&styles->chart_series, lv_disp_dpx(theme.disp, 2));
|
||||
|
||||
style_init_reset(&styles->chart_indic);
|
||||
lv_style_set_radius(&styles->chart_indic,LV_RADIUS_CIRCLE);
|
||||
lv_style_set_radius(&styles->chart_indic, LV_RADIUS_CIRCLE);
|
||||
lv_style_set_size(&styles->chart_indic, lv_disp_dpx(theme.disp, 8));
|
||||
lv_style_set_bg_color(&styles->chart_indic, theme.color_primary);
|
||||
lv_style_set_bg_opa(&styles->chart_indic, LV_OPA_COVER);
|
||||
|
@ -464,32 +472,38 @@ static void style_init(void)
|
|||
style_init_reset(&styles->table_cell);
|
||||
lv_style_set_border_width(&styles->table_cell, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->table_cell, color_grey);
|
||||
lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM );
|
||||
lv_style_set_border_side(&styles->table_cell, LV_BORDER_SIDE_TOP | LV_BORDER_SIDE_BOTTOM);
|
||||
#endif
|
||||
|
||||
#if LV_USE_TEXTAREA
|
||||
style_init_reset(&styles->ta_cursor);
|
||||
lv_style_set_border_color(&styles->ta_cursor, color_text);
|
||||
lv_style_set_border_width(&styles->ta_cursor, lv_disp_dpx(theme.disp, 2));
|
||||
lv_style_set_pad_left(&styles->ta_cursor, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_pad_left(&styles->ta_cursor, - lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_side(&styles->ta_cursor, LV_BORDER_SIDE_LEFT);
|
||||
lv_style_set_anim_time(&styles->ta_cursor, 400);
|
||||
|
||||
style_init_reset(&styles->ta_placeholder);
|
||||
lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY, 2) : lv_palette_lighten(LV_PALETTE_GREY, 1));
|
||||
lv_style_set_text_color(&styles->ta_placeholder, (theme.flags & MODE_DARK) ? lv_palette_darken(LV_PALETTE_GREY,
|
||||
2) : lv_palette_lighten(LV_PALETTE_GREY, 1));
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
style_init_reset(&styles->calendar_bg);
|
||||
lv_style_set_pad_all(&styles->calendar_bg, PAD_SMALL);
|
||||
lv_style_set_pad_gap(&styles->calendar_bg, PAD_SMALL / 2);
|
||||
lv_style_set_radius(&styles->calendar_bg, 0);
|
||||
style_init_reset(&styles->calendar_btnm_bg);
|
||||
lv_style_set_pad_all(&styles->calendar_btnm_bg, PAD_SMALL);
|
||||
lv_style_set_pad_gap(&styles->calendar_btnm_bg, PAD_SMALL / 2);
|
||||
|
||||
style_init_reset(&styles->calendar_day);
|
||||
lv_style_set_border_width(&styles->calendar_day, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->calendar_day, color_grey);
|
||||
lv_style_set_bg_color(&styles->calendar_day, color_card);
|
||||
lv_style_set_bg_opa(&styles->calendar_day, LV_OPA_20);
|
||||
style_init_reset(&styles->calendar_btnm_day);
|
||||
lv_style_set_border_width(&styles->calendar_btnm_day, lv_disp_dpx(theme.disp, 1));
|
||||
lv_style_set_border_color(&styles->calendar_btnm_day, color_grey);
|
||||
lv_style_set_bg_color(&styles->calendar_btnm_day, color_card);
|
||||
lv_style_set_bg_opa(&styles->calendar_btnm_day, LV_OPA_20);
|
||||
|
||||
style_init_reset(&styles->calendar_header);
|
||||
lv_style_set_pad_hor(&styles->calendar_header, PAD_SMALL);
|
||||
lv_style_set_pad_top(&styles->calendar_header, PAD_SMALL);
|
||||
lv_style_set_pad_bottom(&styles->calendar_header, PAD_TINY);
|
||||
lv_style_set_pad_gap(&styles->calendar_header, PAD_SMALL);
|
||||
#endif
|
||||
|
||||
#if LV_USE_COLORWHEEL
|
||||
|
@ -504,6 +518,10 @@ static void style_init(void)
|
|||
|
||||
style_init_reset(&styles->msgbox_bg);
|
||||
lv_style_set_max_width(&styles->msgbox_bg, lv_pct(100));
|
||||
|
||||
style_init_reset(&styles->msgbox_backdrop_bg);
|
||||
lv_style_set_bg_color(&styles->msgbox_backdrop_bg, lv_palette_main(LV_PALETTE_GREY));
|
||||
lv_style_set_bg_opa(&styles->msgbox_backdrop_bg, LV_OPA_50);
|
||||
#endif
|
||||
#if LV_USE_KEYBOARD
|
||||
style_init_reset(&styles->keyboard_btn_bg);
|
||||
|
@ -556,7 +574,8 @@ static void style_init(void)
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font)
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark,
|
||||
const lv_font_t * font)
|
||||
{
|
||||
|
||||
/*This trick is required only to avoid the garbage collection of
|
||||
|
@ -589,6 +608,13 @@ lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, l
|
|||
return (lv_theme_t *)&theme;
|
||||
}
|
||||
|
||||
lv_theme_t * lv_theme_default_get(void)
|
||||
{
|
||||
if(!inited) return NULL;
|
||||
|
||||
return (lv_theme_t *)&theme;
|
||||
}
|
||||
|
||||
bool lv_theme_default_is_inited(void)
|
||||
{
|
||||
return inited;
|
||||
|
@ -624,13 +650,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_WIN
|
||||
/*Header*/
|
||||
if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->bg_color_grey, 0);
|
||||
lv_obj_add_style(obj, &styles->pad_tiny, 0);
|
||||
return;
|
||||
}
|
||||
/*Content*/
|
||||
else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->scr, 0);
|
||||
lv_obj_add_style(obj, &styles->pad_normal, 0);
|
||||
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
|
||||
|
@ -638,11 +664,20 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
else if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
|
||||
/*No style*/
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
|
||||
lv_obj_add_style(obj, &styles->scrollbar_scrolled, LV_PART_SCROLLBAR | LV_STATE_SCROLLED);
|
||||
}
|
||||
#if LV_USE_BTN
|
||||
#if LV_USE_BTN
|
||||
else if(lv_obj_check_type(obj, &lv_btn_class)) {
|
||||
lv_obj_add_style(obj, &styles->btn, 0);
|
||||
lv_obj_add_style(obj, &styles->bg_color_primary, 0);
|
||||
|
@ -693,6 +728,20 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR
|
||||
if(lv_obj_check_type(lv_obj_get_parent(obj), &lv_calendar_class)) {
|
||||
lv_obj_add_style(obj, &styles->calendar_btnm_bg, 0);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
|
||||
lv_obj_add_style(obj, &styles->calendar_btnm_day, LV_PART_ITEMS);
|
||||
lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
|
||||
lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
|
||||
|
@ -772,6 +821,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
else if(lv_obj_check_type(obj, &lv_switch_class)) {
|
||||
lv_obj_add_style(obj, &styles->bg_color_grey, 0);
|
||||
lv_obj_add_style(obj, &styles->circle, 0);
|
||||
lv_obj_add_style(obj, &styles->anim_fast, 0);
|
||||
lv_obj_add_style(obj, &styles->disabled, LV_STATE_DISABLED);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->bg_color_primary, LV_PART_INDICATOR | LV_STATE_CHECKED);
|
||||
|
@ -781,6 +831,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
lv_obj_add_style(obj, &styles->bg_color_white, LV_PART_KNOB);
|
||||
lv_obj_add_style(obj, &styles->switch_knob, LV_PART_KNOB);
|
||||
lv_obj_add_style(obj, &styles->disabled, LV_PART_KNOB | LV_STATE_DISABLED);
|
||||
|
||||
lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR | LV_STATE_CHECKED);
|
||||
lv_obj_add_style(obj, &styles->transition_normal, LV_PART_INDICATOR);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -876,26 +929,19 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
#if LV_USE_CALENDAR
|
||||
else if(lv_obj_check_type(obj, &lv_calendar_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->calendar_bg, 0);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_STATE_EDITED);
|
||||
lv_obj_add_style(obj, &styles->calendar_day, LV_PART_ITEMS);
|
||||
lv_obj_add_style(obj, &styles->pressed, LV_PART_ITEMS | LV_STATE_PRESSED);
|
||||
lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
|
||||
lv_obj_add_style(obj, &styles->outline_primary, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->outline_secondary, LV_PART_ITEMS | LV_STATE_EDITED);
|
||||
lv_obj_add_style(obj, &styles->pad_zero, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_ARROW
|
||||
else if(lv_obj_check_type(obj, &lv_calendar_header_arrow_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->calendar_header, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_CALENDAR_HEADER_DROPDOWN
|
||||
else if(lv_obj_check_type(obj, &lv_calendar_header_dropdown_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->calendar_header, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -943,6 +989,9 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
lv_obj_add_style(obj, &styles->msgbox_bg, 0);
|
||||
return;
|
||||
}
|
||||
else if(lv_obj_check_type(obj, &lv_msgbox_backdrop_class)) {
|
||||
lv_obj_add_style(obj, &styles->msgbox_backdrop_bg, 0);
|
||||
}
|
||||
#endif
|
||||
#if LV_USE_SPINBOX
|
||||
else if(lv_obj_check_type(obj, &lv_spinbox_class)) {
|
||||
|
@ -966,10 +1015,15 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
#endif
|
||||
|
||||
#if LV_USE_TABVIEW
|
||||
if(lv_obj_check_type(obj, &lv_tabview_class)) {
|
||||
else if(lv_obj_check_type(obj, &lv_tabview_class)) {
|
||||
lv_obj_add_style(obj, &styles->scr, 0);
|
||||
lv_obj_add_style(obj, &styles->pad_zero, 0);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LV_USE_WIN
|
||||
else if(lv_obj_check_type(obj, &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->clip_corner, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -984,8 +1038,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_LED
|
||||
else if(lv_obj_check_type(obj, &lv_led_class)) {
|
||||
lv_obj_add_style(obj, &styles->led, 0);
|
||||
}
|
||||
lv_obj_add_style(obj, &styles->led, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,19 @@ extern "C" {
|
|||
* @param font pointer to a font to use.
|
||||
* @return a pointer to reference this theme later
|
||||
*/
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font);
|
||||
lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark,
|
||||
const lv_font_t * font);
|
||||
|
||||
/**
|
||||
* Get default theme
|
||||
* @return a pointer to default theme, or NULL if this is not initialized
|
||||
*/
|
||||
lv_theme_t * lv_theme_default_get(void);
|
||||
|
||||
/**
|
||||
* Check if default theme is initialized
|
||||
* @return true if default theme is initialized, false otherwise
|
||||
*/
|
||||
bool lv_theme_default_is_inited(void);
|
||||
|
||||
/**********************
|
||||
|
|
|
@ -78,7 +78,7 @@ static void style_init(bool dark_bg, const lv_font_t * font)
|
|||
{
|
||||
style_init_reset(&styles->scrollbar);
|
||||
lv_style_set_bg_opa(&styles->scrollbar, LV_OPA_COVER);
|
||||
lv_style_set_bg_color(&styles->scrollbar,COLOR_FG);
|
||||
lv_style_set_bg_color(&styles->scrollbar, COLOR_FG);
|
||||
lv_style_set_width(&styles->scrollbar, PAD_DEF);
|
||||
|
||||
style_init_reset(&styles->scr);
|
||||
|
@ -219,13 +219,13 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_WIN
|
||||
/*Header*/
|
||||
if(lv_obj_get_child_id(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
if(lv_obj_get_index(obj) == 0 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->no_radius, 0);
|
||||
return;
|
||||
}
|
||||
/*Content*/
|
||||
else if(lv_obj_get_child_id(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
else if(lv_obj_get_index(obj) == 1 && lv_obj_check_type(lv_obj_get_parent(obj), &lv_win_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
lv_obj_add_style(obj, &styles->no_radius, 0);
|
||||
lv_obj_add_style(obj, &styles->scrollbar, LV_PART_SCROLLBAR);
|
||||
|
@ -279,7 +279,7 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
lv_obj_add_style(obj, &styles->inv, LV_PART_ITEMS | LV_STATE_CHECKED);
|
||||
lv_obj_add_style(obj, &styles->disabled, LV_PART_ITEMS | LV_STATE_DISABLED);
|
||||
lv_obj_add_style(obj, &styles->underline, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
lv_obj_add_style(obj, &styles->large_border, LV_PART_ITEMS | LV_STATE_FOCUS_KEY);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -476,8 +476,8 @@ static void theme_apply(lv_theme_t * th, lv_obj_t * obj)
|
|||
|
||||
#if LV_USE_LED
|
||||
else if(lv_obj_check_type(obj, &lv_led_class)) {
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
}
|
||||
lv_obj_add_style(obj, &styles->card, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*********************/
|
||||
#define LV_OBJX_NAME "lv_animimg"
|
||||
|
||||
#define MY_CLASS &lv_animimg_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -56,7 +58,7 @@ const lv_obj_class_t lv_animimg_class = {
|
|||
|
||||
lv_obj_t * lv_animimg_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_animimg_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -64,14 +66,16 @@ lv_obj_t * lv_animimg_create(lv_obj_t * parent)
|
|||
|
||||
void lv_animimg_set_src(lv_obj_t * obj, lv_img_dsc_t * dsc[], uint8_t num)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_animimg_t * animimg = (lv_animimg_t *)obj;
|
||||
animimg->dsc = dsc;
|
||||
animimg->pic_count = num;
|
||||
lv_anim_set_values(&animimg->anim, 0 , num);
|
||||
lv_anim_set_values(&animimg->anim, 0, num);
|
||||
}
|
||||
|
||||
void lv_animimg_start(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_animimg_t * animimg = (lv_animimg_t *)obj;
|
||||
lv_anim_start(&animimg->anim);
|
||||
}
|
||||
|
@ -82,6 +86,7 @@ void lv_animimg_start(lv_obj_t * obj)
|
|||
|
||||
void lv_animimg_set_duration(lv_obj_t * obj, uint32_t duration)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_animimg_t * animimg = (lv_animimg_t *)obj;
|
||||
lv_anim_set_time(&animimg->anim, duration);
|
||||
lv_anim_set_playback_delay(&animimg->anim, duration);
|
||||
|
@ -89,6 +94,7 @@ void lv_animimg_set_duration(lv_obj_t * obj, uint32_t duration)
|
|||
|
||||
void lv_animimg_set_repeat_count(lv_obj_t * obj, uint16_t count)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_animimg_t * animimg = (lv_animimg_t *)obj;
|
||||
lv_anim_set_repeat_count(&animimg->anim, count);
|
||||
}
|
||||
|
@ -115,7 +121,7 @@ static void lv_animimg_constructor(const lv_obj_class_t * class_p, lv_obj_t * ob
|
|||
lv_anim_set_var(&animimg->anim, obj);
|
||||
lv_anim_set_time(&animimg->anim, 30);
|
||||
lv_anim_set_exec_cb(&animimg->anim, (lv_anim_exec_xcb_t)index_change);
|
||||
lv_anim_set_values(&animimg->anim, 0 , 1);
|
||||
lv_anim_set_values(&animimg->anim, 0, 1);
|
||||
lv_anim_set_repeat_count(&animimg->anim, LV_ANIM_REPEAT_INFINITE);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ extern "C" {
|
|||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_USE_IMG == 0
|
||||
#error "lv_animing: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1)"
|
||||
#error "lv_animimg: lv_img is required. Enable it in lv_conf.h (LV_USE_IMG 1)"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
|
@ -37,8 +37,8 @@ typedef struct {
|
|||
lv_img_t img;
|
||||
lv_anim_t anim;
|
||||
/*picture sequence */
|
||||
lv_img_dsc_t **dsc;
|
||||
int8_t pic_count;
|
||||
lv_img_dsc_t ** dsc;
|
||||
int8_t pic_count;
|
||||
} lv_animimg_t;
|
||||
|
||||
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
#include "../../../lvgl.h"
|
||||
#if LV_USE_CALENDAR
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_CALENDAR_CTRL_TODAY LV_BTNMATRIX_CTRL_CUSTOM_1
|
||||
#define LV_CALENDAR_CTRL_HIGHLIGHT LV_BTNMATRIX_CTRL_CUSTOM_2
|
||||
|
||||
#define MY_CLASS &lv_calendar_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -37,13 +41,12 @@ static void highlight_update(lv_obj_t * calendar);
|
|||
const lv_obj_class_t lv_calendar_class = {
|
||||
.constructor_cb = lv_calendar_constructor,
|
||||
.width_def = (LV_DPI_DEF * 3) / 2,
|
||||
.height_def =(LV_DPI_DEF * 3) / 2,
|
||||
.height_def = (LV_DPI_DEF * 3) / 2,
|
||||
.group_def = LV_OBJ_CLASS_GROUP_DEF_TRUE,
|
||||
.instance_size = sizeof(lv_calendar_t),
|
||||
.base_class = &lv_btnmatrix_class
|
||||
.base_class = &lv_obj_class
|
||||
};
|
||||
|
||||
|
||||
static const char * day_names_def[7] = LV_CALENDAR_DEFAULT_DAY_NAMES;
|
||||
|
||||
/**********************
|
||||
|
@ -56,7 +59,7 @@ static const char * day_names_def[7] = LV_CALENDAR_DEFAULT_DAY_NAMES;
|
|||
|
||||
lv_obj_t * lv_calendar_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_calendar_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -68,16 +71,21 @@ lv_obj_t * lv_calendar_create(lv_obj_t * parent)
|
|||
|
||||
void lv_calendar_set_day_names(lv_obj_t * obj, const char * day_names[])
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
uint32_t i;
|
||||
for(i = 0; i < 7; i++) {
|
||||
calendar->map[i] = day_names[i];
|
||||
}
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_calendar_set_today_date(lv_obj_t * obj, uint32_t year, uint32_t month, uint32_t day)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
calendar->today.year = year;
|
||||
calendar->today.month = month;
|
||||
calendar->today.day = day;
|
||||
|
@ -89,7 +97,9 @@ void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highli
|
|||
{
|
||||
LV_ASSERT_NULL(highlighted);
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
calendar->highlighted_dates = highlighted;
|
||||
calendar->highlighted_dates_num = date_num;
|
||||
|
||||
|
@ -98,7 +108,9 @@ void lv_calendar_set_highlighted_dates(lv_obj_t * obj, lv_calendar_date_t highli
|
|||
|
||||
void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
calendar->showed_date.year = year;
|
||||
calendar->showed_date.month = month;
|
||||
calendar->showed_date.day = 1;
|
||||
|
@ -111,9 +123,9 @@ void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month)
|
|||
uint8_t i;
|
||||
|
||||
/*Remove the disabled state but revert it for day names*/
|
||||
lv_btnmatrix_clear_btn_ctrl_all(obj, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
lv_btnmatrix_clear_btn_ctrl_all(calendar->btnm, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
for(i = 0; i < 7; i++) {
|
||||
lv_btnmatrix_set_btn_ctrl(obj, i, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
lv_btnmatrix_set_btn_ctrl(calendar->btnm, i, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
}
|
||||
|
||||
uint8_t act_mo_len = get_month_length(d.year, d.month);
|
||||
|
@ -126,65 +138,82 @@ void lv_calendar_set_showed_date(lv_obj_t * obj, uint32_t year, uint32_t month)
|
|||
uint8_t prev_mo_len = get_month_length(d.year, d.month - 1);
|
||||
for(i = 0, c = prev_mo_len - day_first + 1; i < day_first; i++, c++) {
|
||||
lv_snprintf(calendar->nums[i], sizeof(calendar->nums[0]), "%d", c);
|
||||
lv_btnmatrix_set_btn_ctrl(obj, i + 7, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
lv_btnmatrix_set_btn_ctrl(calendar->btnm, i + 7, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
}
|
||||
|
||||
for(i = day_first + act_mo_len, c = 1; i < 6 * 7; i++, c++) {
|
||||
lv_snprintf(calendar->nums[i], sizeof(calendar->nums[0]), "%d", c);
|
||||
lv_btnmatrix_set_btn_ctrl(obj, i + 7, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
lv_btnmatrix_set_btn_ctrl(calendar->btnm, i + 7, LV_BTNMATRIX_CTRL_DISABLED);
|
||||
}
|
||||
|
||||
highlight_update(obj);
|
||||
|
||||
/*Reset the focused button if the days changes*/
|
||||
if(lv_btnmatrix_get_selected_btn(calendar->btnm) != LV_BTNMATRIX_BTN_NONE) {
|
||||
lv_btnmatrix_set_selected_btn(calendar->btnm, day_first + 7);
|
||||
}
|
||||
|
||||
lv_obj_invalidate(obj);
|
||||
|
||||
/* The children of the calendar are probably headers.
|
||||
* Notify them to let the headers updated to the new date*/
|
||||
uint32_t child_cnt = lv_obj_get_child_cnt(obj);
|
||||
for(i = 0; i < child_cnt; i++) {
|
||||
lv_obj_t * child = lv_obj_get_child(obj, i);
|
||||
if(child == calendar->btnm) continue;
|
||||
lv_event_send(child, LV_EVENT_VALUE_CHANGED, obj);
|
||||
}
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return return pointer to an `lv_calendar_date_t` variable containing the date of today.
|
||||
*/
|
||||
lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
const lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
return calendar->btnm;
|
||||
}
|
||||
|
||||
const lv_calendar_date_t * lv_calendar_get_today_date(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
const lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
return &calendar->today;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently showed
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` variable containing the date is being shown.
|
||||
*/
|
||||
const lv_calendar_date_t * lv_calendar_get_showed_date(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
const lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
return &calendar->showed_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the the highlighted dates
|
||||
* @param calendar pointer to a calendar object
|
||||
* @return pointer to an `lv_calendar_date_t` array containing the dates.
|
||||
*/
|
||||
lv_calendar_date_t * lv_calendar_get_highlighted_dates(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
return calendar->highlighted_dates;
|
||||
}
|
||||
|
||||
uint16_t lv_calendar_get_highlighted_dates_num(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
return calendar->highlighted_dates_num;
|
||||
}
|
||||
|
||||
lv_res_t lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t * date)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
uint16_t d = lv_btnmatrix_get_selected_btn(obj);
|
||||
|
||||
uint16_t d = lv_btnmatrix_get_selected_btn(calendar->btnm);
|
||||
if(d == LV_BTNMATRIX_BTN_NONE) {
|
||||
date->year = 0;
|
||||
date->month = 0;
|
||||
|
@ -192,7 +221,7 @@ lv_res_t lv_calendar_get_pressed_date(const lv_obj_t * obj, lv_calendar_date_t *
|
|||
return LV_RES_INV;
|
||||
}
|
||||
|
||||
const char * txt = lv_btnmatrix_get_btn_text(obj, lv_btnmatrix_get_selected_btn(obj));
|
||||
const char * txt = lv_btnmatrix_get_btn_text(calendar->btnm, lv_btnmatrix_get_selected_btn(calendar->btnm));
|
||||
|
||||
if(txt[1] == 0) date->day = txt[0] - '0';
|
||||
else date->day = (txt[0] - '0') * 10 + (txt[1] - '0');
|
||||
|
@ -232,9 +261,11 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
|||
/*Every 8th string is "\n"*/
|
||||
if(i != 0 && (i + 1) % 8 == 0) {
|
||||
calendar->map[i] = "\n";
|
||||
} else if(i < 8){
|
||||
}
|
||||
else if(i < 8) {
|
||||
calendar->map[i] = day_names_def[i];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
calendar->nums[j][0] = 'x';
|
||||
calendar->map[i] = calendar->nums[j];
|
||||
j++;
|
||||
|
@ -242,14 +273,19 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
|||
}
|
||||
calendar->map[8 * 7 - 1] = "";
|
||||
|
||||
lv_btnmatrix_set_map(obj, calendar->map);
|
||||
lv_btnmatrix_set_btn_ctrl_all(obj, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
|
||||
calendar->btnm = lv_btnmatrix_create(obj);
|
||||
lv_btnmatrix_set_map(calendar->btnm, calendar->map);
|
||||
lv_btnmatrix_set_btn_ctrl_all(calendar->btnm, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
|
||||
lv_obj_add_event_cb(calendar->btnm, draw_part_begin_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||
lv_obj_set_width(calendar->btnm, lv_pct(100));
|
||||
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_grow(calendar->btnm, 1);
|
||||
|
||||
lv_calendar_set_showed_date(obj, calendar->showed_date.year, calendar->showed_date.month);
|
||||
lv_calendar_set_today_date(obj, calendar->today.year, calendar->today.month, calendar->today.day);
|
||||
|
||||
lv_obj_add_event_cb(obj, draw_part_begin_event_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||
lv_obj_add_flag(calendar->btnm, LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
}
|
||||
|
||||
static void draw_part_begin_event_cb(lv_event_t * e)
|
||||
|
@ -285,9 +321,6 @@ static void draw_part_begin_event_cb(lv_event_t * e)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of days in a month
|
||||
* @param year a year
|
||||
|
@ -339,7 +372,7 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day)
|
|||
uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7;
|
||||
#endif
|
||||
|
||||
return day_of_week;
|
||||
return day_of_week ;
|
||||
}
|
||||
|
||||
static void highlight_update(lv_obj_t * obj)
|
||||
|
@ -348,19 +381,20 @@ static void highlight_update(lv_obj_t * obj)
|
|||
uint16_t i;
|
||||
|
||||
/*Clear all kind of selection*/
|
||||
lv_btnmatrix_clear_btn_ctrl_all(obj, LV_CALENDAR_CTRL_TODAY | LV_CALENDAR_CTRL_HIGHLIGHT);
|
||||
lv_btnmatrix_clear_btn_ctrl_all(calendar->btnm, LV_CALENDAR_CTRL_TODAY | LV_CALENDAR_CTRL_HIGHLIGHT);
|
||||
|
||||
uint8_t day_first = get_day_of_week(calendar->showed_date.year, calendar->showed_date.month, 1);
|
||||
if(calendar->highlighted_dates) {
|
||||
for(i = 0; i < calendar->highlighted_dates_num; i++) {
|
||||
if(calendar->highlighted_dates[i].year == calendar->today.year && calendar->highlighted_dates[i].month == calendar->showed_date.month) {
|
||||
lv_btnmatrix_set_btn_ctrl(obj, calendar->highlighted_dates[i].day + 7, LV_CALENDAR_CTRL_HIGHLIGHT);
|
||||
if(calendar->highlighted_dates[i].year == calendar->showed_date.year &&
|
||||
calendar->highlighted_dates[i].month == calendar->showed_date.month) {
|
||||
lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->highlighted_dates[i].day - 1 + day_first + 7, LV_CALENDAR_CTRL_HIGHLIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(calendar->showed_date.year == calendar->today.year && calendar->showed_date.month == calendar->today.month) {
|
||||
uint8_t day_first = get_day_of_week(calendar->today.year, calendar->today.month, 0);
|
||||
lv_btnmatrix_set_btn_ctrl(obj, calendar->today.day + day_first + 7, LV_CALENDAR_CTRL_TODAY);
|
||||
lv_btnmatrix_set_btn_ctrl(calendar->btnm, calendar->today.day - 1 + day_first + 7, LV_CALENDAR_CTRL_TODAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,13 @@ typedef struct {
|
|||
|
||||
/*Data of calendar*/
|
||||
typedef struct {
|
||||
lv_btnmatrix_t btnm;
|
||||
lv_obj_t obj;
|
||||
lv_obj_t * btnm;
|
||||
/*New data for this type*/
|
||||
lv_calendar_date_t today; /*Date of today*/
|
||||
lv_calendar_date_t showed_date; /*Currently visible month (day is ignored)*/
|
||||
lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/
|
||||
lv_calendar_date_t *
|
||||
highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/
|
||||
uint16_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/
|
||||
const char * map[8 * 7];
|
||||
char nums [7 * 6][4];
|
||||
|
@ -101,6 +103,14 @@ void lv_calendar_set_day_names(lv_obj_t * obj, const char ** day_names);
|
|||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get the button matrix object of the calendar.
|
||||
* It shows the dates and day names.
|
||||
* @param obj pointer to a calendar object
|
||||
* @return pointer to a the button matrix
|
||||
*/
|
||||
lv_obj_t * lv_calendar_get_btnmatrix(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the today's date
|
||||
* @param calendar pointer to a calendar object
|
||||
|
|
|
@ -27,18 +27,19 @@
|
|||
**********************/
|
||||
static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void month_event_cb(lv_event_t * e);
|
||||
static void value_changed_event_cb(lv_event_t * e);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_calendar_header_arrow_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.constructor_cb = my_constructor
|
||||
.base_class = &lv_obj_class,
|
||||
.constructor_cb = my_constructor,
|
||||
.width_def = LV_PCT(100),
|
||||
.height_def = LV_DPI_DEF / 3
|
||||
};
|
||||
|
||||
static const char * month_names_def[12] = LV_CALENDAR_DEFAULT_MONTH_NAMES;
|
||||
static lv_obj_t * calendar_param;
|
||||
static lv_coord_t btn_size_param;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -48,10 +49,8 @@ static lv_coord_t btn_size_param;
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calendar, lv_coord_t btn_size)
|
||||
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent)
|
||||
{
|
||||
calendar_param = calendar;
|
||||
btn_size_param = btn_size;
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_calendar_header_arrow_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -67,41 +66,36 @@ static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
/*Use the same paddings as the calendar_param*/
|
||||
lv_obj_set_style_pad_left(obj, lv_obj_get_style_pad_left(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_right(obj, lv_obj_get_style_pad_right(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_top(obj, lv_obj_get_style_pad_top(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_bottom(obj, lv_obj_get_style_pad_bottom(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_column(obj, lv_obj_get_style_pad_column(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_radius(obj, lv_obj_get_style_radius(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_move_to_index(obj, 0);
|
||||
|
||||
const lv_calendar_date_t * cur_date = lv_calendar_get_showed_date(calendar_param);
|
||||
|
||||
lv_obj_update_layout(calendar_param);
|
||||
lv_coord_t w = lv_obj_get_width(calendar_param);
|
||||
lv_obj_set_size(obj, w, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
|
||||
lv_obj_t * mo_prev = lv_btn_create(obj);
|
||||
lv_obj_set_style_bg_img_src(mo_prev, LV_SYMBOL_LEFT, 0);
|
||||
lv_obj_set_size(mo_prev, btn_size_param, btn_size_param);
|
||||
lv_obj_add_event_cb(mo_prev, month_event_cb, LV_EVENT_CLICKED, calendar_param);
|
||||
lv_obj_set_height(mo_prev, lv_pct(100));
|
||||
lv_obj_update_layout(mo_prev);
|
||||
lv_coord_t btn_size = lv_obj_get_height(mo_prev);
|
||||
lv_obj_set_width(mo_prev, btn_size);
|
||||
|
||||
lv_obj_add_event_cb(mo_prev, month_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_clear_flag(mo_prev, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
lv_obj_t * label = lv_label_create(obj);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_CENTER, 0);
|
||||
lv_obj_set_flex_grow(label, 1);
|
||||
lv_label_set_text_fmt(label, "%d %s", cur_date->year, month_names_def[cur_date->month - 1]);
|
||||
|
||||
lv_obj_t * mo_next = lv_btn_create(obj);
|
||||
lv_obj_set_style_bg_img_src(mo_next, LV_SYMBOL_RIGHT, 0);
|
||||
lv_obj_set_size(mo_next, btn_size_param, btn_size_param);
|
||||
lv_obj_add_event_cb(mo_next, month_event_cb, LV_EVENT_CLICKED, calendar_param);
|
||||
lv_obj_set_size(mo_next, btn_size, btn_size);
|
||||
|
||||
lv_obj_add_event_cb(mo_next, month_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_clear_flag(mo_next, LV_OBJ_FLAG_CLICK_FOCUSABLE);
|
||||
|
||||
lv_obj_align_to(obj, calendar_param, LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||
lv_obj_add_event_cb(obj, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
/*Refresh the drop downs*/
|
||||
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void month_event_cb(lv_event_t * e)
|
||||
|
@ -109,7 +103,7 @@ static void month_event_cb(lv_event_t * e)
|
|||
lv_obj_t * btn = lv_event_get_target(e);
|
||||
|
||||
lv_obj_t * header = lv_obj_get_parent(btn);
|
||||
lv_obj_t * calendar = lv_event_get_user_data(e);
|
||||
lv_obj_t * calendar = lv_obj_get_parent(header);
|
||||
|
||||
const lv_calendar_date_t * d;
|
||||
d = lv_calendar_get_showed_date(calendar);
|
||||
|
@ -120,14 +114,17 @@ static void month_event_cb(lv_event_t * e)
|
|||
if(newd.month == 1) {
|
||||
newd.month = 12;
|
||||
newd.year --;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
newd.month --;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(newd.month == 12) {
|
||||
newd.month = 1;
|
||||
newd.year ++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
newd.month ++;
|
||||
}
|
||||
}
|
||||
|
@ -138,5 +135,15 @@ static void month_event_cb(lv_event_t * e)
|
|||
lv_label_set_text_fmt(label, "%d %s", newd.year, month_names_def[newd.month - 1]);
|
||||
}
|
||||
|
||||
static void value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * header = lv_event_get_target(e);
|
||||
lv_obj_t * calendar = lv_obj_get_parent(header);
|
||||
|
||||
const lv_calendar_date_t * cur_date = lv_calendar_get_showed_date(calendar);
|
||||
lv_obj_t * label = lv_obj_get_child(header, 1);
|
||||
lv_label_set_text_fmt(label, "%d %s", cur_date->year, month_names_def[cur_date->month - 1]);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_CALENDAR_HEADER_ARROW*/
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ extern const lv_obj_class_t lv_calendar_header_arrow_class;
|
|||
**********************/
|
||||
|
||||
/**
|
||||
* Create a calendar objects
|
||||
* @param par pointer to an object, it will be the parent of the new calendar
|
||||
* @return pointer to the created calendar
|
||||
* Create a calendar header with drop-drowns to select the year and month
|
||||
* @param parent pointer to a calendar object.
|
||||
* @return the created header
|
||||
*/
|
||||
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent, lv_obj_t * calendar, lv_coord_t btn_size);
|
||||
lv_obj_t * lv_calendar_header_arrow_create(lv_obj_t * parent);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
|
|
@ -27,28 +27,29 @@
|
|||
static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void year_event_cb(lv_event_t * e);
|
||||
static void month_event_cb(lv_event_t * e);
|
||||
static void value_changed_event_cb(lv_event_t * e);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_calendar_header_dropdown_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.constructor_cb = my_constructor
|
||||
};
|
||||
.base_class = &lv_obj_class,
|
||||
.width_def = LV_PCT(100),
|
||||
.height_def = LV_SIZE_CONTENT,
|
||||
.constructor_cb = my_constructor
|
||||
};
|
||||
|
||||
static const char * month_list = "01\n02\n03\n04\n05\n06\n07\n08\n09\n10\n11\n12";
|
||||
static const char * year_list = {
|
||||
"2023\n2022\n2021\n"
|
||||
"2020\n2019\n2018\n2017\n2016\n2015\n2014\n2013\n2012\n2011\n2010\n2009\n2008\n2007\n2006\n2005\n2004\n2003\n2002\n2001\n"
|
||||
"2000\n1999\n1998\n1997\n1996\n1995\n1994\n1993\n1992\n1991\n1990\n1989\n1988\n1987\n1986\n1985\n1984\n1983\n1982\n1981\n"
|
||||
"1980\n1979\n1978\n1977\n1976\n1975\n1974\n1973\n1972\n1971\n1970\n1969\n1968\n1967\n1966\n1965\n1964\n1963\n1962\n1961\n"
|
||||
"1960\n1959\n1958\n1957\n1956\n1955\n1954\n1953\n1952\n1951\n1950\n1949\n1948\n1947\n1946\n1945\n1944\n1943\n1942\n1941\n"
|
||||
"1940\n1939\n1938\n1937\n1936\n1935\n1934\n1933\n1932\n1931\n1930\n1929\n1928\n1927\n1926\n1925\n1924\n1923\n1922\n1921\n"
|
||||
"1920\n1919\n1918\n1917\n1916\n1915\n1914\n1913\n1912\n1911\n1910\n1909\n1908\n1907\n1906\n1905\n1904\n1903\n1902\n1901"
|
||||
"2023\n2022\n2021\n"
|
||||
"2020\n2019\n2018\n2017\n2016\n2015\n2014\n2013\n2012\n2011\n2010\n2009\n2008\n2007\n2006\n2005\n2004\n2003\n2002\n2001\n"
|
||||
"2000\n1999\n1998\n1997\n1996\n1995\n1994\n1993\n1992\n1991\n1990\n1989\n1988\n1987\n1986\n1985\n1984\n1983\n1982\n1981\n"
|
||||
"1980\n1979\n1978\n1977\n1976\n1975\n1974\n1973\n1972\n1971\n1970\n1969\n1968\n1967\n1966\n1965\n1964\n1963\n1962\n1961\n"
|
||||
"1960\n1959\n1958\n1957\n1956\n1955\n1954\n1953\n1952\n1951\n1950\n1949\n1948\n1947\n1946\n1945\n1944\n1943\n1942\n1941\n"
|
||||
"1940\n1939\n1938\n1937\n1936\n1935\n1934\n1933\n1932\n1931\n1930\n1929\n1928\n1927\n1926\n1925\n1924\n1923\n1922\n1921\n"
|
||||
"1920\n1919\n1918\n1917\n1916\n1915\n1914\n1913\n1912\n1911\n1910\n1909\n1908\n1907\n1906\n1905\n1904\n1903\n1902\n1901"
|
||||
};
|
||||
|
||||
static lv_obj_t * calendar_param;
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
@ -57,9 +58,8 @@ static lv_obj_t * calendar_param;
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * calendar)
|
||||
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent)
|
||||
{
|
||||
calendar_param = calendar;
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_calendar_header_dropdown_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
|
||||
|
@ -76,36 +76,23 @@ static void my_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||
|
||||
LV_UNUSED(class_p);
|
||||
|
||||
/*Use the same paddings as the calendar_param*/
|
||||
lv_obj_set_style_pad_left(obj,lv_obj_get_style_pad_left(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_right(obj,lv_obj_get_style_pad_right(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_top(obj,lv_obj_get_style_pad_top(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_bottom(obj,lv_obj_get_style_pad_bottom(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_pad_column(obj,lv_obj_get_style_pad_column(calendar_param, LV_PART_MAIN), 0);
|
||||
lv_obj_set_style_radius(obj,lv_obj_get_style_radius(calendar_param, LV_PART_MAIN), 0);
|
||||
|
||||
const lv_calendar_date_t * cur_date = lv_calendar_get_showed_date(calendar_param);
|
||||
|
||||
lv_obj_update_layout(calendar_param);
|
||||
lv_coord_t w = lv_obj_get_width(calendar_param);
|
||||
lv_obj_set_size(obj, w, LV_SIZE_CONTENT);
|
||||
lv_obj_t * calendar = lv_obj_get_parent(obj);
|
||||
lv_obj_move_to_index(obj, 0);
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW);
|
||||
lv_obj_set_flex_align(obj, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
|
||||
lv_obj_t * year_dd = lv_dropdown_create(obj);
|
||||
lv_dropdown_set_options(year_dd, year_list);
|
||||
lv_dropdown_set_selected(year_dd, 2023 - cur_date->year);
|
||||
lv_obj_add_event_cb(year_dd, year_event_cb, LV_EVENT_VALUE_CHANGED, calendar_param);
|
||||
lv_obj_add_event_cb(year_dd, year_event_cb, LV_EVENT_VALUE_CHANGED, calendar);
|
||||
lv_obj_set_flex_grow(year_dd, 1);
|
||||
|
||||
lv_obj_t * month_dd = lv_dropdown_create(obj);
|
||||
lv_dropdown_set_options(month_dd, month_list);
|
||||
lv_dropdown_set_selected(month_dd, cur_date->month - 1);
|
||||
lv_obj_add_event_cb(month_dd, month_event_cb, LV_EVENT_VALUE_CHANGED, calendar_param);
|
||||
lv_obj_add_event_cb(month_dd, month_event_cb, LV_EVENT_VALUE_CHANGED, calendar);
|
||||
lv_obj_set_flex_grow(month_dd, 1);
|
||||
|
||||
lv_obj_align_to(obj, calendar_param, LV_ALIGN_OUT_TOP_MID, 0, 0);
|
||||
|
||||
lv_obj_add_event_cb(obj, value_changed_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
/*Refresh the drop downs*/
|
||||
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
|
||||
static void month_event_cb(lv_event_t * e)
|
||||
|
@ -122,6 +109,7 @@ static void month_event_cb(lv_event_t * e)
|
|||
|
||||
lv_calendar_set_showed_date(calendar, newd.year, newd.month);
|
||||
}
|
||||
|
||||
static void year_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * dropdown = lv_event_get_target(e);
|
||||
|
@ -137,5 +125,18 @@ static void year_event_cb(lv_event_t * e)
|
|||
lv_calendar_set_showed_date(calendar, newd.year, newd.month);
|
||||
}
|
||||
|
||||
static void value_changed_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * header = lv_event_get_target(e);
|
||||
lv_obj_t * calendar = lv_obj_get_parent(header);
|
||||
const lv_calendar_date_t * cur_date = lv_calendar_get_showed_date(calendar);
|
||||
|
||||
lv_obj_t * year_dd = lv_obj_get_child(header, 0);
|
||||
lv_dropdown_set_selected(year_dd, 2023 - cur_date->year);
|
||||
|
||||
lv_obj_t * month_dd = lv_obj_get_child(header, 1);
|
||||
lv_dropdown_set_selected(month_dd, cur_date->month - 1);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_CALENDAR_HEADER_ARROW*/
|
||||
|
||||
|
|
|
@ -30,11 +30,11 @@ extern const lv_obj_class_t lv_calendar_header_dropdown_class;
|
|||
**********************/
|
||||
|
||||
/**
|
||||
* Create a calendar objects
|
||||
* @param par pointer to an object, it will be the parent of the new calendar
|
||||
* @return pointer to the created calendar
|
||||
* Create a calendar header with drop-drowns to select the year and month
|
||||
* @param parent pointer to a calendar object.
|
||||
* @return the created header
|
||||
*/
|
||||
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent, lv_obj_t * calendar);
|
||||
lv_obj_t * lv_calendar_header_dropdown_create(lv_obj_t * parent);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "lv_chart.h"
|
||||
#if LV_USE_CHART != 0
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -17,6 +19,7 @@
|
|||
#define LV_CHART_HDIV_DEF 3
|
||||
#define LV_CHART_VDIV_DEF 5
|
||||
#define LV_CHART_POINT_CNT_DEF 10
|
||||
#define LV_CHART_LABEL_MAX_TEXT_LENGTH 16
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -29,7 +32,7 @@ static void lv_chart_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||
static void lv_chart_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj);
|
||||
static void lv_chart_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
||||
|
||||
static void draw_div_lines(lv_obj_t * obj , const lv_area_t * mask);
|
||||
static void draw_div_lines(lv_obj_t * obj, const lv_area_t * mask);
|
||||
static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area);
|
||||
|
@ -63,7 +66,7 @@ const lv_obj_class_t lv_chart_class = {
|
|||
|
||||
lv_obj_t * lv_chart_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -130,25 +133,25 @@ void lv_chart_set_range(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t min, lv
|
|||
|
||||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
switch(axis) {
|
||||
case LV_CHART_AXIS_PRIMARY_Y:
|
||||
chart->ymin[0] = min;
|
||||
chart->ymax[0] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_SECONDARY_Y:
|
||||
chart->ymin[1] = min;
|
||||
chart->ymax[1] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_PRIMARY_X:
|
||||
chart->xmin[0] = min;
|
||||
chart->xmax[0] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_SECONDARY_X:
|
||||
chart->xmin[1] = min;
|
||||
chart->xmax[1] = max;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("Invalid axis: %d", axis);
|
||||
return;
|
||||
case LV_CHART_AXIS_PRIMARY_Y:
|
||||
chart->ymin[0] = min;
|
||||
chart->ymax[0] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_SECONDARY_Y:
|
||||
chart->ymin[1] = min;
|
||||
chart->ymax[1] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_PRIMARY_X:
|
||||
chart->xmin[0] = min;
|
||||
chart->xmax[0] = max;
|
||||
break;
|
||||
case LV_CHART_AXIS_SECONDARY_X:
|
||||
chart->xmin[1] = min;
|
||||
chart->xmax[1] = max;
|
||||
break;
|
||||
default:
|
||||
LV_LOG_WARN("Invalid axis: %d", axis);
|
||||
return;
|
||||
}
|
||||
|
||||
lv_chart_refresh(obj);
|
||||
|
@ -188,6 +191,8 @@ void lv_chart_set_zoom_x(lv_obj_t * obj, uint16_t zoom_x)
|
|||
|
||||
chart->zoom_x = zoom_x;
|
||||
lv_obj_refresh_self_size(obj);
|
||||
/*Be the chart doesn't remain scrolled out*/
|
||||
lv_obj_readjust_scroll(obj, LV_ANIM_OFF);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
|
@ -200,6 +205,8 @@ void lv_chart_set_zoom_y(lv_obj_t * obj, uint16_t zoom_y)
|
|||
|
||||
chart->zoom_y = zoom_y;
|
||||
lv_obj_refresh_self_size(obj);
|
||||
/*Be the chart doesn't remain scrolled out*/
|
||||
lv_obj_readjust_scroll(obj, LV_ANIM_OFF);
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
|
@ -219,7 +226,8 @@ uint16_t lv_chart_get_zoom_y(const lv_obj_t * obj)
|
|||
return chart->zoom_y;
|
||||
}
|
||||
|
||||
void lv_chart_set_axis_tick(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len, lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size)
|
||||
void lv_chart_set_axis_tick(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len,
|
||||
lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
|
@ -263,6 +271,7 @@ void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint1
|
|||
{
|
||||
LV_ASSERT_NULL(obj);
|
||||
LV_ASSERT_NULL(ser);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
if(id >= chart->point_cnt) {
|
||||
|
@ -272,8 +281,8 @@ void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint1
|
|||
return;
|
||||
}
|
||||
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
|
||||
if(chart->type == LV_CHART_TYPE_LINE) {
|
||||
p_out->x = (w * id) / (chart->point_cnt - 1);
|
||||
|
@ -283,8 +292,10 @@ void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint1
|
|||
}
|
||||
else if(chart->type == LV_CHART_TYPE_BAR) {
|
||||
uint32_t ser_cnt = _lv_ll_get_len(&chart->series_ll);
|
||||
int32_t ser_gap = (lv_obj_get_style_pad_column(obj, LV_PART_ITEMS) * chart->zoom_x) >> 8; /*Gap between the column on the ~same X*/
|
||||
int32_t block_gap = (lv_obj_get_style_pad_column(obj, LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
int32_t ser_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_ITEMS) * chart->zoom_x) >> 8; /*Gap between the column on the ~same X*/
|
||||
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
lv_coord_t block_w = (w - ((chart->point_cnt - 1) * block_gap)) / chart->point_cnt;
|
||||
lv_coord_t col_w = block_w / ser_cnt;
|
||||
|
||||
|
@ -303,11 +314,12 @@ void lv_chart_get_point_pos_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint1
|
|||
p_out->x += lv_obj_get_style_pad_left(obj, LV_PART_MAIN) + border_width;
|
||||
p_out->x -= lv_obj_get_scroll_left(obj);
|
||||
|
||||
p_out->y = (int32_t)((int32_t)ser->y_points[id] - chart->ymin[ser->y_axis_sec]) * h;
|
||||
p_out->y = p_out->y / (chart->ymax[ser->y_axis_sec] - chart->ymin[ser->y_axis_sec]);
|
||||
p_out->y = h - p_out->y;
|
||||
int32_t temp_y = 0;
|
||||
temp_y = (int32_t)((int32_t)ser->y_points[id] - chart->ymin[ser->y_axis_sec]) * h;
|
||||
temp_y = temp_y / (chart->ymax[ser->y_axis_sec] - chart->ymin[ser->y_axis_sec]);
|
||||
p_out->y = h - temp_y;
|
||||
p_out->y += lv_obj_get_style_pad_top(obj, LV_PART_MAIN) + border_width;
|
||||
|
||||
p_out->y -= lv_obj_get_scroll_top(obj);
|
||||
}
|
||||
|
||||
void lv_chart_refresh(lv_obj_t * obj)
|
||||
|
@ -323,7 +335,7 @@ void lv_chart_refresh(lv_obj_t * obj)
|
|||
|
||||
lv_chart_series_t * lv_chart_add_series(lv_obj_t * obj, lv_color_t color, lv_chart_axis_t axis)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
|
@ -560,7 +572,8 @@ void lv_chart_set_value_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t
|
|||
ser->y_points[id] = value;
|
||||
}
|
||||
|
||||
void lv_chart_set_value_by_id2(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t x_value, lv_coord_t y_value)
|
||||
void lv_chart_set_value_by_id2(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t x_value,
|
||||
lv_coord_t y_value)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
LV_ASSERT_NULL(ser);
|
||||
|
@ -702,18 +715,24 @@ static void lv_chart_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
chart->pressed_point_id = id;
|
||||
lv_event_send(obj, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
}
|
||||
} else if(code == LV_EVENT_RELEASED) {
|
||||
}
|
||||
else if(code == LV_EVENT_RELEASED) {
|
||||
invalidate_point(obj, chart->pressed_point_id);
|
||||
chart->pressed_point_id = LV_CHART_POINT_NONE;
|
||||
} else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
}
|
||||
else if(code == LV_EVENT_SIZE_CHANGED) {
|
||||
lv_obj_refresh_self_size(obj);
|
||||
} else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_event_set_ext_draw_size(e, LV_MAX4(chart->tick[0].draw_size, chart->tick[1].draw_size, chart->tick[2].draw_size, chart->tick[3].draw_size));
|
||||
} else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
}
|
||||
else if(code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
|
||||
lv_event_set_ext_draw_size(e, LV_MAX4(chart->tick[0].draw_size, chart->tick[1].draw_size, chart->tick[2].draw_size,
|
||||
chart->tick[3].draw_size));
|
||||
}
|
||||
else if(code == LV_EVENT_GET_SELF_SIZE) {
|
||||
lv_point_t * p = lv_event_get_param(e);
|
||||
p->x = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
p->y = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
} else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
p->x = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
p->y = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
}
|
||||
else if(code == LV_EVENT_DRAW_MAIN) {
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
draw_div_lines(obj, clip_area);
|
||||
draw_axes(obj, clip_area);
|
||||
|
@ -744,17 +763,23 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_MAIN, &line_dsc);
|
||||
|
||||
lv_obj_draw_part_dsc_t obj_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&obj_draw_dsc, clip_area);
|
||||
obj_draw_dsc.line_dsc = &line_dsc;
|
||||
obj_draw_dsc.part = LV_PART_MAIN;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.part = LV_PART_MAIN;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_DIV_LINE_INIT;
|
||||
part_draw_dsc.line_dsc = &line_dsc;
|
||||
part_draw_dsc.id = 0xFFFFFFFF;
|
||||
part_draw_dsc.p1 = NULL;
|
||||
part_draw_dsc.p2 = NULL;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
lv_opa_t border_opa = lv_obj_get_style_border_opa(obj, LV_PART_MAIN);
|
||||
lv_coord_t border_w = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
|
@ -775,17 +800,19 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
}
|
||||
|
||||
for(i = i_start; i < i_end; i++) {
|
||||
p1.y = (int32_t)((int32_t)(h - line_dsc.width) * i) / (chart->hdiv_cnt - 1);
|
||||
p1.y = (int32_t)((int32_t)h * i) / (chart->hdiv_cnt - 1);
|
||||
p1.y += y_ofs;
|
||||
p2.y = p1.y;
|
||||
|
||||
obj_draw_dsc.p1 = &p1;
|
||||
obj_draw_dsc.p2 = &p2;
|
||||
obj_draw_dsc.id = i;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_DIV_LINE_HOR;
|
||||
part_draw_dsc.p1 = &p1;
|
||||
part_draw_dsc.p2 = &p2;
|
||||
part_draw_dsc.id = i;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &obj_draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &obj_draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -801,19 +828,27 @@ static void draw_div_lines(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
}
|
||||
|
||||
for(i = i_start; i < i_end; i++) {
|
||||
p1.x = (int32_t)((int32_t)(w - line_dsc.width) * i) / (chart->vdiv_cnt - 1);
|
||||
p1.x = (int32_t)((int32_t)w * i) / (chart->vdiv_cnt - 1);
|
||||
p1.x += x_ofs;
|
||||
p2.x = p1.x;
|
||||
|
||||
obj_draw_dsc.p1 = &p1;
|
||||
obj_draw_dsc.p2 = &p2;
|
||||
obj_draw_dsc.id = i;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_DIV_LINE_VER;
|
||||
part_draw_dsc.p1 = &p1;
|
||||
part_draw_dsc.p2 = &p2;
|
||||
part_draw_dsc.id = i;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &obj_draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &obj_draw_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
part_draw_dsc.id = 0xFFFFFFFF;
|
||||
part_draw_dsc.p1 = NULL;
|
||||
part_draw_dsc.p2 = NULL;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
|
||||
}
|
||||
|
||||
static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
||||
|
@ -822,6 +857,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
if(_lv_area_intersect(&com_area, &obj->coords, clip_area) == false) return;
|
||||
|
||||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
if(chart->point_cnt < 2) return;
|
||||
|
||||
uint16_t i;
|
||||
lv_point_t p1;
|
||||
|
@ -829,8 +865,8 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN) + border_width;
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t x_ofs = obj->coords.x1 + pad_left - lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t y_ofs = obj->coords.y1 + pad_top - lv_obj_get_scroll_top(obj);
|
||||
lv_chart_series_t * ser;
|
||||
|
@ -859,7 +895,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
|
||||
/*Go through all data lines*/
|
||||
_LV_LL_READ_BACK(&chart->series_ll, ser) {
|
||||
if (ser->hidden) continue;
|
||||
if(ser->hidden) continue;
|
||||
line_dsc_default.color = ser->color;
|
||||
point_dsc_default.bg_color = ser->color;
|
||||
|
||||
|
@ -874,12 +910,14 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
y_tmp = y_tmp / (chart->ymax[ser->y_axis_sec] - chart->ymin[ser->y_axis_sec]);
|
||||
p2.y = h - y_tmp + y_ofs;
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
dsc.line_dsc = &line_dsc_default;
|
||||
dsc.rect_dsc = &point_dsc_default;
|
||||
dsc.sub_part_ptr = ser;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_LINE_AND_POINT;
|
||||
part_draw_dsc.part = LV_PART_ITEMS;
|
||||
part_draw_dsc.line_dsc = &line_dsc_default;
|
||||
part_draw_dsc.rect_dsc = &point_dsc_default;
|
||||
part_draw_dsc.sub_part_ptr = ser;
|
||||
|
||||
lv_coord_t y_min = p2.y;
|
||||
lv_coord_t y_max = p2.y;
|
||||
|
@ -906,7 +944,7 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
if(i != 0) {
|
||||
if(crowded_mode) {
|
||||
if(ser->y_points[p_prev] != LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
/*Draw only one vertical line between the min an max y values on the same x value*/
|
||||
/*Draw only one vertical line between the min and max y-values on the same x-value*/
|
||||
y_max = LV_MAX(y_max, p2.y);
|
||||
y_min = LV_MIN(y_min, p2.y);
|
||||
if(p1.x != p2.x) {
|
||||
|
@ -922,30 +960,31 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
y_max = y_cur;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_area_t point_area;
|
||||
point_area.x1 = p1.x - point_w;
|
||||
point_area.x2 = p1.x + point_w;
|
||||
point_area.y1 = p1.y - point_h;
|
||||
point_area.y2 = p1.y + point_h;
|
||||
|
||||
dsc.id = i - 1;
|
||||
dsc.p1 = ser->y_points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
|
||||
dsc.p2 = ser->y_points[p_act] != LV_CHART_POINT_NONE ? &p2 : NULL;
|
||||
dsc.draw_area = &point_area;
|
||||
dsc.value = ser->y_points[p_prev];
|
||||
part_draw_dsc.id = i - 1;
|
||||
part_draw_dsc.p1 = ser->y_points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
|
||||
part_draw_dsc.p2 = ser->y_points[p_act] != LV_CHART_POINT_NONE ? &p2 : NULL;
|
||||
part_draw_dsc.draw_area = &point_area;
|
||||
part_draw_dsc.value = ser->y_points[p_prev];
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
if(ser->y_points[p_prev] != LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
|
||||
}
|
||||
|
||||
if(point_w && point_h && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
if(point_w && point_h && ser->y_points[p_prev] != LV_CHART_POINT_NONE) {
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -962,14 +1001,14 @@ static void draw_series_line(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
point_area.y1 = p2.y - point_h;
|
||||
point_area.y2 = p2.y + point_h;
|
||||
|
||||
dsc.id = i - 1;
|
||||
dsc.p1 = NULL;
|
||||
dsc.p2 = NULL;
|
||||
dsc.draw_area = &point_area;
|
||||
dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
part_draw_dsc.id = i - 1;
|
||||
part_draw_dsc.p1 = NULL;
|
||||
part_draw_dsc.p2 = NULL;
|
||||
part_draw_dsc.draw_area = &point_area;
|
||||
part_draw_dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -989,8 +1028,8 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t x_ofs = obj->coords.x1 + pad_left + border_width - lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t y_ofs = obj->coords.y1 + pad_top + border_width - lv_obj_get_scroll_top(obj);
|
||||
lv_chart_series_t * ser;
|
||||
|
@ -1016,7 +1055,7 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
|
||||
/*Go through all data lines*/
|
||||
_LV_LL_READ_BACK(&chart->series_ll, ser) {
|
||||
if (ser->hidden) continue;
|
||||
if(ser->hidden) continue;
|
||||
line_dsc_default.color = ser->color;
|
||||
point_dsc_default.bg_color = ser->color;
|
||||
|
||||
|
@ -1034,17 +1073,20 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
p2.y = lv_map(ser->y_points[p_act], chart->ymin[ser->y_axis_sec], chart->ymax[ser->y_axis_sec], 0, h);
|
||||
p2.y = h - p2.y;
|
||||
p2.y += y_ofs;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
p2.x = LV_COORD_MIN;
|
||||
p2.y = LV_COORD_MIN;
|
||||
}
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
dsc.line_dsc = &line_dsc_default;
|
||||
dsc.rect_dsc = &point_dsc_default;
|
||||
dsc.sub_part_ptr = ser;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.part = LV_PART_ITEMS;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_LINE_AND_POINT;
|
||||
part_draw_dsc.line_dsc = &line_dsc_default;
|
||||
part_draw_dsc.rect_dsc = &point_dsc_default;
|
||||
part_draw_dsc.sub_part_ptr = ser;
|
||||
|
||||
for(i = 0; i < chart->point_cnt; i++) {
|
||||
p1.x = p2.x;
|
||||
|
@ -1058,7 +1100,8 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
|
||||
p2.x = lv_map(ser->x_points[p_act], chart->xmin[ser->x_axis_sec], chart->xmax[ser->x_axis_sec], 0, w);
|
||||
p2.x += x_ofs;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
p_prev = p_act;
|
||||
continue;
|
||||
}
|
||||
|
@ -1071,13 +1114,13 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
point_area.y1 = p1.y - point_h;
|
||||
point_area.y2 = p1.y + point_h;
|
||||
|
||||
dsc.id = i - 1;
|
||||
dsc.p1 = ser->y_points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
|
||||
dsc.p2 = ser->y_points[p_act] != LV_CHART_POINT_NONE ? &p2 : NULL;
|
||||
dsc.draw_area = &point_area;
|
||||
dsc.value = ser->y_points[p_prev];
|
||||
part_draw_dsc.id = i - 1;
|
||||
part_draw_dsc.p1 = ser->y_points[p_prev] != LV_CHART_POINT_NONE ? &p1 : NULL;
|
||||
part_draw_dsc.p2 = ser->y_points[p_act] != LV_CHART_POINT_NONE ? &p2 : NULL;
|
||||
part_draw_dsc.draw_area = &point_area;
|
||||
part_draw_dsc.value = ser->y_points[p_prev];
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
if(ser->y_points[p_prev] != LV_CHART_POINT_NONE && ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
lv_draw_line(&p1, &p2, &series_mask, &line_dsc_default);
|
||||
|
@ -1086,7 +1129,7 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
}
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
p_prev = p_act;
|
||||
}
|
||||
|
@ -1101,14 +1144,14 @@ static void draw_series_scatter(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
point_area.y1 = p2.y - point_h;
|
||||
point_area.y2 = p2.y + point_h;
|
||||
|
||||
dsc.id = i - 1;
|
||||
dsc.p1 = NULL;
|
||||
dsc.p2 = NULL;
|
||||
dsc.draw_area = &point_area;
|
||||
dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
part_draw_dsc.id = i - 1;
|
||||
part_draw_dsc.p1 = NULL;
|
||||
part_draw_dsc.p2 = NULL;
|
||||
part_draw_dsc.draw_area = &point_area;
|
||||
part_draw_dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_rect(&point_area, &series_mask, &point_dsc_default);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1125,15 +1168,17 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_area_t col_a;
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
int32_t y_tmp;
|
||||
lv_chart_series_t * ser;
|
||||
uint32_t ser_cnt = _lv_ll_get_len(&chart->series_ll);
|
||||
int32_t block_gap = (lv_obj_get_style_pad_column(obj, LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
lv_coord_t block_w = (w - ((chart->point_cnt - 1) * block_gap)) / chart->point_cnt;
|
||||
lv_coord_t col_w = block_w / ser_cnt;
|
||||
int32_t ser_gap = (lv_obj_get_style_pad_column(obj, LV_PART_ITEMS) * chart->zoom_x) >> 8; /*Gap between the column on the ~same X*/
|
||||
int32_t ser_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_ITEMS) * chart->zoom_x) >> 8; /*Gap between the column on the ~same X*/
|
||||
lv_coord_t x_ofs = pad_left - lv_obj_get_scroll_left(obj);
|
||||
lv_coord_t y_ofs = pad_top - lv_obj_get_scroll_top(obj);
|
||||
|
||||
|
@ -1150,19 +1195,21 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
bool mask_ret = _lv_area_intersect(&series_mask, &obj->coords, clip_area);
|
||||
if(mask_ret == false) return;
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, &series_mask);
|
||||
dsc.part = LV_PART_ITEMS;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, &series_mask);
|
||||
part_draw_dsc.part = LV_PART_ITEMS;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_BAR;
|
||||
|
||||
/*Go through all points*/
|
||||
for(i = 0; i < chart->point_cnt; i++) {
|
||||
lv_coord_t x_act = (int32_t)((int32_t)(w + block_gap) * i) / (chart->point_cnt) + obj->coords.x1 + x_ofs;
|
||||
|
||||
dsc.id = i;
|
||||
part_draw_dsc.id = i;
|
||||
|
||||
/*Draw the current point of all data line*/
|
||||
_LV_LL_READ_BACK(&chart->series_ll, ser) {
|
||||
if (ser->hidden) continue;
|
||||
if(ser->hidden) continue;
|
||||
lv_coord_t start_point = chart->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0;
|
||||
|
||||
col_a.x1 = x_act;
|
||||
|
@ -1180,13 +1227,13 @@ static void draw_series_bar(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
col_a.y1 = h - y_tmp + obj->coords.y1 + y_ofs;
|
||||
|
||||
if(ser->y_points[p_act] != LV_CHART_POINT_NONE) {
|
||||
dsc.draw_area = &col_a;
|
||||
dsc.rect_dsc = &col_dsc;
|
||||
dsc.sub_part_ptr = ser;
|
||||
dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
part_draw_dsc.draw_area = &col_a;
|
||||
part_draw_dsc.rect_dsc = &col_dsc;
|
||||
part_draw_dsc.sub_part_ptr = ser;
|
||||
part_draw_dsc.value = ser->y_points[p_act];
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_rect(&col_a, &series_mask, &col_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1218,11 +1265,13 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
lv_coord_t point_w = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
|
||||
lv_coord_t point_h = lv_obj_get_style_width(obj, LV_PART_CURSOR) / 2;
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.line_dsc = &line_dsc_tmp;
|
||||
dsc.rect_dsc = &point_dsc_tmp;
|
||||
dsc.part = LV_PART_CURSOR;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.line_dsc = &line_dsc_tmp;
|
||||
part_draw_dsc.rect_dsc = &point_dsc_tmp;
|
||||
part_draw_dsc.part = LV_PART_CURSOR;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_CURSOR;
|
||||
|
||||
lv_area_t clip_area2;
|
||||
_lv_area_intersect(&clip_area2, clip_area, &obj->coords);
|
||||
|
@ -1234,15 +1283,16 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
line_dsc_tmp.color = cursor->color;
|
||||
point_dsc_tmp.bg_color = cursor->color;
|
||||
|
||||
dsc.p1 = &p1;
|
||||
dsc.p2 = &p2;
|
||||
part_draw_dsc.p1 = &p1;
|
||||
part_draw_dsc.p2 = &p2;
|
||||
|
||||
lv_coord_t cx;
|
||||
lv_coord_t cy;
|
||||
if(cursor->pos_set) {
|
||||
cx = cursor->pos.x;
|
||||
cy = cursor->pos.y;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if(cursor->point_id == LV_CHART_POINT_NONE) continue;
|
||||
lv_point_t p;
|
||||
lv_chart_get_point_pos_by_id(obj, cursor->ser, cursor->point_id, &p);
|
||||
|
@ -1253,15 +1303,29 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
cx += obj->coords.x1;
|
||||
cy += obj->coords.y1;
|
||||
|
||||
lv_area_t point_area;
|
||||
if(point_w && point_h) {
|
||||
point_area.x1 = cx - point_w;
|
||||
point_area.x2 = cx + point_w;
|
||||
point_area.y1 = cy - point_h;
|
||||
point_area.y2 = cy + point_h;
|
||||
|
||||
part_draw_dsc.draw_area = &point_area;
|
||||
}
|
||||
else {
|
||||
part_draw_dsc.draw_area = NULL;
|
||||
}
|
||||
|
||||
if(cursor->dir & LV_DIR_HOR) {
|
||||
p1.x = cursor->dir & LV_DIR_LEFT ? obj->coords.x1 : cx;
|
||||
p1.y = cy;
|
||||
p2.x = cursor->dir & LV_DIR_RIGHT ? obj->coords.x2 : cx;
|
||||
p2.y = p1.y;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_line(&p1, &p2, &clip_area2, &line_dsc_tmp);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_draw_rect(&point_area, &clip_area2, &point_dsc_tmp);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
|
||||
if(cursor->dir & LV_DIR_VER) {
|
||||
|
@ -1270,27 +1334,12 @@ static void draw_cursors(lv_obj_t * obj, const lv_area_t * clip_area)
|
|||
p2.x = p1.x;
|
||||
p2.y = cursor->dir & LV_DIR_BOTTOM ? obj->coords.y2 : cy;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_line(&p1, &p2, &clip_area2, &line_dsc_tmp);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
}
|
||||
|
||||
if(point_w && point_h) {
|
||||
lv_area_t point_area;
|
||||
|
||||
point_area.x1 = cx - point_w;
|
||||
point_area.x2 = cx + point_w;
|
||||
point_area.y1 = cy - point_h;
|
||||
point_area.y2 = cy + point_h;
|
||||
|
||||
dsc.draw_area = &point_area;
|
||||
dsc.p1 = NULL;
|
||||
dsc.p2 = NULL;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
lv_draw_rect(&point_area, &clip_area2, &point_dsc_tmp);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1312,7 +1361,7 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
|
||||
lv_coord_t border_width = lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t pad_top = lv_obj_get_style_pad_top(obj, LV_PART_MAIN);
|
||||
lv_coord_t h = (lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t h = ((int32_t)lv_obj_get_content_height(obj) * chart->zoom_y) >> 8;
|
||||
lv_coord_t y_ofs = obj->coords.y1 + pad_top + border_width - lv_obj_get_scroll_top(obj);
|
||||
|
||||
lv_coord_t label_gap;
|
||||
|
@ -1320,7 +1369,8 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
if(axis == LV_CHART_AXIS_PRIMARY_Y) {
|
||||
label_gap = lv_obj_get_style_pad_left(obj, LV_PART_TICKS);
|
||||
x_ofs = obj->coords.x1;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
label_gap = lv_obj_get_style_pad_right(obj, LV_PART_TICKS);
|
||||
x_ofs = obj->coords.x2;
|
||||
}
|
||||
|
@ -1341,12 +1391,14 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
lv_draw_label_dsc_init(&label_dsc);
|
||||
lv_obj_init_draw_label_dsc(obj, LV_PART_TICKS, &label_dsc);
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.id = axis;
|
||||
dsc.part = LV_PART_TICKS;
|
||||
dsc.line_dsc = &line_dsc;
|
||||
dsc.label_dsc = &label_dsc;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_TICK_LABEL;
|
||||
part_draw_dsc.id = axis;
|
||||
part_draw_dsc.part = LV_PART_TICKS;
|
||||
part_draw_dsc.line_dsc = &line_dsc;
|
||||
part_draw_dsc.label_dsc = &label_dsc;
|
||||
|
||||
uint32_t total_tick_num = (t->major_cnt - 1) * (t->minor_cnt);
|
||||
for(i = 0; i <= total_tick_num; i++) {
|
||||
|
@ -1367,22 +1419,25 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
if(major) p2.x = p1.x - major_len; /*major tick*/
|
||||
else p2.x = p1.x - minor_len; /*minor tick*/
|
||||
|
||||
if(p1.y + line_dsc.width / 2 >= obj->coords.y1 &&
|
||||
p2.y - line_dsc.width / 2 <= obj->coords.y2)
|
||||
{
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
}
|
||||
part_draw_dsc.p1 = &p1;
|
||||
part_draw_dsc.p2 = &p2;
|
||||
|
||||
int32_t tick_value = lv_map(total_tick_num - i, 0, total_tick_num, chart->ymin[sec_axis], chart->ymax[sec_axis]);
|
||||
part_draw_dsc.value = tick_value;
|
||||
|
||||
/*add text only to major tick*/
|
||||
if(major && t->label_en) {
|
||||
int32_t tick_value = lv_map(total_tick_num - i, 0, total_tick_num, chart->ymin[sec_axis], chart->ymax[sec_axis]);
|
||||
lv_snprintf(dsc.text, sizeof(dsc.text), "%d", tick_value);
|
||||
dsc.value = tick_value;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
if(major && t->label_en) {
|
||||
char buf[LV_CHART_LABEL_MAX_TEXT_LENGTH];
|
||||
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, tick_value);
|
||||
part_draw_dsc.label_dsc = &label_dsc;
|
||||
part_draw_dsc.text = buf;
|
||||
part_draw_dsc.text_length = LV_CHART_LABEL_MAX_TEXT_LENGTH;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
/*reserve appropriate area*/
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
lv_txt_get_size(&size, part_draw_dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
|
||||
LV_TEXT_FLAG_NONE);
|
||||
|
||||
/*set the area at some distance of the major tick len left of the tick*/
|
||||
lv_area_t a;
|
||||
|
@ -1399,12 +1454,23 @@ static void draw_y_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
}
|
||||
|
||||
if(a.y2 >= obj->coords.y1 &&
|
||||
a.y1 <= obj->coords.y2)
|
||||
{
|
||||
lv_draw_label(&a, clip_area, &label_dsc, dsc.text, NULL);
|
||||
a.y1 <= obj->coords.y2) {
|
||||
lv_draw_label(&a, clip_area, &label_dsc, part_draw_dsc.text, NULL);
|
||||
}
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
}
|
||||
else {
|
||||
part_draw_dsc.label_dsc = NULL;
|
||||
part_draw_dsc.text = NULL;
|
||||
part_draw_dsc.text_length = 0;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
}
|
||||
|
||||
if(p1.y + line_dsc.width / 2 >= obj->coords.y1 &&
|
||||
p2.y - line_dsc.width / 2 <= obj->coords.y2) {
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
}
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1421,7 +1487,7 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
lv_point_t p2;
|
||||
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN) + lv_obj_get_style_border_width(obj, LV_PART_MAIN);
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
|
@ -1434,7 +1500,8 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
if(axis == LV_CHART_AXIS_PRIMARY_X) {
|
||||
label_gap = t->label_en ? lv_obj_get_style_pad_bottom(obj, LV_PART_TICKS) : 0;
|
||||
y_ofs = obj->coords.y2;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
label_gap = t->label_en ? lv_obj_get_style_pad_top(obj, LV_PART_TICKS) : 0;
|
||||
y_ofs = obj->coords.y1;
|
||||
}
|
||||
|
@ -1450,18 +1517,21 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
line_dsc.dash_gap = 0;
|
||||
line_dsc.dash_width = 0;
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
dsc.id = LV_CHART_AXIS_PRIMARY_X;
|
||||
dsc.part = LV_PART_TICKS;
|
||||
dsc.label_dsc = &label_dsc;
|
||||
dsc.line_dsc = &line_dsc;
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_CHART_DRAW_PART_TICK_LABEL;
|
||||
part_draw_dsc.id = LV_CHART_AXIS_PRIMARY_X;
|
||||
part_draw_dsc.part = LV_PART_TICKS;
|
||||
part_draw_dsc.label_dsc = &label_dsc;
|
||||
part_draw_dsc.line_dsc = &line_dsc;
|
||||
|
||||
uint8_t sec_axis = axis == LV_CHART_AXIS_PRIMARY_X ? 0 : 1;
|
||||
|
||||
/*The columns ticks should be aligned to the center of blocks*/
|
||||
if(chart->type == LV_CHART_TYPE_BAR) {
|
||||
int32_t block_gap = (lv_obj_get_style_pad_column(obj, LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the columns on ~adjacent X*/
|
||||
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the columns on ~adjacent X*/
|
||||
lv_coord_t block_w = (w + block_gap) / (chart->point_cnt);
|
||||
x_ofs += (block_w - block_gap) / 2;
|
||||
w -= block_w - block_gap;
|
||||
|
@ -1479,49 +1549,65 @@ static void draw_x_ticks(lv_obj_t * obj, const lv_area_t * clip_area, lv_chart_a
|
|||
if(sec_axis) p2.y = p1.y - (major ? t->major_len : t->minor_len);
|
||||
else p2.y = p1.y + (major ? t->major_len : t->minor_len);
|
||||
|
||||
if(p1.x + line_dsc.width / 2 >= obj->coords.x1 &&
|
||||
p2.x - line_dsc.width / 2 <= obj->coords.x2)
|
||||
{
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
}
|
||||
part_draw_dsc.p1 = &p1;
|
||||
part_draw_dsc.p2 = &p2;
|
||||
|
||||
/*add text only to major tick*/
|
||||
if(!major || !t->label_en) continue;
|
||||
|
||||
int32_t tick_value;
|
||||
if(chart->type == LV_CHART_TYPE_SCATTER) {
|
||||
tick_value = lv_map(i, 0, total_tick_num, chart->xmin[sec_axis], chart->xmax[sec_axis]);
|
||||
} else {
|
||||
tick_value = i / t->minor_cnt;
|
||||
}
|
||||
|
||||
lv_snprintf(dsc.text, sizeof(dsc.text), "%d", tick_value);
|
||||
dsc.value = tick_value;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
|
||||
/*reserve appropriate area*/
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
/*set the area at some distance of the major tick len under of the tick*/
|
||||
lv_area_t a;
|
||||
a.x1 = (p2.x - size.x / 2);
|
||||
a.x2 = (p2.x + size.x / 2);
|
||||
if(sec_axis) {
|
||||
a.y2 = p2.y - label_gap;
|
||||
a.y1 = a.y2 - size.y;
|
||||
}
|
||||
else {
|
||||
a.y1 = p2.y + label_gap;
|
||||
a.y2 = a.y1 + size.y;
|
||||
tick_value = i / t->minor_cnt;
|
||||
}
|
||||
part_draw_dsc.value = tick_value;
|
||||
|
||||
if(major && t->label_en) {
|
||||
char buf[LV_CHART_LABEL_MAX_TEXT_LENGTH];
|
||||
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, tick_value);
|
||||
part_draw_dsc.label_dsc = &label_dsc;
|
||||
part_draw_dsc.text = buf;
|
||||
part_draw_dsc.text_length = LV_CHART_LABEL_MAX_TEXT_LENGTH;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
/*reserve appropriate area*/
|
||||
lv_point_t size;
|
||||
lv_txt_get_size(&size, part_draw_dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space, LV_COORD_MAX,
|
||||
LV_TEXT_FLAG_NONE);
|
||||
|
||||
/*set the area at some distance of the major tick len under of the tick*/
|
||||
lv_area_t a;
|
||||
a.x1 = (p2.x - size.x / 2);
|
||||
a.x2 = (p2.x + size.x / 2);
|
||||
if(sec_axis) {
|
||||
a.y2 = p2.y - label_gap;
|
||||
a.y1 = a.y2 - size.y;
|
||||
}
|
||||
else {
|
||||
a.y1 = p2.y + label_gap;
|
||||
a.y2 = a.y1 + size.y;
|
||||
}
|
||||
|
||||
if(a.x2 >= obj->coords.x1 &&
|
||||
a.x1 <= obj->coords.x2) {
|
||||
lv_draw_label(&a, clip_area, &label_dsc, part_draw_dsc.text, NULL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
part_draw_dsc.label_dsc = NULL;
|
||||
part_draw_dsc.text = NULL;
|
||||
part_draw_dsc.text_length = 0;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
}
|
||||
|
||||
if(a.x2 >= obj->coords.x1 &&
|
||||
a.x1 <= obj->coords.x2)
|
||||
{
|
||||
lv_draw_label(&a, clip_area, &label_dsc, dsc.text, NULL);
|
||||
|
||||
if(p1.x + line_dsc.width / 2 >= obj->coords.x1 &&
|
||||
p2.x - line_dsc.width / 2 <= obj->coords.x2) {
|
||||
lv_draw_line(&p1, &p2, clip_area, &line_dsc);
|
||||
}
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1542,9 +1628,9 @@ static void draw_axes(lv_obj_t * obj, const lv_area_t * mask)
|
|||
static uint32_t get_index_from_x(lv_obj_t * obj, lv_coord_t x)
|
||||
{
|
||||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t pad_left = lv_obj_get_style_pad_left(obj, LV_PART_MAIN);
|
||||
x-= pad_left;
|
||||
x -= pad_left;
|
||||
|
||||
if(x < 0) return 0;
|
||||
if(x > w) return chart->point_cnt - 1;
|
||||
|
@ -1559,7 +1645,7 @@ static void invalidate_point(lv_obj_t * obj, uint16_t i)
|
|||
lv_chart_t * chart = (lv_chart_t *)obj;
|
||||
if(i >= chart->point_cnt) return;
|
||||
|
||||
lv_coord_t w = (lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t w = ((int32_t)lv_obj_get_content_width(obj) * chart->zoom_x) >> 8;
|
||||
lv_coord_t scroll_left = lv_obj_get_scroll_left(obj);
|
||||
|
||||
/*In shift mode the whole chart changes so the whole object*/
|
||||
|
@ -1594,7 +1680,8 @@ static void invalidate_point(lv_obj_t * obj, uint16_t i)
|
|||
}
|
||||
else if(chart->type == LV_CHART_TYPE_BAR) {
|
||||
lv_area_t col_a;
|
||||
int32_t block_gap = (lv_obj_get_style_pad_column(obj, LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
int32_t block_gap = ((int32_t)lv_obj_get_style_pad_column(obj,
|
||||
LV_PART_MAIN) * chart->zoom_x) >> 8; /*Gap between the column on ~adjacent X*/
|
||||
lv_coord_t block_w = (w + block_gap) / chart->point_cnt;
|
||||
|
||||
lv_coord_t x_act;
|
||||
|
@ -1620,7 +1707,7 @@ static void new_points_alloc(lv_obj_t * obj, lv_chart_series_t * ser, uint32_t c
|
|||
{
|
||||
if((*a) == NULL) return;
|
||||
|
||||
lv_chart_t * chart = (lv_chart_t*) obj;
|
||||
lv_chart_t * chart = (lv_chart_t *) obj;
|
||||
uint32_t point_cnt_old = chart->point_cnt;
|
||||
uint32_t i;
|
||||
|
||||
|
@ -1632,7 +1719,7 @@ static void new_points_alloc(lv_obj_t * obj, lv_chart_series_t * ser, uint32_t c
|
|||
if(cnt >= point_cnt_old) {
|
||||
for(i = 0; i < point_cnt_old; i++) {
|
||||
new_points[i] =
|
||||
(*a)[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
(*a)[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
for(i = point_cnt_old; i < cnt; i++) {
|
||||
new_points[i] = LV_CHART_POINT_NONE; /*Fill up the rest with default value*/
|
||||
|
@ -1641,7 +1728,7 @@ static void new_points_alloc(lv_obj_t * obj, lv_chart_series_t * ser, uint32_t c
|
|||
else {
|
||||
for(i = 0; i < cnt; i++) {
|
||||
new_points[i] =
|
||||
(*a)[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
(*a)[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1664,13 +1751,18 @@ static void new_points_alloc(lv_obj_t * obj, lv_chart_series_t * ser, uint32_t c
|
|||
|
||||
lv_chart_tick_dsc_t * get_tick_gsc(lv_obj_t * obj, lv_chart_axis_t axis)
|
||||
{
|
||||
lv_chart_t * chart = (lv_chart_t*) obj;
|
||||
lv_chart_t * chart = (lv_chart_t *) obj;
|
||||
switch(axis) {
|
||||
case LV_CHART_AXIS_PRIMARY_Y: return &chart->tick[0];
|
||||
case LV_CHART_AXIS_PRIMARY_X: return &chart->tick[1];
|
||||
case LV_CHART_AXIS_SECONDARY_Y: return &chart->tick[2];
|
||||
case LV_CHART_AXIS_SECONDARY_X: return &chart->tick[3];
|
||||
default: return NULL;
|
||||
case LV_CHART_AXIS_PRIMARY_Y:
|
||||
return &chart->tick[0];
|
||||
case LV_CHART_AXIS_PRIMARY_X:
|
||||
return &chart->tick[1];
|
||||
case LV_CHART_AXIS_SECONDARY_Y:
|
||||
return &chart->tick[2];
|
||||
case LV_CHART_AXIS_SECONDARY_X:
|
||||
return &chart->tick[3];
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,17 +82,17 @@ typedef struct {
|
|||
lv_color_t color;
|
||||
lv_chart_series_t * ser;
|
||||
lv_dir_t dir;
|
||||
uint8_t pos_set:1; /*1: pos is set; 0: point_id is set*/
|
||||
uint8_t pos_set: 1; /*1: pos is set; 0: point_id is set*/
|
||||
} lv_chart_cursor_t;
|
||||
|
||||
typedef struct {
|
||||
lv_coord_t major_len;
|
||||
lv_coord_t minor_len;
|
||||
lv_coord_t draw_size;
|
||||
uint32_t minor_cnt :15;
|
||||
uint32_t major_cnt :15;
|
||||
uint32_t label_en :1;
|
||||
}lv_chart_tick_dsc_t;
|
||||
uint32_t minor_cnt : 15;
|
||||
uint32_t major_cnt : 15;
|
||||
uint32_t label_en : 1;
|
||||
} lv_chart_tick_dsc_t;
|
||||
|
||||
|
||||
typedef struct {
|
||||
|
@ -110,12 +110,26 @@ typedef struct {
|
|||
uint16_t point_cnt; /**< Point number in a data line*/
|
||||
uint16_t zoom_x;
|
||||
uint16_t zoom_y;
|
||||
lv_chart_type_t type :3; /**< Line or column chart*/
|
||||
lv_chart_type_t type : 3; /**< Line or column chart*/
|
||||
lv_chart_update_mode_t update_mode : 1;
|
||||
}lv_chart_t;
|
||||
} lv_chart_t;
|
||||
|
||||
extern const lv_obj_class_t lv_chart_class;
|
||||
|
||||
/**
|
||||
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_chart_class`
|
||||
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
|
||||
*/
|
||||
typedef enum {
|
||||
LV_CHART_DRAW_PART_DIV_LINE_INIT, /**< Used before/after drawn the div lines*/
|
||||
LV_CHART_DRAW_PART_DIV_LINE_HOR, /**< Used for each horizontal division lines*/
|
||||
LV_CHART_DRAW_PART_DIV_LINE_VER, /**< Used for each vertical division lines*/
|
||||
LV_CHART_DRAW_PART_LINE_AND_POINT, /**< Used on line and scatter charts for lines and points*/
|
||||
LV_CHART_DRAW_PART_BAR, /**< Used on bar charts for the rectangles*/
|
||||
LV_CHART_DRAW_PART_CURSOR, /**< Used on cursor lines and points*/
|
||||
LV_CHART_DRAW_PART_TICK_LABEL, /**< Used on tick lines and labels*/
|
||||
} lv_chart_draw_part_type_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
@ -204,7 +218,8 @@ uint16_t lv_chart_get_zoom_y(const lv_obj_t * obj);
|
|||
* @param draw_size extra size required to draw the tick and labels
|
||||
* (start with 20 px and increase if the ticks/labels are clipped)
|
||||
*/
|
||||
void lv_chart_set_axis_tick(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len, lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size);
|
||||
void lv_chart_set_axis_tick(lv_obj_t * obj, lv_chart_axis_t axis, lv_coord_t major_len, lv_coord_t minor_len,
|
||||
lv_coord_t major_cnt, lv_coord_t minor_cnt, bool label_en, lv_coord_t draw_size);
|
||||
|
||||
/**
|
||||
* Get the type of a chart
|
||||
|
@ -292,7 +307,7 @@ void lv_chart_set_x_start_point(lv_obj_t * obj, lv_chart_series_t * ser, uint16_
|
|||
* Get the next series.
|
||||
* @param chart pointer to a chart
|
||||
* @param ser the previous series or NULL to get the first
|
||||
* @return the next series or NULL if thre is no more.
|
||||
* @return the next series or NULL if there is no more.
|
||||
*/
|
||||
lv_chart_series_t * lv_chart_get_series_next(const lv_obj_t * chart, const lv_chart_series_t * ser);
|
||||
|
||||
|
@ -326,7 +341,8 @@ void lv_chart_set_cursor_pos(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_po
|
|||
* @param ser pointer to a series
|
||||
* @param point_id the point's index or `LV_CHART_POINT_NONE` to not assign to any points.
|
||||
*/
|
||||
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser, uint16_t point_id);
|
||||
void lv_chart_set_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * cursor, lv_chart_series_t * ser,
|
||||
uint16_t point_id);
|
||||
|
||||
/**
|
||||
* Get the coordinate of the cursor with respect to the paddings
|
||||
|
@ -344,7 +360,7 @@ lv_point_t lv_chart_get_cursor_point(lv_obj_t * chart, lv_chart_cursor_t * curso
|
|||
* Initialize all data points of a series with a value
|
||||
* @param obj pointer to chart object
|
||||
* @param ser pointer to a data series on 'chart'
|
||||
* @param value the new value for all points. `LV_CHART_POINT_DEF` can be used to hide the points.
|
||||
* @param value the new value for all points. `LV_CHART_POINT_NONE` can be used to hide the points.
|
||||
*/
|
||||
void lv_chart_set_all_value(lv_obj_t * obj, lv_chart_series_t * ser, lv_coord_t value);
|
||||
|
||||
|
@ -383,7 +399,8 @@ void lv_chart_set_value_by_id(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t
|
|||
* @param x_value the new X value of the next data
|
||||
* @param y_value the new Y value of the next data
|
||||
*/
|
||||
void lv_chart_set_value_by_id2(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t x_value, lv_coord_t y_value);
|
||||
void lv_chart_set_value_by_id2(lv_obj_t * obj, lv_chart_series_t * ser, uint16_t id, lv_coord_t x_value,
|
||||
lv_coord_t y_value);
|
||||
|
||||
/**
|
||||
* Set an external array for the y data points to use for the chart
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
#include "lv_colorwheel.h"
|
||||
#if LV_USE_COLORWHEEL
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -50,12 +52,12 @@ static uint16_t get_angle(lv_obj_t * obj);
|
|||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_colorwheel_class = {.instance_size = sizeof(lv_colorwheel_t), .base_class = &lv_obj_class,
|
||||
.constructor_cb = lv_colorwheel_constructor,
|
||||
.event_cb = lv_colorwheel_event,
|
||||
.width_def = LV_DPI_DEF * 2,
|
||||
.height_def = LV_DPI_DEF * 2,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
};
|
||||
.constructor_cb = lv_colorwheel_constructor,
|
||||
.event_cb = lv_colorwheel_event,
|
||||
.width_def = LV_DPI_DEF * 2,
|
||||
.height_def = LV_DPI_DEF * 2,
|
||||
.editable = LV_OBJ_CLASS_EDITABLE_TRUE,
|
||||
};
|
||||
|
||||
static bool create_knob_recolor;
|
||||
|
||||
|
@ -74,7 +76,7 @@ static bool create_knob_recolor;
|
|||
*/
|
||||
lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
create_knob_recolor = knob_recolor;
|
||||
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
|
@ -98,6 +100,7 @@ bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv)
|
|||
if(hsv.s > 100) hsv.s = 100;
|
||||
if(hsv.v > 100) hsv.v = 100;
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
if(colorwheel->hsv.h == hsv.h && colorwheel->hsv.s == hsv.s && colorwheel->hsv.v == hsv.v) return false;
|
||||
|
@ -132,6 +135,7 @@ bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color)
|
|||
*/
|
||||
void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
colorwheel->mode = mode;
|
||||
|
@ -146,6 +150,7 @@ void lv_colorwheel_set_mode(lv_obj_t * obj, lv_colorwheel_mode_t mode)
|
|||
*/
|
||||
void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
colorwheel->mode_fixed = fixed;
|
||||
|
@ -163,6 +168,7 @@ void lv_colorwheel_set_mode_fixed(lv_obj_t * obj, bool fixed)
|
|||
*/
|
||||
lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
return colorwheel->hsv;
|
||||
|
@ -175,6 +181,7 @@ lv_color_hsv_t lv_colorwheel_get_hsv(lv_obj_t * obj)
|
|||
*/
|
||||
lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
return lv_color_hsv_to_rgb(colorwheel->hsv.h, colorwheel->hsv.s, colorwheel->hsv.v);
|
||||
|
@ -187,6 +194,7 @@ lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj)
|
|||
*/
|
||||
lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
return colorwheel->mode;
|
||||
|
@ -199,6 +207,7 @@ lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj)
|
|||
*/
|
||||
bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_colorwheel_t * colorwheel = (lv_colorwheel_t *)obj;
|
||||
|
||||
return colorwheel->mode_fixed;
|
||||
|
@ -287,6 +296,8 @@ static void draw_disc_grad(lv_event_t * e)
|
|||
}
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_free_param(&mask_out_param);
|
||||
lv_draw_mask_free_param(&mask_in_param);
|
||||
lv_draw_mask_remove_id(mask_out_id);
|
||||
lv_draw_mask_remove_id(mask_in_id);
|
||||
#endif
|
||||
|
@ -588,7 +599,7 @@ static lv_res_t double_click_reset(lv_obj_t * obj)
|
|||
|
||||
#define SWAPPTR(A, B) do { uint8_t * t = A; A = B; B = t; } while(0)
|
||||
#define HSV_PTR_SWAP(sextant,r,g,b) if((sextant) & 2) { SWAPPTR((r), (b)); } if((sextant) & 4) { SWAPPTR((g), (b)); } if(!((sextant) & 6)) { \
|
||||
if(!((sextant) & 1)) { SWAPPTR((r), (g)); } } else { if((sextant) & 1) { SWAPPTR((r), (g)); } }
|
||||
if(!((sextant) & 1)) { SWAPPTR((r), (g)); } } else { if((sextant) & 1) { SWAPPTR((r), (g)); } }
|
||||
|
||||
/**
|
||||
* Based on the idea from https://www.vagrearg.org/content/hsvrgb
|
||||
|
@ -602,10 +613,13 @@ static lv_res_t double_click_reset(lv_obj_t * obj)
|
|||
* We replace division by 255 by a division by 256, a.k.a a shift right by 8 bits.
|
||||
* This is wrong, but since this is only used to compute the pixels on the screen and not the final color, it's ok.
|
||||
*/
|
||||
static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *g , uint8_t *b);
|
||||
static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *g , uint8_t *b)
|
||||
static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t * r, uint8_t * g, uint8_t * b);
|
||||
static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t * r, uint8_t * g, uint8_t * b)
|
||||
{
|
||||
if (!s) { *r = *g = *b = v; return; }
|
||||
if(!s) {
|
||||
*r = *g = *b = v;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8_t sextant = h >> 8;
|
||||
HSV_PTR_SWAP(sextant, r, g, b); /*Swap pointers so the conversion code is the same*/
|
||||
|
@ -621,7 +635,8 @@ static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *
|
|||
if(!(sextant & 1)) {
|
||||
/*Up slope*/
|
||||
ww = !h_frac ? ((uint16_t)s << 8) : (s * (uint8_t)(-h_frac)); /*Skip multiply if not required*/
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/*Down slope*/
|
||||
ww = s * h_frac;
|
||||
}
|
||||
|
@ -633,7 +648,7 @@ static void fast_hsv2rgb(uint16_t h, uint8_t s, uint8_t v, uint8_t *r, uint8_t *
|
|||
|
||||
static lv_color_t angle_to_mode_color_fast(lv_obj_t * obj, uint16_t angle)
|
||||
{
|
||||
lv_colorwheel_t * ext = (lv_colorwheel_t*)obj;
|
||||
lv_colorwheel_t * ext = (lv_colorwheel_t *)obj;
|
||||
uint8_t r = 0, g = 0, b = 0;
|
||||
static uint16_t h = 0;
|
||||
static uint8_t s = 0, v = 0, m = 255;
|
||||
|
@ -642,25 +657,29 @@ static lv_color_t angle_to_mode_color_fast(lv_obj_t * obj, uint16_t angle)
|
|||
default:
|
||||
case LV_COLORWHEEL_MODE_HUE:
|
||||
/*Don't recompute costly scaling if it does not change*/
|
||||
if (m != ext->mode) {
|
||||
s = (uint8_t)(((uint16_t)ext->hsv.s * 51) / 20); v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20);
|
||||
m = ext->mode;
|
||||
if(m != ext->mode) {
|
||||
s = (uint8_t)(((uint16_t)ext->hsv.s * 51) / 20);
|
||||
v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20);
|
||||
m = ext->mode;
|
||||
}
|
||||
fast_hsv2rgb(angle * 6, s, v, &r, &g, &b); /*A smart compiler will replace x * 6 by (x << 2) + (x << 1) if it's more efficient*/
|
||||
fast_hsv2rgb(angle * 6, s, v, &r, &g,
|
||||
&b); /*A smart compiler will replace x * 6 by (x << 2) + (x << 1) if it's more efficient*/
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_SATURATION:
|
||||
/*Don't recompute costly scaling if it does not change*/
|
||||
if (m != ext->mode) {
|
||||
h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360); v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20);
|
||||
m = ext->mode;
|
||||
if(m != ext->mode) {
|
||||
h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360);
|
||||
v = (uint8_t)(((uint16_t)ext->hsv.v * 51) / 20);
|
||||
m = ext->mode;
|
||||
}
|
||||
fast_hsv2rgb(h, angle, v, &r, &g, &b);
|
||||
break;
|
||||
case LV_COLORWHEEL_MODE_VALUE:
|
||||
/*Don't recompute costly scaling if it does not change*/
|
||||
if (m != ext->mode) {
|
||||
h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360); s = (uint8_t)(((uint16_t)ext->hsv.s * 51) / 20);
|
||||
m = ext->mode;
|
||||
if(m != ext->mode) {
|
||||
h = (uint16_t)(((uint32_t)ext->hsv.h * 6 * 256) / 360);
|
||||
s = (uint8_t)(((uint16_t)ext->hsv.s * 51) / 20);
|
||||
m = ext->mode;
|
||||
}
|
||||
fast_hsv2rgb(h, s, angle, &r, &g, &b);
|
||||
break;
|
||||
|
|
|
@ -34,10 +34,10 @@ lv_imgbtn_state_t get_state(const lv_obj_t * imgbtn);
|
|||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_imgbtn_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.instance_size = sizeof(lv_imgbtn_t),
|
||||
.constructor_cb = lv_imgbtn_constructor,
|
||||
.event_cb = lv_imgbtn_event,
|
||||
.base_class = &lv_obj_class,
|
||||
.instance_size = sizeof(lv_imgbtn_t),
|
||||
.constructor_cb = lv_imgbtn_constructor,
|
||||
.event_cb = lv_imgbtn_event,
|
||||
};
|
||||
|
||||
/**********************
|
||||
|
@ -55,7 +55,7 @@ const lv_obj_class_t lv_imgbtn_class = {
|
|||
*/
|
||||
lv_obj_t * lv_imgbtn_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -77,7 +77,7 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * parent)
|
|||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src_left, const void * src_mid,
|
||||
const void * src_right)
|
||||
const void * src_right)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
|
@ -90,6 +90,23 @@ void lv_imgbtn_set_src(lv_obj_t * obj, lv_imgbtn_state_t state, const void * src
|
|||
refr_img(obj);
|
||||
}
|
||||
|
||||
void lv_imgbtn_set_state(lv_obj_t * obj, lv_imgbtn_state_t state)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_state_t obj_state = LV_STATE_DEFAULT;
|
||||
if(state == LV_IMGBTN_STATE_PRESSED || state == LV_IMGBTN_STATE_CHECKED_PRESSED) obj_state |= LV_STATE_PRESSED;
|
||||
if(state == LV_IMGBTN_STATE_DISABLED || state == LV_IMGBTN_STATE_CHECKED_DISABLED) obj_state |= LV_STATE_DISABLED;
|
||||
if(state == LV_IMGBTN_STATE_CHECKED_DISABLED || state == LV_IMGBTN_STATE_CHECKED_PRESSED || state == LV_IMGBTN_STATE_CHECKED_RELEASED) {
|
||||
obj_state |= LV_STATE_CHECKED;
|
||||
}
|
||||
|
||||
lv_obj_clear_state(obj, LV_STATE_CHECKED | LV_STATE_PRESSED | LV_STATE_DISABLED);
|
||||
lv_obj_add_state(obj, obj_state);
|
||||
|
||||
refr_img(obj);
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
@ -146,13 +163,13 @@ const void * lv_imgbtn_get_src_right(lv_obj_t * obj, lv_imgbtn_state_t state)
|
|||
static void lv_imgbtn_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
/*Initialize the allocated 'ext'*/
|
||||
lv_memset_00((void *)imgbtn->img_src_mid, sizeof(imgbtn->img_src_mid));
|
||||
lv_memset_00(imgbtn->img_src_left, sizeof(imgbtn->img_src_left));
|
||||
lv_memset_00(imgbtn->img_src_right, sizeof(imgbtn->img_src_right));
|
||||
lv_imgbtn_t * imgbtn = (lv_imgbtn_t *)obj;
|
||||
/*Initialize the allocated 'ext'*/
|
||||
lv_memset_00((void *)imgbtn->img_src_mid, sizeof(imgbtn->img_src_mid));
|
||||
lv_memset_00(imgbtn->img_src_left, sizeof(imgbtn->img_src_left));
|
||||
lv_memset_00(imgbtn->img_src_right, sizeof(imgbtn->img_src_right));
|
||||
|
||||
imgbtn->act_cf = LV_IMG_CF_UNKNOWN;
|
||||
imgbtn->act_cf = LV_IMG_CF_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
|
@ -181,8 +198,7 @@ static void lv_imgbtn_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
lv_imgbtn_state_t state = suggest_state(obj, get_state(obj));
|
||||
if(imgbtn->img_src_left[state] == NULL &&
|
||||
imgbtn->img_src_mid[state] != NULL &&
|
||||
imgbtn->img_src_right[state] == NULL)
|
||||
{
|
||||
imgbtn->img_src_right[state] == NULL) {
|
||||
lv_img_header_t header;
|
||||
lv_img_decoder_get_info(imgbtn->img_src_mid[state], &header);
|
||||
p->x = LV_MAX(p->x, header.w);
|
||||
|
@ -260,8 +276,7 @@ static void draw_main(lv_event_t * e)
|
|||
coords_part.x2 = coords_part.x1 + header.w - 1;
|
||||
coords_part.y2 = coords_part.y1 + header.h - 1;
|
||||
|
||||
for(i = 0; i < clip_center_area.x2 + header.w - 1; i += header.w) {
|
||||
|
||||
for(i = coords_part.x1; i < (lv_coord_t)(clip_center_area.x2 + header.w - 1); i += header.w) {
|
||||
lv_draw_img(&coords_part, &clip_center_area, src, &img_dsc);
|
||||
coords_part.x1 = coords_part.x2 + 1;
|
||||
coords_part.x2 += header.w;
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef enum {
|
|||
LV_IMGBTN_STATE_CHECKED_PRESSED,
|
||||
LV_IMGBTN_STATE_CHECKED_DISABLED,
|
||||
_LV_IMGBTN_STATE_NUM,
|
||||
}lv_imgbtn_state_t;
|
||||
} lv_imgbtn_state_t;
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -75,9 +75,16 @@ lv_obj_t * lv_imgbtn_create(lv_obj_t * parent);
|
|||
* to a file)
|
||||
*/
|
||||
void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid,
|
||||
const void * src_right);
|
||||
const void * src_right);
|
||||
|
||||
|
||||
/**
|
||||
* Use this function instead of `lv_obj_add/clear_state` to set a state manually
|
||||
* @param imgbtn pointer to an image button object
|
||||
* @param state the new state
|
||||
*/
|
||||
void lv_imgbtn_set_state(lv_obj_t * imgbtn, lv_imgbtn_state_t state);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
*====================*/
|
||||
|
|
|
@ -11,10 +11,15 @@
|
|||
#if LV_USE_KEYBOARD
|
||||
|
||||
#include "../../../widgets/lv_textarea.h"
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_keyboard_class
|
||||
#define LV_KB_BTN(width) LV_BTNMATRIX_CTRL_POPOVER | width
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -27,6 +32,8 @@ static void lv_keyboard_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
|||
|
||||
static void lv_keyboard_update_map(lv_obj_t * obj);
|
||||
|
||||
static void lv_keyboard_update_ctrl_map(lv_obj_t * obj);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
|
@ -46,9 +53,9 @@ static const char * const default_kb_map_lc[] = {"1#", "q", "w", "e", "r", "t",
|
|||
};
|
||||
|
||||
static const lv_btnmatrix_ctrl_t default_kb_ctrl_lc_map[] = {
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1, 1, 1, 1, 1, 1, 1, 1, LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1),
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2
|
||||
};
|
||||
|
||||
|
@ -59,9 +66,9 @@ static const char * const default_kb_map_uc[] = {"1#", "Q", "W", "E", "R", "T",
|
|||
};
|
||||
|
||||
static const lv_btnmatrix_ctrl_t default_kb_ctrl_uc_map[] = {
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1, 1, 1, 1, 1, 1, 1, 1, LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1, LV_BTNMATRIX_CTRL_CHECKED | 1,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 5, LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_KB_BTN(4), LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 6, LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_KB_BTN(3), LV_BTNMATRIX_CTRL_CHECKED | 7,
|
||||
LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | LV_KB_BTN(1),
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2
|
||||
};
|
||||
|
||||
|
@ -72,9 +79,9 @@ static const char * const default_kb_map_spec[] = {"1", "2", "3", "4", "5", "6",
|
|||
};
|
||||
|
||||
static const lv_btnmatrix_ctrl_t default_kb_ctrl_spec_map[] = {
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, LV_BTNMATRIX_CTRL_CHECKED | 2,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_BTNMATRIX_CTRL_CHECKED | 2,
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1),
|
||||
LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1), LV_KB_BTN(1),
|
||||
LV_KEYBOARD_CTRL_BTN_FLAGS | 2, LV_BTNMATRIX_CTRL_CHECKED | 2, 6, LV_BTNMATRIX_CTRL_CHECKED | 2, LV_KEYBOARD_CTRL_BTN_FLAGS | 2
|
||||
};
|
||||
|
||||
|
@ -91,18 +98,26 @@ static const lv_btnmatrix_ctrl_t default_kb_ctrl_num_map[] = {
|
|||
1, 1, 1, 1, 1
|
||||
};
|
||||
|
||||
static const char * * kb_map[5] = {
|
||||
static const char * * kb_map[9] = {
|
||||
(const char * *)default_kb_map_lc,
|
||||
(const char * *)default_kb_map_uc,
|
||||
(const char * *)default_kb_map_spec,
|
||||
(const char * *)default_kb_map_num,
|
||||
(const char * *)default_kb_map_lc,
|
||||
(const char * *)default_kb_map_lc,
|
||||
(const char * *)default_kb_map_lc,
|
||||
(const char * *)default_kb_map_lc,
|
||||
(const char * *)NULL,
|
||||
};
|
||||
static const lv_btnmatrix_ctrl_t * kb_ctrl[5] = {
|
||||
static const lv_btnmatrix_ctrl_t * kb_ctrl[9] = {
|
||||
default_kb_ctrl_lc_map,
|
||||
default_kb_ctrl_uc_map,
|
||||
default_kb_ctrl_spec_map,
|
||||
default_kb_ctrl_num_map,
|
||||
default_kb_ctrl_lc_map,
|
||||
default_kb_ctrl_lc_map,
|
||||
default_kb_ctrl_lc_map,
|
||||
default_kb_ctrl_lc_map,
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
@ -121,7 +136,7 @@ static const lv_btnmatrix_ctrl_t * kb_ctrl[5] = {
|
|||
*/
|
||||
lv_obj_t * lv_keyboard_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_keyboard_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -142,6 +157,7 @@ void lv_keyboard_set_textarea(lv_obj_t * obj, lv_obj_t * ta)
|
|||
LV_ASSERT_OBJ(ta, &lv_textarea_class);
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
|
||||
/*Hide the cursor of the old Text area if cursor management is enabled*/
|
||||
|
@ -164,12 +180,29 @@ void lv_keyboard_set_textarea(lv_obj_t * obj, lv_obj_t * ta)
|
|||
*/
|
||||
void lv_keyboard_set_mode(lv_obj_t * obj, lv_keyboard_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
if(keyboard->mode == mode) return;
|
||||
|
||||
keyboard->mode = mode;
|
||||
lv_btnmatrix_set_map(obj, kb_map[mode]);
|
||||
lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[mode]);
|
||||
lv_keyboard_update_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the button title in a popover when pressed.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param en whether "popovers" mode is enabled
|
||||
*/
|
||||
void lv_keyboard_set_popovers(lv_obj_t * obj, bool en)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
|
||||
if (keyboard->popovers == en) {
|
||||
return;
|
||||
}
|
||||
|
||||
keyboard->popovers = en;
|
||||
lv_keyboard_update_ctrl_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +212,8 @@ void lv_keyboard_set_mode(lv_obj_t * obj, lv_keyboard_mode_t mode)
|
|||
* @param map pointer to a string array to describe the map.
|
||||
* See 'lv_btnmatrix_set_map()' for more info.
|
||||
*/
|
||||
void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * map[], const lv_btnmatrix_ctrl_t ctrl_map[])
|
||||
void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * map[],
|
||||
const lv_btnmatrix_ctrl_t ctrl_map[])
|
||||
{
|
||||
kb_map[mode] = map;
|
||||
kb_ctrl[mode] = ctrl_map;
|
||||
|
@ -197,6 +231,7 @@ void lv_keyboard_set_map(lv_obj_t * obj, lv_keyboard_mode_t mode, const char * m
|
|||
*/
|
||||
lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
return keyboard->ta;
|
||||
}
|
||||
|
@ -208,25 +243,38 @@ lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * obj)
|
|||
*/
|
||||
lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
return keyboard->mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell whether "popovers" mode is enabled or not.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return true: "popovers" mode is enabled; false: disabled
|
||||
*/
|
||||
bool lv_btnmatrix_get_popovers(const lv_obj_t * obj)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
return keyboard->popovers;
|
||||
}
|
||||
|
||||
/*=====================
|
||||
* Other functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Default keyboard event to add characters to the Text area and change the map.
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the
|
||||
* If a custom `event_cb` is added to the keyboard this function can be called from it to handle the
|
||||
* button clicks
|
||||
* @param kb pointer to a keyboard
|
||||
* @param kb pointer to a keyboard
|
||||
* @param event the triggering event
|
||||
*/
|
||||
void lv_keyboard_def_event_cb(lv_event_t * e)
|
||||
{
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
uint16_t btn_id = lv_btnmatrix_get_selected_btn(obj);
|
||||
if(btn_id == LV_BTNMATRIX_BTN_NONE) return;
|
||||
|
@ -282,13 +330,17 @@ void lv_keyboard_def_event_cb(lv_event_t * e)
|
|||
lv_res_t res = lv_event_send(keyboard->ta, LV_EVENT_READY, NULL);
|
||||
if(res != LV_RES_OK) return;
|
||||
}
|
||||
} else if(strcmp(txt, LV_SYMBOL_LEFT) == 0) {
|
||||
}
|
||||
else if(strcmp(txt, LV_SYMBOL_LEFT) == 0) {
|
||||
lv_textarea_cursor_left(keyboard->ta);
|
||||
} else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0) {
|
||||
}
|
||||
else if(strcmp(txt, LV_SYMBOL_RIGHT) == 0) {
|
||||
lv_textarea_cursor_right(keyboard->ta);
|
||||
} else if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) {
|
||||
}
|
||||
else if(strcmp(txt, LV_SYMBOL_BACKSPACE) == 0) {
|
||||
lv_textarea_del_char(keyboard->ta);
|
||||
} else if(strcmp(txt, "+/-") == 0) {
|
||||
}
|
||||
else if(strcmp(txt, "+/-") == 0) {
|
||||
uint16_t cur = lv_textarea_get_cursor_pos(keyboard->ta);
|
||||
const char * ta_txt = lv_textarea_get_text(keyboard->ta);
|
||||
if(ta_txt[0] == '-') {
|
||||
|
@ -326,24 +378,52 @@ static void lv_keyboard_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
|||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
keyboard->ta = NULL;
|
||||
keyboard->mode = LV_KEYBOARD_MODE_TEXT_LOWER;
|
||||
keyboard->popovers = 0;
|
||||
|
||||
lv_obj_align(obj, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
lv_obj_add_event_cb(obj, lv_keyboard_def_event_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_set_style_base_dir(obj, LV_BASE_DIR_LTR, 0);
|
||||
|
||||
lv_btnmatrix_set_map(obj, kb_map[keyboard->mode]);
|
||||
lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]);
|
||||
lv_keyboard_update_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the key map for the current mode
|
||||
* @param kb pointer to a keyboard object
|
||||
* Update the key and control map for the current mode
|
||||
* @param obj pointer to a keyboard object
|
||||
*/
|
||||
static void lv_keyboard_update_map(lv_obj_t * obj)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
lv_btnmatrix_set_map(obj, kb_map[keyboard->mode]);
|
||||
lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]);
|
||||
lv_keyboard_update_ctrl_map(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the control map for the current mode
|
||||
* @param obj pointer to a keyboard object
|
||||
*/
|
||||
static void lv_keyboard_update_ctrl_map(lv_obj_t * obj)
|
||||
{
|
||||
lv_keyboard_t * keyboard = (lv_keyboard_t *)obj;
|
||||
|
||||
if (keyboard->popovers) {
|
||||
/*Apply the current control map (already includes LV_BTNMATRIX_CTRL_POPOVER flags)*/
|
||||
lv_btnmatrix_set_ctrl_map(obj, kb_ctrl[keyboard->mode]);
|
||||
} else {
|
||||
/*Make a copy of the current control map*/
|
||||
lv_btnmatrix_t * btnm = (lv_btnmatrix_t *)obj;
|
||||
lv_btnmatrix_ctrl_t * ctrl_map = lv_mem_alloc(btnm->btn_cnt * sizeof(lv_btnmatrix_ctrl_t));
|
||||
lv_memcpy(ctrl_map, kb_ctrl[keyboard->mode], sizeof(lv_btnmatrix_ctrl_t) * btnm->btn_cnt);
|
||||
|
||||
/*Remove all LV_BTNMATRIX_CTRL_POPOVER flags*/
|
||||
for(uint16_t i = 0; i < btnm->btn_cnt; i++) {
|
||||
ctrl_map[i] &= (~LV_BTNMATRIX_CTRL_POPOVER);
|
||||
}
|
||||
|
||||
/*Apply new control map and clean up*/
|
||||
lv_btnmatrix_set_ctrl_map(obj, ctrl_map);
|
||||
lv_mem_free(ctrl_map);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*LV_USE_KEYBOARD*/
|
||||
|
|
|
@ -41,6 +41,10 @@ enum {
|
|||
LV_KEYBOARD_MODE_TEXT_UPPER,
|
||||
LV_KEYBOARD_MODE_SPECIAL,
|
||||
LV_KEYBOARD_MODE_NUMBER,
|
||||
LV_KEYBOARD_MODE_USER_1,
|
||||
LV_KEYBOARD_MODE_USER_2,
|
||||
LV_KEYBOARD_MODE_USER_3,
|
||||
LV_KEYBOARD_MODE_USER_4,
|
||||
};
|
||||
typedef uint8_t lv_keyboard_mode_t;
|
||||
|
||||
|
@ -49,6 +53,7 @@ typedef struct {
|
|||
lv_btnmatrix_t btnm;
|
||||
lv_obj_t * ta; /*Pointer to the assigned text area*/
|
||||
lv_keyboard_mode_t mode; /*Key map type*/
|
||||
uint8_t popovers : 1; /*Show button titles in popovers on press*/
|
||||
} lv_keyboard_t;
|
||||
|
||||
extern const lv_obj_class_t lv_keyboard_class;
|
||||
|
@ -82,6 +87,13 @@ void lv_keyboard_set_textarea(lv_obj_t * kb, lv_obj_t * ta);
|
|||
*/
|
||||
void lv_keyboard_set_mode(lv_obj_t * kb, lv_keyboard_mode_t mode);
|
||||
|
||||
/**
|
||||
* Show the button title in a popover when pressed.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @param en whether "popovers" mode is enabled
|
||||
*/
|
||||
void lv_keyboard_set_popovers(lv_obj_t * kb, bool en);
|
||||
|
||||
/**
|
||||
* Set a new map for the keyboard
|
||||
* @param kb pointer to a Keyboard object
|
||||
|
@ -89,7 +101,8 @@ void lv_keyboard_set_mode(lv_obj_t * kb, lv_keyboard_mode_t mode);
|
|||
* @param map pointer to a string array to describe the map.
|
||||
* See 'lv_btnmatrix_set_map()' for more info.
|
||||
*/
|
||||
void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[], const lv_btnmatrix_ctrl_t ctrl_map[]);
|
||||
void lv_keyboard_set_map(lv_obj_t * kb, lv_keyboard_mode_t mode, const char * map[],
|
||||
const lv_btnmatrix_ctrl_t ctrl_map[]);
|
||||
|
||||
/*=====================
|
||||
* Getter functions
|
||||
|
@ -109,6 +122,13 @@ lv_obj_t * lv_keyboard_get_textarea(const lv_obj_t * kb);
|
|||
*/
|
||||
lv_keyboard_mode_t lv_keyboard_get_mode(const lv_obj_t * kb);
|
||||
|
||||
/**
|
||||
* Tell whether "popovers" mode is enabled or not.
|
||||
* @param kb pointer to a Keyboard object
|
||||
* @return true: "popovers" mode is enabled; false: disabled
|
||||
*/
|
||||
bool lv_btnmatrix_get_popovers(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the current map of a keyboard
|
||||
* @param kb pointer to a keyboard object
|
||||
|
@ -125,9 +145,9 @@ static inline const char ** lv_keyboard_get_map_array(const lv_obj_t * kb)
|
|||
|
||||
/**
|
||||
* Default keyboard event to add characters to the Text area and change the map.
|
||||
* If a custom `event_cb` is added to the keyboard this function be called from it to handle the
|
||||
* If a custom `event_cb` is added to the keyboard this function can be called from it to handle the
|
||||
* button clicks
|
||||
* @param kb pointer to a keyboard
|
||||
* @param kb pointer to a keyboard
|
||||
* @param event the triggering event
|
||||
*/
|
||||
void lv_keyboard_def_event_cb(lv_event_t * e);
|
||||
|
|
|
@ -9,19 +9,13 @@
|
|||
#include "lv_led.h"
|
||||
#if LV_USE_LED
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define MY_CLASS &lv_led_class
|
||||
|
||||
#ifndef LV_LED_BRIGHT_MIN
|
||||
# define LV_LED_BRIGHT_MIN 80
|
||||
#endif
|
||||
|
||||
#ifndef LV_LED_BRIGHT_MAX
|
||||
# define LV_LED_BRIGHT_MAX 255
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
@ -36,12 +30,12 @@ static void lv_led_event(const lv_obj_class_t * class_p, lv_event_t * e);
|
|||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_led_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.constructor_cb = lv_led_constructor,
|
||||
.width_def = LV_DPI_DEF / 5,
|
||||
.height_def = LV_DPI_DEF / 5,
|
||||
.event_cb = lv_led_event,
|
||||
.instance_size = sizeof(lv_led_t),
|
||||
.base_class = &lv_obj_class,
|
||||
.constructor_cb = lv_led_constructor,
|
||||
.width_def = LV_DPI_DEF / 5,
|
||||
.height_def = LV_DPI_DEF / 5,
|
||||
.event_cb = lv_led_event,
|
||||
.instance_size = sizeof(lv_led_t),
|
||||
};
|
||||
|
||||
/**********************
|
||||
|
@ -59,7 +53,7 @@ const lv_obj_class_t lv_led_class = {
|
|||
*/
|
||||
lv_obj_t * lv_led_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -76,6 +70,8 @@ lv_obj_t * lv_led_create(lv_obj_t * parent)
|
|||
*/
|
||||
void lv_led_set_color(lv_obj_t * obj, lv_color_t color)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_led_t * led = (lv_led_t *)obj;
|
||||
led->color = color;
|
||||
lv_obj_invalidate(obj);
|
||||
|
@ -88,13 +84,12 @@ void lv_led_set_color(lv_obj_t * obj, lv_color_t color)
|
|||
*/
|
||||
void lv_led_set_brightness(lv_obj_t * obj, uint8_t bright)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_led_t * led = (lv_led_t *)obj;
|
||||
if(led->bright == bright) return;
|
||||
|
||||
if(bright <= LV_LED_BRIGHT_MIN) bright = LV_LED_BRIGHT_MIN;
|
||||
if(bright >= LV_LED_BRIGHT_MAX) bright = LV_LED_BRIGHT_MAX;
|
||||
|
||||
led->bright = bright;
|
||||
led->bright = LV_CLAMP(LV_LED_BRIGHT_MIN, bright, LV_LED_BRIGHT_MAX);
|
||||
|
||||
/*Invalidate the object there fore it will be redrawn*/
|
||||
lv_obj_invalidate(obj);
|
||||
|
@ -142,6 +137,8 @@ void lv_led_toggle(lv_obj_t * obj)
|
|||
*/
|
||||
uint8_t lv_led_get_brightness(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
lv_led_t * led = (lv_led_t *)obj;
|
||||
return led->bright;
|
||||
}
|
||||
|
@ -165,10 +162,12 @@ static void lv_led_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
lv_res_t res;
|
||||
|
||||
/* Call the ancestor's event handler */
|
||||
res = lv_obj_event_base(MY_CLASS, e);
|
||||
if(res != LV_RES_OK) return;
|
||||
|
||||
lv_event_code_t code = lv_event_get_code(e);
|
||||
if(code != LV_EVENT_DRAW_MAIN && code != LV_EVENT_DRAW_MAIN_END) {
|
||||
res = lv_obj_event_base(MY_CLASS, e);
|
||||
if(res != LV_RES_OK) return;
|
||||
}
|
||||
|
||||
lv_obj_t * obj = lv_event_get_target(e);
|
||||
if(code == LV_EVENT_DRAW_MAIN) {
|
||||
/*Make darker colors in a temporary style according to the brightness*/
|
||||
|
@ -195,12 +194,23 @@ static void lv_led_event(const lv_obj_class_t * class_p, lv_event_t * e)
|
|||
/*Set the current shadow width according to brightness proportionally between LV_LED_BRIGHT_OFF
|
||||
* and LV_LED_BRIGHT_ON*/
|
||||
rect_dsc.shadow_width = ((led->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_width) /
|
||||
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
|
||||
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
|
||||
rect_dsc.shadow_spread = ((led->bright - LV_LED_BRIGHT_MIN) * rect_dsc.shadow_spread) /
|
||||
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
|
||||
(LV_LED_BRIGHT_MAX - LV_LED_BRIGHT_MIN);
|
||||
|
||||
const lv_area_t * clip_area = lv_event_get_param(e);
|
||||
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.draw_area = &obj->coords;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_LED_DRAW_PART_RECTANGLE;
|
||||
part_draw_dsc.rect_dsc = &rect_dsc;
|
||||
part_draw_dsc.part = LV_PART_MAIN;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_rect(&obj->coords, clip_area, &rect_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,15 @@ extern "C" {
|
|||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
/** Brightness when the LED if OFF */
|
||||
#ifndef LV_LED_BRIGHT_MIN
|
||||
# define LV_LED_BRIGHT_MIN 80
|
||||
#endif
|
||||
|
||||
/** Brightness when the LED if ON */
|
||||
#ifndef LV_LED_BRIGHT_MAX
|
||||
# define LV_LED_BRIGHT_MAX 255
|
||||
#endif
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -35,6 +44,14 @@ typedef struct {
|
|||
|
||||
extern const lv_obj_class_t lv_led_class;
|
||||
|
||||
/**
|
||||
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_led_class`
|
||||
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
|
||||
*/
|
||||
typedef enum {
|
||||
LV_LED_DRAW_PART_RECTANGLE, /**< The main rectangle*/
|
||||
} lv_led_draw_part_type_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
|
|
@ -55,7 +55,7 @@ const lv_obj_class_t lv_list_text_class = {
|
|||
|
||||
lv_obj_t * lv_list_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_class, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
|
||||
|
@ -64,7 +64,7 @@ lv_obj_t * lv_list_create(lv_obj_t * parent)
|
|||
|
||||
lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_text_class, list);
|
||||
lv_obj_class_init_obj(obj);
|
||||
lv_label_set_text(obj, txt);
|
||||
|
@ -75,7 +75,7 @@ lv_obj_t * lv_list_add_text(lv_obj_t * list, const char * txt)
|
|||
|
||||
lv_obj_t * lv_list_add_btn(lv_obj_t * list, const char * icon, const char * txt)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_list_btn_class, list);
|
||||
lv_obj_class_init_obj(obj);
|
||||
lv_obj_set_size(obj, LV_PCT(100), LV_SIZE_CONTENT);
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "lv_meter.h"
|
||||
#if LV_USE_METER != 0
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -51,7 +53,7 @@ const lv_obj_class_t lv_meter_class = {
|
|||
|
||||
lv_obj_t * lv_meter_create(lv_obj_t * parent)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(MY_CLASS, parent);
|
||||
lv_obj_class_init_obj(obj);
|
||||
return obj;
|
||||
|
@ -63,6 +65,7 @@ lv_obj_t * lv_meter_create(lv_obj_t * parent)
|
|||
|
||||
lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
|
||||
lv_meter_scale_t * scale = _lv_ll_ins_head(&meter->scale_ll);
|
||||
|
@ -81,7 +84,8 @@ lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj)
|
|||
return scale;
|
||||
}
|
||||
|
||||
void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t cnt, uint16_t width, uint16_t len, lv_color_t color)
|
||||
void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t cnt, uint16_t width, uint16_t len,
|
||||
lv_color_t color)
|
||||
{
|
||||
scale->tick_cnt = cnt;
|
||||
scale->tick_width = width;
|
||||
|
@ -90,7 +94,8 @@ void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t
|
|||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t nth, uint16_t width, uint16_t len, lv_color_t color, int16_t label_gap)
|
||||
void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t nth, uint16_t width,
|
||||
uint16_t len, lv_color_t color, int16_t label_gap)
|
||||
{
|
||||
scale->tick_major_nth = nth;
|
||||
scale->tick_major_width = width;
|
||||
|
@ -100,7 +105,8 @@ void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, ui
|
|||
lv_obj_invalidate(obj);
|
||||
}
|
||||
|
||||
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t rotation)
|
||||
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range,
|
||||
uint32_t rotation)
|
||||
{
|
||||
scale->min = min;
|
||||
scale->max = max;
|
||||
|
@ -113,8 +119,10 @@ void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t
|
|||
* Add indicator
|
||||
*====================*/
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width,
|
||||
lv_color_t color, int16_t r_mod)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
|
@ -131,8 +139,10 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t
|
|||
return indic;
|
||||
}
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src, lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src,
|
||||
lv_coord_t pivot_x, lv_coord_t pivot_y)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
|
@ -149,8 +159,10 @@ lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t
|
|||
return indic;
|
||||
}
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod)
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color,
|
||||
int16_t r_mod)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
|
@ -167,8 +179,10 @@ lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale
|
|||
return indic;
|
||||
}
|
||||
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start, lv_color_t color_end, bool local, int16_t width_mod)
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start,
|
||||
lv_color_t color_end, bool local, int16_t width_mod)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
lv_meter_indicator_t * indic = _lv_ll_ins_head(&meter->indicator_ll);
|
||||
LV_ASSERT_MALLOC(indic);
|
||||
|
@ -205,7 +219,8 @@ void lv_meter_set_indicator_value(lv_obj_t * obj, lv_meter_indicator_t * indic,
|
|||
inv_line(obj, indic, old_start);
|
||||
inv_line(obj, indic, old_end);
|
||||
inv_line(obj, indic, value);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_obj_invalidate(obj);
|
||||
}
|
||||
}
|
||||
|
@ -264,6 +279,7 @@ static void lv_meter_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||
static void lv_meter_destructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
{
|
||||
LV_UNUSED(class_p);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_meter_t * meter = (lv_meter_t *)obj;
|
||||
_lv_ll_clear(&meter->indicator_ll);
|
||||
_lv_ll_clear(&meter->scale_ll);
|
||||
|
@ -322,6 +338,14 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area
|
|||
|
||||
lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
lv_meter_indicator_t * indic;
|
||||
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.arc_dsc = &arc_dsc;
|
||||
part_draw_dsc.part = LV_PART_INDICATOR;
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.type = LV_METER_DRAW_PART_ARC;
|
||||
|
||||
_LV_LL_READ_BACK(&meter->indicator_ll, indic) {
|
||||
if(indic->type != LV_METER_INDICATOR_TYPE_ARC) continue;
|
||||
|
||||
|
@ -331,9 +355,18 @@ static void draw_arcs(lv_obj_t * obj, const lv_area_t * clip_area, const lv_area
|
|||
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
|
||||
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_draw_arc(scale_center.x, scale_center.y, r_out + indic->type_data.arc.r_mod, start_angle, end_angle, clip_area, &arc_dsc);
|
||||
int32_t start_angle = lv_map(indic->start_value, scale->min, scale->max, scale->rotation,
|
||||
scale->rotation + scale->angle_range);
|
||||
int32_t end_angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation,
|
||||
scale->rotation + scale->angle_range);
|
||||
|
||||
part_draw_dsc.radius = r_out + indic->type_data.arc.r_mod;
|
||||
part_draw_dsc.sub_part_ptr = indic;
|
||||
part_draw_dsc.p1 = &scale_center;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_arc(scale_center.x, scale_center.y, part_draw_dsc.radius, start_angle, end_angle, clip_area, &arc_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,22 +392,24 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
|
||||
lv_meter_scale_t * scale;
|
||||
|
||||
lv_obj_draw_part_dsc_t dsc;
|
||||
lv_obj_draw_dsc_init(&dsc, clip_area);
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_radius_param_t inner_minor_mask;
|
||||
lv_draw_mask_radius_param_t inner_major_mask;
|
||||
lv_draw_mask_radius_param_t outer_mask;
|
||||
#endif
|
||||
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.part = LV_PART_TICKS;
|
||||
part_draw_dsc.type = LV_METER_DRAW_PART_TICK;
|
||||
part_draw_dsc.line_dsc = &line_dsc;
|
||||
|
||||
_LV_LL_READ_BACK(&meter->scale_ll, scale) {
|
||||
part_draw_dsc.sub_part_ptr = scale;
|
||||
|
||||
lv_coord_t r_out = r_edge + scale->r_mod;
|
||||
lv_coord_t r_in_minor = r_out - scale->tick_length;
|
||||
lv_coord_t r_in_major = r_out - scale->tick_major_length;
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_area_t area_inner_minor;
|
||||
area_inner_minor.x1 = p_center.x - r_in_minor;
|
||||
area_inner_minor.y1 = p_center.y - r_in_minor;
|
||||
|
@ -397,8 +432,7 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
lv_draw_mask_radius_init(&outer_mask, &area_outer, LV_RADIUS_CIRCLE, false);
|
||||
int16_t outer_mask_id = lv_draw_mask_add(&outer_mask, NULL);
|
||||
|
||||
int16_t inner_act_mask_id = -1; /*Will be added later*/
|
||||
#endif
|
||||
int16_t inner_act_mask_id = LV_MASK_ID_INV; /*Will be added later*/
|
||||
|
||||
uint32_t minor_cnt = scale->tick_major_nth ? scale->tick_major_nth - 1 : 0xFFFF;
|
||||
for(i = 0; i < scale->tick_cnt; i++) {
|
||||
|
@ -409,11 +443,8 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
major = true;
|
||||
}
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
inner_act_mask_id = lv_draw_mask_add(major ? &inner_major_mask : &inner_minor_mask, NULL);
|
||||
#endif
|
||||
|
||||
int32_t value_of_line = lv_map(i, 0, scale->tick_cnt - 1, scale->min, scale->max);
|
||||
part_draw_dsc.value = value_of_line;
|
||||
|
||||
lv_color_t line_color = major ? scale->tick_major_color : scale->tick_color;
|
||||
lv_color_t line_color_ori = line_color;
|
||||
|
@ -429,11 +460,13 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
|
||||
if(indic->type_data.scale_lines.color_start.full == indic->type_data.scale_lines.color_end.full) {
|
||||
line_color = indic->type_data.scale_lines.color_start;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
lv_opa_t ratio;
|
||||
if(indic->type_data.scale_lines.local_grad) {
|
||||
ratio = lv_map(value_of_line, indic->start_value, indic->end_value, LV_OPA_TRANSP, LV_OPA_COVER);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ratio = lv_map(value_of_line, scale->min, scale->max, LV_OPA_TRANSP, LV_OPA_COVER);
|
||||
}
|
||||
line_color = lv_color_mix(indic->type_data.scale_lines.color_end, indic->type_data.scale_lines.color_start, ratio);
|
||||
|
@ -457,40 +490,22 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
int32_t cos_high = lv_trigo_cos(angle_high + scale->rotation);
|
||||
int32_t cos_mid = (cos_low * (256 - angle_rem) + cos_high * angle_rem) >> 8;
|
||||
|
||||
|
||||
line_dsc.color = line_color;
|
||||
line_dsc.width = line_width;
|
||||
#if LV_DRAW_COMPLEX
|
||||
/*Use the interpolated angle to get the outer x and y coordinates.
|
||||
*Draw a little bit longer lines to be sure the mask will clip them correctly*/
|
||||
lv_point_t p_outer;
|
||||
p_outer.x = (int32_t)(((int32_t)cos_mid * (r_out + line_width) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x;
|
||||
p_outer.y = (int32_t)(((int32_t)sin_mid * (r_out + line_width) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y;
|
||||
lv_draw_line(&p_outer, &p_center, clip_area, &line_dsc);
|
||||
#else
|
||||
/*Use the interpolated angle to get the outer and inner x and y coordinates.*/
|
||||
lv_point_t p_outer;
|
||||
p_outer.x = (int32_t)(((int32_t)cos_mid * (r_out) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x;
|
||||
p_outer.y = (int32_t)(((int32_t)sin_mid * (r_out) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y;
|
||||
lv_point_t p_inner;
|
||||
lv_coord_t r_in = major ? r_in_major : r_in_minor;
|
||||
p_inner.x = (int32_t)(((int32_t)cos_mid * (r_in) + 127) >> (LV_TRIGO_SHIFT)) + p_center.x;
|
||||
p_inner.y = (int32_t)(((int32_t)sin_mid * (r_in) + 127) >> (LV_TRIGO_SHIFT)) + p_center.y;
|
||||
lv_draw_line(&p_outer, &p_inner, clip_area, &line_dsc);
|
||||
#endif
|
||||
|
||||
line_dsc.color = line_color_ori;
|
||||
line_dsc.width = line_width_ori;
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_remove_id(inner_act_mask_id);
|
||||
#endif
|
||||
part_draw_dsc.p1 = &p_outer;
|
||||
part_draw_dsc.p1 = &p_center;
|
||||
part_draw_dsc.id = i;
|
||||
part_draw_dsc.label_dsc = &label_dsc;
|
||||
|
||||
/*Draw the text*/
|
||||
if(major) {
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_remove_id(outer_mask_id);
|
||||
#endif
|
||||
uint32_t r_text = r_in_major - scale->label_gap;
|
||||
lv_point_t p;
|
||||
p.x = (int32_t)((int32_t)((int32_t)cos_mid * r_text + 127) >> LV_TRIGO_SHIFT) + p_center.x;
|
||||
|
@ -499,15 +514,17 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
lv_draw_label_dsc_t label_dsc_tmp;
|
||||
lv_memcpy(&label_dsc_tmp, &label_dsc, sizeof(label_dsc_tmp));
|
||||
|
||||
dsc.id = i / scale->tick_major_nth;
|
||||
dsc.value = value_of_line;
|
||||
dsc.label_dsc = &label_dsc_tmp;
|
||||
lv_snprintf(dsc.text, sizeof(dsc.text), "%d", value_of_line);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &dsc);
|
||||
part_draw_dsc.label_dsc = &label_dsc_tmp;
|
||||
char buf[16];
|
||||
|
||||
lv_snprintf(buf, sizeof(buf), "%" LV_PRId32, value_of_line);
|
||||
part_draw_dsc.text = buf;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
|
||||
lv_point_t label_size;
|
||||
lv_txt_get_size(&label_size, dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
lv_txt_get_size(&label_size, part_draw_dsc.text, label_dsc.font, label_dsc.letter_space, label_dsc.line_space,
|
||||
LV_COORD_MAX, LV_TEXT_FLAG_NONE);
|
||||
|
||||
lv_area_t label_cord;
|
||||
label_cord.x1 = p.x - label_size.x / 2;
|
||||
|
@ -515,18 +532,29 @@ static void draw_ticks_and_labels(lv_obj_t * obj, const lv_area_t * clip_area, c
|
|||
label_cord.x2 = label_cord.x1 + label_size.x;
|
||||
label_cord.y2 = label_cord.y1 + label_size.y;
|
||||
|
||||
lv_draw_label(&label_cord, clip_area, &label_dsc, dsc.text, NULL);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &dsc);
|
||||
lv_draw_label(&label_cord, clip_area, &label_dsc, part_draw_dsc.text, NULL);
|
||||
|
||||
#if LV_DRAW_COMPLEX
|
||||
outer_mask_id = lv_draw_mask_add(&outer_mask, NULL);
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
part_draw_dsc.label_dsc = NULL;
|
||||
part_draw_dsc.text = NULL;
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
}
|
||||
|
||||
inner_act_mask_id = lv_draw_mask_add(major ? &inner_major_mask : &inner_minor_mask, NULL);
|
||||
lv_draw_line(&p_outer, &p_center, clip_area, &line_dsc);
|
||||
lv_draw_mask_remove_id(inner_act_mask_id);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_MAIN_END, &part_draw_dsc);
|
||||
|
||||
line_dsc.color = line_color_ori;
|
||||
line_dsc.width = line_width_ori;
|
||||
|
||||
}
|
||||
#if LV_DRAW_COMPLEX
|
||||
lv_draw_mask_free_param(&inner_minor_mask);
|
||||
lv_draw_mask_free_param(&inner_major_mask);
|
||||
lv_draw_mask_free_param(&outer_mask);
|
||||
lv_draw_mask_remove_id(outer_mask_id);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,17 +570,23 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
|
|||
|
||||
lv_draw_line_dsc_t line_dsc;
|
||||
lv_draw_line_dsc_init(&line_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_INDICATOR, &line_dsc);
|
||||
lv_obj_init_draw_line_dsc(obj, LV_PART_ITEMS, &line_dsc);
|
||||
|
||||
lv_draw_img_dsc_t img_dsc;
|
||||
lv_draw_img_dsc_init(&img_dsc);
|
||||
lv_obj_init_draw_img_dsc(obj, LV_PART_INDICATOR, &img_dsc);
|
||||
img_dsc.antialias = 1;
|
||||
lv_obj_init_draw_img_dsc(obj, LV_PART_ITEMS, &img_dsc);
|
||||
lv_opa_t opa_main = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
|
||||
lv_obj_draw_part_dsc_t part_draw_dsc;
|
||||
lv_obj_draw_dsc_init(&part_draw_dsc, clip_area);
|
||||
part_draw_dsc.class_p = MY_CLASS;
|
||||
part_draw_dsc.p1 = &scale_center;
|
||||
|
||||
lv_meter_indicator_t * indic;
|
||||
_LV_LL_READ_BACK(&meter->indicator_ll, indic) {
|
||||
lv_meter_scale_t * scale = indic->scale;
|
||||
part_draw_dsc.sub_part_ptr = indic;
|
||||
|
||||
if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_LINE) {
|
||||
int32_t angle = lv_map(indic->end_value, scale->min, scale->max, scale->rotation, scale->rotation + scale->angle_range);
|
||||
lv_coord_t r_out = r_edge + scale->r_mod + indic->type_data.needle_line.r_mod;
|
||||
|
@ -562,7 +596,14 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
|
|||
line_dsc.color = indic->type_data.needle_line.color;
|
||||
line_dsc.width = indic->type_data.needle_line.width;
|
||||
line_dsc.opa = indic->opa > LV_OPA_MAX ? opa_main : (opa_main * indic->opa) >> 8;
|
||||
|
||||
part_draw_dsc.id = LV_METER_DRAW_PART_NEEDLE_LINE;
|
||||
part_draw_dsc.line_dsc = &line_dsc;
|
||||
part_draw_dsc.p2 = &p_end;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_line(&scale_center, &p_end, clip_area, &line_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
else if(indic->type == LV_METER_INDICATOR_TYPE_NEEDLE_IMG) {
|
||||
if(indic->type_data.needle_img.src == NULL) continue;
|
||||
|
@ -582,7 +623,12 @@ static void draw_needles(lv_obj_t * obj, const lv_area_t * clip_area, const lv_a
|
|||
angle = angle * 10;
|
||||
if(angle > 3600) angle -= 3600;
|
||||
img_dsc.angle = angle;
|
||||
|
||||
part_draw_dsc.img_dsc = &img_dsc;
|
||||
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_BEGIN, &part_draw_dsc);
|
||||
lv_draw_img(&a, clip_area, indic->type_data.needle_img.src, &img_dsc);
|
||||
lv_event_send(obj, LV_EVENT_DRAW_PART_END, &part_draw_dsc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -605,8 +651,10 @@ static void inv_arc(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t old_va
|
|||
|
||||
int32_t start_angle = lv_map(old_value, scale->min, scale->max, scale->rotation, scale->angle_range + scale->rotation);
|
||||
int32_t end_angle = lv_map(new_value, scale->min, scale->max, scale->rotation, scale->angle_range + scale->rotation);
|
||||
|
||||
lv_area_t a;
|
||||
lv_draw_arc_get_area(scale_center.x, scale_center.y, r_out, LV_MIN(start_angle, end_angle), LV_MAX(start_angle, end_angle), indic->type_data.arc.width, rounded, &a);
|
||||
lv_draw_arc_get_area(scale_center.x, scale_center.y, r_out, LV_MIN(start_angle, end_angle), LV_MAX(start_angle,
|
||||
end_angle), indic->type_data.arc.width, rounded, &a);
|
||||
lv_obj_invalidate_area(obj, &a);
|
||||
}
|
||||
|
||||
|
@ -656,6 +704,6 @@ static void inv_line(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value
|
|||
a.y2 += scale_center.y + 2;
|
||||
|
||||
lv_obj_invalidate_area(obj, &a);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -17,6 +17,11 @@ extern "C" {
|
|||
|
||||
#if LV_USE_METER != 0
|
||||
|
||||
/*Testing of dependencies*/
|
||||
#if LV_DRAW_COMPLEX == 0
|
||||
#error "lv_meter: Complex drawing is required. Enable it in lv_conf.h (LV_DRAW_COMPLEX 1)"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -44,7 +49,7 @@ typedef struct {
|
|||
int16_t r_mod;
|
||||
uint16_t angle_range;
|
||||
int16_t rotation;
|
||||
}lv_meter_scale_t;
|
||||
} lv_meter_scale_t;
|
||||
|
||||
enum {
|
||||
LV_METER_INDICATOR_TYPE_NEEDLE_IMG,
|
||||
|
@ -64,26 +69,26 @@ typedef struct {
|
|||
struct {
|
||||
const void * src;
|
||||
lv_point_t pivot;
|
||||
}needle_img;
|
||||
} needle_img;
|
||||
struct {
|
||||
uint16_t width;
|
||||
int16_t r_mod;
|
||||
lv_color_t color;
|
||||
}needle_line;
|
||||
} needle_line;
|
||||
struct {
|
||||
uint16_t width;
|
||||
const void * src;
|
||||
lv_color_t color;
|
||||
int16_t r_mod;
|
||||
}arc;
|
||||
} arc;
|
||||
struct {
|
||||
int16_t width_mod;
|
||||
lv_color_t color_start;
|
||||
lv_color_t color_end;
|
||||
uint8_t local_grad :1;
|
||||
}scale_lines;
|
||||
uint8_t local_grad : 1;
|
||||
} scale_lines;
|
||||
} type_data;
|
||||
}lv_meter_indicator_t;
|
||||
} lv_meter_indicator_t;
|
||||
|
||||
/*Data of line meter*/
|
||||
typedef struct {
|
||||
|
@ -94,6 +99,17 @@ typedef struct {
|
|||
|
||||
extern const lv_obj_class_t lv_meter_class;
|
||||
|
||||
/**
|
||||
* `type` field in `lv_obj_draw_part_dsc_t` if `class_p = lv_meter_class`
|
||||
* Used in `LV_EVENT_DRAW_PART_BEGIN` and `LV_EVENT_DRAW_PART_END`
|
||||
*/
|
||||
typedef enum {
|
||||
LV_METER_DRAW_PART_ARC, /**< The arc indicator*/
|
||||
LV_METER_DRAW_PART_NEEDLE_LINE, /**< The needle lines*/
|
||||
LV_METER_DRAW_PART_NEEDLE_IMG, /**< The needle images*/
|
||||
LV_METER_DRAW_PART_TICK, /**< The tick lines and labels*/
|
||||
} lv_meter_draw_part_type_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
@ -126,7 +142,8 @@ lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj);
|
|||
* @param len length of tick lines
|
||||
* @param color color of tick lines
|
||||
*/
|
||||
void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t cnt, uint16_t width, uint16_t len, lv_color_t color);
|
||||
void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t cnt, uint16_t width, uint16_t len,
|
||||
lv_color_t color);
|
||||
|
||||
/**
|
||||
* Make some "normal" ticks major ticks and set their attributes.
|
||||
|
@ -139,7 +156,8 @@ void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t
|
|||
* @param color color of the major ticks
|
||||
* @param label_gap gap between the major ticks and the labels
|
||||
*/
|
||||
void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t nth, uint16_t width, uint16_t len, lv_color_t color, int16_t label_gap);
|
||||
void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t nth, uint16_t width,
|
||||
uint16_t len, lv_color_t color, int16_t label_gap);
|
||||
|
||||
/**
|
||||
* Set the value and angular range of a scale.
|
||||
|
@ -150,7 +168,8 @@ void lv_meter_set_scale_major_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, ui
|
|||
* @param angle_range the angular range of the scale
|
||||
* @param rotation the angular offset from the 3 o'clock position (clock-wise)
|
||||
*/
|
||||
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range, uint32_t rotation);
|
||||
void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t min, int32_t max, uint32_t angle_range,
|
||||
uint32_t rotation);
|
||||
|
||||
/*=====================
|
||||
* Add indicator
|
||||
|
@ -165,7 +184,8 @@ void lv_meter_set_scale_range(lv_obj_t * obj, lv_meter_scale_t * scale, int32_t
|
|||
* @param r_mod the radius modifier (added to the scale's radius) to get the lines length
|
||||
* @return the new indicator
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod);
|
||||
lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width,
|
||||
lv_color_t color, int16_t r_mod);
|
||||
|
||||
/**
|
||||
* Add a needle image indicator the scale
|
||||
|
@ -177,7 +197,8 @@ lv_meter_indicator_t * lv_meter_add_needle_line(lv_obj_t * obj, lv_meter_scale_t
|
|||
* @return the new indicator
|
||||
* @note the needle image should point to the right, like -O----->
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src, lv_coord_t pivot_x, lv_coord_t pivot_y);
|
||||
lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t * scale, const void * src,
|
||||
lv_coord_t pivot_x, lv_coord_t pivot_y);
|
||||
|
||||
/**
|
||||
* Add an arc indicator the scale
|
||||
|
@ -188,7 +209,8 @@ lv_meter_indicator_t * lv_meter_add_needle_img(lv_obj_t * obj, lv_meter_scale_t
|
|||
* @param r_mod the radius modifier (added to the scale's radius) to get the outer radius of the arc
|
||||
* @return the new indicator
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color, int16_t r_mod);
|
||||
lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t width, lv_color_t color,
|
||||
int16_t r_mod);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -201,7 +223,8 @@ lv_meter_indicator_t * lv_meter_add_arc(lv_obj_t * obj, lv_meter_scale_t * scale
|
|||
* @param width_mod add this the affected tick's width
|
||||
* @return the new indicator
|
||||
*/
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start, lv_color_t color_end, bool local, int16_t width_mod);
|
||||
lv_meter_indicator_t * lv_meter_add_scale_lines(lv_obj_t * obj, lv_meter_scale_t * scale, lv_color_t color_start,
|
||||
lv_color_t color_end, bool local, int16_t width_mod);
|
||||
|
||||
/*=====================
|
||||
* Set indicator value
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
#include "lv_msgbox.h"
|
||||
#if LV_USE_MSGBOX
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
#define LV_MSGBOX_FLAG_AUTO_PARENT LV_OBJ_FLAG_WIDGET_1 /*Mark that the parent was automatically created*/
|
||||
#define MY_CLASS &lv_msgbox_class
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
|
@ -27,7 +29,26 @@ static void msgbox_close_click_event_cb(lv_event_t * e);
|
|||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
const lv_obj_class_t lv_msgbox_class = {.base_class = &lv_obj_class};
|
||||
const lv_obj_class_t lv_msgbox_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.width_def = LV_DPI_DEF * 2,
|
||||
.height_def = LV_SIZE_CONTENT,
|
||||
.instance_size = sizeof(lv_msgbox_t)
|
||||
};
|
||||
|
||||
const lv_obj_class_t lv_msgbox_content_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.width_def = LV_PCT(100),
|
||||
.height_def = LV_SIZE_CONTENT,
|
||||
.instance_size = sizeof(lv_obj_t)
|
||||
};
|
||||
|
||||
const lv_obj_class_t lv_msgbox_backdrop_class = {
|
||||
.base_class = &lv_obj_class,
|
||||
.width_def = LV_PCT(100),
|
||||
.height_def = LV_PCT(100),
|
||||
.instance_size = sizeof(lv_obj_t)
|
||||
};
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
|
@ -37,95 +58,123 @@ const lv_obj_class_t lv_msgbox_class = {.base_class = &lv_obj_class};
|
|||
* GLOBAL FUNCTIONS
|
||||
**********************/
|
||||
|
||||
lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[], bool add_close_btn)
|
||||
lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[],
|
||||
bool add_close_btn)
|
||||
{
|
||||
LV_LOG_INFO("begin")
|
||||
LV_LOG_INFO("begin");
|
||||
bool auto_parent = false;
|
||||
if(parent == NULL) {
|
||||
auto_parent = true;
|
||||
parent = lv_obj_create(lv_layer_top());
|
||||
lv_obj_remove_style_all(parent);
|
||||
parent = lv_obj_class_create_obj(&lv_msgbox_backdrop_class, lv_layer_top());
|
||||
LV_ASSERT_MALLOC(parent);
|
||||
lv_obj_class_init_obj(parent);
|
||||
lv_obj_clear_flag(parent, LV_OBJ_FLAG_IGNORE_LAYOUT);
|
||||
lv_obj_set_style_bg_color(parent, lv_palette_main(LV_PALETTE_GREY), 0);
|
||||
lv_obj_set_style_bg_opa(parent, LV_OPA_50, 0);
|
||||
lv_obj_set_size(parent, LV_PCT(100), LV_PCT(100));
|
||||
}
|
||||
|
||||
lv_obj_t * mbox = lv_obj_class_create_obj(&lv_msgbox_class, parent);
|
||||
lv_obj_class_init_obj(mbox);
|
||||
LV_ASSERT_MALLOC(mbox);
|
||||
if(mbox == NULL) return NULL;
|
||||
lv_obj_t * obj = lv_obj_class_create_obj(&lv_msgbox_class, parent);
|
||||
LV_ASSERT_MALLOC(obj);
|
||||
lv_obj_class_init_obj(obj);
|
||||
if(obj == NULL) return NULL;
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
|
||||
if(auto_parent) lv_obj_add_flag(mbox, LV_MSGBOX_FLAG_AUTO_PARENT);
|
||||
if(auto_parent) lv_obj_add_flag(obj, LV_MSGBOX_FLAG_AUTO_PARENT);
|
||||
|
||||
lv_obj_set_size(mbox, LV_DPI_DEF * 2, LV_SIZE_CONTENT);
|
||||
lv_obj_set_flex_flow(mbox, LV_FLEX_FLOW_ROW_WRAP);
|
||||
lv_obj_set_flex_align(mbox, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_START);
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_ROW_WRAP);
|
||||
|
||||
lv_obj_t * label;
|
||||
label = lv_label_create(mbox);
|
||||
lv_label_set_text(label, title);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
if(add_close_btn) lv_obj_set_flex_grow(label, 1);
|
||||
else lv_obj_set_width(label, LV_PCT(100));
|
||||
bool has_title = title && strlen(title) > 0;
|
||||
|
||||
/*When a close button is required, we need the empty label as spacer to push the button to the right*/
|
||||
if (add_close_btn || has_title) {
|
||||
mbox->title = lv_label_create(obj);
|
||||
lv_label_set_text(mbox->title, has_title ? title : "");
|
||||
lv_label_set_long_mode(mbox->title, LV_LABEL_LONG_SCROLL_CIRCULAR);
|
||||
if(add_close_btn) lv_obj_set_flex_grow(mbox->title, 1);
|
||||
else lv_obj_set_width(mbox->title, LV_PCT(100));
|
||||
}
|
||||
|
||||
if(add_close_btn) {
|
||||
lv_obj_t * close_btn = lv_btn_create(mbox);
|
||||
lv_obj_set_ext_click_area(close_btn, LV_DPX(10));
|
||||
lv_obj_add_event_cb(close_btn, msgbox_close_click_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
label = lv_label_create(close_btn);
|
||||
mbox->close_btn = lv_btn_create(obj);
|
||||
lv_obj_set_ext_click_area(mbox->close_btn, LV_DPX(10));
|
||||
lv_obj_add_event_cb(mbox->close_btn, msgbox_close_click_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
lv_obj_t * label = lv_label_create(mbox->close_btn);
|
||||
lv_label_set_text(label, LV_SYMBOL_CLOSE);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(close_btn, LV_PART_MAIN);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(mbox->close_btn, LV_PART_MAIN);
|
||||
lv_coord_t close_btn_size = lv_font_get_line_height(font) + LV_DPX(10);
|
||||
lv_obj_set_size(close_btn, close_btn_size, close_btn_size);
|
||||
lv_obj_set_size(mbox->close_btn, close_btn_size, close_btn_size);
|
||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||
}
|
||||
|
||||
label = lv_label_create(mbox);
|
||||
lv_label_set_text(label, txt);
|
||||
lv_label_set_long_mode(label, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(label, LV_PCT(100));
|
||||
mbox->content = lv_obj_class_create_obj(&lv_msgbox_content_class, obj);
|
||||
|
||||
bool has_txt = txt && strlen(txt) > 0;
|
||||
if (has_txt) {
|
||||
mbox->text = lv_label_create(mbox->content);
|
||||
lv_label_set_text(mbox->text, txt);
|
||||
lv_label_set_long_mode(mbox->text, LV_LABEL_LONG_WRAP);
|
||||
lv_obj_set_width(mbox->text, lv_pct(100));
|
||||
}
|
||||
|
||||
if(btn_txts) {
|
||||
lv_obj_t * btns = lv_btnmatrix_create(mbox);
|
||||
lv_btnmatrix_set_map(btns, btn_txts);
|
||||
lv_btnmatrix_set_btn_ctrl_all(btns, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
|
||||
mbox->btns = lv_btnmatrix_create(obj);
|
||||
lv_btnmatrix_set_map(mbox->btns, btn_txts);
|
||||
lv_btnmatrix_set_btn_ctrl_all(mbox->btns, LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_NO_REPEAT);
|
||||
|
||||
uint32_t btn_cnt = 0;
|
||||
while(btn_txts[btn_cnt] && btn_txts[btn_cnt][0] != '\0') {
|
||||
btn_cnt++;
|
||||
}
|
||||
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(btns, LV_PART_ITEMS);
|
||||
const lv_font_t * font = lv_obj_get_style_text_font(mbox->btns, LV_PART_ITEMS);
|
||||
lv_coord_t btn_h = lv_font_get_line_height(font) + LV_DPI_DEF / 10;
|
||||
lv_obj_set_size(btns, btn_cnt * (2 * LV_DPI_DEF / 3), btn_h);
|
||||
lv_obj_add_flag(btns, LV_OBJ_FLAG_EVENT_BUBBLE); /*To see the event directly on the message box*/
|
||||
lv_obj_set_size(mbox->btns, btn_cnt * (2 * LV_DPI_DEF / 3), btn_h);
|
||||
lv_obj_set_style_max_width(mbox->btns, lv_pct(100), 0);
|
||||
lv_obj_add_flag(mbox->btns, LV_OBJ_FLAG_EVENT_BUBBLE); /*To see the event directly on the message box*/
|
||||
}
|
||||
|
||||
return mbox;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_child(mbox, 0);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
return mbox->title;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj)
|
||||
{
|
||||
lv_obj_t * obj = lv_obj_get_child(mbox, 1);
|
||||
if(lv_obj_check_type(obj, &lv_btn_class)) return obj;
|
||||
else return NULL;
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
return mbox->close_btn;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_child(mbox, lv_obj_get_child_cnt(mbox) - 2);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
return mbox->text;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox)
|
||||
lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj)
|
||||
{
|
||||
return lv_obj_get_child(mbox, lv_obj_get_child_cnt(mbox) - 1);
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
return mbox->content;
|
||||
}
|
||||
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_msgbox_t * mbox = (lv_msgbox_t *)obj;
|
||||
return mbox->btns;
|
||||
}
|
||||
|
||||
uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox)
|
||||
{
|
||||
lv_obj_t * btnm = lv_msgbox_get_btns(mbox);
|
||||
return lv_btnmatrix_get_selected_btn(btnm);
|
||||
}
|
||||
|
||||
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox)
|
||||
|
@ -140,6 +189,11 @@ void lv_msgbox_close(lv_obj_t * mbox)
|
|||
else lv_obj_del(mbox);
|
||||
}
|
||||
|
||||
void lv_msgbox_close_async(lv_obj_t * dialog)
|
||||
{
|
||||
if(lv_obj_has_flag(dialog, LV_MSGBOX_FLAG_AUTO_PARENT)) lv_obj_del_async(lv_obj_get_parent(dialog));
|
||||
else lv_obj_del_async(dialog);
|
||||
}
|
||||
|
||||
/**********************
|
||||
* STATIC FUNCTIONS
|
||||
|
|
|
@ -33,14 +33,26 @@ extern "C" {
|
|||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
lv_obj_t obj;
|
||||
lv_obj_t * title;
|
||||
lv_obj_t * close_btn;
|
||||
lv_obj_t * content;
|
||||
lv_obj_t * text;
|
||||
lv_obj_t * btns;
|
||||
} lv_msgbox_t;
|
||||
|
||||
extern const lv_obj_class_t lv_msgbox_class;
|
||||
extern const lv_obj_class_t lv_msgbox_content_class;
|
||||
extern const lv_obj_class_t lv_msgbox_backdrop_class;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Create a message box objects
|
||||
* Create a message box object
|
||||
* @param parent pointer to parent or NULL to create a full screen modal message box
|
||||
* @param title the title of the message box
|
||||
* @param txt the text of the message box
|
||||
|
@ -48,20 +60,32 @@ extern const lv_obj_class_t lv_msgbox_class;
|
|||
* @param add_close_btn true: add a close button
|
||||
* @return pointer to the message box object
|
||||
*/
|
||||
lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[], bool add_close_btn);
|
||||
lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[],
|
||||
bool add_close_btn);
|
||||
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox);
|
||||
lv_obj_t * lv_msgbox_get_title(lv_obj_t * obj);
|
||||
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox);
|
||||
lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * obj);
|
||||
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * mbox);
|
||||
lv_obj_t * lv_msgbox_get_text(lv_obj_t * obj);
|
||||
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox);
|
||||
lv_obj_t * lv_msgbox_get_content(lv_obj_t * obj);
|
||||
|
||||
lv_obj_t * lv_msgbox_get_btns(lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* Get the index of the selected button
|
||||
* @param mbox message box object
|
||||
* @return index of the button (LV_BTNMATRIX_BTN_NONE: if unset)
|
||||
*/
|
||||
uint16_t lv_msgbox_get_active_btn(lv_obj_t * mbox);
|
||||
|
||||
const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox);
|
||||
|
||||
void lv_msgbox_close(lv_obj_t * mbox);
|
||||
|
||||
void lv_msgbox_close_async(lv_obj_t * mbox);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#if LV_USE_SPAN != 0
|
||||
|
||||
#include "../../../misc/lv_assert.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
@ -45,7 +47,6 @@ static void refresh_self_size(lv_obj_t * obj);
|
|||
static const lv_font_t * lv_span_get_style_text_font(lv_obj_t * par, lv_span_t * span);
|
||||
static lv_coord_t lv_span_get_style_text_letter_space(lv_obj_t * par, lv_span_t * span);
|
||||
static lv_color_t lv_span_get_style_text_color(lv_obj_t * par, lv_span_t * span);
|
||||
static lv_color_t lv_span_get_style_text_color(lv_obj_t * par, lv_span_t * span);
|
||||
static lv_opa_t lv_span_get_style_text_opa(lv_obj_t * par, lv_span_t * span);
|
||||
static lv_opa_t lv_span_get_style_text_blend_mode(lv_obj_t * par, lv_span_t * span);
|
||||
static int32_t lv_span_get_style_text_decor(lv_obj_t * par, lv_span_t * span);
|
||||
|
@ -57,9 +58,10 @@ static bool lv_txt_get_snippet(const char * txt, const lv_font_t * font, lv_coor
|
|||
uint32_t * end_ofs);
|
||||
|
||||
static void lv_snippet_clear(void);
|
||||
static uint16_t lv_get_snippet_cnt();
|
||||
static uint16_t lv_get_snippet_cnt(void);
|
||||
static void lv_snippet_push(lv_snippet_t * item);
|
||||
static lv_snippet_t * lv_get_snippet(uint16_t index);
|
||||
static lv_coord_t convert_indent_pct(lv_obj_t * spans, lv_coord_t width);
|
||||
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
|
@ -107,6 +109,7 @@ lv_span_t * lv_spangroup_new_span(lv_obj_t * obj)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
lv_span_t * span = _lv_ll_ins_tail(&spans->child_ll);
|
||||
LV_ASSERT_MALLOC(span);
|
||||
|
@ -132,6 +135,7 @@ void lv_spangroup_del_span(lv_obj_t * obj, lv_span_t * span)
|
|||
return;
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
lv_span_t * cur_span;
|
||||
_LV_LL_READ(&spans->child_ll, cur_span) {
|
||||
|
@ -214,6 +218,7 @@ void lv_spangroup_set_align(lv_obj_t * obj, lv_text_align_t align)
|
|||
*/
|
||||
void lv_spangroup_set_overflow(lv_obj_t * obj, lv_span_overflow_t overflow)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
if(spans->overflow == overflow) return;
|
||||
|
||||
|
@ -224,10 +229,12 @@ void lv_spangroup_set_overflow(lv_obj_t * obj, lv_span_overflow_t overflow)
|
|||
/**
|
||||
* Set the indent of the spangroup.
|
||||
* @param obj pointer to a spangroup object.
|
||||
* @param indent The first line indentation
|
||||
* @param indent The first line indentation, support percent
|
||||
* for LV_SPAN_MODE_FIXED and LV_SPAN_MODE_BREAK mode.
|
||||
*/
|
||||
void lv_spangroup_set_indent(lv_obj_t * obj, lv_coord_t indent)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
if(spans->indent == indent) return;
|
||||
|
||||
|
@ -243,9 +250,8 @@ void lv_spangroup_set_indent(lv_obj_t * obj, lv_coord_t indent)
|
|||
*/
|
||||
void lv_spangroup_set_mode(lv_obj_t * obj, lv_span_mode_t mode)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
if(spans->mode == mode) return;
|
||||
|
||||
spans->mode = mode;
|
||||
lv_spangroup_refr_mode(obj);
|
||||
}
|
||||
|
@ -254,6 +260,73 @@ void lv_spangroup_set_mode(lv_obj_t * obj, lv_span_mode_t mode)
|
|||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get a spangroup child by its index.
|
||||
*
|
||||
* @param obj The spangroup object
|
||||
* @param id the index of the child.
|
||||
* 0: the oldest (firstly created) child
|
||||
* 1: the second oldest
|
||||
* child count-1: the youngest
|
||||
* -1: the youngest
|
||||
* -2: the second youngest
|
||||
* @return The child span at index `id`, or NULL if the ID does not exist
|
||||
*/
|
||||
lv_span_t * lv_spangroup_get_child(const lv_obj_t * obj, int32_t id)
|
||||
{
|
||||
if(obj == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
lv_ll_t * linked_list = &spans->child_ll;
|
||||
|
||||
bool traverse_forwards = (id >= 0);
|
||||
int32_t cur_idx = 0;
|
||||
lv_ll_node_t * cur_node = linked_list->head;
|
||||
|
||||
/*If using a negative index, start from the tail and use cur -1 to indicate the end*/
|
||||
if(!traverse_forwards) {
|
||||
cur_idx = -1;
|
||||
cur_node = linked_list->tail;
|
||||
}
|
||||
|
||||
while(cur_node != NULL) {
|
||||
if(cur_idx == id) {
|
||||
return (lv_span_t *) cur_node;
|
||||
}
|
||||
if(traverse_forwards) {
|
||||
cur_node = (lv_ll_node_t *) _lv_ll_get_next(linked_list, cur_node);
|
||||
cur_idx++;
|
||||
}
|
||||
else {
|
||||
cur_node = (lv_ll_node_t *) _lv_ll_get_prev(linked_list, cur_node);
|
||||
cur_idx--;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param obj The spangroup object to get the child count of.
|
||||
* @return The span count of the spangroup.
|
||||
*/
|
||||
uint32_t lv_spangroup_get_child_cnt(const lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
|
||||
if(obj == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
return _lv_ll_get_len(&(spans->child_ll));
|
||||
}
|
||||
|
||||
/**
|
||||
* get the align of the spangroup.
|
||||
* @param obj pointer to a spangroup object.
|
||||
|
@ -271,6 +344,7 @@ lv_text_align_t lv_spangroup_get_align(lv_obj_t * obj)
|
|||
*/
|
||||
lv_span_overflow_t lv_spangroup_get_overflow(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
return spans->overflow;
|
||||
}
|
||||
|
@ -282,6 +356,7 @@ lv_span_overflow_t lv_spangroup_get_overflow(lv_obj_t * obj)
|
|||
*/
|
||||
lv_coord_t lv_spangroup_get_indent(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
return spans->indent;
|
||||
}
|
||||
|
@ -293,6 +368,7 @@ lv_coord_t lv_spangroup_get_indent(lv_obj_t * obj)
|
|||
*/
|
||||
lv_span_mode_t lv_spangroup_get_mode(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
return spans->mode;
|
||||
}
|
||||
|
@ -303,6 +379,7 @@ lv_span_mode_t lv_spangroup_get_mode(lv_obj_t * obj)
|
|||
*/
|
||||
void lv_spangroup_refr_mode(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
|
||||
if(spans->mode == LV_SPAN_MODE_EXPAND) {
|
||||
|
@ -340,6 +417,7 @@ void lv_spangroup_refr_mode(lv_obj_t * obj)
|
|||
*/
|
||||
lv_coord_t lv_spangroup_get_max_line_h(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
|
||||
lv_coord_t max_line_h = 0;
|
||||
|
@ -361,21 +439,23 @@ lv_coord_t lv_spangroup_get_max_line_h(lv_obj_t * obj)
|
|||
*/
|
||||
lv_coord_t lv_spangroup_get_expand_width(lv_obj_t * obj)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
|
||||
if(_lv_ll_get_head(&spans->child_ll) == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
lv_coord_t width = 0;
|
||||
lv_coord_t width = LV_COORD_IS_PCT(spans->indent) ? 0 : spans->indent;
|
||||
lv_span_t * cur_span;
|
||||
lv_coord_t letter_space = 0;
|
||||
_LV_LL_READ(&spans->child_ll, cur_span) {
|
||||
const lv_font_t * font = lv_span_get_style_text_font(obj, cur_span);
|
||||
lv_coord_t letter_space = lv_span_get_style_text_letter_space(obj, cur_span);
|
||||
letter_space = lv_span_get_style_text_letter_space(obj, cur_span);
|
||||
uint32_t j = 0;
|
||||
const char * cur_txt = cur_span->txt;
|
||||
span_text_check(&cur_txt);
|
||||
while(cur_txt[j] != 0) {
|
||||
while(cur_txt[j] != '\0') {
|
||||
uint32_t letter = _lv_txt_encoded_next(cur_txt, &j);
|
||||
uint32_t letter_next = _lv_txt_encoded_next(&cur_txt[j], NULL);
|
||||
int32_t letter_w = lv_font_get_glyph_width(font, letter, letter_next);
|
||||
|
@ -383,7 +463,7 @@ lv_coord_t lv_spangroup_get_expand_width(lv_obj_t * obj)
|
|||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
return width - letter_space;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,6 +472,7 @@ lv_coord_t lv_spangroup_get_expand_width(lv_obj_t * obj)
|
|||
*/
|
||||
lv_coord_t lv_spangroup_get_expand_height(lv_obj_t * obj, lv_coord_t width)
|
||||
{
|
||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
if(_lv_ll_get_head(&spans->child_ll) == NULL || width <= 0) {
|
||||
return 0;
|
||||
|
@ -401,12 +482,13 @@ lv_coord_t lv_spangroup_get_expand_height(lv_obj_t * obj, lv_coord_t width)
|
|||
lv_text_flag_t txt_flag = LV_TEXT_FLAG_NONE;
|
||||
lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);
|
||||
lv_coord_t max_width = width;
|
||||
lv_coord_t max_w = max_width - spans->indent; /* first line need minus indent */
|
||||
lv_coord_t indent = convert_indent_pct(obj, max_width);
|
||||
lv_coord_t max_w = max_width - indent; /* first line need minus indent */
|
||||
|
||||
/* coords of draw span-txt */
|
||||
lv_point_t txt_pos;
|
||||
txt_pos.y = 0;
|
||||
txt_pos.x = 0 + spans->indent; /* first line need add indent */
|
||||
txt_pos.x = 0 + indent; /* first line need add indent */
|
||||
|
||||
lv_span_t * cur_span = _lv_ll_get_head(&spans->child_ll);
|
||||
const char * cur_txt = cur_span->txt;
|
||||
|
@ -429,6 +511,8 @@ lv_coord_t lv_spangroup_get_expand_height(lv_obj_t * obj, lv_coord_t width)
|
|||
cur_txt = cur_span->txt;
|
||||
span_text_check(&cur_txt);
|
||||
cur_txt_ofs = 0;
|
||||
/* maybe also cur_txt[cur_txt_ofs] == '\0' */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* init span info to snippet. */
|
||||
|
@ -475,6 +559,7 @@ lv_coord_t lv_spangroup_get_expand_height(lv_obj_t * obj, lv_coord_t width)
|
|||
txt_pos.y += max_line_h;
|
||||
max_w = max_width;
|
||||
}
|
||||
txt_pos.y -= line_space;
|
||||
|
||||
return txt_pos.y;
|
||||
}
|
||||
|
@ -587,6 +672,12 @@ static bool lv_txt_get_snippet(const char * txt, const lv_font_t * font,
|
|||
lv_coord_t letter_space, lv_coord_t max_width, lv_text_flag_t flag,
|
||||
lv_coord_t * use_width, uint32_t * end_ofs)
|
||||
{
|
||||
if(txt == NULL || txt[0] == '\0') {
|
||||
*end_ofs = 0;
|
||||
*use_width = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t ofs = _lv_txt_get_next_line(txt, font, letter_space, max_width, flag);
|
||||
lv_coord_t width = lv_txt_get_width(txt, ofs, font, letter_space, flag);
|
||||
*end_ofs = ofs;
|
||||
|
@ -611,7 +702,7 @@ static void lv_snippet_push(lv_snippet_t * item)
|
|||
}
|
||||
}
|
||||
|
||||
static uint16_t lv_get_snippet_cnt()
|
||||
static uint16_t lv_get_snippet_cnt(void)
|
||||
{
|
||||
return snippet_stack.index;
|
||||
}
|
||||
|
@ -694,13 +785,11 @@ static lv_blend_mode_t lv_span_get_style_text_blend_mode(lv_obj_t * par, lv_span
|
|||
|
||||
static int32_t lv_span_get_style_text_decor(lv_obj_t * par, lv_span_t * span)
|
||||
{
|
||||
LV_UNUSED(par);
|
||||
|
||||
int32_t decor;
|
||||
lv_style_value_t value;
|
||||
lv_res_t res = lv_style_get_prop(&span->style, LV_STYLE_TEXT_DECOR, &value);
|
||||
if(res != LV_RES_OK) {
|
||||
decor = LV_TEXT_DECOR_NONE;
|
||||
decor = (lv_text_decor_t)lv_obj_get_style_text_decor(par, LV_PART_MAIN);;
|
||||
}
|
||||
else {
|
||||
decor = (int32_t)value.num;
|
||||
|
@ -716,6 +805,23 @@ static inline void span_text_check(const char ** text)
|
|||
}
|
||||
}
|
||||
|
||||
static lv_coord_t convert_indent_pct(lv_obj_t * obj, lv_coord_t width)
|
||||
{
|
||||
lv_spangroup_t * spans = (lv_spangroup_t *)obj;
|
||||
|
||||
lv_coord_t indent = spans->indent;
|
||||
if(LV_COORD_IS_PCT(spans->indent)) {
|
||||
if(spans->mode == LV_SPAN_MODE_EXPAND) {
|
||||
indent = 0;
|
||||
}
|
||||
else {
|
||||
indent = (width * LV_COORD_GET_PCT(spans->indent)) / 100;
|
||||
}
|
||||
}
|
||||
|
||||
return indent;
|
||||
}
|
||||
|
||||
/**
|
||||
* draw span group
|
||||
* @param spans obj handle
|
||||
|
@ -740,12 +846,14 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
lv_text_flag_t txt_flag = LV_TEXT_FLAG_NONE;
|
||||
lv_coord_t line_space = lv_obj_get_style_text_line_space(obj, LV_PART_MAIN);;
|
||||
lv_coord_t max_width = lv_area_get_width(coords);
|
||||
lv_coord_t max_w = max_width - spans->indent; /* first line need minus indent */
|
||||
lv_coord_t indent = convert_indent_pct(obj, max_width);
|
||||
lv_coord_t max_w = max_width - indent; /* first line need minus indent */
|
||||
lv_opa_t obj_opa = lv_obj_get_style_opa(obj, LV_PART_MAIN);
|
||||
|
||||
/* coords of draw span-txt */
|
||||
lv_point_t txt_pos;
|
||||
txt_pos.y = coords->y1;
|
||||
txt_pos.x = coords->x1 + spans->indent; /* first line need add indent */
|
||||
txt_pos.x = coords->x1 + indent; /* first line need add indent */
|
||||
|
||||
lv_span_t * cur_span = _lv_ll_get_head(&spans->child_ll);
|
||||
const char * cur_txt = cur_span->txt;
|
||||
|
@ -754,8 +862,11 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
lv_snippet_t snippet; /* use to save cur_span info and push it to stack */
|
||||
memset(&snippet, 0, sizeof(snippet));
|
||||
|
||||
bool is_first_line = true;
|
||||
/* the loop control how many lines need to draw */
|
||||
while(cur_span) {
|
||||
bool is_end_line = false;
|
||||
bool ellipsis_valid = false;
|
||||
lv_coord_t max_line_h = 0; /* the max height of span-font when a line have a lot of span */
|
||||
lv_snippet_clear();
|
||||
|
||||
|
@ -768,6 +879,8 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
cur_txt = cur_span->txt;
|
||||
span_text_check(&cur_txt);
|
||||
cur_txt_ofs = 0;
|
||||
/* maybe also cur_txt[cur_txt_ofs] == '\0' */
|
||||
continue;
|
||||
}
|
||||
|
||||
/* init span info to snippet. */
|
||||
|
@ -779,8 +892,10 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
}
|
||||
|
||||
if(spans->overflow == LV_SPAN_OVERFLOW_ELLIPSIS) {
|
||||
/* span txt overflow, don't push */
|
||||
/* curretn line span txt overflow, don't push */
|
||||
if(txt_pos.y + snippet.line_h - line_space > coords->y2 + 1) {
|
||||
ellipsis_valid = true;
|
||||
is_end_line = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -791,13 +906,32 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
bool isfill = lv_txt_get_snippet(&cur_txt[cur_txt_ofs], snippet.font, snippet.letter_space,
|
||||
max_w, txt_flag, &use_width, &next_ofs);
|
||||
|
||||
/* break word deal width */
|
||||
if(isfill && next_ofs > 0 && lv_get_snippet_cnt() > 0) {
|
||||
uint32_t letter = (uint32_t)cur_txt[cur_txt_ofs + next_ofs - 1];
|
||||
if(!(letter == '\0' || letter == '\n' || letter == '\r' || _lv_txt_is_break_char(letter))) {
|
||||
letter = (uint32_t)cur_txt[cur_txt_ofs + next_ofs];
|
||||
if(!(letter == '\0' || letter == '\n' || letter == '\r' || _lv_txt_is_break_char(letter))) {
|
||||
break;
|
||||
if(isfill) {
|
||||
lv_coord_t next_line_h = snippet.line_h;
|
||||
if(cur_txt[cur_txt_ofs + next_ofs] == '\0') {
|
||||
next_line_h = 0;
|
||||
lv_span_t * next_span = _lv_ll_get_next(&spans->child_ll, cur_span);
|
||||
if(next_span) { /* have the next line */
|
||||
next_line_h = lv_font_get_line_height(lv_span_get_style_text_font(obj, next_span)) + line_space;
|
||||
}
|
||||
}
|
||||
lv_coord_t cur_line_h = max_line_h < snippet.line_h ? snippet.line_h : max_line_h;
|
||||
if(txt_pos.y + cur_line_h + next_line_h - line_space > coords->y2 + 1) { /* for overflow if is end line. */
|
||||
if(cur_txt[cur_txt_ofs + next_ofs] != '\0') {
|
||||
next_ofs = strlen(&cur_txt[cur_txt_ofs]);
|
||||
use_width = lv_txt_get_width(&cur_txt[cur_txt_ofs], next_ofs, snippet.font, snippet.letter_space, txt_flag);
|
||||
ellipsis_valid = spans->overflow == LV_SPAN_OVERFLOW_ELLIPSIS ? true : false;
|
||||
is_end_line = true;
|
||||
}
|
||||
}
|
||||
else if(next_ofs > 0 && lv_get_snippet_cnt() > 0) {
|
||||
/* break word deal width */
|
||||
uint32_t letter = (uint32_t)cur_txt[cur_txt_ofs + next_ofs - 1];
|
||||
if(!(letter == '\0' || letter == '\n' || letter == '\r' || _lv_txt_is_break_char(letter))) {
|
||||
letter = (uint32_t)cur_txt[cur_txt_ofs + next_ofs];
|
||||
if(!(letter == '\0' || letter == '\n' || letter == '\r' || _lv_txt_is_break_char(letter))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -811,10 +945,10 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
}
|
||||
|
||||
lv_snippet_push(&snippet);
|
||||
if(isfill) {
|
||||
max_w = max_w - use_width - snippet.letter_space;
|
||||
if(isfill || max_w <= 0) {
|
||||
break;
|
||||
}
|
||||
max_w -= use_width;
|
||||
}
|
||||
|
||||
/* start current line deal width */
|
||||
|
@ -829,38 +963,19 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
goto Next_line_init;
|
||||
}
|
||||
|
||||
/* overflow deal width */
|
||||
bool ellipsis_valid = false;
|
||||
if(spans->overflow == LV_SPAN_OVERFLOW_ELLIPSIS) {
|
||||
lv_coord_t next_line_h = snippet.line_h;
|
||||
if(cur_txt[cur_txt_ofs] == '\0') { /* current span deal with ok, need get next line first line height */
|
||||
next_line_h = 0;
|
||||
if(cur_span) {
|
||||
lv_span_t * next_span = _lv_ll_get_next(&spans->child_ll, cur_span);
|
||||
if(next_span) { /* have the next line */
|
||||
next_line_h = lv_font_get_line_height(lv_span_get_style_text_font(obj, next_span)) + line_space;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(txt_pos.y + max_line_h + next_line_h > coords->y2 + 1) {
|
||||
ellipsis_valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
/* align deal with */
|
||||
lv_text_align_t align = lv_obj_get_style_text_align(obj, LV_PART_MAIN);
|
||||
if(align != LV_TEXT_ALIGN_LEFT) {
|
||||
lv_coord_t align_ofs = 0;
|
||||
lv_coord_t txts_w = 0;
|
||||
lv_coord_t txts_w = is_first_line ? indent : 0;
|
||||
for(int i = 0; i < item_cnt; i++) {
|
||||
lv_snippet_t * pinfo = lv_get_snippet(i);
|
||||
txts_w += pinfo->txt_w;
|
||||
txts_w = txts_w + pinfo->txt_w + pinfo->letter_space;
|
||||
}
|
||||
txts_w -= lv_get_snippet(item_cnt - 1)->letter_space;
|
||||
align_ofs = max_width > txts_w ? max_width - txts_w : 0;
|
||||
if(align == LV_TEXT_ALIGN_CENTER) {
|
||||
align_ofs = (max_width - txts_w) / 2;
|
||||
}
|
||||
else if(align == LV_TEXT_ALIGN_RIGHT) {
|
||||
align_ofs = max_width - txts_w;
|
||||
align_ofs = align_ofs >> 1;
|
||||
}
|
||||
txt_pos.x += align_ofs;
|
||||
}
|
||||
|
@ -877,6 +992,9 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
pos.y = txt_pos.y + max_line_h - pinfo->line_h;
|
||||
lv_color_t letter_color = lv_span_get_style_text_color(obj, pinfo->span);
|
||||
lv_opa_t letter_opa = lv_span_get_style_text_opa(obj, pinfo->span);
|
||||
if(obj_opa < LV_OPA_MAX) {
|
||||
letter_opa = (uint16_t)((uint16_t)letter_opa * obj_opa) >> 8;
|
||||
}
|
||||
lv_blend_mode_t blend_mode = lv_span_get_style_text_blend_mode(obj, pinfo->span);
|
||||
uint32_t txt_bytes = pinfo->bytes;
|
||||
|
||||
|
@ -884,7 +1002,6 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
uint16_t dot_letter_w = 0;
|
||||
uint16_t dot_width = 0;
|
||||
if(ellipsis_valid) {
|
||||
txt_bytes = strlen(bidi_txt);
|
||||
dot_letter_w = lv_font_get_glyph_width(pinfo->font, '.', '.');
|
||||
dot_width = dot_letter_w * 3;
|
||||
}
|
||||
|
@ -913,6 +1030,9 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
lv_draw_letter(&pos, &clipped_area, pinfo->font, '.', letter_color, letter_opa, blend_mode);
|
||||
pos.x = pos.x + dot_letter_w + pinfo->letter_space;
|
||||
}
|
||||
if(pos.x <= ellipsis_width) {
|
||||
pos.x = ellipsis_width + 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
@ -944,7 +1064,7 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
p1.x = txt_pos.x;
|
||||
p1.y = pos.y + (pinfo->line_h / 2) + line_dsc.width / 2;
|
||||
p1.y = pos.y + ((pinfo->line_h - line_space) >> 1) + (line_dsc.width >> 1);
|
||||
p2.x = pos.x;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, mask, &line_dsc);
|
||||
|
@ -954,7 +1074,7 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
lv_point_t p1;
|
||||
lv_point_t p2;
|
||||
p1.x = txt_pos.x;
|
||||
p1.y = pos.y + pinfo->line_h + line_dsc.width / 2;
|
||||
p1.y = pos.y + pinfo->line_h - line_space - pinfo->font->base_line - pinfo->font->underline_position;
|
||||
p2.x = pos.x;
|
||||
p2.y = p1.y;
|
||||
lv_draw_line(&p1, &p2, &clipped_area, &line_dsc);
|
||||
|
@ -965,9 +1085,10 @@ static void lv_draw_span(lv_obj_t * obj, const lv_area_t * coords, const lv_area
|
|||
|
||||
Next_line_init:
|
||||
/* next line init */
|
||||
is_first_line = false;
|
||||
txt_pos.x = coords->x1;
|
||||
txt_pos.y += max_line_h;
|
||||
if(txt_pos.y > clipped_area.y2 + 1) {
|
||||
if(is_end_line || txt_pos.y > clipped_area.y2 + 1) {
|
||||
return;
|
||||
}
|
||||
max_w = max_width;
|
||||
|
|
|
@ -137,6 +137,27 @@ void lv_spangroup_set_mode(lv_obj_t * obj, lv_span_mode_t mode);
|
|||
* Getter functions
|
||||
*====================*/
|
||||
|
||||
/**
|
||||
* Get a spangroup child by its index.
|
||||
*
|
||||
* @param obj The spangroup object
|
||||
* @param id the index of the child.
|
||||
* 0: the oldest (firstly created) child
|
||||
* 1: the second oldest
|
||||
* child count-1: the youngest
|
||||
* -1: the youngest
|
||||
* -2: the second youngest
|
||||
* @return The child span at index `id`, or NULL if the ID does not exist
|
||||
*/
|
||||
lv_span_t * lv_spangroup_get_child(const lv_obj_t * obj, int32_t id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param obj The spangroup object to get the child count of.
|
||||
* @return The span count of the spangroup.
|
||||
*/
|
||||
uint32_t lv_spangroup_get_child_cnt(const lv_obj_t * obj);
|
||||
|
||||
/**
|
||||
* get the align of the spangroup.
|
||||
* @param obj pointer to a spangroup object.
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue