diff --git a/docs/misc/boxmodel.png b/docs/misc/boxmodel.png index bdd013368..0368fa99a 100644 Binary files a/docs/misc/boxmodel.png and b/docs/misc/boxmodel.png differ diff --git a/src/core/lv_event.c b/src/core/lv_event.c index 45c50c8d2..ff5bd6133 100644 --- a/src/core/lv_event.c +++ b/src/core/lv_event.c @@ -18,6 +18,16 @@ * TYPEDEFS **********************/ +typedef struct _lv_event_t { + struct _lv_obj_t * target; + struct _lv_obj_t * current_target; + lv_event_code_t code; + void * user_data; + void * param; + struct _lv_event_t * prev; + uint8_t deleted :1; +}lv_event_t; + typedef struct _lv_event_dsc_t{ lv_event_cb_t cb; void * user_data; diff --git a/src/core/lv_event.h b/src/core/lv_event.h index 689cbc4bc..d5c5af1a6 100644 --- a/src/core/lv_event.h +++ b/src/core/lv_event.h @@ -81,16 +81,8 @@ typedef enum { _LV_EVENT_LAST /** Number of default events*/ }lv_event_code_t; - -typedef struct _lv_event_t { - struct _lv_obj_t * target; - struct _lv_obj_t * current_target; - lv_event_code_t code; - void * user_data; - void * param; - struct _lv_event_t * prev; - uint8_t deleted :1; -}lv_event_t; +struct _lv_event_t; +typedef struct _lv_event_t lv_event_t; /** * @brief Event callback. diff --git a/src/core/lv_group.c b/src/core/lv_group.c index e5c9252d8..c017514b1 100644 --- a/src/core/lv_group.c +++ b/src/core/lv_group.c @@ -20,6 +20,26 @@ /********************** * TYPEDEFS **********************/ +/** + * 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). + */ +typedef struct _lv_group_t { + lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/ + struct _lv_obj_t ** obj_focus; /**< The object in focus*/ + + lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/ +#if LV_USE_USER_DATA + void * user_data; +#endif + + uint8_t frozen : 1; /**< 1: can't focus to new object*/ + uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/ + uint8_t refocus_policy : 1; /**< 1: Focus prev if focused on deletion. 0: Focus next if focused on + deletion.*/ + uint8_t wrap : 1; /**< 1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end + of list.*/ +} lv_group_t; /********************** * STATIC PROTOTYPES @@ -321,6 +341,10 @@ bool lv_group_get_wrap(lv_group_t * group) return group->wrap ? true : false; } +uint32_t lv_group_get_obj_count(lv_group_t * group) +{ + return _lv_ll_get_len(&group->obj_ll); +} /********************** * STATIC FUNCTIONS **********************/ diff --git a/src/core/lv_group.h b/src/core/lv_group.h index fab33343e..cc0cb4533 100644 --- a/src/core/lv_group.h +++ b/src/core/lv_group.h @@ -46,33 +46,16 @@ typedef uint8_t lv_key_t; * TYPEDEFS **********************/ struct _lv_group_t; +typedef struct _lv_group_t lv_group_t; + struct _lv_obj_t; 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). - */ -typedef struct _lv_group_t { - lv_ll_t obj_ll; /**< Linked list to store the objects in the group*/ - struct _lv_obj_t ** obj_focus; /**< The object in focus*/ - - lv_group_focus_cb_t focus_cb; /**< A function to call when a new object is focused (optional)*/ -#if LV_USE_USER_DATA - void * user_data; -#endif - - uint8_t frozen : 1; /**< 1: can't focus to new object*/ - uint8_t editing : 1; /**< 1: Edit mode, 0: Navigate mode*/ - uint8_t refocus_policy : 1; /**< 1: Focus prev if focused on deletion. 0: Focus next if focused on - deletion.*/ - uint8_t wrap : 1; /**< 1: Focus next/prev can wrap at end of list. 0: Focus next/prev stops at end - of list.*/ -} lv_group_t; - -enum { LV_GROUP_REFOCUS_POLICY_NEXT = 0, LV_GROUP_REFOCUS_POLICY_PREV = 1 }; -typedef uint8_t lv_group_refocus_policy_t; +typedef enum { + LV_GROUP_REFOCUS_POLICY_NEXT = 0, + LV_GROUP_REFOCUS_POLICY_PREV = 1 +}lv_group_refocus_policy_t; /********************** * GLOBAL PROTOTYPES @@ -212,11 +195,18 @@ bool lv_group_get_editing(const lv_group_t * group); /** * Get whether focus next/prev will allow wrapping from first->last or last->first object. - * @param group pointer to group + * @param group pointer to group * @param en true: wrapping enabled; false: wrapping disabled */ bool lv_group_get_wrap(lv_group_t * group); +/** + * Get the number of object in the group + * @param group pointer to a group + * @return number of objects in the group + */ +uint32_t lv_group_get_obj_count(lv_group_t * group); + /********************** * MACROS **********************/ diff --git a/src/core/lv_indev.c b/src/core/lv_indev.c index 55b10898e..2e16b8e5f 100644 --- a/src/core/lv_indev.c +++ b/src/core/lv_indev.c @@ -35,12 +35,12 @@ static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data); static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data); static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data); static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data); -static void indev_proc_press(lv_indev_proc_t * proc); -static void indev_proc_release(lv_indev_proc_t * proc); +static void indev_proc_press(_lv_indev_proc_t * proc); +static void indev_proc_release(_lv_indev_proc_t * proc); static void indev_proc_reset_query_handler(lv_indev_t * indev); -static void indev_click_focus(lv_indev_proc_t * proc); -static void indev_gesture(lv_indev_proc_t * proc); -static bool indev_reset_check(lv_indev_proc_t * proc); +static void indev_click_focus(_lv_indev_proc_t * proc); +static void indev_gesture(_lv_indev_proc_t * proc); +static bool indev_reset_check(_lv_indev_proc_t * proc); /********************** * STATIC VARIABLES @@ -595,7 +595,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /*On enter long press toggle edit mode.*/ if(editable) { /*Don't leave edit mode if there is only one object (nowhere to navigate)*/ - if(_lv_ll_get_len(&g->obj_ll) > 1) { + if(lv_group_get_obj_count(g) > 1) { 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*/ } @@ -654,9 +654,9 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } /*An object is being edited and the button is released.*/ - else if(g->editing) { + else if(lv_group_get_editing(g)) { /*Ignore long pressed enter release because it comes from mode switch*/ - if(!i->proc.long_pr_sent || _lv_ll_get_len(&g->obj_ll) <= 1) { + if(!i->proc.long_pr_sent || lv_group_get_obj_count(g) <= 1) { lv_event_send(indev_obj_act, LV_EVENT_RELEASED, indev_act); if(indev_reset_check(&i->proc)) return; @@ -674,7 +674,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } /*If the focused object is editable and now in navigate mode then on enter switch edit mode*/ - else if(editable && !g->editing && !i->proc.long_pr_sent) { + else if(editable && !lv_group_get_editing(g) && !i->proc.long_pr_sent) { lv_group_set_editing(g, true); /*Set edit mode*/ } } @@ -765,7 +765,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) * @param indev pointer to an input device 'proc' * @return LV_RES_OK: no indev reset required; LV_RES_INV: indev reset is required */ -static void indev_proc_press(lv_indev_proc_t * proc) +static void indev_proc_press(_lv_indev_proc_t * proc) { LV_LOG_INFO("pressed at x:%d y:%d", proc->types.pointer.act_point.x, proc->types.pointer.act_point.y); indev_obj_act = proc->types.pointer.act_obj; @@ -901,7 +901,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) * Process the released state of LV_INDEV_TYPE_POINTER input devices * @param proc pointer to an input device 'proc' */ -static void indev_proc_release(lv_indev_proc_t * proc) +static void indev_proc_release(_lv_indev_proc_t * proc) { if(proc->wait_until_release != 0) { proc->types.pointer.act_obj = NULL; @@ -978,7 +978,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev) * Handle focus/defocus on click for POINTER input devices * @param proc pointer to the state of the indev */ -static void indev_click_focus(lv_indev_proc_t * proc) +static void indev_click_focus(_lv_indev_proc_t * proc) { /*Handle click focus*/ lv_obj_t * obj_to_focus = indev_obj_act; @@ -1047,7 +1047,7 @@ static void indev_click_focus(lv_indev_proc_t * proc) * Handle the gesture of indev_proc_p->types.pointer.act_obj * @param indev pointer to a input device state */ -void indev_gesture(lv_indev_proc_t * proc) +void indev_gesture(_lv_indev_proc_t * proc) { if(proc->types.pointer.scroll_obj) return; @@ -1100,7 +1100,7 @@ void indev_gesture(lv_indev_proc_t * proc) * @param proc pointer to an input device 'proc' * @return true if indev query should be immediately truncated. */ -static bool indev_reset_check(lv_indev_proc_t * proc) +static bool indev_reset_check(_lv_indev_proc_t * proc) { if(proc->reset_query) { indev_obj_act = NULL; diff --git a/src/core/lv_indev_scroll.c b/src/core/lv_indev_scroll.c index efd7cf2d0..8cefbe6fd 100644 --- a/src/core/lv_indev_scroll.c +++ b/src/core/lv_indev_scroll.c @@ -21,13 +21,13 @@ /********************** * STATIC PROTOTYPES **********************/ -static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc); -static void init_scroll_limits(lv_indev_proc_t * proc); +static lv_obj_t * find_scroll_obj(_lv_indev_proc_t * proc); +static void init_scroll_limits(_lv_indev_proc_t * proc); static lv_coord_t find_snap_point_x(const lv_obj_t * obj, lv_coord_t min, lv_coord_t max, lv_coord_t ofs); static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coord_t max, lv_coord_t ofs); -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 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); /********************** @@ -42,7 +42,7 @@ static lv_coord_t elastic_diff(lv_obj_t * scroll_obj, lv_coord_t diff, lv_coord_ * GLOBAL FUNCTIONS **********************/ -void _lv_indev_scroll_handler(lv_indev_proc_t * proc) +void _lv_indev_scroll_handler(_lv_indev_proc_t * proc) { lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj; /*If there is no scroll object yet try to find one*/ @@ -91,7 +91,7 @@ void _lv_indev_scroll_handler(lv_indev_proc_t * proc) } -void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc) +void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc) { lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj; if(scroll_obj == NULL) return; @@ -236,7 +236,7 @@ void lv_indev_scroll_get_snap_dist(lv_obj_t * obj, lv_point_t * p) * STATIC FUNCTIONS **********************/ -static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc) +static lv_obj_t * find_scroll_obj(_lv_indev_proc_t * proc) { lv_obj_t * obj_candidate = NULL; lv_dir_t dir_candidate = LV_DIR_NONE; @@ -341,7 +341,7 @@ static lv_obj_t * find_scroll_obj(lv_indev_proc_t * proc) return obj_candidate; } -static void init_scroll_limits(lv_indev_proc_t * proc) +static void init_scroll_limits(_lv_indev_proc_t * proc) { lv_obj_t * obj = proc->types.pointer.scroll_obj; /*If there no STOP allow scrolling anywhere*/ @@ -508,7 +508,7 @@ static lv_coord_t find_snap_point_y(const lv_obj_t * obj, lv_coord_t min, lv_coo return dist == LV_COORD_MAX ? 0 : -dist; } -static void scroll_limit_diff(lv_indev_proc_t * proc, lv_coord_t * diff_x, lv_coord_t * diff_y) +static void scroll_limit_diff(_lv_indev_proc_t * proc, lv_coord_t * diff_x, lv_coord_t * diff_y) { if(diff_y) { if(proc->types.pointer.scroll_sum.y + *diff_y < proc->types.pointer.scroll_area.y1) { @@ -533,7 +533,7 @@ static void scroll_limit_diff(lv_indev_proc_t * proc, lv_coord_t * diff_x, lv_co -static lv_coord_t scroll_throw_predict_y(lv_indev_proc_t * proc) +static lv_coord_t scroll_throw_predict_y(_lv_indev_proc_t * proc) { lv_coord_t y = proc->types.pointer.scroll_throw_vect.y; lv_coord_t move = 0; @@ -549,7 +549,7 @@ 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 scroll_throw_predict_x(_lv_indev_proc_t * proc) { lv_coord_t x = proc->types.pointer.scroll_throw_vect.x; lv_coord_t move = 0; diff --git a/src/core/lv_indev_scroll.h b/src/core/lv_indev_scroll.h index 83f6aed91..76c64d176 100644 --- a/src/core/lv_indev_scroll.h +++ b/src/core/lv_indev_scroll.h @@ -31,13 +31,13 @@ extern "C" { * Handle scrolling. Called by LVGL during input device processing * @param proc pointer to an input device's proc field */ -void _lv_indev_scroll_handler(lv_indev_proc_t * proc); +void _lv_indev_scroll_handler(_lv_indev_proc_t * proc); /** * Handle throwing after scrolling. Called by LVGL during input device processing * @param proc pointer to an input device's proc field */ -void _lv_indev_scroll_throw_handler(lv_indev_proc_t * proc); +void _lv_indev_scroll_throw_handler(_lv_indev_proc_t * proc); /** * Predict where would a scroll throw end diff --git a/src/draw/lv_draw_label.h b/src/draw/lv_draw_label.h index 930a89ef7..fb71210d5 100644 --- a/src/draw/lv_draw_label.h +++ b/src/draw/lv_draw_label.h @@ -51,7 +51,7 @@ typedef struct { * all the previous characters needs to be checked to calculate the positions. * This structure stores an earlier (e.g. at -1000 px) coordinate and the index of that line. * Therefore the calculations can start from here.*/ -typedef struct { +typedef struct _lv_draw_label_hint_t { /** Index of the line at `y` coordinate*/ int32_t line_start; diff --git a/src/draw/lv_img_decoder.c b/src/draw/lv_img_decoder.c index 4040a1f2c..0bf13831a 100644 --- a/src/draw/lv_img_decoder.c +++ b/src/draw/lv_img_decoder.c @@ -21,6 +21,17 @@ /********************** * TYPEDEFS **********************/ +typedef struct _lv_img_decoder { + lv_img_decoder_info_f_t info_cb; + lv_img_decoder_open_f_t open_cb; + lv_img_decoder_read_line_f_t read_line_cb; + lv_img_decoder_close_f_t close_cb; + +#if LV_USE_USER_DATA + void * user_data; +#endif +} lv_img_decoder_t; + typedef struct { lv_fs_file_t f; lv_color_t * palette; diff --git a/src/draw/lv_img_decoder.h b/src/draw/lv_img_decoder.h index 6c852eae4..01e28342f 100644 --- a/src/draw/lv_img_decoder.h +++ b/src/draw/lv_img_decoder.h @@ -43,6 +43,7 @@ typedef uint8_t lv_img_src_t; /*Decoder function definitions*/ struct _lv_img_decoder; +typedef struct _lv_img_decoder lv_img_decoder_t; struct _lv_img_decoder_dsc; /** @@ -83,17 +84,6 @@ typedef lv_res_t (*lv_img_decoder_read_line_f_t)(struct _lv_img_decoder * decode */ typedef void (*lv_img_decoder_close_f_t)(struct _lv_img_decoder * decoder, struct _lv_img_decoder_dsc * dsc); -typedef struct _lv_img_decoder { - lv_img_decoder_info_f_t info_cb; - lv_img_decoder_open_f_t open_cb; - lv_img_decoder_read_line_f_t read_line_cb; - lv_img_decoder_close_f_t close_cb; - -#if LV_USE_USER_DATA - void * user_data; -#endif -} lv_img_decoder_t; - /**Describe an image decoding session. Stores data about the decoding*/ typedef struct _lv_img_decoder_dsc { /**The decoder which was able to open the image source*/ diff --git a/src/hal/lv_hal_disp.h b/src/hal/lv_hal_disp.h index 5d0e61d7b..1e3214f53 100644 --- a/src/hal/lv_hal_disp.h +++ b/src/hal/lv_hal_disp.h @@ -46,7 +46,7 @@ struct _lv_theme_t; /** * Structure for holding display buffer information. */ -typedef struct { +typedef struct _lv_disp_draw_buf_t{ void * buf1; /**< First display buffer.*/ void * buf2; /**< Second display buffer.*/ diff --git a/src/hal/lv_hal_indev.h b/src/hal/lv_hal_indev.h index d52b0e2df..5cdfe243f 100644 --- a/src/hal/lv_hal_indev.h +++ b/src/hal/lv_hal_indev.h @@ -168,13 +168,13 @@ typedef struct _lv_indev_proc_t { uint32_t pr_timestamp; /**< Pressed time stamp*/ uint32_t longpr_rep_timestamp; /**< Long press repeat time stamp*/ -} lv_indev_proc_t; +} _lv_indev_proc_t; /** The main input device descriptor with driver, runtime data ('proc') and some additional * information*/ typedef struct _lv_indev_t { lv_indev_drv_t * driver; - lv_indev_proc_t proc; + _lv_indev_proc_t proc; struct _lv_obj_t * cursor; /**< Cursor for LV_INPUT_TYPE_POINTER*/ struct _lv_group_t * group; /**< Keypad destination group*/ const lv_point_t * btn_points; /**< Array points assigned to the button ()screen will be pressed diff --git a/src/widgets/lv_arc.c b/src/widgets/lv_arc.c index d775260fc..e0f2064f8 100644 --- a/src/widgets/lv_arc.c +++ b/src/widgets/lv_arc.c @@ -523,7 +523,7 @@ static void lv_arc_event(const lv_obj_class_t * class_p, lv_event_t * e) lv_event_code_t code = lv_event_get_code(e); lv_obj_t * obj = lv_event_get_target(e); - lv_arc_t * arc = (lv_arc_t *)e->target; + lv_arc_t * arc = (lv_arc_t *)lv_event_get_target(e); if(code == LV_EVENT_PRESSING) { lv_indev_t * indev = lv_indev_get_act(); if(indev == NULL) return;