diff --git a/src/lv_core/lv_group.c b/src/lv_core/lv_group.c index f71819672..bda9f098d 100644 --- a/src/lv_core/lv_group.c +++ b/src/lv_core/lv_group.c @@ -157,14 +157,12 @@ void lv_group_remove_obj(lv_obj_t * obj) { lv_group_t * g = obj->group_p; if(g == NULL) return; - if(g->obj_focus == NULL) - return; /*Just to be sure (Not possible if there is at least one object in the group)*/ + if(g->obj_focus == NULL) return; /*Just to be sure (Not possible if there is at least one object in the group)*/ /*Focus on the next object*/ if(*g->obj_focus == obj) { /*If this is the only object in the group then focus to nothing.*/ - if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && - lv_ll_get_tail(&g->obj_ll) == g->obj_focus) { + if(lv_ll_get_head(&g->obj_ll) == g->obj_focus && lv_ll_get_tail(&g->obj_ll) == g->obj_focus) { (*g->obj_focus)->signal_cb(*g->obj_focus, LV_SIGNAL_DEFOCUS, NULL); } /*If there more objects in the group then focus to the next/prev object*/ @@ -199,20 +197,21 @@ void lv_group_remove_obj(lv_obj_t * obj) */ void lv_group_remove_all_objs(lv_group_t * group) { - /*Defocus the the currently focused object*/ - if(group->obj_focus != NULL) { - (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL); - lv_obj_invalidate(*group->obj_focus); - group->obj_focus = NULL; - } + /*Defocus the the currently focused object*/ + if(group->obj_focus != NULL) { + (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL); + lv_obj_invalidate(*group->obj_focus); + group->obj_focus = NULL; + } - /*Remove the objects from the group*/ - lv_obj_t ** obj; - LV_LL_READ(group->obj_ll, obj) { - (*obj)->group_p = NULL; - } + /*Remove the objects from the group*/ + lv_obj_t ** obj; + LV_LL_READ(group->obj_ll, obj) + { + (*obj)->group_p = NULL; + } - lv_ll_clear(&(group->obj_ll)); + lv_ll_clear(&(group->obj_ll)); } /** @@ -359,8 +358,7 @@ void lv_group_set_editing(lv_group_t * group, bool edit) lv_obj_t * focused = lv_group_get_focused(group); if(focused) { - focused->signal_cb(focused, LV_SIGNAL_FOCUS, - NULL); /*Focus again to properly leave/open edit/navigate mode*/ + focused->signal_cb(focused, LV_SIGNAL_FOCUS, NULL); /*Focus again to properly leave/open edit/navigate mode*/ lv_res_t res = lv_event_send(*group->obj_focus, LV_EVENT_FOCUSED, NULL); if(res != LV_RES_OK) return; } @@ -557,8 +555,7 @@ static void style_mod_def(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_ORANGE; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); @@ -588,8 +585,7 @@ static void style_mod_edit_def(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); @@ -657,8 +653,7 @@ static void focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *) if(!lv_obj_get_hidden(*obj_next)) break; } - if(obj_next == group->obj_focus) - return; /*There's only one visible object and it's already focused*/ + if(obj_next == group->obj_focus) return; /*There's only one visible object and it's already focused*/ if(group->obj_focus) { (*group->obj_focus)->signal_cb(*group->obj_focus, LV_SIGNAL_DEFOCUS, NULL); diff --git a/src/lv_core/lv_group.h b/src/lv_core/lv_group.h index 43bc8d12c..58b258d6d 100644 --- a/src/lv_core/lv_group.h +++ b/src/lv_core/lv_group.h @@ -28,18 +28,18 @@ extern "C" { /*For compatibility in signal function define the keys regardless to `LV_USE_GROUP`*/ enum { - LV_KEY_UP = 17, /*0x11*/ - LV_KEY_DOWN = 18, /*0x12*/ - LV_KEY_RIGHT = 19, /*0x13*/ - LV_KEY_LEFT = 20, /*0x14*/ - LV_KEY_ESC = 27, /*0x1B*/ - LV_KEY_DEL = 127, /*0x7F*/ - LV_KEY_BACKSPACE = 8, /*0x08*/ - LV_KEY_ENTER = 10, /*0x0A, '\n'*/ - LV_KEY_NEXT = 9, /*0x09, '\t'*/ - LV_KEY_PREV=11, /*0x0B, '*/ - LV_KEY_HOME = 2, /*0x02, STX*/ - LV_KEY_END = 3, /*0x03, ETX*/ + LV_KEY_UP = 17, /*0x11*/ + LV_KEY_DOWN = 18, /*0x12*/ + LV_KEY_RIGHT = 19, /*0x13*/ + LV_KEY_LEFT = 20, /*0x14*/ + LV_KEY_ESC = 27, /*0x1B*/ + LV_KEY_DEL = 127, /*0x7F*/ + LV_KEY_BACKSPACE = 8, /*0x08*/ + LV_KEY_ENTER = 10, /*0x0A, '\n'*/ + LV_KEY_NEXT = 9, /*0x09, '\t'*/ + LV_KEY_PREV = 11, /*0x0B, '*/ + LV_KEY_HOME = 2, /*0x02, STX*/ + LV_KEY_END = 3, /*0x03, ETX*/ }; typedef uint8_t lv_key_t; @@ -57,10 +57,10 @@ typedef struct _lv_group_t lv_ll_t obj_ll; /*Linked list to store the objects in the group */ lv_obj_t ** obj_focus; /*The object in focus*/ - lv_group_style_mod_cb_t style_mod_cb; /*A function to modifies the style of the focused object*/ + lv_group_style_mod_cb_t style_mod_cb; /*A function to modifies the style of the focused object*/ lv_group_style_mod_cb_t style_mod_edit_cb; /*A function which modifies the style of the edited object*/ - lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/ - lv_style_t style_tmp; /*Stores the modified style of the focused object */ + lv_group_focus_cb_t focus_cb; /*A function to call when a new object is focused (optional)*/ + lv_style_t style_tmp; /*Stores the modified style of the focused object */ #if LV_USE_USER_DATA lv_group_user_data_t user_data; #endif @@ -71,8 +71,8 @@ typedef struct _lv_group_t focused */ 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.*/ + 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 }; @@ -118,7 +118,7 @@ void lv_group_remove_obj(lv_obj_t * obj); * @param group pointer to a group */ void lv_group_remove_all_objs(lv_group_t * group); - + /** * Focus on an object (defocus the current) * @param obj pointer to an object to focus on diff --git a/src/lv_core/lv_indev.c b/src/lv_core/lv_indev.c index 6dc7b7891..398de855b 100644 --- a/src/lv_core/lv_indev.c +++ b/src/lv_core/lv_indev.c @@ -42,7 +42,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev); static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj); static void indev_drag(lv_indev_proc_t * state); static void indev_drag_throw(lv_indev_proc_t * proc); -static bool indev_reset_check(lv_indev_proc_t *proc); +static bool indev_reset_check(lv_indev_proc_t * proc); /********************** * STATIC VARIABLES @@ -117,7 +117,7 @@ void lv_indev_read_task(lv_task_t * task) } while(more_to_read); /*End of indev processing, so no act indev*/ - indev_act = NULL; + indev_act = NULL; indev_obj_act = NULL; LV_LOG_TRACE("indev read task finished"); @@ -196,8 +196,7 @@ void lv_indev_set_cursor(lv_indev_t * indev, lv_obj_t * cur_obj) indev->cursor = cur_obj; lv_obj_set_parent(indev->cursor, lv_disp_get_layer_sys(indev->driver.disp)); - lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, - indev->proc.types.pointer.act_point.y); + lv_obj_set_pos(indev->cursor, indev->proc.types.pointer.act_point.x, indev->proc.types.pointer.act_point.y); } #if LV_USE_GROUP @@ -265,8 +264,7 @@ uint32_t lv_indev_get_key(const lv_indev_t * indev) bool lv_indev_is_dragging(const lv_indev_t * indev) { if(indev == NULL) return false; - if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) - return false; + if(indev->driver.type != LV_INDEV_TYPE_POINTER && indev->driver.type != LV_INDEV_TYPE_BUTTON) return false; return indev->proc.types.pointer.drag_in_prog == 0 ? false : true; } @@ -339,8 +337,8 @@ lv_obj_t * lv_indev_get_obj_act(void) static void indev_pointer_proc(lv_indev_t * i, lv_indev_data_t * data) { /*Move the cursor if set and moved*/ - if(i->cursor != NULL && (i->proc.types.pointer.last_point.x != data->point.x || - i->proc.types.pointer.last_point.y != data->point.y)) { + if(i->cursor != NULL && + (i->proc.types.pointer.last_point.x != data->point.x || i->proc.types.pointer.last_point.y != data->point.y)) { lv_obj_set_pos(i->cursor, data->point.x, data->point.y); } @@ -415,15 +413,13 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) } /*Move the focus on NEXT*/ else if(data->key == LV_KEY_NEXT) { - lv_group_set_editing(g, - false); /*Editing is not used by KEYPAD is be sure it is disabled*/ + lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ lv_group_focus_next(g); if(indev_reset_check(&i->proc)) return; } /*Move the focus on PREV*/ else if(data->key == LV_KEY_PREV) { - lv_group_set_editing(g, - false); /*Editing is not used by KEYPAD is be sure it is disabled*/ + lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ lv_group_focus_prev(g); if(indev_reset_check(&i->proc)) return; } @@ -435,8 +431,7 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) /*Pressing*/ else if(data->state == LV_INDEV_STATE_PR && prev_state == LV_INDEV_STATE_PR) { /*Long press time has elapsed?*/ - if(i->proc.long_pr_sent == 0 && - lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { + if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { i->proc.long_pr_sent = 1; if(data->key == LV_KEY_ENTER) { i->proc.longpr_rep_timestamp = lv_tick_get(); @@ -461,15 +456,13 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) } /*Move the focus on NEXT again*/ else if(data->key == LV_KEY_NEXT) { - lv_group_set_editing( - g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ + lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ lv_group_focus_next(g); if(indev_reset_check(&i->proc)) return; } /*Move the focus on PREV again*/ else if(data->key == LV_KEY_PREV) { - lv_group_set_editing( - g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ + lv_group_set_editing(g, false); /*Editing is not used by KEYPAD is be sure it is disabled*/ lv_group_focus_prev(g); if(indev_reset_check(&i->proc)) return; } @@ -530,7 +523,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) /* Save the last keys before anything else. * They need to be already saved if the the function returns for any reason*/ - lv_indev_state_t last_state = i->proc.types.keypad.last_state; + lv_indev_state_t last_state = i->proc.types.keypad.last_state; i->proc.types.keypad.last_state = data->state; i->proc.types.keypad.last_key = data->key; @@ -581,10 +574,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } } /*Pressing*/ - else if(data->state == LV_INDEV_STATE_PR && - last_state == LV_INDEV_STATE_PR) { - if(i->proc.long_pr_sent == 0 && - lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { + else if(data->state == LV_INDEV_STATE_PR && last_state == LV_INDEV_STATE_PR) { + if(i->proc.long_pr_sent == 0 && lv_tick_elaps(i->proc.pr_timestamp) > i->driver.long_press_time) { bool editable = false; indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); @@ -592,9 +583,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) if(editable) { /*Don't leave edit mode if there is only one object (nowhere to navigate)*/ if(lv_ll_is_empty(&g->obj_ll) == false) { - lv_group_set_editing(g, lv_group_get_editing(g) - ? false - : true); /*Toggle edit mode on long press*/ + lv_group_set_editing(g, lv_group_get_editing(g) ? false : true); /*Toggle edit mode on long press*/ } } /*If not editable then just send a long press signal*/ @@ -608,8 +597,7 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data) } } /*Release happened*/ - else if(data->state == LV_INDEV_STATE_REL && - last_state == LV_INDEV_STATE_PR) { + else if(data->state == LV_INDEV_STATE_REL && last_state == LV_INDEV_STATE_PR) { bool editable = false; indev_obj_act->signal_cb(indev_obj_act, LV_SIGNAL_GET_EDITABLE, &editable); @@ -676,8 +664,7 @@ static void indev_button_proc(lv_indev_t * i, lv_indev_data_t * data) /*Still the same point is pressed*/ if(i->proc.types.pointer.last_point.x == i->proc.types.pointer.act_point.x && - i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && - data->state == LV_INDEV_STATE_PR) { + i->proc.types.pointer.last_point.y == i->proc.types.pointer.act_point.y && data->state == LV_INDEV_STATE_PR) { indev_proc_press(&i->proc); } else { /*If a new point comes always make a release*/ @@ -735,7 +722,7 @@ static void indev_proc_press(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; } - proc->types.pointer.act_obj = indev_obj_act; /*Save the pressed object*/ + proc->types.pointer.act_obj = indev_obj_act; /*Save the pressed object*/ proc->types.pointer.last_obj = indev_obj_act; if(indev_obj_act != NULL) { @@ -890,7 +877,7 @@ static void indev_proc_release(lv_indev_proc_t * proc) if(indev_reset_check(proc)) return; - /*Handle click focus*/ + /*Handle click focus*/ #if LV_USE_GROUP lv_group_t * g = lv_obj_get_group(indev_obj_act); @@ -971,7 +958,7 @@ static void indev_proc_reset_query_handler(lv_indev_t * indev) indev->proc.types.pointer.drag_throw_vect.x = 0; indev->proc.types.pointer.drag_throw_vect.y = 0; indev->proc.reset_query = 0; - indev_obj_act = NULL; + indev_obj_act = NULL; } } /** @@ -994,13 +981,13 @@ static lv_obj_t * indev_search_obj(const lv_indev_proc_t * proc, lv_obj_t * obj) if(lv_area_is_point_on(&ext_area, &proc->types.pointer.act_point)) { #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL - lv_area_t ext_area; - ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1; - ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2; - ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1; - ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2; + lv_area_t ext_area; + ext_area.x1 = obj->coords.x1 - obj->ext_click_pad.x1; + ext_area.x2 = obj->coords.x2 + obj->ext_click_pad.x2; + ext_area.y1 = obj->coords.y1 - obj->ext_click_pad.y1; + ext_area.y2 = obj->coords.y2 + obj->ext_click_pad.y2; - if(lv_area_is_point_on(&ext_area, &proc->types.pointer.act_point)) { + if(lv_area_is_point_on(&ext_area, &proc->types.pointer.act_point)) { #else if(lv_area_is_point_on(&obj->coords, &proc->types.pointer.act_point)) { #endif @@ -1073,8 +1060,8 @@ static void indev_drag(lv_indev_proc_t * state) /*Set new position if the vector is not zero*/ if(state->types.pointer.vect.x != 0 || state->types.pointer.vect.y != 0) { - uint16_t inv_buf_size = lv_disp_get_inv_buf_size( - indev_act->driver.disp); /*Get the number of currently invalidated areas*/ + uint16_t inv_buf_size = + lv_disp_get_inv_buf_size(indev_act->driver.disp); /*Get the number of currently invalidated areas*/ lv_coord_t prev_x = drag_obj->coords.x1; lv_coord_t prev_y = drag_obj->coords.y1; @@ -1090,8 +1077,7 @@ static void indev_drag(lv_indev_proc_t * state) act_x += state->types.pointer.drag_sum.x; act_y += state->types.pointer.drag_sum.y; } - lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, - act_y + state->types.pointer.vect.y); + lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y); } else if(allowed_dirs & LV_DRAG_DIR_HOR) { if(drag_just_started) { act_x += state->types.pointer.drag_sum.x; @@ -1124,8 +1110,7 @@ static void indev_drag(lv_indev_proc_t * state) lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj)); if(act_par_w == prev_par_w && act_par_h == prev_par_h) { uint16_t new_inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp); - lv_disp_pop_from_inv_buf(indev_act->driver.disp, - new_inv_buf_size - inv_buf_size); + lv_disp_pop_from_inv_buf(indev_act->driver.disp, new_inv_buf_size - inv_buf_size); } } } @@ -1218,7 +1203,7 @@ static void indev_drag_throw(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/lv_core/lv_indev.h b/src/lv_core/lv_indev.h index b1527ea0e..69ab5a410 100644 --- a/src/lv_core/lv_indev.h +++ b/src/lv_core/lv_indev.h @@ -146,7 +146,7 @@ lv_task_t * lv_indev_get_read_task(lv_disp_t * indev); * NULL if no object is currently being handled or if groups aren't used. * @return pointer to currently active object */ -lv_obj_t * lv_indev_get_obj_act( void ); +lv_obj_t * lv_indev_get_obj_act(void); /********************** * MACROS diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index 2c03375ca..bdd6f6313 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -39,7 +39,7 @@ typedef struct _lv_event_temp_data lv_obj_t * obj; bool deleted; struct _lv_event_temp_data * prev; -}lv_event_temp_data_t; +} lv_event_temp_data_t; /********************** * STATIC PROTOTYPES @@ -134,8 +134,7 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) LV_LOG_TRACE("Screen create started"); lv_disp_t * disp = lv_disp_get_default(); if(!disp) { - LV_LOG_WARN( - "lv_obj_create: not display created to so far. No place to assign the new screen"); + LV_LOG_WARN("lv_obj_create: not display created to so far. No place to assign the new screen"); return NULL; } @@ -147,11 +146,11 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t)); /*Set coordinates to full screen size*/ - new_obj->coords.x1 = 0; - new_obj->coords.y1 = 0; - new_obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1; - new_obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1; - new_obj->ext_draw_pad = 0; + new_obj->coords.x1 = 0; + new_obj->coords.y1 = 0; + new_obj->coords.x2 = lv_disp_get_hor_res(NULL) - 1; + new_obj->coords.y2 = lv_disp_get_ver_res(NULL) - 1; + new_obj->ext_draw_pad = 0; #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad)); @@ -220,11 +219,11 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) lv_ll_init(&(new_obj->child_ll), sizeof(lv_obj_t)); /*Set coordinates left top corner of parent*/ - new_obj->coords.x1 = parent->coords.x1; - new_obj->coords.y1 = parent->coords.y1; - new_obj->coords.x2 = parent->coords.x1 + LV_OBJ_DEF_WIDTH; - new_obj->coords.y2 = parent->coords.y1 + LV_OBJ_DEF_HEIGHT; - new_obj->ext_draw_pad = 0; + new_obj->coords.x1 = parent->coords.x1; + new_obj->coords.y1 = parent->coords.y1; + new_obj->coords.x2 = parent->coords.x1 + LV_OBJ_DEF_WIDTH; + new_obj->coords.y2 = parent->coords.y1 + LV_OBJ_DEF_HEIGHT; + new_obj->ext_draw_pad = 0; #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad)); @@ -256,7 +255,6 @@ lv_obj_t * lv_obj_create(lv_obj_t * parent, const lv_obj_t * copy) lv_obj_set_design_cb(new_obj, lv_obj_design); new_obj->event_cb = NULL; - #if LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL memset(&new_obj->ext_click_pad, 0, sizeof(new_obj->ext_click_pad)); #endif @@ -381,7 +379,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj) if(group) lv_group_remove_obj(obj); #endif - /*Remove the animations from this object*/ + /*Remove the animations from this object*/ #if LV_USE_ANIMATION lv_anim_del(obj, NULL); #endif @@ -426,7 +424,7 @@ lv_res_t lv_obj_del(lv_obj_t * obj) } #if LV_USE_GROUP - if(indev->group == group && obj == lv_indev_get_obj_act() ) { + if(indev->group == group && obj == lv_indev_get_obj_act()) { lv_indev_reset(indev); } #endif @@ -494,9 +492,8 @@ void lv_obj_invalidate(const lv_obj_t * obj) /*Check through all parents*/ while(par != NULL) { union_ok = lv_area_intersect(&area_trunc, &area_trunc, &par->coords); - if(union_ok == false) break; /*If no common parts with parent break;*/ - if(lv_obj_get_hidden(par)) - return; /*If the parent is hidden then the child is hidden and won't be drawn*/ + if(union_ok == false) break; /*If no common parts with parent break;*/ + if(lv_obj_get_hidden(par)) return; /*If the parent is hidden then the child is hidden and won't be drawn*/ par = lv_obj_get_parent(par); } @@ -608,8 +605,8 @@ void lv_obj_set_pos(lv_obj_t * obj, lv_coord_t x, lv_coord_t y) /*Convert x and y to absolute coordinates*/ lv_obj_t * par = obj->par; - x = x + par->coords.x1; - y = y + par->coords.y1; + x = x + par->coords.x1; + y = y + par->coords.y1; /*Calculate and set the movement*/ lv_point_t diff; @@ -743,8 +740,7 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h) * @param x_mod x coordinate shift after alignment * @param y_mod y coordinate shift after alignment */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, - lv_coord_t y_mod) +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) { lv_coord_t new_x = lv_obj_get_x(obj); lv_coord_t new_y = lv_obj_get_y(obj); @@ -889,8 +885,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co * @param x_mod x coordinate shift after alignment * @param y_mod y coordinate shift after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, - lv_coord_t y_mod) +void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod) { lv_coord_t new_x = lv_obj_get_x(obj); lv_coord_t new_y = lv_obj_get_y(obj); @@ -1038,11 +1033,9 @@ void lv_obj_realign(lv_obj_t * obj) { #if LV_USE_OBJ_REALIGN if(obj->realign.origo_align) - lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, - obj->realign.yofs); + lv_obj_align_origo(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); else - lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, - obj->realign.yofs); + lv_obj_align(obj, obj->realign.base, obj->realign.align, obj->realign.xofs, obj->realign.yofs); #else (void)obj; LV_LOG_WARN("lv_obj_realaign: no effect because LV_USE_OBJ_REALIGN = 0"); @@ -1075,7 +1068,7 @@ void lv_obj_set_auto_realign(lv_obj_t * obj, bool en) */ void lv_obj_set_ext_click_area(lv_obj_t * obj, uint8_t w, uint8_t h) { - obj->ext_click_pad_hor= w; + obj->ext_click_pad_hor = w; obj->ext_click_pad_ver = h; } #endif @@ -1101,11 +1094,11 @@ void lv_obj_set_ext_click_area(lv_obj_t * obj, lv_coord_t left, lv_coord_t right obj->ext_click_pad_hor = LV_MATH_MAX(left, right); obj->ext_click_pad_ver = LV_MATH_MAX(top, bottom); #else - (void) obj; /*Unused*/ - (void) left; /*Unused*/ - (void) right; /*Unused*/ - (void) top; /*Unused*/ - (void) bottom; /*Unused*/ + (void)obj; /*Unused*/ + (void)left; /*Unused*/ + (void)right; /*Unused*/ + (void)top; /*Unused*/ + (void)bottom; /*Unused*/ #endif } @@ -1174,13 +1167,11 @@ void lv_obj_report_style_mod(lv_style_t * style) */ void lv_obj_set_hidden(lv_obj_t * obj, bool en) { - if(!obj->hidden) - lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */ + if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */ obj->hidden = en == false ? 0 : 1; - if(!obj->hidden) - lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */ + if(!obj->hidden) lv_obj_invalidate(obj); /*Invalidate when not hidden (hidden objects are ignored) */ lv_obj_t * par = lv_obj_get_parent(obj); par->signal_cb(par, LV_SIGNAL_CHILD_CHG, obj); @@ -1341,9 +1332,9 @@ lv_res_t lv_event_send(lv_obj_t * obj, lv_event_t event, const void * data) lv_res_t lv_event_send_func(lv_event_cb_t event_cb, lv_obj_t * obj, lv_event_t event, const void * data) { lv_event_temp_data_t event_temp_data; - event_temp_data.obj = obj; + event_temp_data.obj = obj; event_temp_data.deleted = false; - event_temp_data.prev = NULL; + event_temp_data.prev = NULL; if(event_temp_data_head == NULL) { event_temp_data_head = &event_temp_data; @@ -1571,12 +1562,14 @@ uint16_t lv_obj_count_children(const lv_obj_t * obj) * @param obj pointer to an object * @return children number of 'obj' */ -uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj){ +uint16_t lv_obj_count_children_recursive(const lv_obj_t * obj) +{ lv_obj_t * i; uint16_t cnt = 0; - LV_LL_READ(obj->child_ll, i) { - cnt++; // Count the child + LV_LL_READ(obj->child_ll, i) + { + cnt++; // Count the child cnt += lv_obj_count_children_recursive(i); // recursively count children's children } @@ -1696,7 +1689,7 @@ lv_coord_t lv_obj_get_ext_click_pad_left(const lv_obj_t * obj) #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL return obj->ext_click_pad.x1; #else - (void) obj; /*Unused*/ + (void)obj; /*Unused*/ return 0; #endif } @@ -1713,7 +1706,7 @@ lv_coord_t lv_obj_get_ext_click_pad_right(const lv_obj_t * obj) #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL return obj->ext_click_pad.x2; #else - (void) obj; /*Unused*/ + (void)obj; /*Unused*/ return 0; #endif } @@ -1730,7 +1723,7 @@ lv_coord_t lv_obj_get_ext_click_pad_top(const lv_obj_t * obj) #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL return obj->ext_click_pad.y1; #else - (void) obj; /*Unused*/ + (void)obj; /*Unused*/ return 0; #endif } @@ -1747,7 +1740,7 @@ lv_coord_t lv_obj_get_ext_click_pad_bottom(const lv_obj_t * obj) #elif LV_USE_EXT_CLICK_AREA == LV_EXT_CLICK_AREA_FULL return obj->ext_click_pad.y2; #else - (void) obj; /*Unused*/ + (void)obj; /*Unused*/ return 0; #endif } @@ -2031,7 +2024,7 @@ lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj) * @param obj pointer to an object * @return pointer to the user data */ -lv_obj_user_data_t *lv_obj_get_user_data_ptr(lv_obj_t * obj) +lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj) { return &obj->user_data; } @@ -2240,7 +2233,6 @@ static void delete_children(lv_obj_t * obj) if(group) lv_group_remove_obj(obj); #endif - while(i != NULL) { /*Get the next object before delete this*/ i_next = lv_ll_get_next(&(obj->child_ll), i); @@ -2274,7 +2266,7 @@ static void delete_children(lv_obj_t * obj) indev->proc.types.pointer.last_pressed = NULL; } #if LV_USE_GROUP - if(indev->group == group && obj == lv_indev_get_obj_act() ) { + if(indev->group == group && obj == lv_indev_get_obj_act()) { lv_indev_reset(indev); } #endif diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 56b395e8f..add883d4b 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -45,9 +45,9 @@ extern "C" { #define LV_MAX_ANCESTOR_NUM 8 -#define LV_EXT_CLICK_AREA_OFF 0 -#define LV_EXT_CLICK_AREA_TINY 1 -#define LV_EXT_CLICK_AREA_FULL 2 +#define LV_EXT_CLICK_AREA_OFF 0 +#define LV_EXT_CLICK_AREA_TINY 1 +#define LV_EXT_CLICK_AREA_FULL 2 /********************** * TYPEDEFS @@ -62,15 +62,14 @@ enum { }; typedef uint8_t lv_design_mode_t; -typedef bool (*lv_design_cb_t)(struct _lv_obj_t * obj, const lv_area_t * mask_p, - lv_design_mode_t mode); +typedef bool (*lv_design_cb_t)(struct _lv_obj_t * obj, const lv_area_t * mask_p, lv_design_mode_t mode); enum { - LV_EVENT_PRESSED, /*The object has been pressed*/ - LV_EVENT_PRESSING, /*The object is being pressed (called continuously while pressing)*/ - LV_EVENT_PRESS_LOST, /*Still pressing but slid from the objects*/ - LV_EVENT_SHORT_CLICKED, /*Released before long press time. Not called if dragged.*/ - LV_EVENT_LONG_PRESSED, /*Pressing for `LV_INDEV_LONG_PRESS_TIME` time. Not called if dragged.*/ + LV_EVENT_PRESSED, /*The object has been pressed*/ + LV_EVENT_PRESSING, /*The object is being pressed (called continuously while pressing)*/ + LV_EVENT_PRESS_LOST, /*Still pressing but slid from the objects*/ + LV_EVENT_SHORT_CLICKED, /*Released before long press time. Not called if dragged.*/ + LV_EVENT_LONG_PRESSED, /*Pressing for `LV_INDEV_LONG_PRESS_TIME` time. Not called if dragged.*/ LV_EVENT_LONG_PRESSED_REPEAT, /*Called after `LV_INDEV_LONG_PRESS_TIME` in every `LV_INDEV_LONG_PRESS_REP_TIME` ms. Not called if dragged.*/ LV_EVENT_CLICKED, /*Called on release if not dragged (regardless to long press)*/ @@ -182,7 +181,7 @@ typedef struct _lv_obj_t lv_signal_cb_t signal_cb; /*Object type specific signal function*/ lv_design_cb_t design_cb; /*Object type specific design function*/ - void * ext_attr; /*Object type specific extended data*/ + void * ext_attr; /*Object type specific extended data*/ const lv_style_t * style_p; /*Pointer to the object's style*/ #if LV_USE_GROUP != 0 @@ -199,22 +198,22 @@ typedef struct _lv_obj_t #endif /*Attributes and states*/ - uint8_t click :1; /*1: Can be pressed by an input device*/ - uint8_t drag :1; /*1: Enable the dragging*/ - uint8_t drag_throw :1; /*1: Enable throwing with drag*/ - uint8_t drag_parent :1; /*1: Parent will be dragged instead*/ - uint8_t hidden :1; /*1: Object is hidden*/ - uint8_t top :1; /*1: If the object or its children is clicked it goes to the foreground*/ - uint8_t opa_scale_en :1; /*1: opa_scale is set*/ - uint8_t parent_event :1; /*1: Send the object's events to the parent too. */ + uint8_t click : 1; /*1: Can be pressed by an input device*/ + uint8_t drag : 1; /*1: Enable the dragging*/ + uint8_t drag_throw : 1; /*1: Enable throwing with drag*/ + uint8_t drag_parent : 1; /*1: Parent will be dragged instead*/ + uint8_t hidden : 1; /*1: Object is hidden*/ + uint8_t top : 1; /*1: If the object or its children is clicked it goes to the foreground*/ + uint8_t opa_scale_en : 1; /*1: opa_scale is set*/ + uint8_t parent_event : 1; /*1: Send the object's events to the parent too. */ lv_drag_dir_t drag_dir : 2; /* Which directions the object can be dragged in */ - uint8_t reserved :6; /*Reserved for future use*/ - uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from - `lv_protect_t`*/ - lv_opa_t opa_scale; /*Scale down the opacity by this factor. Effects all children as well*/ + uint8_t reserved : 6; /*Reserved for future use*/ + uint8_t protect; /*Automatically happening actions can be prevented. 'OR'ed values from + `lv_protect_t`*/ + lv_opa_t opa_scale; /*Scale down the opacity by this factor. Effects all children as well*/ lv_coord_t ext_draw_pad; /*EXTtend the size in every direction for drawing. */ - + #if LV_USE_OBJ_REALIGN lv_reailgn_t realign; #endif @@ -370,8 +369,7 @@ void lv_obj_set_height(lv_obj_t * obj, lv_coord_t h); * @param x_mod x coordinate shift after alignment * @param y_mod y coordinate shift after alignment */ -void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, - lv_coord_t y_mod); +void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); /** * Align an object to an other object. @@ -381,8 +379,7 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co * @param x_mod x coordinate shift after alignment * @param y_mod y coordinate shift after alignment */ -void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, - lv_coord_t y_mod); +void lv_obj_align_origo(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod); /** * Realign the object based on the last `lv_obj_align` parameters. @@ -904,7 +901,7 @@ lv_obj_user_data_t lv_obj_get_user_data(lv_obj_t * obj); * @param obj pointer to an object * @return pointer to the user data */ -lv_obj_user_data_t *lv_obj_get_user_data_ptr(lv_obj_t * obj); +lv_obj_user_data_t * lv_obj_get_user_data_ptr(lv_obj_t * obj); /** * Set the object's user data. The data will be copied. diff --git a/src/lv_core/lv_refr.c b/src/lv_core/lv_refr.c index ba5bf83a1..2eb432133 100644 --- a/src/lv_core/lv_refr.c +++ b/src/lv_core/lv_refr.c @@ -24,7 +24,7 @@ * DEFINES *********************/ /* Draw translucent random colored areas on the invalidated (redrawn) areas*/ -#define MASK_AREA_DEBUG 0 +#define MASK_AREA_DEBUG 0 /********************** * TYPEDEFS @@ -154,7 +154,6 @@ void lv_refr_set_disp_refreshing(lv_disp_t * disp) disp_refr = disp; } - /** * Called periodically to handle the refreshing * @param task pointer to the task itself @@ -184,7 +183,8 @@ void lv_disp_refr_task(lv_task_t * task) /* With true double buffering the flushing should be only the address change of the * current frame buffer. Wait until the address change is ready and copy the changed * content to the other frame buffer (new active VDB) to keep the buffers synchronized*/ - while(vdb->flushing); + while(vdb->flushing) + ; uint8_t * buf_act = (uint8_t *)vdb->buf_act; uint8_t * buf_ina = (uint8_t *)vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1; @@ -195,10 +195,8 @@ void lv_disp_refr_task(lv_task_t * task) if(disp_refr->inv_area_joined[a] == 0) { lv_coord_t y; uint32_t start_offs = - (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * - sizeof(lv_color_t); - uint32_t line_length = - lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t); + (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t); + uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t); for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) { memcpy(buf_act + start_offs, buf_ina + start_offs, line_length); @@ -245,18 +243,15 @@ static void lv_refr_join_area(void) } /*Check if the areas are on each other*/ - if(lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) == - false) { + if(lv_area_is_on(&disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]) == false) { continue; } - lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], - &disp_refr->inv_areas[join_from]); + lv_area_join(&joined_area, &disp_refr->inv_areas[join_in], &disp_refr->inv_areas[join_from]); /*Join two area only if the joined area size is smaller*/ - if(lv_area_get_size(&joined_area) < - (lv_area_get_size(&disp_refr->inv_areas[join_in]) + - lv_area_get_size(&disp_refr->inv_areas[join_from]))) { + if(lv_area_get_size(&joined_area) < (lv_area_get_size(&disp_refr->inv_areas[join_in]) + + lv_area_get_size(&disp_refr->inv_areas[join_from]))) { lv_area_copy(&disp_refr->inv_areas[join_in], &joined_area); /*Mark 'join_form' is joined into 'join_in'*/ @@ -305,11 +300,10 @@ static void lv_refr_area(const lv_area_t * area_p) else { lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr); /*Calculate the max row num*/ - 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) - ? y2 = lv_disp_get_ver_res(disp_refr) - 1 - : area_p->y2; + 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) ? y2 = lv_disp_get_ver_res(disp_refr) - 1 : area_p->y2; int32_t max_row = (uint32_t)vdb->size / w; @@ -383,7 +377,8 @@ static void lv_refr_area_part(const lv_area_t * area_p) /*In non double buffered mode, before rendering the next part wait until the previous image is * flushed*/ if(lv_disp_is_double_buf(disp_refr) == false) { - while(vdb->flushing); + while(vdb->flushing) + ; } lv_obj_t * top_p; @@ -436,8 +431,7 @@ static lv_obj_t * lv_refr_get_top_obj(const lv_area_t * area_p, lv_obj_t * obj) /*If no better children check this object*/ if(found_p == NULL) { const lv_style_t * style = lv_obj_get_style(obj); - if(style->body.opa == LV_OPA_COVER && - obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) != false && + if(style->body.opa == LV_OPA_COVER && obj->design_cb(obj, area_p, LV_DESIGN_COVER_CHK) != false && lv_obj_get_opa_scale(obj) == LV_OPA_COVER) { found_p = obj; } @@ -489,7 +483,6 @@ static void lv_refr_obj_and_children(lv_obj_t * top_p, const lv_area_t * mask_p) /*Go a level deeper*/ par = lv_obj_get_parent(par); } - } /** diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index 2dfbd7039..160032144 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -17,11 +17,11 @@ #define STYLE_MIX_SHIFT 8 /*log2(STYLE_MIX_MAX)*/ #define VAL_PROP(v1, v2, r) v1 + (((v2 - v1) * r) >> STYLE_MIX_SHIFT) -#define STYLE_ATTR_MIX(attr, r) \ - if(start->attr != end->attr) { \ - res->attr = VAL_PROP(start->attr, end->attr, r); \ - } else { \ - res->attr = start->attr; \ +#define STYLE_ATTR_MIX(attr, r) \ + if(start->attr != end->attr) { \ + res->attr = VAL_PROP(start->attr, end->attr, r); \ + } else { \ + res->attr = start->attr; \ } /********************** @@ -229,8 +229,7 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src) * @param res store the result style here * @param ratio the ratio of mix [0..256]; 0: `start` style; 256: `end` style */ -void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, - uint16_t ratio) +void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, uint16_t ratio) { STYLE_ATTR_MIX(body.opa, ratio); STYLE_ATTR_MIX(body.radius, ratio); @@ -277,34 +276,32 @@ void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * #if LV_USE_ANIMATION - void lv_style_anim_init(lv_anim_t * a) { lv_anim_init(a); - a->start = 0; - a->end = STYLE_MIX_MAX; - a->exec_cb = (lv_anim_exec_cb_t)style_animator; - a->path_cb = lv_anim_path_linear; - a->ready_cb = style_animation_common_end_cb; + a->start = 0; + a->end = STYLE_MIX_MAX; + a->exec_cb = (lv_anim_exec_cb_t)style_animator; + a->path_cb = lv_anim_path_linear; + a->ready_cb = style_animation_common_end_cb; - lv_style_anim_dsc_t * dsc; - dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t)); - lv_mem_assert(dsc); - if(dsc == NULL) return; - dsc->ready_cb = NULL; - dsc->style_anim = NULL; - lv_style_copy(&dsc->style_start, &lv_style_plain); - lv_style_copy(&dsc->style_end, &lv_style_plain); - - a->var = (void *)dsc; + lv_style_anim_dsc_t * dsc; + dsc = lv_mem_alloc(sizeof(lv_style_anim_dsc_t)); + lv_mem_assert(dsc); + if(dsc == NULL) return; + dsc->ready_cb = NULL; + dsc->style_anim = NULL; + lv_style_copy(&dsc->style_start, &lv_style_plain); + lv_style_copy(&dsc->style_end, &lv_style_plain); + a->var = (void *)dsc; } void lv_style_anim_set_styles(lv_anim_t * a, lv_style_t * to_anim, const lv_style_t * start, const lv_style_t * end) { lv_style_anim_dsc_t * dsc = a->var; - dsc->style_anim = to_anim; + dsc->style_anim = to_anim; memcpy(&dsc->style_start, start, sizeof(lv_style_t)); memcpy(&dsc->style_end, end, sizeof(lv_style_t)); memcpy(dsc->style_anim, start, sizeof(lv_style_t)); @@ -338,7 +335,7 @@ static void style_animator(lv_style_anim_dsc_t * dsc, lv_anim_value_t val) static void style_animation_common_end_cb(lv_anim_t * a) { - (void) a; /*Unused*/ + (void)a; /*Unused*/ lv_style_anim_dsc_t * dsc = a->var; /*To avoid casting*/ if(dsc->ready_cb) dsc->ready_cb(a); diff --git a/src/lv_core/lv_style.h b/src/lv_core/lv_style.h index ddbc1829b..a1f52dca4 100644 --- a/src/lv_core/lv_style.h +++ b/src/lv_core/lv_style.h @@ -143,8 +143,7 @@ void lv_style_copy(lv_style_t * dest, const lv_style_t * src); * @param res store the result style here * @param ratio the ratio of mix [0..256]; 0: `start` style; 256: `end` style */ -void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, - uint16_t ratio); +void lv_style_mix(const lv_style_t * start, const lv_style_t * end, lv_style_t * res, uint16_t ratio); #if LV_USE_ANIMATION @@ -187,7 +186,7 @@ static inline void lv_style_anim_set_time(lv_anim_t * a, uint16_t duration, uint static inline void lv_style_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_cb) { lv_style_anim_dsc_t * dsc = a->var; - dsc->ready_cb = ready_cb; + dsc->ready_cb = ready_cb; } /** diff --git a/src/lv_draw/lv_draw.c b/src/lv_draw/lv_draw.c index c7bcad1e2..2cca6c717 100644 --- a/src/lv_draw/lv_draw.c +++ b/src/lv_draw/lv_draw.c @@ -99,8 +99,8 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa) * @param color color of pixels * @param opa maximum opacity */ -void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, - lv_color_t color, lv_opa_t opa) +void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, + lv_opa_t opa) { bool aa_inv = false; if(length < 0) { @@ -125,8 +125,8 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_ * @param color color of pixels * @param opa maximum opacity */ -void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, - lv_color_t color, lv_opa_t opa) +void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, + lv_opa_t opa) { bool aa_inv = false; if(length < 0) { diff --git a/src/lv_draw/lv_draw.h b/src/lv_draw/lv_draw.h index c6088a3e2..447fe7505 100644 --- a/src/lv_draw/lv_draw.h +++ b/src/lv_draw/lv_draw.h @@ -31,7 +31,6 @@ extern "C" { * TYPEDEFS **********************/ - /********************** * GLOBAL PROTOTYPES **********************/ @@ -56,8 +55,8 @@ lv_opa_t lv_draw_aa_get_opa(lv_coord_t seg, lv_coord_t px_id, lv_opa_t base_opa) * @param color color of pixels * @param opa maximum opacity */ -void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, - lv_color_t color, lv_opa_t opa); +void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, + lv_opa_t opa); /** * Add a horizontal anti-aliasing segment (pixels with decreasing opacity) @@ -68,8 +67,8 @@ void lv_draw_aa_ver_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_ * @param color color of pixels * @param opa maximum opacity */ -void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, - lv_color_t color, lv_opa_t opa); +void lv_draw_aa_hor_seg(lv_coord_t x, lv_coord_t y, lv_coord_t length, const lv_area_t * mask, lv_color_t color, + lv_opa_t opa); #endif /********************** diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index e33c22b09..a5fd3f873 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -21,10 +21,10 @@ * STATIC PROTOTYPES **********************/ static uint16_t fast_atan2(int x, int y); -static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, - lv_color_t color, lv_opa_t opa); -static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, - lv_color_t color, lv_opa_t opa); +static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, + lv_opa_t opa); +static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, + lv_opa_t opa); static bool deg_test_norm(uint16_t deg, uint16_t start, uint16_t end); static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end); @@ -52,8 +52,7 @@ static bool deg_test_inv(uint16_t deg, uint16_t start, uint16_t end); * @param opa_scale scale down all opacities by the factor */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask, - uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, - lv_opa_t opa_scale) + uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale) { lv_coord_t thickness = style->line.width; if(thickness > radius) thickness = radius; @@ -66,9 +65,7 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons lv_coord_t x_end[4]; lv_color_t color = style->line.color; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; bool (*deg_test)(uint16_t, uint16_t, uint16_t); if(start_angle <= end_angle) @@ -150,14 +147,12 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons if(x_start[2] != LV_COORD_MIN) { if(x_end[2] == LV_COORD_MIN) x_end[2] = xi - 1; - hor_line(center_x - x_end[2], center_y + yi, mask, LV_MATH_ABS(x_end[2] - x_start[2]), - color, opa); + hor_line(center_x - x_end[2], center_y + yi, mask, LV_MATH_ABS(x_end[2] - x_start[2]), color, opa); } if(x_start[3] != LV_COORD_MIN) { if(x_end[3] == LV_COORD_MIN) x_end[3] = xi - 1; - hor_line(center_x - x_end[3], center_y - yi, mask, LV_MATH_ABS(x_end[3] - x_start[3]), - color, opa); + hor_line(center_x - x_end[3], center_y - yi, mask, LV_MATH_ABS(x_end[3] - x_start[3]), color, opa); } #if LV_ANTIALIAS @@ -245,8 +240,7 @@ static uint16_t fast_atan2(int x, int y) /********************** * STATIC FUNCTIONS **********************/ -static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, - lv_color_t color, lv_opa_t opa) +static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa) { lv_area_t area; lv_area_set(&area, x, y, x, y + len); @@ -254,8 +248,7 @@ static void ver_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coor lv_draw_fill(&area, mask, color, opa); } -static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, - lv_color_t color, lv_opa_t opa) +static void hor_line(lv_coord_t x, lv_coord_t y, const lv_area_t * mask, lv_coord_t len, lv_color_t color, lv_opa_t opa) { lv_area_t area; lv_area_set(&area, x, y, x + len, y); diff --git a/src/lv_draw/lv_draw_arc.h b/src/lv_draw/lv_draw_arc.h index faff91a61..98d0f0bc3 100644 --- a/src/lv_draw/lv_draw_arc.h +++ b/src/lv_draw/lv_draw_arc.h @@ -39,8 +39,7 @@ extern "C" { * @param opa_scale scale down all opacities by the factor */ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, const lv_area_t * mask, - uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, - lv_opa_t opa_scale); + uint16_t start_angle, uint16_t end_angle, const lv_style_t * style, lv_opa_t opa_scale); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_basic.c b/src/lv_draw/lv_draw_basic.c index dc6badc24..10b773160 100644 --- a/src/lv_draw/lv_draw_basic.c +++ b/src/lv_draw/lv_draw_basic.c @@ -42,12 +42,11 @@ * STATIC PROTOTYPES **********************/ static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); -static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, - lv_color_t color, lv_opa_t opa); +static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, + lv_opa_t opa); #if LV_COLOR_SCREEN_TRANSP -static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, - lv_color_t fg_color, lv_opa_t fg_opa); +static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa); #endif /********************** @@ -70,8 +69,7 @@ static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, * @param color pixel color * @param opa opacity of the area (0..255) */ -void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, - lv_opa_t opa) +void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) { if(opa < LV_OPA_MIN) return; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; @@ -113,8 +111,7 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t * @param color fill color * @param opa opacity of the area (0..255) */ -void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, - lv_opa_t opa) +void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa) { if(opa < LV_OPA_MIN) return; if(opa > LV_OPA_MAX) opa = LV_OPA_COVER; @@ -147,8 +144,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ vdb_buf_tmp += vdb_width * vdb_rel_a.y1; #if LV_USE_GPU - static LV_ATTRIBUTE_MEM_ALIGN lv_color_t - color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/ + static LV_ATTRIBUTE_MEM_ALIGN lv_color_t color_array_tmp[LV_HOR_RES_MAX]; /*Used by 'lv_disp_mem_blend'*/ static lv_coord_t last_width = -1; lv_coord_t w = lv_area_get_width(&vdb_rel_a); @@ -163,8 +159,7 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ disp->driver.mem_fill_cb(&disp->driver, vdb->buf_act, &vdb->area, &vdb_rel_a, color); } /*Use hw blend if present and the area is not too small*/ - else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT && - disp->driver.mem_blend_cb) { + else if(lv_area_get_height(&vdb_rel_a) > VFILL_HW_ACC_SIZE_LIMIT && disp->driver.mem_blend_cb) { /*Fill a one line sized buffer with a color and blend this later*/ if(color_array_tmp[0].full != color.full || last_width != w) { uint16_t i; @@ -226,16 +221,14 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ * @param color color of letter * @param opa opacity of letter (0..255) */ -void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, - uint32_t letter, lv_color_t color, lv_opa_t opa) +void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, uint32_t letter, + lv_color_t color, lv_opa_t opa) { /*clang-format off*/ - const uint8_t bpp1_opa_table[2] = { 0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ + const uint8_t bpp1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ const uint8_t bpp2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ const uint8_t bpp4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ - 68, 85, 102, 119, - 136, 153, 170, 187, - 204, 221, 238, 255}; + 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255}; /*clang-format on*/ if(opa < LV_OPA_MIN) return; @@ -260,19 +253,19 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv switch(g.bpp) { case 1: bpp_opa_table = bpp1_opa_table; - bitmask_init = 0x80; + bitmask_init = 0x80; break; case 2: bpp_opa_table = bpp2_opa_table; - bitmask_init = 0xC0; + bitmask_init = 0xC0; break; case 4: bpp_opa_table = bpp4_opa_table; - bitmask_init = 0xF0; + bitmask_init = 0xF0; break; case 8: bpp_opa_table = NULL; - bitmask_init = 0xFF; + bitmask_init = 0xFF; break; /*No opa table, pixel value will be used directly*/ default: return; /*Invalid bpp. Can't render the letter*/ } @@ -282,9 +275,7 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv if(map_p == NULL) return; /*If the letter is completely out of mask don't draw it */ - if(pos_x + g.box_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + g.box_h < mask_p->y1 || - pos_y > mask_p->y2) - return; + if(pos_x + g.box_w < mask_p->x1 || pos_x > mask_p->x2 || pos_y + g.box_h < mask_p->y1 || pos_y > mask_p->y2) return; lv_disp_t * disp = lv_refr_get_disp_refreshing(); lv_disp_buf_t * vdb = lv_disp_get_buf(disp); @@ -311,15 +302,15 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv /*Move on the map too*/ uint32_t bit_ofs = (row_start * width_bit) + (col_start * g.bpp); - map_p += bit_ofs>> 3; + map_p += bit_ofs >> 3; uint8_t letter_px; lv_opa_t px_opa; uint16_t col_bit; - col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */ + col_bit = bit_ofs & 0x7; /* "& 0x7" equals to "% 8" just faster */ for(row = row_start; row < row_end; row++) { - bitmask = bitmask_init >> col_bit; + bitmask = bitmask_init >> col_bit; for(col = col_start; col < col_end; col++) { letter_px = (*map_p & bitmask) >> (8 - col_bit - g.bpp); if(letter_px != 0) { @@ -327,21 +318,20 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv px_opa = g.bpp == 8 ? letter_px : bpp_opa_table[letter_px]; } else { px_opa = g.bpp == 8 ? (uint16_t)((uint16_t)letter_px * opa) >> 8 - : (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8; + : (uint16_t)((uint16_t)bpp_opa_table[letter_px] * opa) >> 8; } if(disp->driver.set_px_cb) { disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, - (col + pos_x) - vdb->area.x1, - (row + pos_y) - vdb->area.y1, color, px_opa); - } else if (vdb_buf_tmp->full != color.full) { - if(px_opa > LV_OPA_MAX) *vdb_buf_tmp = color; + (col + pos_x) - vdb->area.x1, (row + pos_y) - vdb->area.y1, color, px_opa); + } else if(vdb_buf_tmp->full != color.full) { + if(px_opa > LV_OPA_MAX) + *vdb_buf_tmp = color; else if(px_opa > LV_OPA_MIN) { #if LV_COLOR_SCREEN_TRANSP == 0 *vdb_buf_tmp = lv_color_mix(color, *vdb_buf_tmp, px_opa); #else - *vdb_buf_tmp = - color_mix_2_alpha(*vdb_buf_tmp, (*vdb_buf_tmp).alpha, color, px_opa); + *vdb_buf_tmp = color_mix_2_alpha(*vdb_buf_tmp, (*vdb_buf_tmp).alpha, color, px_opa); #endif } } @@ -377,9 +367,8 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv * @param recolor mix the pixels with this color * @param recolor_opa the intense of recoloring */ -void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, - lv_opa_t opa, bool chroma_key, bool alpha_byte, lv_color_t recolor, - lv_opa_t recolor_opa) +void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, lv_opa_t opa, + bool chroma_key, bool alpha_byte, lv_color_t recolor, lv_opa_t recolor_opa) { if(opa < LV_OPA_MIN) return; @@ -426,8 +415,7 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint lv_coord_t map_useful_w = lv_area_get_width(&masked_a); /*The simplest case just copy the pixels into the VDB*/ - if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && - recolor_opa == LV_OPA_TRANSP) { + if(chroma_key == false && alpha_byte == false && opa == LV_OPA_COVER && recolor_opa == LV_OPA_TRANSP) { /*Use the custom VDB write function is exists*/ if(disp->driver.set_px_cb) { @@ -435,8 +423,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint for(row = masked_a.y1; row <= masked_a.y2; row++) { for(col = 0; col < map_useful_w; col++) { lv_color_t px_color = *((lv_color_t *)&map_p[(uint32_t)col * px_size_byte]); - disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, - col + masked_a.x1, row, px_color, opa); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, row, + px_color, opa); } map_p += map_width * px_size_byte; /*Next row on the map*/ } @@ -502,22 +490,21 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint } /*Handle custom VDB write is present*/ if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, - col + masked_a.x1, row, recolored_px, opa_result); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, + row, recolored_px, opa_result); } /*Normal native VDB write*/ else { if(opa_result == LV_OPA_COVER) vdb_buf_tmp[col].full = recolored_px.full; else - vdb_buf_tmp[col] = - lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result); + vdb_buf_tmp[col] = lv_color_mix(recolored_px, vdb_buf_tmp[col], opa_result); } } else { /*Handle custom VDB write is present*/ if(disp->driver.set_px_cb) { - disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, - col + masked_a.x1, row, px_color, opa_result); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)vdb->buf_act, vdb_width, col + masked_a.x1, + row, px_color, opa_result); } /*Normal native VDB write*/ else { @@ -527,8 +514,8 @@ void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint #if LV_COLOR_SCREEN_TRANSP == 0 vdb_buf_tmp[col] = lv_color_mix(px_color, vdb_buf_tmp[col], opa_result); #else - vdb_buf_tmp[col] = color_mix_2_alpha( - vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result); + vdb_buf_tmp[col] = + color_mix_2_alpha(vdb_buf_tmp[col], vdb_buf_tmp[col].alpha, px_color, opa_result); #endif } } @@ -572,8 +559,8 @@ static void sw_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t len * @param color fill color * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover) */ -static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, - lv_color_t color, lv_opa_t opa) +static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_t * fill_area, lv_color_t color, + lv_opa_t opa) { /*Set all row in vdb to the given color*/ lv_coord_t row; @@ -584,8 +571,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_ if(disp->driver.set_px_cb) { for(col = fill_area->x1; col <= fill_area->x2; col++) { for(row = fill_area->y1; row <= fill_area->y2; row++) { - disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, - opa); + disp->driver.set_px_cb(&disp->driver, (uint8_t *)mem, mem_width, col, row, color, opa); } } } else { @@ -647,8 +633,7 @@ static void sw_color_fill(lv_area_t * mem_area, lv_color_t * mem, const lv_area_ * @param fg_opa alpha of the foreground color * @return the mixed color. the alpha channel (color.alpha) contains the result alpha */ -static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, - lv_color_t fg_color, lv_opa_t fg_opa) +static inline lv_color_t color_mix_2_alpha(lv_color_t bg_color, lv_opa_t bg_opa, lv_color_t fg_color, lv_opa_t fg_opa) { /* Pick the foreground if it's fully opaque or the Background is fully transparent*/ if(fg_opa == LV_OPA_COVER || bg_opa <= LV_OPA_MIN) { diff --git a/src/lv_draw/lv_draw_basic.h b/src/lv_draw/lv_draw_basic.h index 87482237d..266b0c6cc 100644 --- a/src/lv_draw/lv_draw_basic.h +++ b/src/lv_draw/lv_draw_basic.h @@ -35,8 +35,7 @@ extern "C" { * GLOBAL PROTOTYPES **********************/ -void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, - lv_opa_t opa); +void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); /** * Fill an area in the Virtual Display Buffer * @param cords_p coordinates of the area to fill @@ -44,8 +43,7 @@ void lv_draw_px(lv_coord_t x, lv_coord_t y, const lv_area_t * mask_p, lv_color_t * @param color fill color * @param opa opacity of the area (0..255) */ -void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, - lv_opa_t opa); +void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_t color, lv_opa_t opa); /** * Draw a letter in the Virtual Display Buffer @@ -56,8 +54,8 @@ void lv_draw_fill(const lv_area_t * cords_p, const lv_area_t * mask_p, lv_color_ * @param color color of letter * @param opa opacity of letter (0..255) */ -void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, - uint32_t letter, lv_color_t color, lv_opa_t opa); +void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv_font_t * font_p, uint32_t letter, + lv_color_t color, lv_opa_t opa); /** * Draw a color map to the display (image) @@ -70,9 +68,8 @@ void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * mask_p, const lv * @param recolor mix the pixels with this color * @param recolor_opa the intense of recoloring */ -void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, - lv_opa_t opa, bool chroma_key, bool alpha_byte, lv_color_t recolor, - lv_opa_t recolor_opa); +void lv_draw_map(const lv_area_t * cords_p, const lv_area_t * mask_p, const uint8_t * map_p, lv_opa_t opa, + bool chroma_key, bool alpha_byte, lv_color_t recolor, lv_opa_t recolor_opa); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 466037da0..dceec352e 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -43,14 +43,13 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas * @param style style of the image * @param opa_scale scale down all opacities by the factor */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, - const lv_style_t * style, lv_opa_t opa_scale) +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_style_t * style, + lv_opa_t opa_scale) { if(src == NULL) { LV_LOG_WARN("Image draw: src is NULL"); lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); - lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, - NULL, -1, -1); + lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1); return; } @@ -60,8 +59,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * if(res == LV_RES_INV) { LV_LOG_WARN("Image draw error"); lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER); - lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, - NULL, -1, -1); + lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, "No\ndata", LV_TXT_FLAG_NONE, NULL, -1, -1); return; } } @@ -76,8 +74,7 @@ void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * * used. * @return color of the point */ -lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, - const lv_style_t * style) +lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, const lv_style_t * style) { lv_color_t p_color = LV_COLOR_BLACK; if(x >= dsc->header.w) { @@ -98,8 +95,7 @@ lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t uint8_t * buf_u8 = (uint8_t *)dsc->data; - if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || - dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED || + if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA) { uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; @@ -217,8 +213,7 @@ void lv_img_buf_set_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_ { uint8_t * buf_u8 = (uint8_t *)dsc->data; - if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || - dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { + if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { uint8_t px_size = lv_img_color_format_get_px_size(dsc->header.cf) >> 3; uint32_t px = dsc->header.w * y * px_size + x * px_size; memcpy(&buf_u8[px], &c, px_size); @@ -447,9 +442,8 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas successfully.*/ } - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->image.opa - : (uint16_t)((uint16_t)style->image.opa * opa_scale) >> 8; + lv_opa_t opa = + opa_scale == LV_OPA_COVER ? style->image.opa : (uint16_t)((uint16_t)style->image.opa * opa_scale) >> 8; lv_img_header_t header; lv_res_t header_res; @@ -473,8 +467,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas /* The decoder open could open the image and gave the entire uncompressed image. * Just draw it!*/ if(img_data) { - lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, - style->image.intense); + lv_draw_map(coords, mask, img_data, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); } /* The whole uncompressed image is not available. Try to read it line-by-line*/ else { @@ -483,8 +476,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas #if LV_COMPILER_VLA_SUPPORTED uint8_t buf[(lv_area_get_width(&mask_com) * ((LV_COLOR_DEPTH >> 3) + 1))]; #else - uint8_t buf[LV_HOR_RES_MAX * - ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ + uint8_t buf[LV_HOR_RES_MAX * ((LV_COLOR_DEPTH >> 3) + 1)]; /*+1 because of the possible alpha byte*/ #endif lv_area_t line; lv_area_copy(&line, &mask_com); @@ -500,8 +492,7 @@ static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mas LV_LOG_WARN("Image draw can't read the line"); return LV_RES_INV; } - lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, - style->image.intense); + lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense); line.y1++; line.y2++; y++; diff --git a/src/lv_draw/lv_draw_img.h b/src/lv_draw/lv_draw_img.h index 5db721af7..721a507e0 100644 --- a/src/lv_draw/lv_draw_img.h +++ b/src/lv_draw/lv_draw_img.h @@ -36,8 +36,8 @@ extern "C" { * @param style style of the image * @param opa_scale scale down all opacities by the factor */ -void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, - const lv_style_t * style, lv_opa_t opa_scale); +void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_style_t * style, + lv_opa_t opa_scale); /** * Get the type of an image source @@ -59,8 +59,7 @@ lv_img_src_t lv_img_src_get_type(const void * src); * used. * @return color of the point */ -lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, - const lv_style_t * style); +lv_color_t lv_img_buf_get_px_color(lv_img_dsc_t * dsc, lv_coord_t x, lv_coord_t y, const lv_style_t * style); /** * Get the alpha value of an image's pixel * @param dsc pointer to an image descriptor diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index 947dd7035..f44679acd 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -53,9 +53,8 @@ static uint8_t hex_char_to_num(char hex); * @param sel_start start index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) * @param sel_end end index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) */ -void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset, - uint16_t sel_start, uint16_t sel_end) +void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, + const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end) { const lv_font_t * font = style->text.font; lv_coord_t w; @@ -65,8 +64,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st } else { /*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, style->text.font, style->text.letter_space, style->text.line_space, - LV_COORD_MAX, flag); + lv_txt_get_size(&p, txt, style->text.font, style->text.letter_space, style->text.line_space, LV_COORD_MAX, + flag); w = p.x; } @@ -101,22 +100,18 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st /*Align to middle*/ if(flag & LV_TXT_FLAG_CENTER) { - line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, - style->text.letter_space, flag); + line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += (lv_area_get_width(coords) - line_width) / 2; } /*Align to the right*/ else if(flag & LV_TXT_FLAG_RIGHT) { - line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, - style->text.letter_space, flag); + line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += lv_area_get_width(coords) - line_width; } - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->text.opa - : (uint16_t)((uint16_t)style->text.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->text.opa : (uint16_t)((uint16_t)style->text.opa * opa_scale) >> 8; cmd_state_t cmd_state = CMD_STATE_WAIT; uint32_t i; @@ -138,7 +133,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st uint32_t letter; uint32_t letter_next; while(i < line_end) { - letter = lv_txt_encoded_next(txt, &i); + letter = lv_txt_encoded_next(txt, &i); letter_next = lv_txt_encoded_next(&txt[i], NULL); /*Handle the re-color command*/ @@ -148,8 +143,7 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st par_start = i; cmd_state = CMD_STATE_PAR; continue; - } else if(cmd_state == - CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */ + } else if(cmd_state == CMD_STATE_PAR) { /*Other start char in parameter escaped cmd. char */ cmd_state = CMD_STATE_WAIT; } else if(cmd_state == CMD_STATE_IN) { /*Command end */ cmd_state = CMD_STATE_WAIT; @@ -210,16 +204,16 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_st pos.x = coords->x1; /*Align to middle*/ if(flag & LV_TXT_FLAG_CENTER) { - line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, - style->text.letter_space, flag); + line_width = + lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += (lv_area_get_width(coords) - line_width) / 2; } /*Align to the right*/ else if(flag & LV_TXT_FLAG_RIGHT) { - line_width = lv_txt_get_width(&txt[line_start], line_end - line_start, font, - style->text.letter_space, flag); + line_width = + lv_txt_get_width(&txt[line_start], line_end - line_start, font, style->text.letter_space, flag); pos.x += lv_area_get_width(coords) - line_width; } diff --git a/src/lv_draw/lv_draw_label.h b/src/lv_draw/lv_draw_label.h index 11b0c8235..31086f59a 100644 --- a/src/lv_draw/lv_draw_label.h +++ b/src/lv_draw/lv_draw_label.h @@ -39,9 +39,8 @@ extern "C" { * @param sel_start start index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) * @param sel_end end index of selected area (`LV_LABEL_TXT_SEL_OFF` if none) */ -void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale, const char * txt, lv_txt_flag_t flag, lv_point_t * offset, - uint16_t sel_start, uint16_t sel_end); +void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale, + const char * txt, lv_txt_flag_t flag, lv_point_t * offset, uint16_t sel_start, uint16_t sel_end); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index c965d981d..2f367d546 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -51,8 +51,8 @@ static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_opa_t opa_scale); static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); -static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); +static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); static void line_init(line_draw_t * line, const lv_point_t * p1, const lv_point_t * p2); static bool line_next(line_draw_t * line); static bool line_next_y(line_draw_t * line); @@ -150,15 +150,13 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv p_tmp.x = main_line.p2.x; p_tmp.y = main_line.p2.y - 1; line_init(&main_line, &p1, &p_tmp); - main_line.sy = LV_MATH_ABS( - main_line.sy); /*The sign can change if the line becomes horizontal*/ + main_line.sy = LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/ } else if(main_line.p1.y > main_line.p2.y) { dir_ori = false; p_tmp.x = main_line.p2.x; p_tmp.y = main_line.p2.y + 1; line_init(&main_line, &p1, &p_tmp); - main_line.sy = -LV_MATH_ABS( - main_line.sy); /*The sign can change if the line becomes horizontal*/ + main_line.sy = -LV_MATH_ABS(main_line.sy); /*The sign can change if the line becomes horizontal*/ } } else { if(main_line.p1.x < main_line.p2.x) { @@ -166,15 +164,13 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv p_tmp.x = main_line.p2.x - 1; p_tmp.y = main_line.p2.y; line_init(&main_line, &p1, &p_tmp); - main_line.sx = LV_MATH_ABS( - main_line.sx); /*The sign can change if the line becomes vertical*/ + main_line.sx = LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/ } else if(main_line.p1.x > main_line.p2.x) { dir_ori = false; p_tmp.x = main_line.p2.x + 1; p_tmp.y = main_line.p2.y; line_init(&main_line, &p1, &p_tmp); - main_line.sx = -LV_MATH_ABS( - main_line.sx); /*The sign can change if the line becomes vertical*/ + main_line.sx = -LV_MATH_ABS(main_line.sx); /*The sign can change if the line becomes vertical*/ } } } @@ -187,15 +183,12 @@ void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv * STATIC FUNCTIONS **********************/ -static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale) +static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) { lv_coord_t width = style->line.width - 1; lv_coord_t width_half = width >> 1; lv_coord_t width_1 = width & 0x1; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->line.opa - : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; lv_area_t act_area; act_area.x1 = main_line->p1.x; @@ -211,15 +204,12 @@ static void line_draw_hor(line_draw_t * main_line, const lv_area_t * mask, const lv_draw_fill(&draw_area, mask, style->line.color, opa); } -static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale) +static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) { lv_coord_t width = style->line.width - 1; lv_coord_t width_half = width >> 1; lv_coord_t width_1 = width & 0x1; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->line.opa - : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; lv_area_t act_area; act_area.x1 = main_line->p1.x - width_half; @@ -235,13 +225,11 @@ static void line_draw_ver(line_draw_t * main_line, const lv_area_t * mask, const lv_draw_fill(&draw_area, mask, style->line.color, opa); } -static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->line.opa - : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->line.opa : (uint16_t)((uint16_t)style->line.opa * opa_scale) >> 8; #if LV_ANTIALIAS bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); #endif @@ -298,8 +286,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ /*Finish the pattern line if it's length equal to the desired width (Use Pythagoras * theorem)*/ - uint32_t sqr = pattern_line.p_act.x * pattern_line.p_act.x + - pattern_line.p_act.y * pattern_line.p_act.y; + uint32_t sqr = pattern_line.p_act.x * pattern_line.p_act.x + pattern_line.p_act.y * pattern_line.p_act.y; if(sqr >= width_sqr) { width = i; #if LV_ANTIALIAS @@ -345,22 +332,20 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ lv_coord_t seg_w = pattern[i].y - pattern[aa_last_corner].y; if(main_line->sy < 0) { lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, - main_line->p1.y + pattern[aa_last_corner].y + seg_w + - 1, - seg_w, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y + seg_w + 1, seg_w, mask, + style->line.color, opa); lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, - main_line->p2.y + pattern[aa_last_corner].y + seg_w + - 1, - -seg_w, mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y + seg_w + 1, -seg_w, mask, + style->line.color, opa); } else { lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, - main_line->p1.y + pattern[aa_last_corner].y, seg_w, - mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y, seg_w, mask, + style->line.color, opa); lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, - main_line->p2.y + pattern[aa_last_corner].y, -seg_w, - mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y, -seg_w, mask, + style->line.color, opa); } aa_last_corner = i; } @@ -368,23 +353,21 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ if(pattern[i - 1].y != pattern[i].y) { lv_coord_t seg_w = pattern[i].x - pattern[aa_last_corner].x; if(main_line->sx < 0) { - lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + - 1, - main_line->p1.y + pattern[aa_last_corner].y - 1, - seg_w, mask, style->line.color, opa); + lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w + 1, + main_line->p1.y + pattern[aa_last_corner].y - 1, seg_w, mask, + style->line.color, opa); - lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + - 1, - main_line->p2.y + pattern[aa_last_corner].y + 1, - -seg_w, mask, style->line.color, opa); + lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w + 1, + main_line->p2.y + pattern[aa_last_corner].y + 1, -seg_w, mask, + style->line.color, opa); } else { lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, - main_line->p1.y + pattern[aa_last_corner].y - 1, - seg_w, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y - 1, seg_w, mask, + style->line.color, opa); lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, - main_line->p2.y + pattern[aa_last_corner].y + 1, - -seg_w, mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y + 1, -seg_w, mask, + style->line.color, opa); } aa_last_corner = i; } @@ -401,41 +384,41 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ lv_coord_t seg_w = pattern[width_safe - 1].y - pattern[aa_last_corner].y; if(main_line->sy < 0) { lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, - main_line->p1.y + pattern[aa_last_corner].y + seg_w, - seg_w + main_line->sy, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y + seg_w, seg_w + main_line->sy, mask, + style->line.color, opa); lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, - main_line->p2.y + pattern[aa_last_corner].y + seg_w, - -(seg_w + main_line->sy), mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y + seg_w, -(seg_w + main_line->sy), mask, + style->line.color, opa); } else { lv_draw_aa_ver_seg(main_line->p1.x + pattern[aa_last_corner].x - 1, - main_line->p1.y + pattern[aa_last_corner].y, - seg_w + main_line->sy, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y, seg_w + main_line->sy, mask, + style->line.color, opa); lv_draw_aa_ver_seg(main_line->p2.x + pattern[aa_last_corner].x + 1, - main_line->p2.y + pattern[aa_last_corner].y, - -(seg_w + main_line->sy), mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y, -(seg_w + main_line->sy), mask, + style->line.color, opa); } } else { lv_coord_t seg_w = pattern[width_safe - 1].x - pattern[aa_last_corner].x; if(main_line->sx < 0) { lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x + seg_w, - main_line->p1.y + pattern[aa_last_corner].y - 1, - seg_w + main_line->sx, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y - 1, seg_w + main_line->sx, mask, + style->line.color, opa); lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x + seg_w, - main_line->p2.y + pattern[aa_last_corner].y + 1, - -(seg_w + main_line->sx), mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y + 1, -(seg_w + main_line->sx), mask, + style->line.color, opa); } else { lv_draw_aa_hor_seg(main_line->p1.x + pattern[aa_last_corner].x, - main_line->p1.y + pattern[aa_last_corner].y - 1, - seg_w + main_line->sx, mask, style->line.color, opa); + main_line->p1.y + pattern[aa_last_corner].y - 1, seg_w + main_line->sx, mask, + style->line.color, opa); lv_draw_aa_hor_seg(main_line->p2.x + pattern[aa_last_corner].x, - main_line->p2.y + pattern[aa_last_corner].y + 1, - -(seg_w + main_line->sx), mask, style->line.color, opa); + main_line->p2.y + pattern[aa_last_corner].y + 1, -(seg_w + main_line->sx), mask, + style->line.color, opa); } } } @@ -486,8 +469,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ * When stepping in y one pixel remains empty on every corner (don't do this on the * first segment ) */ if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) { - lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, - opa); + lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); } } @@ -496,8 +478,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1, -(main_line->p_act.x - prev_p.x), mask, style->line.color, opa); lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, - prev_p.y + pattern[width_safe - 1].y + aa_shift2, - main_line->p_act.x - prev_p.x, mask, style->line.color, opa); + prev_p.y + pattern[width_safe - 1].y + aa_shift2, main_line->p_act.x - prev_p.x, + mask, style->line.color, opa); } #endif @@ -517,8 +499,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ /* Fill the gaps * When stepping in y one pixel remains empty on every corner */ if(i != 0 && pattern[i].x != pattern[i - 1].x && !first_run) { - lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, - opa); + lv_draw_px(draw_area.x1, draw_area.y1 - main_line->sy, mask, style->line.color, opa); } } @@ -526,8 +507,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ if(aa) { lv_draw_aa_hor_seg(prev_p.x + pattern[0].x, prev_p.y + pattern[0].y - aa_shift1, -(main_line->p_act.x - prev_p.x + 1), mask, style->line.color, opa); - lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, - prev_p.y + pattern[width_safe - 1].y + aa_shift2, + lv_draw_aa_hor_seg(prev_p.x + pattern[width_safe - 1].x, prev_p.y + pattern[width_safe - 1].y + aa_shift2, main_line->p_act.x - prev_p.x + 1, mask, style->line.color, opa); } #endif @@ -548,8 +528,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ * When stepping in x one pixel remains empty on every corner (don't do this on the * first segment ) */ if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) { - lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, - opa); + lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); } } @@ -558,8 +537,8 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y, -(main_line->p_act.y - prev_p.y), mask, style->line.color, opa); lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, - prev_p.y + pattern[width_safe - 1].y, - main_line->p_act.y - prev_p.y, mask, style->line.color, opa); + prev_p.y + pattern[width_safe - 1].y, main_line->p_act.y - prev_p.y, mask, + style->line.color, opa); } #endif @@ -581,8 +560,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ /* Fill the gaps * When stepping in x one pixel remains empty on every corner */ if(i != 0 && pattern[i].y != pattern[i - 1].y && !first_run) { - lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, - opa); + lv_draw_px(draw_area.x1 - main_line->sx, draw_area.y1, mask, style->line.color, opa); } } @@ -590,8 +568,7 @@ static void line_draw_skew(line_draw_t * main_line, bool dir_ori, const lv_area_ if(aa) { lv_draw_aa_ver_seg(prev_p.x + pattern[0].x - aa_shift1, prev_p.y + pattern[0].y, -(main_line->p_act.y - prev_p.y + 1), mask, style->line.color, opa); - lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, - prev_p.y + pattern[width_safe - 1].y, + lv_draw_aa_ver_seg(prev_p.x + pattern[width_safe - 1].x + aa_shift2, prev_p.y + pattern[width_safe - 1].y, main_line->p_act.y - prev_p.y + 1, mask, style->line.color, opa); } #endif diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index 02d4b804b..56291a547 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -31,24 +31,24 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); +static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); #if LV_USE_SHADOW -static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale); -static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, const lv_opa_t * map); +static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale); +static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + const lv_opa_t * map); #endif static uint16_t lv_draw_cont_radius_corr(uint16_t r, lv_coord_t w, lv_coord_t h); @@ -76,8 +76,7 @@ static lv_opa_t antialias_get_opa_circ(lv_coord_t seg, lv_coord_t px_id, lv_opa_ * @param style pointer to a style * @param opa_scale scale down all opacities by the factor */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale) +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) { if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return; @@ -120,8 +119,8 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_sty * @param rects_p pointer to a rectangle style * @param opa_scale scale down all opacities by the factor */ -static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { uint16_t radius = style->body.radius; bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); @@ -131,9 +130,7 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma uint8_t mix; lv_coord_t height = lv_area_get_height(coords); lv_coord_t width = lv_area_get_width(coords); - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; radius = lv_draw_cont_radius_corr(radius, width, height); @@ -194,8 +191,8 @@ static void lv_draw_rect_main_mid(const lv_area_t * coords, const lv_area_t * ma * @param rects_p pointer to a rectangle style * @param opa_scale scale down all opacities by the factor */ -static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { uint16_t radius = style->body.radius; bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); @@ -203,9 +200,7 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * lv_color_t mcolor = style->body.main_color; lv_color_t gcolor = style->body.grad_color; lv_color_t act_color; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; uint8_t mix; lv_coord_t height = lv_area_get_height(coords); lv_coord_t width = lv_area_get_width(coords); @@ -287,31 +282,27 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); } - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, - rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, aa_color_hor_bottom, - aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, - lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, aa_color_hor_bottom, - aa_opa); - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, - lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, aa_color_hor_top, - aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, - rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, aa_color_hor_top, - aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, + aa_color_hor_bottom, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, + aa_color_hor_bottom, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, + aa_color_hor_top, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, + aa_color_hor_top, aa_opa); - mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height; + mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height; aa_color_ver = lv_color_mix(mcolor, gcolor, mix); - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, - rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, - lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, + aa_color_ver, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, + aa_color_ver, aa_opa); aa_color_ver = lv_color_mix(gcolor, mcolor, mix); - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, - lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, - rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, + aa_color_ver, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, + aa_color_ver, aa_opa); } out_x_last = cir.x; @@ -377,21 +368,17 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * } /*Save the current coordinates*/ - lv_area_set(&mid_bot_area, lb_origo.x + LV_CIRC_OCT4_X(cir), - lb_origo.y + LV_CIRC_OCT4_Y(cir), rb_origo.x + LV_CIRC_OCT1_X(cir), - rb_origo.y + LV_CIRC_OCT1_Y(cir)); + lv_area_set(&mid_bot_area, lb_origo.x + LV_CIRC_OCT4_X(cir), lb_origo.y + LV_CIRC_OCT4_Y(cir), + rb_origo.x + LV_CIRC_OCT1_X(cir), rb_origo.y + LV_CIRC_OCT1_Y(cir)); - lv_area_set(&edge_bot_area, lb_origo.x + LV_CIRC_OCT3_X(cir), - lb_origo.y + LV_CIRC_OCT3_Y(cir), rb_origo.x + LV_CIRC_OCT2_X(cir), - rb_origo.y + LV_CIRC_OCT2_Y(cir)); + lv_area_set(&edge_bot_area, lb_origo.x + LV_CIRC_OCT3_X(cir), lb_origo.y + LV_CIRC_OCT3_Y(cir), + rb_origo.x + LV_CIRC_OCT2_X(cir), rb_origo.y + LV_CIRC_OCT2_Y(cir)); - lv_area_set(&mid_top_area, lt_origo.x + LV_CIRC_OCT5_X(cir), - lt_origo.y + LV_CIRC_OCT5_Y(cir), rt_origo.x + LV_CIRC_OCT8_X(cir), - rt_origo.y + LV_CIRC_OCT8_Y(cir)); + lv_area_set(&mid_top_area, lt_origo.x + LV_CIRC_OCT5_X(cir), lt_origo.y + LV_CIRC_OCT5_Y(cir), + rt_origo.x + LV_CIRC_OCT8_X(cir), rt_origo.y + LV_CIRC_OCT8_Y(cir)); - lv_area_set(&edge_top_area, lt_origo.x + LV_CIRC_OCT6_X(cir), - lt_origo.y + LV_CIRC_OCT6_Y(cir), rt_origo.x + LV_CIRC_OCT7_X(cir), - rt_origo.y + LV_CIRC_OCT7_Y(cir)); + lv_area_set(&edge_top_area, lt_origo.x + LV_CIRC_OCT6_X(cir), lt_origo.y + LV_CIRC_OCT6_Y(cir), + rt_origo.x + LV_CIRC_OCT7_X(cir), rt_origo.y + LV_CIRC_OCT7_Y(cir)); lv_circ_next(&cir, &cir_tmp); } @@ -462,27 +449,27 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * lv_coord_t i; for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, - mask, aa_color_hor_top, aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, - mask, aa_color_hor_top, aa_opa); - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, - mask, aa_color_hor_bottom, aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, - mask, aa_color_hor_bottom, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, + aa_color_hor_top, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, + aa_color_hor_top, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, + aa_color_hor_bottom, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, + aa_color_hor_bottom, aa_opa); mix = (uint32_t)((uint32_t)(radius - out_y_seg_start + i) * 255) / height; aa_color_ver = lv_color_mix(mcolor, gcolor, mix); - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, - mask, aa_color_ver, aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, - mask, aa_color_ver, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, aa_color_ver, + aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, aa_color_ver, + aa_opa); aa_color_ver = lv_color_mix(gcolor, mcolor, mix); - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, - mask, aa_color_ver, aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, - mask, aa_color_ver, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, aa_color_ver, + aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, aa_color_ver, + aa_opa); } /*In some cases the last pixel is not drawn*/ @@ -495,14 +482,14 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * aa_color_hor_bottom = lv_color_mix(mcolor, gcolor, mix); lv_opa_t aa_opa = opa >> 1; - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, - aa_color_hor_bottom, aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, - aa_color_hor_bottom, aa_opa); - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, - aa_color_hor_top, aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, - aa_color_hor_top, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, aa_color_hor_bottom, + aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, aa_color_hor_bottom, + aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, aa_color_hor_top, + aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, aa_color_hor_top, + aa_opa); } } #endif @@ -515,18 +502,17 @@ static void lv_draw_rect_main_corner(const lv_area_t * coords, const lv_area_t * * @param rstyle pointer to a rectangle style * @param opa_scale scale down all opacities by the factor */ -static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { uint16_t radius = style->body.radius; bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); lv_coord_t width = lv_area_get_width(coords); lv_coord_t height = lv_area_get_height(coords); - lv_coord_t bwidth = style->body.border.width; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.border.opa - : (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8; + lv_coord_t bwidth = style->body.border.width; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.border.opa + : (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8; lv_border_part_t part = style->body.border.part; lv_color_t color = style->body.border.color; lv_area_t work_area; @@ -716,17 +702,16 @@ static void lv_draw_rect_border_straight(const lv_area_t * coords, const lv_area * @param style pointer to a style * @param opa_scale scale down all opacities by the factor */ -static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { uint16_t radius = style->body.radius; bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); - lv_coord_t bwidth = style->body.border.width; + lv_coord_t bwidth = style->body.border.width; lv_color_t color = style->body.border.color; lv_border_part_t part = style->body.border.part; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.border.opa - : (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.border.opa + : (uint16_t)((uint16_t)style->body.border.opa * opa_scale) >> 8; /*0 px border width drawn as 1 px, so decrement the bwidth*/ bwidth--; @@ -819,38 +804,30 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, - rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, - rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, - lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, - lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, - lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, - lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, - rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, - rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } @@ -880,53 +857,45 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, - rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, - lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, - lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, - rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } /*Be sure the pixels on the middle are not drawn twice*/ if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) { if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, - rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, - style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, + mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, - lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, - style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, + mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, - lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, - style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, + mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, - rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, - style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, + mask, style->body.border.color, aa_opa); } } } @@ -1025,39 +994,31 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = opa - lv_draw_aa_get_opa(seg_size, i, opa); if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, - rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, - aa_opa); - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, - rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, style->body.border.color, - aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) + 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, + style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) + 1, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, - lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, style->body.border.color, - aa_opa); - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, - lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, - aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) + 1, mask, + style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) - 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, - lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, - aa_opa); - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, - lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, style->body.border.color, - aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) - 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, + style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) - 1, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, - rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, style->body.border.color, - aa_opa); - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, - rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, - aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) - 1, mask, + style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) + 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, + style->body.border.color, aa_opa); } } @@ -1069,23 +1030,23 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t lv_opa_t aa_opa = opa >> 1; if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), - mask, style->body.border.color, aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p), rb_origo.y + LV_CIRC_OCT2_Y(aa_p), mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), - mask, style->body.border.color, aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p), lb_origo.y + LV_CIRC_OCT4_Y(aa_p), mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), - mask, style->body.border.color, aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p), lt_origo.y + LV_CIRC_OCT6_Y(aa_p), mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), - mask, style->body.border.color, aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p), rt_origo.y + LV_CIRC_OCT8_Y(aa_p), mask, + style->body.border.color, aa_opa); } } @@ -1098,51 +1059,43 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t for(i = 0; i < seg_size; i++) { lv_opa_t aa_opa = lv_draw_aa_get_opa(seg_size, i, opa); if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, - rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, style->body.border.color, - aa_opa); + lv_draw_px(rb_origo.x + LV_CIRC_OCT1_X(aa_p) - 1, rb_origo.y + LV_CIRC_OCT1_Y(aa_p) + i, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, - lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, style->body.border.color, - aa_opa); + lv_draw_px(lb_origo.x + LV_CIRC_OCT3_X(aa_p) - i, lb_origo.y + LV_CIRC_OCT3_Y(aa_p) - 1, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, - lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, style->body.border.color, - aa_opa); + lv_draw_px(lt_origo.x + LV_CIRC_OCT5_X(aa_p) + 1, lt_origo.y + LV_CIRC_OCT5_Y(aa_p) - i, mask, + style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, - rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, style->body.border.color, - aa_opa); + lv_draw_px(rt_origo.x + LV_CIRC_OCT7_X(aa_p) + i, rt_origo.y + LV_CIRC_OCT7_Y(aa_p) + 1, mask, + style->body.border.color, aa_opa); } if(LV_CIRC_OCT1_X(aa_p) - 1 != LV_CIRC_OCT2_X(aa_p) + i) { if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, - rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, + lv_draw_px(rb_origo.x + LV_CIRC_OCT2_X(aa_p) + i, rb_origo.y + LV_CIRC_OCT2_Y(aa_p) - 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_BOTTOM) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, - lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, + lv_draw_px(lb_origo.x + LV_CIRC_OCT4_X(aa_p) + 1, lb_origo.y + LV_CIRC_OCT4_Y(aa_p) + i, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_LEFT)) { - lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, - lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, + lv_draw_px(lt_origo.x + LV_CIRC_OCT6_X(aa_p) - i, lt_origo.y + LV_CIRC_OCT6_Y(aa_p) + 1, mask, style->body.border.color, aa_opa); } if((part & LV_BORDER_TOP) && (part & LV_BORDER_RIGHT)) { - lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, - rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, + lv_draw_px(rt_origo.x + LV_CIRC_OCT8_X(aa_p) - 1, rt_origo.y + LV_CIRC_OCT8_Y(aa_p) - i, mask, style->body.border.color, aa_opa); } } @@ -1159,8 +1112,8 @@ static void lv_draw_rect_border_corner(const lv_area_t * coords, const lv_area_t * @param mask pointer to a mask area (from the design functions) * @param opa_scale scale down all opacities by the factor */ -static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { /* If mask is in the middle of cords do not draw shadow*/ lv_coord_t radius = style->body.radius; @@ -1188,8 +1141,8 @@ static void lv_draw_shadow(const lv_area_t * coords, const lv_area_t * mask, } } -static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { /* KNOWN ISSUE @@ -1246,13 +1199,10 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask #endif #endif /*1D Blur horizontally*/ - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; for(line = 0; line < filter_width; line++) { - line_1d_blur[line] = - (uint32_t)((uint32_t)(filter_width - line) * (opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / - (filter_width * filter_width); + line_1d_blur[line] = (uint32_t)((uint32_t)(filter_width - line) * (opa * 2) << SHADOW_OPA_EXTRA_PRECISION) / + (filter_width * filter_width); } uint16_t col; @@ -1288,9 +1238,8 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask bool line_ready; for(line = 0; line <= radius + swidth; line++) { /*Check all rows and make the 1D blur to 2D*/ line_ready = false; - for(col = 0; col <= radius + swidth; - col++) { /*Check all pixels in a 1D blur line (from the origo to last shadow pixel - (radius + swidth))*/ + for(col = 0; col <= radius + swidth; col++) { /*Check all pixels in a 1D blur line (from the origo to last + shadow pixel (radius + swidth))*/ /*Sum the opacities from the lines above and below this 'row'*/ int16_t line_rel; @@ -1300,8 +1249,7 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask int16_t col_rel; if(line + line_rel < 0) { /*Below the radius, here is the blur of the edge */ col_rel = radius - curve_x[line] - col; - } else if(line + line_rel > - radius) { /*Above the radius, here won't be more 1D blur*/ + } else if(line + line_rel > radius) { /*Above the radius, here won't be more 1D blur*/ break; } else { /*Blur from the curve*/ col_rel = curve_x[line + line_rel] - curve_x[line] - col; @@ -1312,13 +1260,11 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask if(line_rel == -swidth) line_ready = true; /*If no data even on the very first line then it wont't be anything else in this line*/ - break; /*Break anyway because only smaller 'col_rel' values will come */ + break; /*Break anyway because only smaller 'col_rel' values will come */ } else if(col_rel > swidth) px_opa_sum += line_1d_blur[0]; /*Inside the not blurred area*/ else - px_opa_sum += - line_1d_blur[swidth - - col_rel]; /*On the 1D blur (+ swidth to align to the center)*/ + px_opa_sum += line_1d_blur[swidth - col_rel]; /*On the 1D blur (+ swidth to align to the center)*/ } line_2d_blur[col] = px_opa_sum >> SHADOW_OPA_EXTRA_PRECISION; @@ -1374,8 +1320,8 @@ static void lv_draw_shadow_full(const lv_area_t * coords, const lv_area_t * mask } } -static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, lv_opa_t opa_scale) +static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + lv_opa_t opa_scale) { bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); lv_coord_t radius = style->body.radius; @@ -1415,9 +1361,7 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma #endif #endif - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; for(col = 0; col < swidth; col++) { line_1d_blur[col] = (uint32_t)((uint32_t)(swidth - col) * opa / 2) / (swidth); } @@ -1476,8 +1420,8 @@ static void lv_draw_shadow_bottom(const lv_area_t * coords, const lv_area_t * ma } } -static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, - const lv_style_t * style, const lv_opa_t * map) +static void lv_draw_shadow_full_straight(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, + const lv_opa_t * map) { bool aa = lv_disp_get_antialiasing(lv_refr_get_disp_refreshing()); lv_coord_t radius = style->body.radius; diff --git a/src/lv_draw/lv_draw_rect.h b/src/lv_draw/lv_draw_rect.h index 3d347eb8f..852b72912 100644 --- a/src/lv_draw/lv_draw_rect.h +++ b/src/lv_draw/lv_draw_rect.h @@ -34,8 +34,7 @@ extern "C" { * @param style pointer to a style * @param opa_scale scale down all opacities by the factor */ -void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale); +void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); /********************** * MACROS diff --git a/src/lv_draw/lv_draw_triangle.c b/src/lv_draw/lv_draw_triangle.c index 02147095b..e06af2b18 100644 --- a/src/lv_draw/lv_draw_triangle.c +++ b/src/lv_draw/lv_draw_triangle.c @@ -43,8 +43,7 @@ static void point_swap(lv_point_t * p1, lv_point_t * p2); * @param style style for of the triangle * @param opa_scale scale down all opacities by the factor (0..255) */ -void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale) +void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale) { /*Return is the triangle is degenerated*/ @@ -55,9 +54,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l if(points[0].x == points[1].x && points[1].x == points[2].x) return; if(points[0].y == points[1].y && points[1].y == points[2].y) return; - lv_opa_t opa = opa_scale == LV_OPA_COVER - ? style->body.opa - : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; + lv_opa_t opa = opa_scale == LV_OPA_COVER ? style->body.opa : (uint16_t)((uint16_t)style->body.opa * opa_scale) >> 8; /*Is the triangle flat or tall?*/ lv_coord_t x_min = LV_MATH_MIN(LV_MATH_MIN(points[0].x, points[1].x), points[2].x); @@ -71,7 +68,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l * Some pixels are overdrawn on the common edges of the triangles * so use it only if the triangle has no opacity*/ - /* Draw from horizontal lines*/ + /* Draw from horizontal lines*/ if(x_max - x_min < y_max - y_min) { tri_draw_tall(points, mask, style, opa); } @@ -90,7 +87,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l * @param opa_scale scale down all opacities by the factor (0..255) */ void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale) + lv_opa_t opa_scale) { if(point_cnt < 3) return; if(points == NULL) return; @@ -102,8 +99,8 @@ void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_are for(i = 0; i < point_cnt - 1; i++) { tri[1].x = points[i].x; tri[1].y = points[i].y; - tri[2].x = points[i+1].x; - tri[2].y = points[i+1].y; + tri[2].x = points[i + 1].x; + tri[2].y = points[i + 1].y; lv_draw_triangle(tri, mask, style, opa_scale); } } @@ -112,31 +109,22 @@ void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_are * STATIC FUNCTIONS **********************/ - void tri_draw_flat(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa) { /*Return if the points are out of the mask*/ - if(points[0].x < mask->x1 && - points[1].x < mask->x1 && - points[2].x < mask->x1) { + if(points[0].x < mask->x1 && points[1].x < mask->x1 && points[2].x < mask->x1) { return; } - if(points[0].x > mask->x2 && - points[1].x > mask->x2 && - points[2].x > mask->x2) { + if(points[0].x > mask->x2 && points[1].x > mask->x2 && points[2].x > mask->x2) { return; } - if(points[0].y < mask->y1 && - points[1].y < mask->y1 && - points[2].y < mask->y1) { + if(points[0].y < mask->y1 && points[1].y < mask->y1 && points[2].y < mask->y1) { return; } - if(points[0].y > mask->y2 && - points[1].y > mask->y2 && - points[2].y > mask->y2) { + if(points[0].y > mask->y2 && points[1].y > mask->y2 && points[2].y > mask->y2) { return; } @@ -218,7 +206,7 @@ void tri_draw_flat(const lv_point_t * points, const lv_area_t * mask, const lv_s /*Calc. the next point of edge2*/ y2_tmp = edge2.y; do { - if(edge2.x == tri[2].x && edge2.y == tri[2].y) return; + if(edge2.x == tri[2].x && edge2.y == tri[2].y) return; err_tmp2 = err2; if(err_tmp2 > -dx2) { err2 -= dy2; @@ -337,7 +325,6 @@ void tri_draw_tall(const lv_point_t * points, const lv_area_t * mask, const lv_s } } - /** * Swap two points * p1 pointer to the first point diff --git a/src/lv_draw/lv_draw_triangle.h b/src/lv_draw/lv_draw_triangle.h index e9ba0bf33..b6b230d97 100644 --- a/src/lv_draw/lv_draw_triangle.h +++ b/src/lv_draw/lv_draw_triangle.h @@ -34,8 +34,7 @@ extern "C" { * @param style style for of the triangle * @param opa_scale scale down all opacities by the factor (0..255) */ -void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale); +void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const lv_style_t * style, lv_opa_t opa_scale); /** * Draw a polygon from triangles. Only convex polygons are supported @@ -46,8 +45,7 @@ void lv_draw_triangle(const lv_point_t * points, const lv_area_t * mask, const l * @param opa_scale scale down all opacities by the factor (0..255) */ void lv_draw_polygon(const lv_point_t * points, uint32_t point_cnt, const lv_area_t * mask, const lv_style_t * style, - lv_opa_t opa_scale); - + lv_opa_t opa_scale); /********************** * MACROS diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index c6d6db791..5d539864e 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -23,13 +23,13 @@ /********************** * TYPEDEFS **********************/ -typedef struct { +typedef struct +{ #if LV_USE_FILESYSTEM lv_fs_file_t * f; #endif lv_color_t * palette; -}lv_img_decoder_built_in_data_t; - +} lv_img_decoder_built_in_data_t; /********************** * STATIC PROTOTYPES @@ -37,16 +37,15 @@ typedef struct { static lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * src, lv_img_header_t * header); static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc); -static 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); +static 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); static void lv_img_decoder_built_in_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc); -static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * dsc, - lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf); -static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, - uint8_t * buf); -static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, - uint8_t * buf); - +static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf); +static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf); +static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf); /********************** * STATIC VARIABLES @@ -96,7 +95,8 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header) lv_res_t res = LV_RES_INV; lv_img_decoder_t * d; - LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) { + LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) + { res = LV_RES_INV; if(d->info_cb) { res = d->info_cb(d, src, header); @@ -122,9 +122,9 @@ lv_res_t lv_img_decoder_get_info(const char * src, lv_img_header_t * header) */ const uint8_t * lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src, const lv_style_t * style) { - dsc->style = style; - dsc->src = src; - dsc->src_type = lv_img_src_get_type(src); + dsc->style = style; + dsc->src = src; + dsc->src_type = lv_img_src_get_type(src); dsc->user_data = NULL; lv_res_t header_res; @@ -133,8 +133,9 @@ const uint8_t * lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src const uint8_t * res = NULL; lv_img_decoder_t * d; - LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) { - res = NULL; + LV_LL_READ(LV_GC_ROOT(_lv_img_defoder_ll), d) + { + res = NULL; dsc->decoder = d; if(d->open_cb) res = d->open_cb(d, dsc); @@ -156,7 +157,7 @@ const uint8_t * lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src lv_res_t lv_img_decoder_read_line(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf) { lv_res_t res = LV_RES_INV; - if(dsc->decoder->read_line_cb)res = dsc->decoder->read_line_cb(dsc->decoder, dsc, x, y, len, buf); + if(dsc->decoder->read_line_cb) res = dsc->decoder->read_line_cb(dsc->decoder, dsc, x, y, len, buf); return res; } @@ -242,7 +243,7 @@ void lv_img_decoder_set_close_cb(lv_img_decoder_t * decoder, lv_img_decoder_clos static 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*/ + (void)decoder; /*Unused*/ lv_img_src_t src_type = lv_img_src_get_type(src); if(src_type == LV_IMG_SRC_VARIABLE) { @@ -308,7 +309,7 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; - user_data->f = lv_mem_alloc(sizeof(f)); + user_data->f = lv_mem_alloc(sizeof(f)); if(user_data->f == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); lv_mem_assert(user_data->f); @@ -324,8 +325,7 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_img_cf_t cf = dsc->header.cf; /*Process true color formats*/ - if(cf == LV_IMG_CF_TRUE_COLOR || cf == LV_IMG_CF_TRUE_COLOR_ALPHA || - cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { + if(cf == LV_IMG_CF_TRUE_COLOR || cf == LV_IMG_CF_TRUE_COLOR_ALPHA || cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { if(dsc->src_type == LV_IMG_SRC_VARIABLE) { /* In case of uncompressed formats the image stored in the ROM/RAM. * So simply give its pointer*/ @@ -336,12 +336,12 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, } } /*Process indexed images. Build a palette*/ - else if(cf == LV_IMG_CF_INDEXED_1BIT || cf == LV_IMG_CF_INDEXED_2BIT || - cf == LV_IMG_CF_INDEXED_4BIT || cf == LV_IMG_CF_INDEXED_8BIT) { + else if(cf == LV_IMG_CF_INDEXED_1BIT || cf == LV_IMG_CF_INDEXED_2BIT || cf == LV_IMG_CF_INDEXED_4BIT || + cf == LV_IMG_CF_INDEXED_8BIT) { #if LV_IMG_CF_INDEXED - uint8_t px_size = lv_img_color_format_get_px_size(cf); - uint32_t palette_size = 1 << px_size; + uint8_t px_size = lv_img_color_format_get_px_size(cf); + uint32_t palette_size = 1 << px_size; /*Allocate the palette*/ if(dsc->user_data == NULL) { @@ -354,7 +354,7 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; - user_data->palette = lv_mem_alloc(palette_size * sizeof(lv_color_t)); + user_data->palette = lv_mem_alloc(palette_size * sizeof(lv_color_t)); if(user_data->palette == NULL) { LV_LOG_ERROR("img_decoder_built_in_open: out of memory"); #if LV_USE_FILESYSTEM @@ -373,8 +373,7 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, lv_fs_read(user_data->f, palette_tmp, palette_size * sizeof(lv_color_t), NULL); palette_p = palette_tmp; #else - LV_LOG_WARN( - "Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0"); + LV_LOG_WARN("Image built-in decoder can read the palette because LV_USE_FILESYSTEM = 0"); return LV_IMG_DECODER_OPEN_FAIL; #endif } else { @@ -393,8 +392,8 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, #endif } /*Alpha indexed images. */ - else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT || - cf == LV_IMG_CF_ALPHA_4BIT || cf == LV_IMG_CF_ALPHA_8BIT) { + else if(cf == LV_IMG_CF_ALPHA_1BIT || cf == LV_IMG_CF_ALPHA_2BIT || cf == LV_IMG_CF_ALPHA_4BIT || + cf == LV_IMG_CF_ALPHA_8BIT) { #if LV_IMG_CF_ALPHA return NULL; /*Nothing to process*/ #else @@ -412,34 +411,26 @@ static const uint8_t * lv_img_decoder_built_in_open(lv_img_decoder_t * decoder, } } - - -static 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) +static 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*/ + (void)decoder; /*Unused*/ lv_res_t res = LV_RES_INV; - if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || - dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || - dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) - { + if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR || dsc->header.cf == LV_IMG_CF_TRUE_COLOR_ALPHA || + dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED) { /* For TRUE_COLOR images read line required only for files. * For variables the image data was returned in `open`*/ if(dsc->src_type == LV_IMG_SRC_FILE) { res = lv_img_decoder_built_in_line_true_color(dsc, x, y, len, buf); } - } else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || - dsc->header.cf == LV_IMG_CF_ALPHA_2BIT || - dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || - dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) { + } else if(dsc->header.cf == LV_IMG_CF_ALPHA_1BIT || dsc->header.cf == LV_IMG_CF_ALPHA_2BIT || + dsc->header.cf == LV_IMG_CF_ALPHA_4BIT || dsc->header.cf == LV_IMG_CF_ALPHA_8BIT) { res = lv_img_decoder_built_in_line_alpha(dsc, x, y, len, buf); - } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || - dsc->header.cf == LV_IMG_CF_INDEXED_2BIT || - dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || - dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) { + } else if(dsc->header.cf == LV_IMG_CF_INDEXED_1BIT || dsc->header.cf == LV_IMG_CF_INDEXED_2BIT || + dsc->header.cf == LV_IMG_CF_INDEXED_4BIT || dsc->header.cf == LV_IMG_CF_INDEXED_8BIT) { res = lv_img_decoder_built_in_line_indexed(dsc, x, y, len, buf); } else { LV_LOG_WARN("Built-in image decoder read not supports the color format"); @@ -451,7 +442,7 @@ static lv_res_t lv_img_decoder_built_in_read_line(lv_img_decoder_t * decoder, l static void lv_img_decoder_built_in_close(lv_img_decoder_t * decoder, lv_img_decoder_dsc_t * dsc) { - (void)decoder; /*Unused*/ + (void)decoder; /*Unused*/ lv_img_decoder_built_in_data_t * user_data = dsc->user_data; if(user_data) { @@ -466,9 +457,8 @@ static void lv_img_decoder_built_in_close(lv_img_decoder_t * decoder, lv_img_dec } } - -static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * dsc, - lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf) +static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf) { #if LV_USE_FILESYSTEM lv_img_decoder_built_in_data_t * user_data = dsc->user_data; @@ -497,17 +487,15 @@ static lv_res_t lv_img_decoder_built_in_line_true_color(lv_img_decoder_dsc_t * d #endif } -static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, - uint8_t * buf) +static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf) { #if LV_IMG_CF_ALPHA - const lv_opa_t alpha1_opa_table[2] = { - 0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ - const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ - const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ - 68, 85, 102, 119, 136, 153, - 170, 187, 204, 221, 238, 255}; + const lv_opa_t alpha1_opa_table[2] = {0, 255}; /*Opacity mapping with bpp = 1 (Just for compatibility)*/ + const lv_opa_t alpha2_opa_table[4] = {0, 85, 170, 255}; /*Opacity mapping with bpp = 2*/ + const lv_opa_t alpha4_opa_table[16] = {0, 17, 34, 51, /*Opacity mapping with bpp = 4*/ + 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255}; /*Simply fill the buffer with the color. Later only the alpha value will be modified.*/ lv_color_t bg_color = dsc->style->image.color; @@ -534,32 +522,32 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l uint32_t ofs = 0; int8_t pos = 0; switch(dsc->header.cf) { - case LV_IMG_CF_ALPHA_1BIT: - w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/ - if(dsc->header.w & 0x7) w++; - ofs += w * y + (x >> 3); /*First pixel*/ - pos = 7 - (x & 0x7); - opa_table = alpha1_opa_table; - break; - case LV_IMG_CF_ALPHA_2BIT: - w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ - if(dsc->header.w & 0x3) w++; - ofs += w * y + (x >> 2); /*First pixel*/ - pos = 6 - ((x & 0x3) * 2); - opa_table = alpha2_opa_table; - break; - case LV_IMG_CF_ALPHA_4BIT: - w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ - if(dsc->header.w & 0x1) w++; - ofs += w * y + (x >> 1); /*First pixel*/ - pos = 4 - ((x & 0x1) * 4); - opa_table = alpha4_opa_table; - break; - case LV_IMG_CF_ALPHA_8BIT: - w = dsc->header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ - ofs += w * y + x; /*First pixel*/ - pos = 0; - break; + case LV_IMG_CF_ALPHA_1BIT: + w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/ + if(dsc->header.w & 0x7) w++; + ofs += w * y + (x >> 3); /*First pixel*/ + pos = 7 - (x & 0x7); + opa_table = alpha1_opa_table; + break; + case LV_IMG_CF_ALPHA_2BIT: + w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ + if(dsc->header.w & 0x3) w++; + ofs += w * y + (x >> 2); /*First pixel*/ + pos = 6 - ((x & 0x3) * 2); + opa_table = alpha2_opa_table; + break; + case LV_IMG_CF_ALPHA_4BIT: + w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ + if(dsc->header.w & 0x1) w++; + ofs += w * y + (x >> 1); /*First pixel*/ + pos = 4 - ((x & 0x1) * 4); + opa_table = alpha4_opa_table; + break; + case LV_IMG_CF_ALPHA_8BIT: + w = dsc->header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ + ofs += w * y + x; /*First pixel*/ + pos = 0; + break; } #if LV_USE_FILESYSTEM @@ -574,14 +562,14 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l if(dsc->src_type == LV_IMG_SRC_VARIABLE) { const lv_img_dsc_t * img_dsc = dsc->src; - data_tmp = img_dsc->data + ofs; + data_tmp = img_dsc->data + ofs; } else { #if LV_USE_FILESYSTEM lv_fs_seek(user_data->f, ofs + 4); /*+4 to skip the header*/ lv_fs_read(user_data->f, fs_buf, w, NULL); data_tmp = fs_buf; #else - LV_LOG_WARN( "Image built-in alpha line reader can't read file because LV_USE_FILESYSTEM = 0"); + LV_LOG_WARN("Image built-in alpha line reader can't read file because LV_USE_FILESYSTEM = 0"); data_tmp = NULL; /*To avoid warnings*/ return LV_RES_INV; #endif @@ -593,7 +581,7 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l val_act = (data_tmp[byte_act] & (mask << pos)) >> pos; buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] = - dsc->header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act]; + dsc->header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act]; pos -= px_size; if(pos < 0) { @@ -605,14 +593,13 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l return LV_RES_OK; #else - LV_LOG_WARN( - "Image built-in alpha line reader failed because LV_IMG_CF_ALPHA is 0 in lv_conf.h"); + LV_LOG_WARN("Image built-in alpha line reader failed because LV_IMG_CF_ALPHA is 0 in lv_conf.h"); return LV_RES_INV; #endif } -static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, - uint8_t * buf) +static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, + lv_coord_t len, uint8_t * buf) { #if LV_IMG_CF_INDEXED @@ -623,33 +610,33 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, int8_t pos = 0; uint32_t ofs = 0; switch(dsc->header.cf) { - case LV_IMG_CF_INDEXED_1BIT: - w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/ - if(dsc->header.w & 0x7) w++; - ofs += w * y + (x >> 3); /*First pixel*/ - ofs += 8; /*Skip the palette*/ - pos = 7 - (x & 0x7); - break; - case LV_IMG_CF_INDEXED_2BIT: - w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ - if(dsc->header.w & 0x3) w++; - ofs += w * y + (x >> 2); /*First pixel*/ - ofs += 16; /*Skip the palette*/ - pos = 6 - ((x & 0x3) * 2); - break; - case LV_IMG_CF_INDEXED_4BIT: - w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ - if(dsc->header.w & 0x1) w++; - ofs += w * y + (x >> 1); /*First pixel*/ - ofs += 64; /*Skip the palette*/ - pos = 4 - ((x & 0x1) * 4); - break; - case LV_IMG_CF_INDEXED_8BIT: - w = dsc->header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ - ofs += w * y + x; /*First pixel*/ - ofs += 1024; /*Skip the palette*/ - pos = 0; - break; + case LV_IMG_CF_INDEXED_1BIT: + w = (dsc->header.w >> 3); /*E.g. w = 20 -> w = 2 + 1*/ + if(dsc->header.w & 0x7) w++; + ofs += w * y + (x >> 3); /*First pixel*/ + ofs += 8; /*Skip the palette*/ + pos = 7 - (x & 0x7); + break; + case LV_IMG_CF_INDEXED_2BIT: + w = (dsc->header.w >> 2); /*E.g. w = 13 -> w = 3 + 1 (bytes)*/ + if(dsc->header.w & 0x3) w++; + ofs += w * y + (x >> 2); /*First pixel*/ + ofs += 16; /*Skip the palette*/ + pos = 6 - ((x & 0x3) * 2); + break; + case LV_IMG_CF_INDEXED_4BIT: + w = (dsc->header.w >> 1); /*E.g. w = 13 -> w = 6 + 1 (bytes)*/ + if(dsc->header.w & 0x1) w++; + ofs += w * y + (x >> 1); /*First pixel*/ + ofs += 64; /*Skip the palette*/ + pos = 4 - ((x & 0x1) * 4); + break; + case LV_IMG_CF_INDEXED_8BIT: + w = dsc->header.w; /*E.g. x = 7 -> w = 7 (bytes)*/ + ofs += w * y + x; /*First pixel*/ + ofs += 1024; /*Skip the palette*/ + pos = 0; + break; } lv_img_decoder_built_in_data_t * user_data = dsc->user_data; @@ -671,8 +658,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, lv_fs_read(user_data->f, fs_buf, w, NULL); data_tmp = fs_buf; #else - LV_LOG_WARN( - "Image built-in indexed line reader can't read file because LV_USE_FILESYSTEM = 0"); + LV_LOG_WARN("Image built-in indexed line reader can't read file because LV_USE_FILESYSTEM = 0"); data_tmp = NULL; /*To avoid warnings*/ return LV_RES_INV; #endif @@ -695,11 +681,7 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, return LV_RES_OK; #else - LV_LOG_WARN( - "Image built-in indexed line reader failed because LV_IMG_CF_INDEXED is 0 in lv_conf.h"); + LV_LOG_WARN("Image built-in indexed line reader failed because LV_IMG_CF_INDEXED is 0 in lv_conf.h"); return LV_RES_INV; #endif } - - - diff --git a/src/lv_draw/lv_img_decoder.h b/src/lv_draw/lv_img_decoder.h index 811247869..d6ed7399a 100644 --- a/src/lv_draw/lv_img_decoder.h +++ b/src/lv_draw/lv_img_decoder.h @@ -37,7 +37,6 @@ extern "C" { #define LV_IMG_PX_SIZE_ALPHA_BYTE 4 #endif - #define LV_IMG_DECODER_OPEN_FAIL ((void *)(-1)) /********************** @@ -72,14 +71,14 @@ typedef struct enum { LV_IMG_CF_UNKNOWN = 0, - LV_IMG_CF_RAW, /*Contains the file as it is. Needs custom decoder function*/ - LV_IMG_CF_RAW_ALPHA, /*Contains the file as it is. The image has alpha. Needs custom decoder - function*/ + LV_IMG_CF_RAW, /*Contains the file as it is. Needs custom decoder function*/ + LV_IMG_CF_RAW_ALPHA, /*Contains the file as it is. The image has alpha. Needs custom decoder + function*/ LV_IMG_CF_RAW_CHROMA_KEYED, /*Contains the file as it is. The image is chroma keyed. Needs custom decoder function*/ - LV_IMG_CF_TRUE_COLOR, /*Color format and depth should match with LV_COLOR settings*/ - LV_IMG_CF_TRUE_COLOR_ALPHA, /*Same as `LV_IMG_CF_TRUE_COLOR` but every pixel has an alpha byte*/ + LV_IMG_CF_TRUE_COLOR, /*Color format and depth should match with LV_COLOR settings*/ + LV_IMG_CF_TRUE_COLOR_ALPHA, /*Same as `LV_IMG_CF_TRUE_COLOR` but every pixel has an alpha byte*/ LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, /*Same as `LV_IMG_CF_TRUE_COLOR` but LV_COLOR_TRANSP pixels will be transparent*/ @@ -116,7 +115,8 @@ struct _lv_img_decoder_dsc; * @param header store the info here * @return LV_RES_OK: info written correctly; LV_RES_INV: failed */ -typedef lv_res_t (*lv_img_decoder_info_f_t)(struct _lv_img_decoder * decoder, const void * src, lv_img_header_t * header); +typedef lv_res_t (*lv_img_decoder_info_f_t)(struct _lv_img_decoder * decoder, const void * src, + lv_img_header_t * header); /** * Open an image for decoding. Prepare it as it is required to read it later @@ -149,7 +149,8 @@ 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 { +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; @@ -158,10 +159,10 @@ typedef struct _lv_img_decoder { #if LV_USE_USER_DATA lv_img_decoder_user_data_t user_data; #endif -}lv_img_decoder_t; +} lv_img_decoder_t; - -typedef struct _lv_img_decoder_dsc { +typedef struct _lv_img_decoder_dsc +{ lv_img_decoder_t * decoder; const lv_style_t * style; const void * src; @@ -171,7 +172,7 @@ typedef struct _lv_img_decoder_dsc { #if LV_USE_USER_DATA void * user_data; #endif -}lv_img_decoder_dsc_t; +} lv_img_decoder_dsc_t; /********************** * GLOBAL PROTOTYPES @@ -218,7 +219,8 @@ const uint8_t * lv_img_decoder_open(lv_img_decoder_dsc_t * dsc, const void * src * @param buf store the data here * @return LV_RES_OK: success; LV_RES_INV: an error occurred */ -lv_res_t lv_img_decoder_read_line(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, uint8_t * buf); +lv_res_t lv_img_decoder_read_line(lv_img_decoder_dsc_t * dsc, lv_coord_t x, lv_coord_t y, lv_coord_t len, + uint8_t * buf); /** * Close a decoding session diff --git a/src/lv_hal/lv_hal_disp.c b/src/lv_hal/lv_hal_disp.c index 327b5c5fc..285613d0c 100644 --- a/src/lv_hal/lv_hal_disp.c +++ b/src/lv_hal/lv_hal_disp.c @@ -56,11 +56,11 @@ void lv_disp_drv_init(lv_disp_drv_t * driver) { memset(driver, 0, sizeof(lv_disp_drv_t)); - driver->flush_cb = NULL; - driver->hor_res = LV_HOR_RES_MAX; - driver->ver_res = LV_VER_RES_MAX; - driver->buffer = NULL; - driver->rotated = 0; + driver->flush_cb = NULL; + driver->hor_res = LV_HOR_RES_MAX; + driver->ver_res = LV_VER_RES_MAX; + driver->buffer = NULL; + driver->rotated = 0; driver->color_chroma_key = LV_COLOR_TRANSP; #if LV_ANTIALIAS @@ -126,8 +126,8 @@ lv_disp_t * lv_disp_drv_register(lv_disp_drv_t * driver) if(disp_def == NULL) disp_def = disp; lv_disp_t * disp_def_tmp = disp_def; - disp_def = disp; /*Temporarily change the default screen to create the default screens on the - new display*/ + disp_def = disp; /*Temporarily change the default screen to create the default screens on the + new display*/ disp->inv_p = 0; diff --git a/src/lv_hal/lv_hal_disp.h b/src/lv_hal/lv_hal_disp.h index e67a28a4f..98298709d 100644 --- a/src/lv_hal/lv_hal_disp.h +++ b/src/lv_hal/lv_hal_disp.h @@ -83,8 +83,8 @@ typedef struct _disp_drv_t /* OPTIONAL: Set a pixel in a buffer according to the special requirements of the display * Can be used for color format not supported in LittelvGL. E.g. 2 bit -> 4 gray scales * Note: Much slower then drawing with supported color formats. */ - void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, - lv_coord_t y, lv_color_t color, lv_opa_t opa); + void (*set_px_cb)(struct _disp_drv_t * disp_drv, uint8_t * buf, lv_coord_t buf_w, lv_coord_t x, lv_coord_t y, + lv_color_t color, lv_opa_t opa); /* OPTIONAL: Called after every refresh cycle to tell the rendering and flushing time + the * number of flushed pixels */ @@ -92,7 +92,8 @@ typedef struct _disp_drv_t #if LV_USE_GPU /*OPTIONAL: Blend two memories using opacity (GPU only)*/ - void (*mem_blend_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa); + void (*mem_blend_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest, const lv_color_t * src, uint32_t length, + lv_opa_t opa); /*OPTIONAL: Fill a memory with a color (GPU only)*/ void (*mem_fill_cb)(struct _disp_drv_t * disp_drv, lv_color_t * dest_buf, const lv_area_t * dest_area, diff --git a/src/lv_hal/lv_hal_indev.c b/src/lv_hal/lv_hal_indev.c index 9629cef30..112734117 100644 --- a/src/lv_hal/lv_hal_indev.c +++ b/src/lv_hal/lv_hal_indev.c @@ -89,8 +89,7 @@ lv_indev_t * lv_indev_drv_register(lv_indev_drv_t * driver) indev->group = NULL; indev->btn_points = NULL; - indev->driver.read_task = - lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev); + indev->driver.read_task = lv_task_create(lv_indev_read_task, LV_INDEV_DEF_READ_PERIOD, LV_TASK_PRIO_MID, indev); return indev; } diff --git a/src/lv_hal/lv_hal_indev.h b/src/lv_hal/lv_hal_indev.h index cea6ebba7..d08c3038f 100644 --- a/src/lv_hal/lv_hal_indev.h +++ b/src/lv_hal/lv_hal_indev.h @@ -54,7 +54,6 @@ typedef uint8_t lv_indev_type_t; enum { LV_INDEV_STATE_REL = 0, LV_INDEV_STATE_PR }; typedef uint8_t lv_indev_state_t; - /*Data type when an input device is read */ typedef struct { @@ -117,9 +116,9 @@ typedef struct _lv_indev_proc_t lv_point_t vect; lv_point_t drag_sum; /*Count the dragged pixels to check LV_INDEV_DEF_DRAG_LIMIT*/ lv_point_t drag_throw_vect; - struct _lv_obj_t * act_obj; /*The object being pressed*/ - struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and - other post-release event)*/ + struct _lv_obj_t * act_obj; /*The object being pressed*/ + struct _lv_obj_t * last_obj; /*The last obejct which was pressed (used by dragthrow and + other post-release event)*/ struct _lv_obj_t * last_pressed; /*The lastly pressed object*/ /*Flags*/ diff --git a/src/lv_misc/lv_anim.c b/src/lv_misc/lv_anim.c index 70edb989a..6961a4927 100644 --- a/src/lv_misc/lv_anim.c +++ b/src/lv_misc/lv_anim.c @@ -73,7 +73,7 @@ void lv_anim_init(lv_anim_t * a) { memset(a, 0, sizeof(lv_anim_t)); a->time = 500; - a->end = 100; + a->end = 100; } /** * Create an animation @@ -83,8 +83,7 @@ void lv_anim_create(lv_anim_t * a) { LV_LOG_TRACE("animation create started") /* Do not let two animations for the same 'var' with the same 'fp'*/ - if(a->exec_cb != NULL) - lv_anim_del(a->var, a->exec_cb); /*fp == NULL would delete all animations of var*/ + if(a->exec_cb != NULL) lv_anim_del(a->var, a->exec_cb); /*fp == NULL would delete all animations of var*/ /*Add the new animation to the animation linked list*/ lv_anim_t * new_anim = lv_ll_ins_head(&LV_GC_ROOT(_lv_anim_ll)); @@ -181,8 +180,7 @@ lv_anim_value_t lv_anim_path_linear(const lv_anim_t * a) uint32_t step; if(a->time == a->act_time) { step = LV_ANIM_RESOLUTION; /*Use the last value if the time fully elapsed*/ - } - else { + } else { step = ((int32_t)a->act_time * LV_ANIM_RESOLUTION) / a->time; } @@ -396,8 +394,7 @@ static void anim_task(lv_task_t * param) anim_list_changed = false; if(!a->has_run) { - a->has_run = - 1; /*The list readying might be reseted so need to know which anim has run already*/ + a->has_run = 1; /*The list readying might be reseted so need to know which anim has run already*/ a->act_time += elaps; if(a->act_time >= 0) { if(a->act_time > a->time) a->act_time = a->time; @@ -438,8 +435,7 @@ static bool anim_ready_handler(lv_anim_t * a) /*Delete the animation if * - no repeat and no play back (simple one shot animation) * - no repeat, play back is enabled and play back is ready */ - if((a->repeat == 0 && a->playback == 0) || - (a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) { + if((a->repeat == 0 && a->playback == 0) || (a->repeat == 0 && a->playback == 1 && a->playback_now == 1)) { /*Create copy from the animation and delete the animation from the list. * This way the `ready_cb` will see the animations like it's animation is ready deleted*/ diff --git a/src/lv_misc/lv_anim.h b/src/lv_misc/lv_anim.h index 22528d381..736a7d950 100644 --- a/src/lv_misc/lv_anim.h +++ b/src/lv_misc/lv_anim.h @@ -57,22 +57,22 @@ typedef void (*lv_anim_ready_cb_t)(struct _lv_anim_t *); /*Describe an animation*/ typedef struct _lv_anim_t { - void * var; /*Variable to animate*/ - lv_anim_exec_cb_t exec_cb; /*Function to execute to animate*/ - lv_anim_path_cb_t path_cb; /*An array with the steps of animations*/ - lv_anim_ready_cb_t ready_cb; /*Call it when the animation is ready*/ - int32_t start; /*Start value*/ - int32_t end; /*End value*/ - uint16_t time; /*Animation time in ms*/ - int16_t act_time; /*Current time in animation. Set to negative to make delay.*/ - uint16_t playback_pause; /*Wait before play back*/ - uint16_t repeat_pause; /*Wait before repeat*/ + void * var; /*Variable to animate*/ + lv_anim_exec_cb_t exec_cb; /*Function to execute to animate*/ + lv_anim_path_cb_t path_cb; /*An array with the steps of animations*/ + lv_anim_ready_cb_t ready_cb; /*Call it when the animation is ready*/ + int32_t start; /*Start value*/ + int32_t end; /*End value*/ + uint16_t time; /*Animation time in ms*/ + int16_t act_time; /*Current time in animation. Set to negative to make delay.*/ + uint16_t playback_pause; /*Wait before play back*/ + uint16_t repeat_pause; /*Wait before repeat*/ #if LV_USE_USER_DATA - lv_anim_user_data_t user_data; /*Custom user data*/ + lv_anim_user_data_t user_data; /*Custom user data*/ #endif - uint8_t playback : 1; /*When the animation is ready play it back*/ - uint8_t repeat : 1; /*Repeat the animation infinitely*/ + uint8_t playback : 1; /*When the animation is ready play it back*/ + uint8_t repeat : 1; /*Repeat the animation infinitely*/ /*Animation system use these - user shouldn't set*/ uint8_t playback_now : 1; /*Play back is in progress*/ uint32_t has_run : 1; /*Indicates the animation has run in this round*/ @@ -108,7 +108,7 @@ void lv_anim_init(lv_anim_t * a); */ static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_cb_t exec_cb) { - a->var = var; + a->var = var; a->exec_cb = exec_cb; } @@ -120,7 +120,7 @@ static inline void lv_anim_set_exec_cb(lv_anim_t * a, void * var, lv_anim_exec_c */ static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t delay) { - a->time = duration; + a->time = duration; a->act_time = -delay; } @@ -133,7 +133,7 @@ static inline void lv_anim_set_time(lv_anim_t * a, uint16_t duration, uint16_t d static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_anim_value_t end) { a->start = start; - a->end = end; + a->end = end; } /** @@ -146,7 +146,7 @@ static inline void lv_anim_set_values(lv_anim_t * a, lv_anim_value_t start, lv_a */ static inline void lv_anim_set_custom_exec_cb(lv_anim_t * a, lv_anim_custom_exec_cb_t exec_cb) { - a->var = a; + a->var = a; a->exec_cb = (lv_anim_exec_cb_t)exec_cb; } @@ -178,7 +178,7 @@ static inline void lv_anim_set_ready_cb(lv_anim_t * a, lv_anim_ready_cb_t ready_ */ static inline void lv_anim_set_playback(lv_anim_t * a, uint16_t wait_time) { - a->playback = 1; + a->playback = 1; a->playback_pause = wait_time; } @@ -198,7 +198,7 @@ static inline void lv_anim_clear_playback(lv_anim_t * a) */ static inline void lv_anim_set_repeat(lv_anim_t * a, uint16_t wait_time) { - a->repeat = 1; + a->repeat = 1; a->repeat_pause = wait_time; } diff --git a/src/lv_misc/lv_area.c b/src/lv_misc/lv_area.c index b8ab43919..025e1733e 100644 --- a/src/lv_misc/lv_area.c +++ b/src/lv_misc/lv_area.c @@ -167,8 +167,7 @@ bool lv_area_is_point_on(const lv_area_t * a_p, const lv_point_t * p_p) */ bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p) { - if((a1_p->x1 <= a2_p->x2) && (a1_p->x2 >= a2_p->x1) && (a1_p->y1 <= a2_p->y2) && - (a1_p->y2 >= a2_p->y1)) { + if((a1_p->x1 <= a2_p->x2) && (a1_p->x2 >= a2_p->x1) && (a1_p->y1 <= a2_p->y2) && (a1_p->y2 >= a2_p->y1)) { return true; } else { return false; diff --git a/src/lv_misc/lv_color.h b/src/lv_misc/lv_color.h index 9b0ded93b..4571fc306 100644 --- a/src/lv_misc/lv_color.h +++ b/src/lv_misc/lv_color.h @@ -310,10 +310,9 @@ static inline uint32_t lv_color_to32(lv_color_t color) return ret.full; #else lv_color32_t ret; - ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ - ret.ch.green = - ((color.ch.green_h << 3) + color.ch.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ - ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.red = color.ch.red * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ + ret.ch.green = ((color.ch.green_h << 3) + color.ch.green_l) * 4; /*(2^8 - 1)/(2^6 - 1) = 255/63 = 4*/ + ret.ch.blue = color.ch.blue * 8; /*(2^8 - 1)/(2^5 - 1) = 255/31 = 8*/ ret.ch.alpha = 0xFF; return ret.full; #endif @@ -420,14 +419,12 @@ static inline lv_color_t lv_color_make(uint8_t r8, uint8_t g8, uint8_t b8) static inline lv_color_t lv_color_hex(uint32_t c) { - return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF), - (uint8_t)(c & 0xFF)); + return lv_color_make((uint8_t)((c >> 16) & 0xFF), (uint8_t)((c >> 8) & 0xFF), (uint8_t)(c & 0xFF)); } static inline lv_color_t lv_color_hex3(uint32_t c) { - return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), - (uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)), + return lv_color_make((uint8_t)(((c >> 4) & 0xF0) | ((c >> 8) & 0xF)), (uint8_t)((c & 0xF0) | ((c & 0xF0) >> 4)), (uint8_t)((c & 0xF) | ((c & 0xF) << 4))); } diff --git a/src/lv_misc/lv_gc.h b/src/lv_misc/lv_gc.h index ac9d93f3d..5d57d15ab 100644 --- a/src/lv_misc/lv_gc.h +++ b/src/lv_misc/lv_gc.h @@ -29,15 +29,15 @@ extern "C" { * DEFINES *********************/ -#define LV_GC_ROOTS(prefix) \ - prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \ - prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \ - prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \ - prefix lv_ll_t _lv_drv_ll; \ - prefix lv_ll_t _lv_file_ll; \ - prefix lv_ll_t _lv_anim_ll; \ - prefix lv_ll_t _lv_group_ll; \ - prefix lv_ll_t _lv_img_defoder_ll; \ +#define LV_GC_ROOTS(prefix) \ + prefix lv_ll_t _lv_task_ll; /*Linked list to store the lv_tasks*/ \ + prefix lv_ll_t _lv_disp_ll; /*Linked list of screens*/ \ + prefix lv_ll_t _lv_indev_ll; /*Linked list of screens*/ \ + prefix lv_ll_t _lv_drv_ll; \ + prefix lv_ll_t _lv_file_ll; \ + prefix lv_ll_t _lv_anim_ll; \ + prefix lv_ll_t _lv_group_ll; \ + prefix lv_ll_t _lv_img_defoder_ll; \ prefix void * _lv_task_act; #define LV_NO_PREFIX diff --git a/src/lv_misc/lv_ll.c b/src/lv_misc/lv_ll.c index 7901a87ad..7077fff1f 100644 --- a/src/lv_misc/lv_ll.c +++ b/src/lv_misc/lv_ll.c @@ -323,11 +323,12 @@ void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act) * @param ll_p pointer to linked list * @return length of the linked list */ -uint32_t lv_ll_get_len(const lv_ll_t *ll_p){ +uint32_t lv_ll_get_len(const lv_ll_t * ll_p) +{ uint32_t len = 0; void * node; - for(node=lv_ll_get_head(ll_p); node!=NULL; node=lv_ll_get_next(ll_p, node)) { + for(node = lv_ll_get_head(ll_p); node != NULL; node = lv_ll_get_next(ll_p, node)) { len++; } diff --git a/src/lv_misc/lv_ll.h b/src/lv_misc/lv_ll.h index 7c6baba63..fbb6d03f3 100644 --- a/src/lv_misc/lv_ll.h +++ b/src/lv_misc/lv_ll.h @@ -129,7 +129,7 @@ void * lv_ll_get_prev(const lv_ll_t * ll_p, const void * n_act); * @param ll_p pointer to linked list * @return length of the linked list */ -uint32_t lv_ll_get_len(const lv_ll_t *ll_p); +uint32_t lv_ll_get_len(const lv_ll_t * ll_p); /** * Move a nodw before an other node in the same linked list @@ -151,8 +151,7 @@ bool lv_ll_is_empty(lv_ll_t * ll_p); #define LV_LL_READ(list, i) for(i = lv_ll_get_head(&list); i != NULL; i = lv_ll_get_next(&list, i)) -#define LV_LL_READ_BACK(list, i) \ - for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i)) +#define LV_LL_READ_BACK(list, i) for(i = lv_ll_get_tail(&list); i != NULL; i = lv_ll_get_prev(&list, i)) #ifdef __cplusplus } /* extern "C" */ diff --git a/src/lv_misc/lv_log.h b/src/lv_misc/lv_log.h index 4deb8f8d4..759820332 100644 --- a/src/lv_misc/lv_log.h +++ b/src/lv_misc/lv_log.h @@ -42,7 +42,7 @@ typedef int8_t lv_log_level_t; /** * Log print function. Receives "Log Level", "File path", "Line number" and "Description". */ -typedef void (*lv_log_print_g_cb_t) (lv_log_level_t level, const char *, uint32_t, const char *); +typedef void (*lv_log_print_g_cb_t)(lv_log_level_t level, const char *, uint32_t, const char *); /********************** * GLOBAL PROTOTYPES @@ -77,25 +77,25 @@ void lv_log_add(lv_log_level_t level, const char * file, int line, const char * #else /*LV_USE_LOG*/ /*Do nothing if `LV_USE_LOG 0`*/ -#define lv_log_add(level, file, line, dsc) \ - { \ - ; \ +#define lv_log_add(level, file, line, dsc) \ + { \ + ; \ } -#define LV_LOG_TRACE(dsc) \ - { \ - ; \ +#define LV_LOG_TRACE(dsc) \ + { \ + ; \ } -#define LV_LOG_INFO(dsc) \ - { \ - ; \ +#define LV_LOG_INFO(dsc) \ + { \ + ; \ } -#define LV_LOG_WARN(dsc) \ - { \ - ; \ +#define LV_LOG_WARN(dsc) \ + { \ + ; \ } -#define LV_LOG_ERROR(dsc) \ - { \ - ; \ +#define LV_LOG_ERROR(dsc) \ + { \ + ; \ } #endif /*LV_USE_LOG*/ diff --git a/src/lv_misc/lv_math.c b/src/lv_misc/lv_math.c index 9f16d3625..d16a16a4b 100644 --- a/src/lv_misc/lv_math.c +++ b/src/lv_misc/lv_math.c @@ -26,13 +26,12 @@ * STATIC VARIABLES **********************/ static int16_t sin0_90_table[] = { - 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, - 7371, 7927, 8481, 9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, - 14364, 14876, 15383, 15886, 16383, 16876, 17364, 17846, 18323, 18794, 19260, 19720, 20173, - 20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, 24351, 24730, 25101, 25465, - 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, 29451, - 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, - 32051, 32165, 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767}; + 0, 572, 1144, 1715, 2286, 2856, 3425, 3993, 4560, 5126, 5690, 6252, 6813, 7371, 7927, 8481, + 9032, 9580, 10126, 10668, 11207, 11743, 12275, 12803, 13328, 13848, 14364, 14876, 15383, 15886, 16383, 16876, + 17364, 17846, 18323, 18794, 19260, 19720, 20173, 20621, 21062, 21497, 21925, 22347, 22762, 23170, 23571, 23964, + 24351, 24730, 25101, 25465, 25821, 26169, 26509, 26841, 27165, 27481, 27788, 28087, 28377, 28659, 28932, 29196, + 29451, 29697, 29934, 30162, 30381, 30591, 30791, 30982, 31163, 31335, 31498, 31650, 31794, 31927, 32051, 32165, + 32269, 32364, 32448, 32523, 32587, 32642, 32687, 32722, 32747, 32762, 32767}; /********************** * MACROS diff --git a/src/lv_misc/lv_mem.c b/src/lv_misc/lv_mem.c index 6dfcea849..2538e98e0 100644 --- a/src/lv_misc/lv_mem.c +++ b/src/lv_misc/lv_mem.c @@ -19,7 +19,7 @@ * DEFINES *********************/ /*Add memory junk on alloc (0xaa) and free(0xbb) (just for testing purposes)*/ -#define LV_MEM_ADD_JUNK 1 +#define LV_MEM_ADD_JUNK 1 #ifdef LV_MEM_ENV64 #define MEM_UNIT uint64_t @@ -126,7 +126,6 @@ void * lv_mem_alloc(uint32_t size) #endif void * alloc = NULL; - #if LV_MEM_CUSTOM == 0 /*Use the built-in allocators*/ lv_mem_ent_t * e = NULL; @@ -154,7 +153,7 @@ void * lv_mem_alloc(uint32_t size) ((lv_mem_ent_t *)alloc)->header.s.d_size = size; ((lv_mem_ent_t *)alloc)->header.s.used = 1; - alloc = &((lv_mem_ent_t *)alloc)->first_data; + alloc = &((lv_mem_ent_t *)alloc)->first_data; } #endif /* LV_ENABLE_GC */ #endif /* LV_MEM_CUSTOM */ diff --git a/src/lv_misc/lv_mem.h b/src/lv_misc/lv_mem.h index b62abc586..5b4efbe6f 100644 --- a/src/lv_misc/lv_mem.h +++ b/src/lv_misc/lv_mem.h @@ -112,20 +112,20 @@ uint32_t lv_mem_get_size(const void * data); * p pointer to a memory */ #if LV_USE_LOG == 0 -#define lv_mem_assert(p) \ - { \ - if(p == NULL) \ - while(1) \ - ; \ +#define lv_mem_assert(p) \ + { \ + if(p == NULL) \ + while(1) \ + ; \ } #else -#define lv_mem_assert(p) \ - { \ - if(p == NULL) { \ - LV_LOG_ERROR("Out of memory!"); \ - while(1) \ - ; \ - } \ +#define lv_mem_assert(p) \ + { \ + if(p == NULL) { \ + LV_LOG_ERROR("Out of memory!"); \ + while(1) \ + ; \ + } \ } #endif #ifdef __cplusplus diff --git a/src/lv_misc/lv_task.c b/src/lv_misc/lv_task.c index 4b35e3997..51a904ca4 100644 --- a/src/lv_misc/lv_task.c +++ b/src/lv_misc/lv_task.c @@ -20,8 +20,8 @@ * DEFINES *********************/ #define IDLE_MEAS_PERIOD 500 /*[ms]*/ -#define DEF_PRIO LV_TASK_PRIO_MID -#define DEF_PERIOD 500 +#define DEF_PRIO LV_TASK_PRIO_MID +#define DEF_PERIOD 500 /********************** * TYPEDEFS @@ -119,8 +119,8 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) else if(task_interrupter) { if(((lv_task_t *)LV_GC_ROOT(_lv_task_act))->prio > task_interrupter->prio) { if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) { - task_interrupter = LV_GC_ROOT( - _lv_task_act); /*Check all tasks again from the highest priority */ + task_interrupter = + LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */ end_flag = false; break; } @@ -130,17 +130,14 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) * Just run the remaining tasks*/ else { if(lv_task_exec(LV_GC_ROOT(_lv_task_act))) { - task_interrupter = LV_GC_ROOT( - _lv_task_act); /*Check all tasks again from the highest priority */ - end_flag = false; + task_interrupter = LV_GC_ROOT(_lv_task_act); /*Check all tasks again from the highest priority */ + end_flag = false; break; } } - if(task_deleted) - break; /*If a task was deleted then this or the next item might be corrupted*/ - if(task_created) - break; /*If a task was created then this or the next item might be corrupted*/ + if(task_deleted) break; /*If a task was deleted then this or the next item might be corrupted*/ + if(task_created) break; /*If a task was created then this or the next item might be corrupted*/ LV_GC_ROOT(_lv_task_act) = next; /*Load the next task*/ } @@ -150,9 +147,8 @@ LV_ATTRIBUTE_TASK_HANDLER void lv_task_handler(void) uint32_t idle_period_time = lv_tick_elaps(idle_period_start); if(idle_period_time >= IDLE_MEAS_PERIOD) { - idle_last = (uint32_t)((uint32_t)busy_time * 100) / - IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/ - idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/ + idle_last = (uint32_t)((uint32_t)busy_time * 100) / IDLE_MEAS_PERIOD; /*Calculate the busy percentage*/ + idle_last = idle_last > 100 ? 0 : 100 - idle_last; /*But we need idle time*/ busy_time = 0; idle_period_start = lv_tick_get(); } @@ -200,21 +196,20 @@ lv_task_t * lv_task_create_basic(void) } } - new_task->period = DEF_PERIOD; - new_task->task_cb = NULL; - new_task->prio = DEF_PRIO; + new_task->period = DEF_PERIOD; + new_task->task_cb = NULL; + new_task->prio = DEF_PRIO; new_task->once = 0; new_task->last_run = lv_tick_get(); - new_task->user_data= NULL; + new_task->user_data = NULL; task_created = true; return new_task; } - /** * Create a new lv_task * @param task a function which is the task itself @@ -360,8 +355,8 @@ static bool lv_task_exec(lv_task_t * task) uint32_t elp = lv_tick_elaps(task->last_run); if(elp >= task->period) { task->last_run = lv_tick_get(); - task_deleted = false; - task_created = false; + task_deleted = false; + task_created = false; if(task->task_cb) task->task_cb(task); /*Delete if it was a one shot lv_task*/ diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index b2f1d35ca..dd49137fa 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -104,9 +104,8 @@ uint32_t (*lv_txt_get_encoded_length)(const char *) = lv_txt_iso8859_ * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid * line breaks */ -void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, - lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, - lv_txt_flag_t flag) +void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space, + lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag) { size_res->x = 0; size_res->y = 0; @@ -123,14 +122,12 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * /*Calc. the height and longest line*/ while(text[line_start] != '\0') { - new_line_start += - lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag); + new_line_start += lv_txt_get_next_line(&text[line_start], font, letter_space, max_width, flag); size_res->y += letter_height; size_res->y += line_space; /*Calculate the the longest line*/ - act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, - letter_space, flag); + act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag); size_res->x = LV_MATH_MAX(act_line_length, size_res->x); line_start = new_line_start; @@ -159,8 +156,8 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * * @return the index of the first char of the new line (in byte index not letter index. With UTF-8 * they are different) */ -uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, - lv_coord_t max_width, lv_txt_flag_t flag) +uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width, + lv_txt_flag_t flag) { if(txt == NULL) return 0; if(font == NULL) return 0; @@ -178,7 +175,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord while(txt[i] != '\0') { lv_coord_t letter_width; - letter = lv_txt_encoded_next(txt, &i); + letter = lv_txt_encoded_next(txt, &i); letter_next = lv_txt_encoded_next(&txt[i], NULL); /*Handle the recolor command*/ @@ -190,8 +187,8 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord /*Check for new line chars*/ if(letter == '\n' || letter == '\r') { - uint32_t i_tmp = i; - uint32_t n = lv_txt_encoded_next(txt, &i_tmp); + uint32_t i_tmp = i; + uint32_t n = lv_txt_encoded_next(txt, &i_tmp); if(letter == '\r' && n == '\n') i = i_tmp; return i; /*Return with the first letter of the next line*/ @@ -216,7 +213,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord cur_w -= w_at_last_break + letter_space; bool other = true; while(txt[i_tmp] != '\0') { - letter = lv_txt_encoded_next(txt, &i_tmp); + letter = lv_txt_encoded_next(txt, &i_tmp); letter_next = lv_txt_encoded_next(&txt[i_tmp], NULL); /*Handle the recolor command*/ @@ -233,8 +230,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord uint32_t char_remain; lv_txt_encoded_prev(txt, &i); for(char_remain = n_char_since_last_break - n_char_fit; - char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN; - char_remain++) { + char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN; char_remain++) { lv_txt_encoded_prev(txt, &i); } } else { @@ -262,8 +258,7 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord uint32_t char_remain; lv_txt_encoded_prev(txt, &i); for(char_remain = n_char_since_last_break - n_char_fit; - char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN; - char_remain++) { + char_remain < LV_TXT_LINE_BREAK_LONG_POST_MIN_LEN; char_remain++) { lv_txt_encoded_prev(txt, &i); } } else { @@ -315,8 +310,8 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord * @param flags settings for the text from 'txt_flag_t' enum * @return length of a char_num long text */ -lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, - lv_coord_t letter_space, lv_txt_flag_t flag) +lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space, + lv_txt_flag_t flag) { if(txt == NULL) return 0; if(font == NULL) return 0; @@ -329,7 +324,7 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * if(length != 0) { while(i < length) { - letter = lv_txt_encoded_next(txt, &i); + letter = lv_txt_encoded_next(txt, &i); letter_next = lv_txt_encoded_next(&txt[i], NULL); if((flag & LV_TXT_FLAG_RECOLOR) != 0) { if(lv_txt_is_cmd(&cmd_state, letter) != false) { @@ -404,8 +399,7 @@ void lv_txt_ins(char * txt_buf, uint32_t pos, const char * ins_txt) uint32_t old_len = strlen(txt_buf); uint32_t ins_len = strlen(ins_txt); uint32_t new_len = ins_len + old_len; - pos = - lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/ + pos = lv_txt_encoded_get_byte_id(txt_buf, pos); /*Convert to byte index instead of letter index*/ /*Copy the second part into the end to make place to text to insert*/ uint32_t i; @@ -693,11 +687,10 @@ static uint32_t lv_txt_utf8_get_length(const char * txt) */ static uint8_t lv_txt_iso8859_1_size(const char * str) { - (void) str; /*Unused*/ + (void)str; /*Unused*/ return 1; } - /** * Convert an Unicode letter to ISO8859-1. * @param letter_uni an Unicode letter @@ -705,8 +698,10 @@ static uint8_t lv_txt_iso8859_1_size(const char * str) */ static uint32_t lv_txt_unicode_to_iso8859_1(uint32_t letter_uni) { - if(letter_uni < 128) return letter_uni; - else return ' '; + if(letter_uni < 128) + return letter_uni; + else + return ' '; } /** @@ -730,9 +725,9 @@ static uint32_t lv_txt_iso8859_1_conv_wc(uint32_t c) */ static uint32_t lv_txt_iso8859_1_next(const char * txt, uint32_t * i) { - if(i == NULL) return txt[1]; /*Get the next char */ + if(i == NULL) return txt[1]; /*Get the next char */ - uint8_t letter = txt[*i] ; + uint8_t letter = txt[*i]; (*i)++; return letter; } @@ -745,10 +740,10 @@ static uint32_t lv_txt_iso8859_1_next(const char * txt, uint32_t * i) */ static uint32_t lv_txt_iso8859_1_prev(const char * txt, uint32_t * i) { - if(i == NULL) return *(txt - 1); /*Get the prev. char */ + if(i == NULL) return *(txt - 1); /*Get the prev. char */ (*i)--; - uint8_t letter = txt[*i] ; + uint8_t letter = txt[*i]; return letter; } @@ -762,11 +757,10 @@ static uint32_t lv_txt_iso8859_1_prev(const char * txt, uint32_t * i) */ static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id) { - (void) txt; /*Unused*/ - return utf8_id; /*In Non encoded no difference*/ + (void)txt; /*Unused*/ + return utf8_id; /*In Non encoded no difference*/ } - /** * Convert a byte index (in an ISO8859-1 text) to character index. * E.g. in "AÁRT" index of 'R' is 2th char but start at byte 3 because 'Á' is 2 bytes long @@ -776,8 +770,8 @@ static uint32_t lv_txt_iso8859_1_get_byte_id(const char * txt, uint32_t utf8_id) */ static uint32_t lv_txt_iso8859_1_get_char_id(const char * txt, uint32_t byte_id) { - (void) txt; /*Unused*/ - return byte_id; /*In Non encoded no difference*/ + (void)txt; /*Unused*/ + return byte_id; /*In Non encoded no difference*/ } /** diff --git a/src/lv_misc/lv_txt.h b/src/lv_misc/lv_txt.h index 1527527e1..3e60fcf61 100644 --- a/src/lv_misc/lv_txt.h +++ b/src/lv_misc/lv_txt.h @@ -29,8 +29,8 @@ extern "C" { *********************/ #define LV_TXT_COLOR_CMD "#" -#define LV_TXT_ENC_UTF8 1 -#define LV_TXT_ENC_ASCII 2 +#define LV_TXT_ENC_UTF8 1 +#define LV_TXT_ENC_ASCII 2 /********************** * TYPEDEFS @@ -66,9 +66,8 @@ typedef uint8_t lv_txt_cmd_state_t; * @param max_width max with of the text (break the lines to fit this size) Set CORD_MAX to avoid * line breaks */ -void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, - lv_coord_t letter_space, lv_coord_t line_space, lv_coord_t max_width, - lv_txt_flag_t flag); +void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * font, lv_coord_t letter_space, + lv_coord_t line_space, lv_coord_t max_width, lv_txt_flag_t flag); /** * Get the next line of text. Check line length and break chars too. @@ -81,8 +80,8 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * * @return the index of the first char of the new line (in byte index not letter index. With UTF-8 * they are different) */ -uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, - lv_coord_t max_width, lv_txt_flag_t flag); +uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord_t letter_space, lv_coord_t max_width, + lv_txt_flag_t flag); /** * Give the length of a text with a given font @@ -94,8 +93,8 @@ uint16_t lv_txt_get_next_line(const char * txt, const lv_font_t * font, lv_coord * @param flags settings for the text from 'txt_flag_t' enum * @return length of a char_num long text */ -lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, - lv_coord_t letter_space, lv_txt_flag_t flag); +lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * font, lv_coord_t letter_space, + lv_txt_flag_t flag); /** * Check next character in a string and decide if te character is part of the command or not diff --git a/src/lv_objx/lv_arc.c b/src/lv_objx/lv_arc.c index 23b0a3b65..7db5fb5e4 100644 --- a/src/lv_objx/lv_arc.c +++ b/src/lv_objx/lv_arc.c @@ -231,10 +231,8 @@ static bool lv_arc_design(lv_obj_t * arc, const lv_area_t * mask, lv_design_mode /*Draw circle on the ends if enabled */ if(style->line.rounded) { lv_coord_t thick_half = style->line.width / 2; - lv_coord_t cir_x = - ((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT); - lv_coord_t cir_y = - ((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT); + lv_coord_t cir_x = ((r - thick_half) * lv_trigo_sin(ext->angle_start) >> LV_TRIGO_SHIFT); + lv_coord_t cir_y = ((r - thick_half) * lv_trigo_sin(ext->angle_start + 90) >> LV_TRIGO_SHIFT); lv_style_t cir_style; lv_style_copy(&cir_style, &lv_style_plain); diff --git a/src/lv_objx/lv_bar.c b/src/lv_objx/lv_bar.c index 9f2ffc26d..4c01d0ac5 100644 --- a/src/lv_objx/lv_bar.c +++ b/src/lv_objx/lv_bar.c @@ -72,14 +72,14 @@ lv_obj_t * lv_bar_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->min_value = 0; - ext->max_value = 100; - ext->cur_value = 0; + ext->min_value = 0; + ext->max_value = 100; + ext->cur_value = 0; #if LV_USE_ANIMATION - ext->anim_time = 200; - ext->anim_start = 0; - ext->anim_end = 0; - ext->anim_state = LV_BAR_ANIM_STATE_INV; + ext->anim_time = 200; + ext->anim_start = 0; + ext->anim_end = 0; + ext->anim_state = LV_BAR_ANIM_STATE_INV; #endif ext->sym = 0; ext->style_indic = &lv_style_pretty_color; @@ -294,7 +294,7 @@ bool lv_bar_get_sym(lv_obj_t * bar) const lv_style_t * lv_bar_get_style(const lv_obj_t * bar, lv_bar_style_t type) { const lv_style_t * style = NULL; - lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); + lv_bar_ext_t * ext = lv_obj_get_ext_attr(bar); switch(type) { case LV_BAR_STYLE_BG: style = lv_obj_get_style(bar); break; @@ -349,7 +349,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode #if LV_USE_ANIMATION || ext->anim_start != LV_BAR_ANIM_STATE_INV #endif - ) { + ) { const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC); lv_area_t indic_area; lv_area_copy(&indic_area, &bar->coords); @@ -367,30 +367,26 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode if(ext->anim_state != LV_BAR_ANIM_STATE_INV) { /*Calculate the coordinates of anim. start and end*/ lv_coord_t anim_start_x = - (int32_t)((int32_t)w * (ext->anim_start - ext->min_value)) / - (ext->max_value - ext->min_value); + (int32_t)((int32_t)w * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value); lv_coord_t anim_end_x = - (int32_t)((int32_t)w * (ext->anim_end - ext->min_value)) / - (ext->max_value - ext->min_value); + (int32_t)((int32_t)w * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ indic_area.x2 = - anim_start_x + - (((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); - }else + anim_start_x + (((anim_end_x - anim_start_x) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); + } else #endif { - indic_area.x2 = (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / - (ext->max_value - ext->min_value); + indic_area.x2 = + (int32_t)((int32_t)w * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value); } indic_area.x2 = indic_area.x1 + indic_area.x2 - 1; if(ext->sym && ext->min_value < 0 && ext->max_value > 0) { /*Calculate the coordinate of the zero point*/ lv_coord_t zero; - zero = - indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value); + zero = indic_area.x1 + (-ext->min_value * w) / (ext->max_value - ext->min_value); if(indic_area.x2 > zero) indic_area.x1 = zero; else { @@ -403,22 +399,19 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode if(ext->anim_state != LV_BAR_ANIM_STATE_INV) { /*Calculate the coordinates of anim. start and end*/ lv_coord_t anim_start_y = - (int32_t)((int32_t)h * (ext->anim_start - ext->min_value)) / - (ext->max_value - ext->min_value); + (int32_t)((int32_t)h * (ext->anim_start - ext->min_value)) / (ext->max_value - ext->min_value); lv_coord_t anim_end_y = - (int32_t)((int32_t)h * (ext->anim_end - ext->min_value)) / - (ext->max_value - ext->min_value); + (int32_t)((int32_t)h * (ext->anim_end - ext->min_value)) / (ext->max_value - ext->min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ indic_area.y1 = - anim_start_y + - (((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); - } else + anim_start_y + (((anim_end_y - anim_start_y) * ext->anim_state) >> LV_BAR_ANIM_STATE_NORM); + } else #endif { - indic_area.y1 = (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / - (ext->max_value - ext->min_value); + indic_area.y1 = + (int32_t)((int32_t)h * (ext->cur_value - ext->min_value)) / (ext->max_value - ext->min_value); } indic_area.y1 = indic_area.y2 - indic_area.y1 + 1; @@ -426,8 +419,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode if(ext->sym && ext->min_value < 0 && ext->max_value > 0) { /*Calculate the coordinate of the zero point*/ lv_coord_t zero; - zero = - indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value); + zero = indic_area.y2 - (-ext->min_value * h) / (ext->max_value - ext->min_value); if(indic_area.y1 < zero) indic_area.y2 = zero; else { @@ -444,7 +436,7 @@ static bool lv_bar_design(lv_obj_t * bar, const lv_area_t * mask, lv_design_mode #if LV_USE_GROUP /*Draw the border*/ if(lv_obj_is_focused(bar)) { - lv_opa_t opa_scale = lv_obj_get_opa_scale(bar); + lv_opa_t opa_scale = lv_obj_get_opa_scale(bar); const lv_style_t * style_bg = lv_bar_get_style(bar, LV_BAR_STYLE_BG); lv_style_t style_tmp; lv_style_copy(&style_tmp, style_bg); @@ -472,11 +464,9 @@ static lv_res_t lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param) res = ancestor_signal(bar, sign, param); if(res != LV_RES_OK) return res; - if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { const lv_style_t * style_indic = lv_bar_get_style(bar, LV_BAR_STYLE_INDIC); - if(style_indic->body.shadow.width > bar->ext_draw_pad) - bar->ext_draw_pad = style_indic->body.shadow.width; + if(style_indic->body.shadow.width > bar->ext_draw_pad) bar->ext_draw_pad = style_indic->body.shadow.width; } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; uint8_t i; diff --git a/src/lv_objx/lv_bar.h b/src/lv_objx/lv_bar.h index 2d923563f..a7a82467b 100644 --- a/src/lv_objx/lv_bar.h +++ b/src/lv_objx/lv_bar.h @@ -27,7 +27,6 @@ extern "C" { #include "lv_btn.h" #include "lv_label.h" - /********************* * DEFINES *********************/ diff --git a/src/lv_objx/lv_btn.c b/src/lv_objx/lv_btn.c index 7dd163953..a74cca648 100644 --- a/src/lv_objx/lv_btn.c +++ b/src/lv_objx/lv_btn.c @@ -353,7 +353,7 @@ uint16_t lv_btn_get_ink_out_time(const lv_obj_t * btn) const lv_style_t * lv_btn_get_style(const lv_obj_t * btn, lv_btn_style_t type) { const lv_style_t * style = NULL; - lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); + lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); switch(type) { case LV_BTN_STYLE_REL: style = ext->styles[LV_BTN_STATE_REL]; break; @@ -408,9 +408,8 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode /*In the first part of the animation increase the size of the circle (ink effect) */ lv_area_t cir_area; - lv_coord_t coord_state = ink_act_value < LV_BTN_INK_VALUE_MAX / 2 - ? ink_act_value - : LV_BTN_INK_VALUE_MAX / 2; + lv_coord_t coord_state = + ink_act_value < LV_BTN_INK_VALUE_MAX / 2 ? ink_act_value : LV_BTN_INK_VALUE_MAX / 2; lv_point_t p_act; p_act.x = ink_point.x; p_act.y = ink_point.y; @@ -421,28 +420,21 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode p_act.y += (y_err * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1); lv_coord_t half_side = LV_MATH_MAX(w, h) / 2; - cir_area.x1 = - p_act.x - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); - cir_area.y1 = - p_act.y - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); - cir_area.x2 = - p_act.x + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); - cir_area.y2 = - p_act.y + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); + cir_area.x1 = p_act.x - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); + cir_area.y1 = p_act.y - ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); + cir_area.x2 = p_act.x + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); + cir_area.y2 = p_act.y + ((half_side * coord_state) >> (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); - lv_area_intersect( - &cir_area, &btn->coords, - &cir_area); /*Limit the area. (It might be too big on the smaller side)*/ + lv_area_intersect(&cir_area, &btn->coords, + &cir_area); /*Limit the area. (It might be too big on the smaller side)*/ /*In the second part animate the radius. Circle -> body.radius*/ - lv_coord_t r_state = ink_act_value > LV_BTN_INK_VALUE_MAX / 2 - ? ink_act_value - LV_BTN_INK_VALUE_MAX / 2 - : 0; + lv_coord_t r_state = + ink_act_value > LV_BTN_INK_VALUE_MAX / 2 ? ink_act_value - LV_BTN_INK_VALUE_MAX / 2 : 0; lv_style_copy(&style_tmp, ext->styles[ink_top_state]); - style_tmp.body.radius = - r_max + (((ext->styles[ink_bg_state]->body.radius - r_max) * r_state) >> - (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); + style_tmp.body.radius = r_max + (((ext->styles[ink_bg_state]->body.radius - r_max) * r_state) >> + (LV_BTN_INK_VALUE_MAX_SHIFT - 1)); style_tmp.body.border.width = 0; /*Draw the circle*/ @@ -450,8 +442,7 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode } else { lv_style_t res; lv_style_copy(&res, ext->styles[ink_bg_state]); - lv_style_mix(ext->styles[ink_bg_state], ext->styles[ink_top_state], &res, - ink_act_value); + lv_style_mix(ext->styles[ink_bg_state], ext->styles[ink_top_state], &res, ink_act_value); lv_draw_rect(&btn->coords, mask, &res, opa_scale); } } @@ -646,7 +637,7 @@ static void lv_btn_ink_effect_anim(lv_obj_t * btn, lv_anim_value_t val) */ static void lv_btn_ink_effect_anim_ready(lv_anim_t * a) { - (void) a; /*Unused*/ + (void)a; /*Unused*/ lv_btn_ext_t * ext = lv_obj_get_ext_attr(ink_obj); lv_btn_state_t state = lv_btn_get_state(ink_obj); @@ -654,8 +645,7 @@ static void lv_btn_ink_effect_anim_ready(lv_anim_t * a) lv_obj_invalidate(ink_obj); ink_ready = true; - if((state == LV_BTN_STATE_REL || state == LV_BTN_STATE_TGL_REL) && ext->toggle == 0 && - ink_playback == false) { + if((state == LV_BTN_STATE_REL || state == LV_BTN_STATE_TGL_REL) && ext->toggle == 0 && ink_playback == false) { lv_anim_t new_a; new_a.var = ink_obj; new_a.start = LV_BTN_INK_VALUE_MAX; diff --git a/src/lv_objx/lv_btn.h b/src/lv_objx/lv_btn.h index cd23e24e3..6cfb2fc23 100644 --- a/src/lv_objx/lv_btn.h +++ b/src/lv_objx/lv_btn.h @@ -61,7 +61,7 @@ typedef struct uint16_t ink_out_time; /*[ms] Time of ink disappearing*/ #endif lv_btn_state_t state : 3; /*Current state of the button from 'lv_btn_state_t' enum*/ - uint8_t toggle : 1; /*1: Toggle enabled*/ + uint8_t toggle : 1; /*1: Toggle enabled*/ } lv_btn_ext_t; /*Styles*/ @@ -129,8 +129,7 @@ static inline void lv_btn_set_layout(lv_obj_t * btn, lv_layout_t layout) * @param top bottom fit policy from `lv_fit_t` * @param bottom bottom fit policy from `lv_fit_t` */ -static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top, - lv_fit_t bottom) +static inline void lv_btn_set_fit4(lv_obj_t * btn, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom) { lv_cont_set_fit4(btn, left, right, top, bottom); } diff --git a/src/lv_objx/lv_btnm.c b/src/lv_objx/lv_btnm.c index 5ac473704..0ab5a95ed 100644 --- a/src/lv_objx/lv_btnm.c +++ b/src/lv_objx/lv_btnm.c @@ -165,11 +165,9 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]) /*Set size and positions of the buttons*/ const lv_style_t * style_bg = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BG); - lv_coord_t max_w = - lv_obj_get_width(btnm) - style_bg->body.padding.left - style_bg->body.padding.right; - lv_coord_t max_h = - lv_obj_get_height(btnm) - style_bg->body.padding.top - style_bg->body.padding.bottom; - lv_coord_t act_y = style_bg->body.padding.top; + lv_coord_t max_w = lv_obj_get_width(btnm) - style_bg->body.padding.left - style_bg->body.padding.right; + lv_coord_t max_h = lv_obj_get_height(btnm) - style_bg->body.padding.top - style_bg->body.padding.bottom; + lv_coord_t act_y = style_bg->body.padding.top; /*Count the lines to calculate button height*/ uint8_t line_cnt = 1; @@ -196,8 +194,7 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]) unit_cnt = 0; btn_cnt = 0; /*Count the buttons in a line*/ - while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 && - strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/ + while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 && strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/ unit_cnt += get_button_width(ext->ctrl_bits[btn_i + btn_cnt]); btn_cnt++; } @@ -232,11 +229,10 @@ void lv_btnm_set_map(const lv_obj_t * btnm, const char * map[]) * If inner padding is zero then use the prev. button x2 as x1 to avoid rounding * errors*/ if(style_bg->body.padding.inner == 0 && act_x != style_bg->body.padding.left) { - lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, - act_x + act_unit_w, act_y + btn_h); - } else { - lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w, + lv_area_set(&ext->button_areas[btn_i], ext->button_areas[btn_i - 1].x2, act_y, act_x + act_unit_w, act_y + btn_h); + } else { + lv_area_set(&ext->button_areas[btn_i], act_x, act_y, act_x + act_unit_w, act_y + btn_h); } unit_act_cnt += get_button_width(ext->ctrl_bits[btn_i]); @@ -402,7 +398,8 @@ void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width /** * Make the button matrix like a selector widget (only one button may be toggled at a time). * - * Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or `lv_btnm_set_btn_ctrl_all`. + * Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or + * `lv_btnm_set_btn_ctrl_all`. * * @param btnm Button matrix object * @param one_toggle Whether "one toggle" mode is enabled @@ -535,8 +532,8 @@ bool lv_btnm_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnm_ctrl_t ctrl) */ const lv_style_t * lv_btnm_get_style(const lv_obj_t * btnm, lv_btnm_style_t type) { - const lv_style_t * style = NULL; - lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + const lv_style_t * style = NULL; + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); switch(type) { case LV_BTNM_STYLE_BG: style = lv_obj_get_style(btnm); break; @@ -588,7 +585,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo ancestor_design_f(btnm, mask, mode); - lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); + lv_btnm_ext_t * ext = lv_obj_get_ext_attr(btnm); const lv_style_t * bg_style = lv_obj_get_style(btnm); const lv_style_t * btn_style; lv_opa_t opa_scale = lv_obj_get_opa_scale(btnm); @@ -638,8 +635,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo else if(btn_i == ext->btn_id_pr && tgl_state == true) btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR); else - btn_style = lv_btnm_get_style( - btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/ + btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/ lv_style_copy(&style_tmp, btn_style); @@ -676,8 +672,7 @@ static bool lv_btnm_design(lv_obj_t * btnm, const lv_area_t * mask, lv_design_mo area_tmp.x2 = area_tmp.x1 + txt_size.x; area_tmp.y2 = area_tmp.y1 + txt_size.y; - lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, - -1, -1); + lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, -1, -1); } } return true; @@ -707,8 +702,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) lv_btnm_set_map(btnm, ext->map_p); } else if(sign == LV_SIGNAL_PRESSED) { lv_indev_t * indev = lv_indev_get_act(); - if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || - lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) { + if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) { uint16_t btn_pr; /*Search the pressed area*/ lv_indev_get_point(param, &p); @@ -724,7 +718,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false && button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) { uint32_t b = ext->btn_id_act; - res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); + res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); } } } else if(sign == LV_SIGNAL_PRESSING) { @@ -740,7 +734,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) } if(btn_pr != LV_BTNM_BTN_NONE) { uint32_t b = ext->btn_id_act; - res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); + res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); if(res == LV_RES_OK) { invalidate_button_area(btnm, btn_pr); } @@ -778,7 +772,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false && button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) { uint32_t b = ext->btn_id_act; - res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); + res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); } } } else if(sign == LV_SIGNAL_LONG_PRESS_REP) { @@ -787,7 +781,7 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) button_is_inactive(ext->ctrl_bits[ext->btn_id_act]) == false && button_is_hidden(ext->ctrl_bits[ext->btn_id_act]) == false) { uint32_t b = ext->btn_id_act; - res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); + res = lv_event_send(btnm, LV_EVENT_SELECTED, &b); } } } else if(sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_DEFOCUS) { @@ -842,8 +836,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) ext->btn_id_pr = 0; } else { uint16_t area_below; - lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 + - (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1); + lv_coord_t pr_center = + ext->button_areas[ext->btn_id_pr].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1); for(area_below = ext->btn_id_pr; area_below < ext->btn_cnt; area_below++) { if(ext->button_areas[area_below].y1 > ext->button_areas[ext->btn_id_pr].y1 && @@ -864,8 +858,8 @@ static lv_res_t lv_btnm_signal(lv_obj_t * btnm, lv_signal_t sign, void * param) ext->btn_id_pr = 0; } else { int16_t area_above; - lv_coord_t pr_center = ext->button_areas[ext->btn_id_pr].x1 + - (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1); + lv_coord_t pr_center = + ext->button_areas[ext->btn_id_pr].x1 + (lv_area_get_width(&ext->button_areas[ext->btn_id_pr]) >> 1); for(area_above = ext->btn_id_pr; area_above >= 0; area_above--) { if(ext->button_areas[area_above].y1 < ext->button_areas[ext->btn_id_pr].y1 && diff --git a/src/lv_objx/lv_btnm.h b/src/lv_objx/lv_btnm.h index b02ab8417..fb02a23f0 100644 --- a/src/lv_objx/lv_btnm.h +++ b/src/lv_objx/lv_btnm.h @@ -42,7 +42,7 @@ enum { LV_BTNM_CTRL_INACTIVE = 0x0020, LV_BTNM_CTRL_TGL_ENABLE = 0x0040, LV_BTNM_CTRL_TGL_STATE = 0x0080, - LV_BTNM_CTRL_CLICK_TRIG = 0x0100, /*1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/ + LV_BTNM_CTRL_CLICK_TRIG = 0x0100, /*1: Send LV_EVENT_SELECTED on CLICK, 0: Send LV_EVENT_SELECTED on PRESS*/ }; typedef uint16_t lv_btnm_ctrl_t; @@ -51,14 +51,13 @@ typedef struct { /*No inherited ext.*/ /*Ext. of ancestor*/ /*New data for this type */ - const char ** map_p; /*Pointer to the current map*/ - lv_area_t * button_areas; /*Array of areas of buttons*/ - lv_btnm_ctrl_t * ctrl_bits; /*Array of control bytes*/ + const char ** map_p; /*Pointer to the current map*/ + lv_area_t * button_areas; /*Array of areas of buttons*/ + lv_btnm_ctrl_t * ctrl_bits; /*Array of control bytes*/ const lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Styles of buttons in each state*/ - uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/ - uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/ - uint16_t - btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */ + uint16_t btn_cnt; /*Number of button in 'map_p'(Handled by the library)*/ + uint16_t btn_id_pr; /*Index of the currently pressed button or LV_BTNM_BTN_NONE*/ + uint16_t btn_id_act; /*Index of the active button (being pressed/released etc) or LV_BTNM_BTN_NONE */ uint8_t recolor : 1; /*Enable button recoloring*/ uint8_t one_toggle : 1; /*Single button toggled at once*/ } lv_btnm_ext_t; @@ -171,7 +170,8 @@ void lv_btnm_set_btn_width(const lv_obj_t * btnm, uint16_t btn_id, uint8_t width /** * Make the button matrix like a selector widget (only one button may be toggled at a time). * - * Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or `lv_btnm_set_btn_ctrl_all`. + * Toggling must be enabled on the buttons you want to be selected with `lv_btnm_set_ctrl` or + * `lv_btnm_set_btn_ctrl_all`. * * @param btnm Button matrix object * @param one_toggle Whether "one toggle" mode is enabled diff --git a/src/lv_objx/lv_calendar.c b/src/lv_objx/lv_calendar.c index 63bf0727e..5d044fd10 100644 --- a/src/lv_objx/lv_calendar.c +++ b/src/lv_objx/lv_calendar.c @@ -54,9 +54,8 @@ static uint8_t is_leap_year(uint32_t year); static lv_signal_cb_t ancestor_signal; static lv_design_cb_t ancestor_design; static const char * day_name[7] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"}; -static const char * month_name[12] = {"January", "February", "March", "April", - "May", "June", "July", "August", - "September", "October", "November", "December"}; +static const char * month_name[12] = {"January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December"}; /********************** * MACROS @@ -125,20 +124,14 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) lv_theme_t * th = lv_theme_get_current(); if(th) { lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, th->style.calendar.bg); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, - th->style.calendar.header); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, - th->style.calendar.header_pr); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, - th->style.calendar.day_names); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, - th->style.calendar.week_box); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, - th->style.calendar.today_box); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, th->style.calendar.header); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER_PR, th->style.calendar.header_pr); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, th->style.calendar.day_names); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, th->style.calendar.week_box); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, th->style.calendar.today_box); lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, th->style.calendar.highlighted_days); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, - th->style.calendar.inactive_days); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, th->style.calendar.inactive_days); } else { lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_BG, &lv_style_pretty); lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HEADER, ext->style_header); @@ -146,10 +139,8 @@ lv_obj_t * lv_calendar_create(lv_obj_t * par, const lv_obj_t * copy) lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_DAY_NAMES, ext->style_day_names); lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_WEEK_BOX, ext->style_week_box); lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_TODAY_BOX, ext->style_today_box); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, - ext->style_highlighted_days); - lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, - ext->style_inactive_days); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_HIGHLIGHTED_DAYS, ext->style_highlighted_days); + lv_calendar_set_style(new_calendar, LV_CALENDAR_STYLE_INACTIVE_DAYS, ext->style_inactive_days); } } /*Copy an existing calendar*/ @@ -235,8 +226,7 @@ void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showe * WILL BE SAVED! CAN'T BE LOCAL ARRAY. * @param date_num number of dates in the array */ -void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, - uint16_t date_num) +void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); ext->highlighted_dates = highlighted; @@ -386,8 +376,8 @@ const char ** lv_calendar_get_month_names(const lv_obj_t * calendar) * */ const lv_style_t * lv_calendar_get_style(const lv_obj_t * calendar, lv_calendar_style_t type) { - const lv_style_t * style = NULL; - lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); + const lv_style_t * style = NULL; + lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); switch(type) { case LV_CALENDAR_STYLE_BG: style = lv_obj_get_style(calendar); break; @@ -435,8 +425,7 @@ static bool lv_calendar_design(lv_obj_t * calendar, const lv_area_t * mask, lv_d /*Draw the object*/ else if(mode == LV_DESIGN_DRAW_MAIN) { lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar); - lv_draw_rect(&calendar->coords, mask, lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG), - opa_scale); + lv_draw_rect(&calendar->coords, mask, lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG), opa_scale); draw_header(calendar, mask); draw_day_names(calendar, mask); @@ -486,18 +475,18 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * ext->btn_pressing = 1; } - ext->pressed_date.year = 0; + ext->pressed_date.year = 0; ext->pressed_date.month = 0; - ext->pressed_date.day = 0; + ext->pressed_date.day = 0; } else if(calculate_touched_day(calendar, &p)) { if(ext->btn_pressing != 0) lv_obj_invalidate(calendar); ext->btn_pressing = 0; } else { if(ext->btn_pressing != 0) lv_obj_invalidate(calendar); - ext->btn_pressing = 0; - ext->pressed_date.year = 0; + ext->btn_pressing = 0; + ext->pressed_date.year = 0; ext->pressed_date.month = 0; - ext->pressed_date.day = 0; + ext->pressed_date.day = 0; } } else if(sign == LV_SIGNAL_PRESS_LOST) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); @@ -525,7 +514,7 @@ static lv_res_t lv_calendar_signal(lv_obj_t * calendar, lv_signal_t sign, void * if(res != LV_RES_OK) return res; } - ext->btn_pressing = 0; + ext->btn_pressing = 0; lv_obj_invalidate(calendar); } else if(sign == LV_SIGNAL_CONTROL) { uint8_t c = *((uint8_t *)param); @@ -574,8 +563,8 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche const lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG); days_area.x1 += style_bg->body.padding.left; days_area.x2 -= style_bg->body.padding.right; - days_area.y1 = calendar->coords.y1 + get_header_height(calendar) + - get_day_names_height(calendar) - style_bg->body.padding.top; + days_area.y1 = + calendar->coords.y1 + get_header_height(calendar) + get_day_names_height(calendar) - style_bg->body.padding.top; if(lv_area_is_point_on(&days_area, touched_point)) { lv_coord_t w = (days_area.x2 - days_area.x1 + 1) / 7; @@ -591,25 +580,20 @@ static bool calculate_touched_day(lv_obj_t * calendar, const lv_point_t * touche i_pos = (y_pos * 7) + x_pos; lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); if(i_pos < get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1)) { - ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0); - ext->pressed_date.month = - ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1); - ext->pressed_date.day = - get_month_length(ext->pressed_date.year, ext->pressed_date.month) - - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos; + ext->pressed_date.year = ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0); + ext->pressed_date.month = ext->showed_date.month == 1 ? 12 : (ext->showed_date.month - 1); + ext->pressed_date.day = get_month_length(ext->pressed_date.year, ext->pressed_date.month) - + get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + 1 + i_pos; } else if(i_pos < (get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) + get_month_length(ext->showed_date.year, ext->showed_date.month))) { ext->pressed_date.year = ext->showed_date.year; ext->pressed_date.month = ext->showed_date.month; - ext->pressed_date.day = - i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); + ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1); } else if(i_pos < 42) { - ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0); - ext->pressed_date.month = - ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1); - ext->pressed_date.day = - i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) - - get_month_length(ext->showed_date.year, ext->showed_date.month); + ext->pressed_date.year = ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0); + ext->pressed_date.month = ext->showed_date.month == 12 ? 1 : (ext->showed_date.month + 1); + ext->pressed_date.day = i_pos + 1 - get_day_of_week(ext->showed_date.year, ext->showed_date.month, 1) - + get_month_length(ext->showed_date.year, ext->showed_date.month); } return true; } else { @@ -639,8 +623,8 @@ static lv_coord_t get_day_names_height(lv_obj_t * calendar) { lv_calendar_ext_t * ext = lv_obj_get_ext_attr(calendar); - return lv_font_get_line_height(ext->style_day_names->text.font) + - ext->style_day_names->body.padding.top + ext->style_day_names->body.padding.bottom; + return lv_font_get_line_height(ext->style_day_names->text.font) + ext->style_day_names->body.padding.top + + ext->style_day_names->body.padding.bottom; } /** @@ -668,23 +652,19 @@ static void draw_header(lv_obj_t * calendar, const lv_area_t * mask) txt_buf[5] = '\0'; strcpy(&txt_buf[5], get_month_name(calendar, ext->showed_date.month)); header_area.y1 += ext->style_header->body.padding.top; - lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, - NULL, -1, -1); + lv_draw_label(&header_area, mask, ext->style_header, opa_scale, txt_buf, LV_TXT_FLAG_CENTER, NULL, -1, -1); /*Add the left arrow*/ const lv_style_t * arrow_style = ext->btn_pressing < 0 ? ext->style_header_pr : ext->style_header; header_area.x1 += ext->style_header->body.padding.left; - lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, - NULL, -1, -1); + lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_LEFT, LV_TXT_FLAG_NONE, NULL, -1, -1); /*Add the right arrow*/ - arrow_style = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header; - header_area.x1 = - header_area.x2 - ext->style_header->body.padding.right - - lv_txt_get_width(LV_SYMBOL_RIGHT, strlen(LV_SYMBOL_RIGHT), arrow_style->text.font, - arrow_style->text.line_space, LV_TXT_FLAG_NONE); - lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, - NULL, -1, -1); + arrow_style = ext->btn_pressing > 0 ? ext->style_header_pr : ext->style_header; + header_area.x1 = header_area.x2 - ext->style_header->body.padding.right - + lv_txt_get_width(LV_SYMBOL_RIGHT, strlen(LV_SYMBOL_RIGHT), arrow_style->text.font, + arrow_style->text.line_space, LV_TXT_FLAG_NONE); + lv_draw_label(&header_area, mask, arrow_style, opa_scale, LV_SYMBOL_RIGHT, LV_TXT_FLAG_NONE, NULL, -1, -1); } /** @@ -698,19 +678,18 @@ static void draw_day_names(lv_obj_t * calendar, const lv_area_t * mask) lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar); lv_coord_t l_pad = ext->style_day_names->body.padding.left; - lv_coord_t w = lv_obj_get_width(calendar) - ext->style_day_names->body.padding.left - - ext->style_day_names->body.padding.right; + lv_coord_t w = + lv_obj_get_width(calendar) - ext->style_day_names->body.padding.left - ext->style_day_names->body.padding.right; lv_coord_t box_w = w / 7; lv_area_t label_area; - label_area.y1 = - calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top; + label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top; label_area.y2 = label_area.y1 + lv_font_get_line_height(ext->style_day_names->text.font); uint32_t i; for(i = 0; i < 7; i++) { label_area.x1 = calendar->coords.x1 + (w * i) / 7 + l_pad; label_area.x2 = label_area.x1 + box_w - 1; - lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i), - LV_TXT_FLAG_CENTER, NULL, -1, -1); + lv_draw_label(&label_area, mask, ext->style_day_names, opa_scale, get_day_name(calendar, i), LV_TXT_FLAG_CENTER, + NULL, -1, -1); } } @@ -725,14 +704,12 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) const lv_style_t * style_bg = lv_calendar_get_style(calendar, LV_CALENDAR_STYLE_BG); lv_area_t label_area; lv_opa_t opa_scale = lv_obj_get_opa_scale(calendar); - label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + - ext->style_day_names->body.padding.top + + label_area.y1 = calendar->coords.y1 + get_header_height(calendar) + ext->style_day_names->body.padding.top + lv_font_get_line_height(ext->style_day_names->text.font) + ext->style_day_names->body.padding.bottom; label_area.y2 = label_area.y1 + lv_font_get_line_height(style_bg->text.font); - lv_coord_t w = - lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right; + lv_coord_t w = lv_obj_get_width(calendar) - style_bg->body.padding.left - style_bg->body.padding.right; lv_coord_t h = calendar->coords.y2 - label_area.y1 - style_bg->body.padding.bottom; lv_coord_t box_w = w / 7; lv_coord_t vert_space = (h - (6 * lv_font_get_line_height(style_bg->text.font))) / 5; @@ -750,8 +727,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) act_style = style_bg; } else { draw_state = DAY_DRAW_PREV_MONTH; - day_cnt = get_month_length(ext->showed_date.year, - ext->showed_date.month - 1); /*Length of the previous month*/ + day_cnt = get_month_length(ext->showed_date.year, ext->showed_date.month - 1); /*Length of the previous month*/ day_cnt -= month_start_day - 1; /*First visible number of the previous month*/ act_style = ext->style_inactive_days; } @@ -768,16 +744,15 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) for(week = 0; week < 6; week++) { /*Draw the "week box"*/ - if(month_of_today_shown && ((draw_state == DAY_DRAW_ACT_MONTH && - ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) || - (draw_state == DAY_DRAW_PREV_MONTH && - ext->today.day <= 7 - month_start_day && week == 0))) { + if(month_of_today_shown && + ((draw_state == DAY_DRAW_ACT_MONTH && ext->today.day >= day_cnt && ext->today.day < day_cnt + 7) || + (draw_state == DAY_DRAW_PREV_MONTH && ext->today.day <= 7 - month_start_day && week == 0))) { lv_area_t week_box_area; lv_area_copy(&week_box_area, &label_area); /*'label_area' is already set for this row*/ - week_box_area.x1 = calendar->coords.x1 + style_bg->body.padding.left - - ext->style_week_box->body.padding.left; - week_box_area.x2 = calendar->coords.x2 - style_bg->body.padding.right + - ext->style_week_box->body.padding.right; + week_box_area.x1 = + calendar->coords.x1 + style_bg->body.padding.left - ext->style_week_box->body.padding.left; + week_box_area.x2 = + calendar->coords.x2 - style_bg->body.padding.right + ext->style_week_box->body.padding.right; week_box_area.y1 -= ext->style_week_box->body.padding.top; week_box_area.y2 += ext->style_week_box->body.padding.bottom; @@ -805,13 +780,12 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) act_style = ext->style_inactive_days; } - label_area.x1 = calendar->coords.x1 + (w * day) / 7 + style_bg->body.padding.left + - style_bg->body.padding.right; + label_area.x1 = + calendar->coords.x1 + (w * day) / 7 + style_bg->body.padding.left + style_bg->body.padding.right; label_area.x2 = label_area.x1 + box_w - 1; /*Draw the "today box"*/ - if(draw_state == DAY_DRAW_ACT_MONTH && month_of_today_shown && - ext->today.day == day_cnt) { + if(draw_state == DAY_DRAW_ACT_MONTH && month_of_today_shown && ext->today.day == day_cnt) { lv_area_t today_box_area; lv_area_copy(&today_box_area, &label_area); today_box_area.x1 = label_area.x1; @@ -825,21 +799,17 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) /*Get the final style : highlighted/week box/today box/normal*/ const lv_style_t * final_style; if(draw_state == DAY_DRAW_PREV_MONTH && - is_highlighted( - calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0), - ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1, day_cnt)) { + is_highlighted(calendar, ext->showed_date.year - (ext->showed_date.month == 1 ? 1 : 0), + ext->showed_date.month == 1 ? 12 : ext->showed_date.month - 1, day_cnt)) { final_style = ext->style_highlighted_days; } else if(draw_state == DAY_DRAW_ACT_MONTH && - is_highlighted(calendar, ext->showed_date.year, ext->showed_date.month, - day_cnt)) { + is_highlighted(calendar, ext->showed_date.year, ext->showed_date.month, day_cnt)) { final_style = ext->style_highlighted_days; } else if(draw_state == DAY_DRAW_NEXT_MONTH && - is_highlighted( - calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0), - ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1, day_cnt)) { + is_highlighted(calendar, ext->showed_date.year + (ext->showed_date.month == 12 ? 1 : 0), + ext->showed_date.month == 12 ? 1 : ext->showed_date.month + 1, day_cnt)) { final_style = ext->style_highlighted_days; - } else if(month_of_today_shown && day_cnt == ext->today.day && - draw_state == DAY_DRAW_ACT_MONTH) + } else if(month_of_today_shown && day_cnt == ext->today.day && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_today_box; else if(in_week_box && draw_state == DAY_DRAW_ACT_MONTH) final_style = ext->style_week_box; @@ -848,8 +818,7 @@ static void draw_days(lv_obj_t * calendar, const lv_area_t * mask) /*Write the day's number*/ lv_utils_num_to_str(day_cnt, buf); - lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, - -1, -1); + lv_draw_label(&label_area, mask, final_style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1); /*Go to the next day*/ day_cnt++; @@ -932,7 +901,7 @@ static uint8_t get_month_length(int32_t year, int32_t month) { month--; /*Range of months id [1..12] but range of indexes is [0..11]*/ if(month < 0) { - year--; /*Already in the previous year (won't be less then -12 to skip a whole year)*/ + year--; /*Already in the previous year (won't be less then -12 to skip a whole year)*/ month = 12 + month; /*`month` is negative, the result will be < 12*/ } if(month >= 12) { @@ -966,8 +935,7 @@ static uint8_t get_day_of_week(uint32_t year, uint32_t month, uint32_t day) uint32_t a = month < 3 ? 1 : 0; uint32_t b = year - a; - uint32_t day_of_week = - (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; + uint32_t day_of_week = (day + (31 * (month - 2 + 12 * a) / 12) + b + (b / 4) - (b / 100) + (b / 400)) % 7; return day_of_week; } diff --git a/src/lv_objx/lv_calendar.h b/src/lv_objx/lv_calendar.h index 997ecd6a8..ad7dda2a7 100644 --- a/src/lv_objx/lv_calendar.h +++ b/src/lv_objx/lv_calendar.h @@ -48,12 +48,10 @@ typedef struct lv_calendar_date_t * highlighted_dates; /*Apply different style on these days (pointer to an array defined by the user)*/ uint8_t highlighted_dates_num; /*Number of elements in `highlighted_days`*/ - int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/ + int8_t btn_pressing; /*-1: prev month pressing, +1 next month pressing on the header*/ lv_calendar_date_t pressed_date; - const char ** - day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/ - const char ** - month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/ + const char ** day_names; /*Pointer to an array with the name of the days (NULL: use default names)*/ + const char ** month_names; /*Pointer to an array with the name of the month (NULL. use default names)*/ /*Styles*/ const lv_style_t * style_header; @@ -121,8 +119,7 @@ void lv_calendar_set_showed_date(lv_obj_t * calendar, lv_calendar_date_t * showe * WILL BE SAVED! CAN'T BE LOCAL ARRAY. * @param date_num number of dates in the array */ -void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, - uint16_t date_num); +void lv_calendar_set_highlighted_dates(lv_obj_t * calendar, lv_calendar_date_t * highlighted, uint16_t date_num); /** * Set the name of the days diff --git a/src/lv_objx/lv_canvas.c b/src/lv_objx/lv_canvas.c index cd1796861..854903f22 100644 --- a/src/lv_objx/lv_canvas.c +++ b/src/lv_objx/lv_canvas.c @@ -214,8 +214,7 @@ const lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_ * @param x left side of the destination position * @param y top side of the destination position */ -void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, - lv_coord_t x, lv_coord_t y) +void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, lv_coord_t y) { lv_canvas_ext_t * ext = lv_obj_get_ext_attr(canvas); if(x + w >= ext->dsc.header.w || y + h >= ext->dsc.header.h) { @@ -247,8 +246,8 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, l * @param pivot_y pivot Y of rotation. Relative to the source canvas * Set to `source height / 2` to rotate around the center */ -void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, - lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y) +void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, lv_coord_t offset_y, + int32_t pivot_x, int32_t pivot_y) { lv_canvas_ext_t * ext_dst = lv_obj_get_ext_attr(canvas); const lv_style_t * style = lv_canvas_get_style(canvas, LV_CANVAS_STYLE_MAIN); @@ -346,8 +345,7 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c lv_color_t y_dest = lv_color_mix(c_dest_int, c_dest_yn, yr); lv_color_t color_res = lv_color_mix(x_dest, y_dest, LV_OPA_50); - if(x + offset_x >= 0 && x + offset_x < dest_width && y + offset_y >= 0 && - y + offset_y < dest_height) { + if(x + offset_x >= 0 && x + offset_x < dest_width && y + offset_y >= 0 && y + offset_y < dest_height) { /*If the image has no alpha channel just simple set the result color on the canvas*/ if(lv_img_color_format_has_alpha(img->header.cf) == false) { lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res); @@ -361,29 +359,23 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c lv_opa_t opa_res = (opa_x + opa_y) / 2; if(opa_res <= LV_OPA_MIN) continue; - lv_color_t bg_color = - lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, style); + lv_color_t bg_color = lv_img_buf_get_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, style); /*If the canvas has no alpha but the image has mix the image's color with * canvas*/ if(lv_img_color_format_has_alpha(ext_dst->dsc.header.cf) == false) { - if(opa_res < LV_OPA_MAX) - color_res = lv_color_mix(color_res, bg_color, opa_res); - lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, - color_res); + if(opa_res < LV_OPA_MAX) color_res = lv_color_mix(color_res, bg_color, opa_res); + lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res); } /*Both the image and canvas has alpha channel. Some extra calculation is required*/ else { - lv_opa_t bg_opa = - lv_img_buf_get_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y); + lv_opa_t bg_opa = lv_img_buf_get_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y); /* Pick the foreground if it's fully opaque or the Background is fully * transparent*/ if(opa_res >= LV_OPA_MAX || bg_opa <= LV_OPA_MIN) { - lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, - color_res); - lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, - opa_res); + lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, color_res); + lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, opa_res); } /*Opaque background: use simple mix*/ else if(bg_opa >= LV_OPA_MAX) { @@ -395,8 +387,7 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c /*Info: * https://en.wikipedia.org/wiki/Alpha_compositing#Analytical_derivation_of_the_over_operator*/ - lv_opa_t opa_res_2 = - 255 - ((uint16_t)((uint16_t)(255 - opa_res) * (255 - bg_opa)) >> 8); + lv_opa_t opa_res_2 = 255 - ((uint16_t)((uint16_t)(255 - opa_res) * (255 - bg_opa)) >> 8); if(opa_res_2 == 0) { opa_res_2 = 1; /*never happens, just to be sure*/ } @@ -404,8 +395,7 @@ void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_c lv_img_buf_set_px_color(&ext_dst->dsc, x + offset_x, y + offset_y, lv_color_mix(color_res, bg_color, ratio)); - lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, - opa_res_2); + lv_img_buf_set_px_alpha(&ext_dst->dsc, x + offset_x, y + offset_y, opa_res_2); } } } @@ -432,7 +422,6 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color) lv_img_buf_set_px_color(dsc, x, y, color); } } - } /** @@ -444,7 +433,8 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color) * @param h height of the rectangle * @param style style of the rectangle (`body` properties are used except `padding`) */ -void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, const lv_style_t * style) +void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, + const lv_style_t * style) { lv_img_dsc_t * dsc = lv_canvas_get_img(canvas); @@ -466,12 +456,12 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord memset(&disp, 0, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, (void*)dsc->data, NULL, dsc->header.w * dsc->header.h); + lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_area_copy(&disp_buf.area, &mask); lv_disp_drv_init(&disp.driver); - disp.driver.buffer = &disp_buf; + disp.driver.buffer = &disp_buf; disp.driver.hor_res = dsc->header.w; disp.driver.ver_res = dsc->header.h; @@ -493,7 +483,8 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ -void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style, const char * txt, lv_label_align_t align) +void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style, + const char * txt, lv_label_align_t align) { lv_img_dsc_t * dsc = lv_canvas_get_img(canvas); @@ -515,12 +506,12 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord memset(&disp, 0, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, (void*)dsc->data, NULL, dsc->header.w * dsc->header.h); + lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_area_copy(&disp_buf.area, &mask); lv_disp_drv_init(&disp.driver); - disp.driver.buffer = &disp_buf; + disp.driver.buffer = &disp_buf; disp.driver.hor_res = dsc->header.w; disp.driver.ver_res = dsc->header.h; @@ -529,18 +520,10 @@ void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord lv_txt_flag_t flag; switch(align) { - case LV_LABEL_ALIGN_LEFT: - flag = LV_TXT_FLAG_NONE; - break; - case LV_LABEL_ALIGN_RIGHT: - flag = LV_TXT_FLAG_RIGHT; - break; - case LV_LABEL_ALIGN_CENTER: - flag = LV_TXT_FLAG_CENTER; - break; - default: - flag = LV_TXT_FLAG_NONE; - break; + case LV_LABEL_ALIGN_LEFT: flag = LV_TXT_FLAG_NONE; break; + case LV_LABEL_ALIGN_RIGHT: flag = LV_TXT_FLAG_RIGHT; break; + case LV_LABEL_ALIGN_CENTER: flag = LV_TXT_FLAG_CENTER; break; + default: flag = LV_TXT_FLAG_NONE; break; } lv_draw_label(&coords, &mask, style, LV_OPA_COVER, txt, flag, NULL, LV_LABEL_TEXT_SEL_OFF, LV_LABEL_TEXT_SEL_OFF); @@ -571,12 +554,12 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t memset(&disp, 0, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, (void*)dsc->data, NULL, dsc->header.w * dsc->header.h); + lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_area_copy(&disp_buf.area, &mask); lv_disp_drv_init(&disp.driver); - disp.driver.buffer = &disp_buf; + disp.driver.buffer = &disp_buf; disp.driver.hor_res = dsc->header.w; disp.driver.ver_res = dsc->header.h; @@ -614,12 +597,12 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32 memset(&disp, 0, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, (void*)dsc->data, NULL, dsc->header.w * dsc->header.h); + lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_area_copy(&disp_buf.area, &mask); lv_disp_drv_init(&disp.driver); - disp.driver.buffer = &disp_buf; + disp.driver.buffer = &disp_buf; disp.driver.hor_res = dsc->header.w; disp.driver.ver_res = dsc->header.h; @@ -631,7 +614,6 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32 lv_refr_set_disp_refreshing(refr_ori); } - /** * Draw an arc on the canvas * @param canvas pointer to a canvas object @@ -642,7 +624,8 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32 * @param end_angle end angle in degrees * @param style style of the polygon (`body.main_color` and `body.opa` is used) */ -void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, int32_t end_angle, const lv_style_t * style) +void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, + int32_t end_angle, const lv_style_t * style) { lv_img_dsc_t * dsc = lv_canvas_get_img(canvas); @@ -658,12 +641,12 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ memset(&disp, 0, sizeof(lv_disp_t)); lv_disp_buf_t disp_buf; - lv_disp_buf_init(&disp_buf, (void*)dsc->data, NULL, dsc->header.w * dsc->header.h); + lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h); lv_area_copy(&disp_buf.area, &mask); lv_disp_drv_init(&disp.driver); - disp.driver.buffer = &disp_buf; + disp.driver.buffer = &disp_buf; disp.driver.hor_res = dsc->header.w; disp.driver.ver_res = dsc->header.h; diff --git a/src/lv_objx/lv_canvas.h b/src/lv_objx/lv_canvas.h index 550ce64f5..a44fd66c8 100644 --- a/src/lv_objx/lv_canvas.h +++ b/src/lv_objx/lv_canvas.h @@ -74,8 +74,7 @@ lv_obj_t * lv_canvas_create(lv_obj_t * par, const lv_obj_t * copy); * @param cf color format. The following formats are supported: * LV_IMG_CF_TRUE_COLOR, LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED, LV_IMG_CF_INDEXES_1/2/4/8BIT */ -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_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf); /** * Set the color of a pixel on the canvas @@ -136,8 +135,8 @@ const lv_style_t * lv_canvas_get_style(const lv_obj_t * canvas, lv_canvas_style_ * @param x left side of the destination position * @param y top side of the destination position */ -void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, - lv_coord_t x, lv_coord_t y); +void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, lv_coord_t h, lv_coord_t x, + lv_coord_t y); /** * Rotate and image and store the result on a canvas. @@ -152,8 +151,8 @@ void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t w, l * @param pivot_y pivot Y of rotation. Relative to the source canvas * Set to `source height / 2` to rotate around the center */ -void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, - lv_coord_t offset_y, int32_t pivot_x, int32_t pivot_y); +void lv_canvas_rotate(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, lv_coord_t offset_x, lv_coord_t offset_y, + int32_t pivot_x, int32_t pivot_y); /** * Fill the canvas with color @@ -171,7 +170,8 @@ void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color); * @param h height of the rectangle * @param style style of the rectangle (`body` properties are used except `padding`) */ -void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, const lv_style_t * style); +void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h, + const lv_style_t * style); /** * Draw a text on the canvas. @@ -183,7 +183,8 @@ void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord * @param txt text to display * @param align align of the text (`LV_LABEL_ALIGN_LEFT/RIGHT/CENTER`) */ -void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style, const char * txt, lv_label_align_t align); +void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style, + const char * txt, lv_label_align_t align); /** * Draw a line on the canvas @@ -213,7 +214,8 @@ void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t * points, uint32 * @param end_angle end angle in degrees * @param style style of the polygon (`body.main_color` and `body.opa` is used) */ -void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, int32_t end_angle, const lv_style_t * style); +void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, + int32_t end_angle, const lv_style_t * style); /********************** * MACROS @@ -222,27 +224,20 @@ void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_ #define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) ((LV_COLOR_SIZE / 8) * w * h) #define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) (LV_IMG_PX_SIZE_ALPHA_BYTE * w * h) -#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) \ - ((((w / 8) + 1) * \ - h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ -#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) \ - (LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2) /*4 * 2: palette*/ +#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) \ + ((((w / 8) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ +#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) (LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2) /*4 * 2: palette*/ -#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) \ - ((((w / 4) + 1) * \ - h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ -#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) \ - (LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) + 4 * 4) /*4 * 4: palette*/ +#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) \ + ((((w / 4) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ +#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) (LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) + 4 * 4) /*4 * 4: palette*/ -#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) \ - ((((w / 2) + 1) * \ - h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ -#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) \ - (LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) + 4 * 16) /*4 * 16: palette*/ +#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) \ + ((((w / 2) + 1) * h)) /*(w / 8) + 1): to be sure no fractional row; LV_COLOR_SIZE / 8) * 2: palette*/ +#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) (LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) + 4 * 16) /*4 * 16: palette*/ #define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) ((w * h)) -#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) \ - (LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) + 4 * 256) /*4 * 256: palette*/ +#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) (LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) + 4 * 256) /*4 * 256: palette*/ #endif /*LV_USE_CANVAS*/ diff --git a/src/lv_objx/lv_cb.c b/src/lv_objx/lv_cb.c index ee4195911..a817caa17 100644 --- a/src/lv_objx/lv_cb.c +++ b/src/lv_objx/lv_cb.c @@ -74,8 +74,7 @@ lv_obj_t * lv_cb_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new checkbox object*/ if(copy == NULL) { ext->bullet = lv_btn_create(new_cb, NULL); - if(ancestor_bullet_design == NULL) - ancestor_bullet_design = lv_obj_get_design_cb(ext->bullet); + if(ancestor_bullet_design == NULL) ancestor_bullet_design = lv_obj_get_design_cb(ext->bullet); lv_obj_set_click(ext->bullet, false); ext->label = lv_label_create(new_cb, NULL); @@ -163,12 +162,8 @@ void lv_cb_set_style(lv_obj_t * cb, lv_cb_style_t type, const lv_style_t * style break; case LV_CB_STYLE_BOX_REL: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_REL, style); break; case LV_CB_STYLE_BOX_PR: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_PR, style); break; - case LV_CB_STYLE_BOX_TGL_REL: - lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style); - break; - case LV_CB_STYLE_BOX_TGL_PR: - lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style); - break; + case LV_CB_STYLE_BOX_TGL_REL: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_REL, style); break; + case LV_CB_STYLE_BOX_TGL_PR: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_TGL_PR, style); break; case LV_CB_STYLE_BOX_INA: lv_btn_set_style(ext->bullet, LV_BTN_STYLE_INA, style); break; } } @@ -202,12 +197,8 @@ const lv_style_t * lv_cb_get_style(const lv_obj_t * cb, lv_cb_style_t type) switch(type) { case LV_CB_STYLE_BOX_REL: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_REL); break; case LV_CB_STYLE_BOX_PR: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_PR); break; - case LV_CB_STYLE_BOX_TGL_REL: - style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL); - break; - case LV_CB_STYLE_BOX_TGL_PR: - style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR); - break; + case LV_CB_STYLE_BOX_TGL_REL: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_REL); break; + case LV_CB_STYLE_BOX_TGL_PR: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_TGL_PR); break; case LV_CB_STYLE_BOX_INA: style = lv_btn_get_style(ext->bullet, LV_BTN_STYLE_INA); break; default: style = NULL; break; } @@ -317,8 +308,7 @@ static lv_res_t lv_cb_signal(lv_obj_t * cb, lv_signal_t sign, void * param) lv_obj_set_size(ext->bullet, lv_font_get_line_height(label_style->text.font), lv_font_get_line_height(label_style->text.font)); lv_btn_set_state(ext->bullet, lv_btn_get_state(cb)); - } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || - sign == LV_SIGNAL_PRESS_LOST) { + } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { lv_btn_set_state(ext->bullet, lv_btn_get_state(cb)); } else if(sign == LV_SIGNAL_CONTROL) { char c = *((char *)param); diff --git a/src/lv_objx/lv_chart.c b/src/lv_objx/lv_chart.c index 5796dab21..ebc0f5f3f 100644 --- a/src/lv_objx/lv_chart.c +++ b/src/lv_objx/lv_chart.c @@ -44,8 +44,8 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask); static void lv_chart_draw_axes(lv_obj_t * chart, const lv_area_t * mask); static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i); -static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i); -static void lv_chart_inv_cols(lv_obj_t * chart, uint16_t i); +static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i); +static void lv_chart_inv_cols(lv_obj_t * chart, uint16_t i); /********************** * STATIC VARIABLES @@ -84,16 +84,16 @@ lv_obj_t * lv_chart_create(lv_obj_t * par, const lv_obj_t * copy) lv_ll_init(&ext->series_ll, sizeof(lv_chart_series_t)); - ext->series.num = 0; - ext->ymin = LV_CHART_YMIN_DEF; - ext->ymax = LV_CHART_YMAX_DEF; - ext->hdiv_cnt = LV_CHART_HDIV_DEF; - ext->vdiv_cnt = LV_CHART_VDIV_DEF; - ext->point_cnt = LV_CHART_PNUM_DEF; - ext->type = LV_CHART_TYPE_LINE; - ext->update_mode = LV_CHART_UPDATE_MODE_SHIFT; - ext->series.opa = LV_OPA_COVER; - ext->series.dark = LV_OPA_50; + ext->series.num = 0; + ext->ymin = LV_CHART_YMIN_DEF; + ext->ymax = LV_CHART_YMAX_DEF; + ext->hdiv_cnt = LV_CHART_HDIV_DEF; + ext->vdiv_cnt = LV_CHART_VDIV_DEF; + ext->point_cnt = LV_CHART_PNUM_DEF; + ext->type = LV_CHART_TYPE_LINE; + ext->update_mode = LV_CHART_UPDATE_MODE_SHIFT; + ext->series.opa = LV_OPA_COVER; + ext->series.dark = LV_OPA_50; ext->series.width = 2; ext->margin = 0; memset(&ext->x_axis, 0, sizeof(ext->x_axis)); @@ -160,7 +160,7 @@ lv_chart_series_t * lv_chart_add_series(lv_obj_t * chart, lv_color_t color) if(ser == NULL) return NULL; - ser->color = color; + ser->color = color; ser->points = lv_mem_alloc(sizeof(lv_coord_t) * ext->point_cnt); lv_mem_assert(ser->points); if(ser->points == NULL) { @@ -281,16 +281,16 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt) if(point_cnt >= point_cnt_old) { for(i = 0; i < point_cnt_old; i++) { - new_points[i] = ser->points[(i + ser->start_point) % - point_cnt_old]; /*Copy old contents to new array*/ + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ } for(i = point_cnt_old; i < point_cnt; i++) { new_points[i] = def; /*Fill up the rest with default value*/ } } else { for(i = 0; i < point_cnt; i++) { - new_points[i] = ser->points[(i + ser->start_point) % - point_cnt_old]; /*Copy old contents to new array*/ + new_points[i] = + ser->points[(i + ser->start_point) % point_cnt_old]; /*Copy old contents to new array*/ } } @@ -397,22 +397,23 @@ void lv_chart_set_points(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y */ void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y) { - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if(ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT) { - ser->points[ser->start_point] = y; /*This was the place of the former left most value, after shifting it is the rightmost*/ - ser->start_point = (ser->start_point + 1) % ext->point_cnt; - lv_chart_refresh(chart); - } else if(ext->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) { - ser->points[ser->start_point] = y; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT) { + ser->points[ser->start_point] = + y; /*This was the place of the former left most value, after shifting it is the rightmost*/ + ser->start_point = (ser->start_point + 1) % ext->point_cnt; + lv_chart_refresh(chart); + } else if(ext->update_mode == LV_CHART_UPDATE_MODE_CIRCULAR) { + ser->points[ser->start_point] = y; - if(ext->type & LV_CHART_TYPE_LINE) lv_chart_inv_lines(chart, ser->start_point); - if(ext->type & LV_CHART_TYPE_COLUMN) lv_chart_inv_cols(chart, ser->start_point); - if(ext->type & LV_CHART_TYPE_POINT) lv_chart_inv_points(chart, ser->start_point); - if(ext->type & LV_CHART_TYPE_VERTICAL_LINE) lv_chart_inv_lines(chart, ser->start_point); + if(ext->type & LV_CHART_TYPE_LINE) lv_chart_inv_lines(chart, ser->start_point); + if(ext->type & LV_CHART_TYPE_COLUMN) lv_chart_inv_cols(chart, ser->start_point); + if(ext->type & LV_CHART_TYPE_POINT) lv_chart_inv_points(chart, ser->start_point); + if(ext->type & LV_CHART_TYPE_VERTICAL_LINE) lv_chart_inv_lines(chart, ser->start_point); if(ext->type & LV_CHART_TYPE_AREA) lv_chart_inv_lines(chart, ser->start_point); - ser->start_point = (ser->start_point + 1) % ext->point_cnt;/*update the x for next incoming y*/ - } + ser->start_point = (ser->start_point + 1) % ext->point_cnt; /*update the x for next incoming y*/ + } } /** @@ -422,11 +423,11 @@ void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y) */ void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mode) { - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - if(ext->update_mode == update_mode) return; + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + if(ext->update_mode == update_mode) return; - ext->update_mode = update_mode; - lv_obj_invalidate(chart); + ext->update_mode = update_mode; + lv_obj_invalidate(chart); } /** @@ -450,9 +451,8 @@ void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin) * @param minor_tick_len the length of the minor tick, AUTO if 0 * @param options extra options */ -void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, - uint8_t major_tick_len, uint8_t minor_tick_len, - lv_chart_axis_options_t options) +void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len, + uint8_t minor_tick_len, lv_chart_axis_options_t options) { lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); ext->x_axis.num_tick_marks = num_tick_marks; @@ -462,9 +462,8 @@ void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t ext->x_axis.options = options; } -void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, - uint8_t major_tick_len, uint8_t minor_tick_len, - lv_chart_axis_options_t options) +void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len, + uint8_t minor_tick_len, lv_chart_axis_options_t options) { lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); ext->y_axis.num_tick_marks = num_tick_marks; @@ -668,10 +667,8 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask) for(div_i = div_i_start; div_i <= div_i_end; div_i++) { p1.y = (int32_t)((int32_t)h * div_i) / (ext->hdiv_cnt + 1); p1.y += y_ofs; - if(div_i == div_i_start) - p1.y += (style->line.width >> 1) + 1; /*The first line might not be visible*/ - if(div_i == div_i_end) - p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ + if(div_i == div_i_start) p1.y += (style->line.width >> 1) + 1; /*The first line might not be visible*/ + if(div_i == div_i_end) p1.y -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ p2.y = p1.y; lv_draw_line(&p1, &p2, mask, style, opa_scale); @@ -693,10 +690,8 @@ static void lv_chart_draw_div(lv_obj_t * chart, const lv_area_t * mask) for(div_i = div_i_start; div_i <= div_i_end; div_i++) { p1.x = (int32_t)((int32_t)w * div_i) / (ext->vdiv_cnt + 1); p1.x += x_ofs; - if(div_i == div_i_start) - p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/ - if(div_i == div_i_end) - p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ + if(div_i == div_i_start) p1.x += (style->line.width >> 1) + 1; /*The first line might not be visible*/ + if(div_i == div_i_end) p1.x -= (style->line.width >> 1) + 1; /*The last line might not be visible*/ p2.x = p1.x; lv_draw_line(&p1, &p2, mask, style, opa_scale); } @@ -755,8 +750,7 @@ static void lv_chart_draw_lines(lv_obj_t * chart, const lv_area_t * mask) y_tmp = y_tmp / (ext->ymax - ext->ymin); p2.y = h - y_tmp + y_ofs; - if(ser->points[p_prev] != LV_CHART_POINT_DEF && - ser->points[p_act] != LV_CHART_POINT_DEF) + if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) lv_draw_line(&p1, &p2, mask, &style, opa_scale); p_prev = p_act; @@ -793,7 +787,8 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask) /*Go through all data lines*/ - LV_LL_READ_BACK(ext->series_ll, ser) { + LV_LL_READ_BACK(ext->series_ll, ser) + { lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; style_point.body.main_color = ser->color; @@ -805,7 +800,7 @@ static void lv_chart_draw_points(lv_obj_t * chart, const lv_area_t * mask) cir_a.x1 -= style_point.body.radius; p_act = (start_point + i) % ext->point_cnt; - y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h; + y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; y_tmp = y_tmp / (ext->ymax - ext->ymin); cir_a.y1 = h - y_tmp + y_ofs; @@ -837,9 +832,8 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask) int32_t y_tmp; lv_chart_series_t * ser; lv_style_t rects; - lv_coord_t col_w = - w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/ - lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ + lv_coord_t col_w = w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/ + lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ lv_style_copy(&rects, &lv_style_plain); rects.body.border.width = 0; @@ -856,11 +850,12 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask) x_act += chart->coords.x1 + x_ofs; /*Draw the current point of all data line*/ - LV_LL_READ_BACK(ext->series_ll, ser) { + LV_LL_READ_BACK(ext->series_ll, ser) + { lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; - col_a.x1 = x_act; - col_a.x2 = col_a.x1 + col_w; + col_a.x1 = x_act; + col_a.x2 = col_a.x1 + col_w; x_act += col_w; if(col_a.x2 < mask->x1) continue; @@ -870,9 +865,9 @@ static void lv_chart_draw_cols(lv_obj_t * chart, const lv_area_t * mask) rects.body.grad_color = lv_color_mix(LV_COLOR_BLACK, ser->color, ext->series.dark); lv_coord_t p_act = (start_point + i) % ext->point_cnt; - y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h; - y_tmp = y_tmp / (ext->ymax - ext->ymin); - col_a.y1 = h - y_tmp + chart->coords.y1; + y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; + y_tmp = y_tmp / (ext->ymax - ext->ymin); + col_a.y1 = h - y_tmp + chart->coords.y1; mask_ret = lv_area_intersect(&col_mask, mask, &col_a); if(mask_ret != false && ser->points[p_act] != LV_CHART_POINT_DEF) { @@ -901,7 +896,7 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas lv_point_t p1; lv_point_t p2; lv_coord_t p_act; - lv_coord_t h = lv_obj_get_height(chart); + lv_coord_t h = lv_obj_get_height(chart); lv_coord_t x_ofs = chart->coords.x1; lv_coord_t y_ofs = chart->coords.y1; int32_t y_tmp; @@ -913,9 +908,10 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas style.line.width = ext->series.width; /*Go through all data lines*/ - LV_LL_READ_BACK(ext->series_ll, ser) { + LV_LL_READ_BACK(ext->series_ll, ser) + { lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; - style.line.color = ser->color; + style.line.color = ser->color; p1.x = 0 + x_ofs; p2.x = 0 + x_ofs; @@ -924,11 +920,10 @@ static void lv_chart_draw_vertical_lines(lv_obj_t * chart, const lv_area_t * mas p2.y = h - y_tmp + y_ofs; p1.y = p2.y; - for(i = 0; i < ext->point_cnt; i++) - { + for(i = 0; i < ext->point_cnt; i++) { p_act = (start_point + i) % ext->point_cnt; - y_tmp = (int32_t)((int32_t) ser->points[p_act] - ext->ymin) * h; + y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; y_tmp = y_tmp / (ext->ymax - ext->ymin); p2.y = h - y_tmp + y_ofs; @@ -971,10 +966,11 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask) lv_style_copy(&style, &lv_style_plain); /*Go through all data lines*/ - LV_LL_READ_BACK(ext->series_ll, ser) { + LV_LL_READ_BACK(ext->series_ll, ser) + { lv_coord_t start_point = ext->update_mode == LV_CHART_UPDATE_MODE_SHIFT ? ser->start_point : 0; - style.body.main_color = ser->color; - style.body.opa = ext->series.opa; + style.body.main_color = ser->color; + style.body.opa = ext->series.opa; p2.x = 0 + x_ofs; @@ -988,14 +984,13 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask) p1.y = p2.y; p_act = (start_point + i) % ext->point_cnt; - p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs; + p2.x = ((w * i) / (ext->point_cnt - 1)) + x_ofs; y_tmp = (int32_t)((int32_t)ser->points[p_act] - ext->ymin) * h; y_tmp = y_tmp / (ext->ymax - ext->ymin); p2.y = h - y_tmp + y_ofs; - if(ser->points[p_prev] != LV_CHART_POINT_DEF && - ser->points[p_act] != LV_CHART_POINT_DEF) { + if(ser->points[p_prev] != LV_CHART_POINT_DEF && ser->points[p_act] != LV_CHART_POINT_DEF) { lv_point_t triangle_points[3]; triangle_points[0] = p1; triangle_points[1] = p2; @@ -1003,7 +998,7 @@ static void lv_chart_draw_areas(lv_obj_t * chart, const lv_area_t * mask) triangle_points[2].y = chart->coords.y2; lv_draw_triangle(triangle_points, mask, &style, opa_scale); triangle_points[2].x = p2.x; - triangle_points[0].y =chart->coords.y2; + triangle_points[0].y = chart->coords.y2; lv_draw_triangle(triangle_points, mask, &style, opa_scale); } p_prev = p_act; @@ -1031,8 +1026,7 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask) lv_coord_t y_ofs = chart->coords.y1; lv_coord_t h = lv_obj_get_height(chart); lv_coord_t w = lv_obj_get_width(chart); - char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + - 1]; /* up to N symbols per label + null terminator */ + char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */ /* calculate the size of tick marks */ if(ext->y_axis.major_tick_len == 0) @@ -1065,9 +1059,8 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask) else num_scale_ticks = (ext->y_axis.num_tick_marks * (num_of_labels - 1)); - for(i = 0; i < (num_scale_ticks + 1); - i++) { /* one extra loop - it may not exist in the list, empty label */ - /* first point of the tick */ + for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */ + /* first point of the tick */ p1.x = 0 + x_ofs; /* second point of the tick */ @@ -1077,8 +1070,8 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask) p2.x = p1.x - minor_tick_len; /* minor tick */ /* draw a line at moving y position */ - p2.y = p1.y = y_ofs + h - (int32_t)(((int32_t)h * i) / num_scale_ticks + 1) - - LV_CHART_AXIS_Y_TICK_OFFSET_FIX; + p2.y = p1.y = + y_ofs + h - (int32_t)(((int32_t)h * i) / num_scale_ticks + 1) - LV_CHART_AXIS_Y_TICK_OFFSET_FIX; if(i != num_scale_ticks) lv_draw_line(&p1, &p2, mask, style, opa_scale); @@ -1108,15 +1101,13 @@ static void lv_chart_draw_y_ticks(lv_obj_t * chart, const lv_area_t * mask) /* reserve appropriate area */ lv_point_t size; - lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER); + lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, LV_TXT_FLAG_CENTER); /* set the area at some distance of the major tick len left of the tick */ - lv_area_t a = {(p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), - (p2.y - size.y / 2), (p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), - (p2.y + size.y / 2)}; - lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, - -1); + lv_area_t a = {(p2.x - size.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.y - size.y / 2), + (p2.x - LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.y + size.y / 2)}; + lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1); } } } @@ -1144,8 +1135,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) lv_coord_t y_ofs = chart->coords.y1; lv_coord_t h = lv_obj_get_height(chart); lv_coord_t w = lv_obj_get_width(chart); - char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + - 1]; /* up to N symbols per label + null terminator */ + char buf[LV_CHART_AXIS_TICK_LABEL_MAX_LEN + 1]; /* up to N symbols per label + null terminator */ /* calculate the size of tick marks */ if(ext->x_axis.major_tick_len == 0) @@ -1178,9 +1168,8 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) else num_scale_ticks = (ext->x_axis.num_tick_marks * (num_of_labels - 1)); - for(i = 0; i < (num_scale_ticks + 1); - i++) { /* one extra loop - it may not exist in the list, empty label */ - /* first point of the tick */ + for(i = 0; i < (num_scale_ticks + 1); i++) { /* one extra loop - it may not exist in the list, empty label */ + /* first point of the tick */ p1.y = h + y_ofs; /* second point of the tick */ @@ -1190,8 +1179,7 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) p2.y = p1.y + minor_tick_len; /* minor tick */ /* draw a line at moving x position */ - p2.x = p1.x = x_ofs + (int32_t)(((int32_t)w * i) / num_scale_ticks + 1) - - LV_CHART_AXIS_X_TICK_OFFSET_FIX; + p2.x = p1.x = x_ofs + (int32_t)(((int32_t)w * i) / num_scale_ticks + 1) - LV_CHART_AXIS_X_TICK_OFFSET_FIX; if(i != num_scale_ticks) lv_draw_line(&p1, &p2, mask, style, opa_scale); @@ -1221,15 +1209,13 @@ static void lv_chart_draw_x_ticks(lv_obj_t * chart, const lv_area_t * mask) /* reserve appropriate area */ lv_point_t size; - lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_CENTER); + lv_txt_get_size(&size, buf, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, LV_TXT_FLAG_CENTER); /* set the area at some distance of the major tick len under of the tick */ - lv_area_t a = {(p2.x - size.x / 2), (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE), - (p2.x + size.x / 2), + lv_area_t a = {(p2.x - size.x / 2), (p2.y + LV_CHART_AXIS_TO_LABEL_DISTANCE), (p2.x + size.x / 2), (p2.y + size.y + LV_CHART_AXIS_TO_LABEL_DISTANCE)}; - lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, - -1); + lv_draw_label(&a, mask, style, opa_scale, buf, LV_TXT_FLAG_CENTER, NULL, -1, -1); } } } @@ -1248,13 +1234,13 @@ static void lv_chart_draw_axes(lv_obj_t * chart, const lv_area_t * mask) */ static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i) { - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - lv_coord_t w = lv_obj_get_width(chart); - lv_coord_t x_ofs = chart->coords.x1; + lv_coord_t w = lv_obj_get_width(chart); + lv_coord_t x_ofs = chart->coords.x1; - if(i < ext->point_cnt) { - lv_area_t coords; + if(i < ext->point_cnt) { + lv_area_t coords; lv_obj_get_coords(chart, &coords); if(i < ext->point_cnt - 1) { coords.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs - ext->series.width; @@ -1267,7 +1253,7 @@ static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i) coords.x2 = ((w * i) / (ext->point_cnt - 1)) + x_ofs + ext->series.width; lv_inv_area(lv_obj_get_disp(chart), &coords); } - } + } } /** @@ -1277,16 +1263,16 @@ static void lv_chart_inv_lines(lv_obj_t * chart, uint16_t i) */ static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i) { - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - lv_area_t cir_a; - lv_coord_t w = lv_obj_get_width(chart); - lv_coord_t x_ofs = chart->coords.x1; + lv_area_t cir_a; + lv_coord_t w = lv_obj_get_width(chart); + lv_coord_t x_ofs = chart->coords.x1; - lv_obj_get_coords(chart, &cir_a); - cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs; - cir_a.x2 = cir_a.x1 + ext->series.width; - cir_a.x1 -= ext->series.width; + lv_obj_get_coords(chart, &cir_a); + cir_a.x1 = ((w * i) / (ext->point_cnt - 1)) + x_ofs; + cir_a.x2 = cir_a.x1 + ext->series.width; + cir_a.x1 -= ext->series.width; lv_inv_area(lv_obj_get_disp(chart), &cir_a); } @@ -1298,21 +1284,21 @@ static void lv_chart_inv_points(lv_obj_t * chart, uint16_t i) */ static void lv_chart_inv_cols(lv_obj_t * chart, uint16_t i) { - lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); + lv_chart_ext_t * ext = lv_obj_get_ext_attr(chart); - lv_area_t col_a; - lv_coord_t w = lv_obj_get_width(chart); - lv_coord_t col_w = w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/ - lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ + lv_area_t col_a; + lv_coord_t w = lv_obj_get_width(chart); + lv_coord_t col_w = w / ((ext->series.num + 1) * ext->point_cnt); /* Suppose + 1 series as separator*/ + lv_coord_t x_ofs = col_w / 2; /*Shift with a half col.*/ - lv_coord_t x_act; + lv_coord_t x_act; - x_act = (int32_t)((int32_t) w * i) / ext->point_cnt; - x_act += chart->coords.x1 + x_ofs; + x_act = (int32_t)((int32_t)w * i) / ext->point_cnt; + x_act += chart->coords.x1 + x_ofs; - lv_obj_get_coords(chart, &col_a); - col_a.x1 = x_act; - col_a.x2 = col_a.x1 + col_w; + lv_obj_get_coords(chart, &col_a); + col_a.x1 = x_act; + col_a.x2 = col_a.x1 + col_w; lv_inv_area(lv_obj_get_disp(chart), &col_a); } diff --git a/src/lv_objx/lv_chart.h b/src/lv_objx/lv_chart.h index 49cb6ecfd..3c3b60196 100644 --- a/src/lv_objx/lv_chart.h +++ b/src/lv_objx/lv_chart.h @@ -35,23 +35,21 @@ extern "C" { /*Chart types*/ enum { - LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/ - LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/ - LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/ - LV_CHART_TYPE_VERTICAL_LINE = - 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/ - LV_CHART_TYPE_AREA = 0x10, /*Draw area chart*/ + LV_CHART_TYPE_LINE = 0x01, /*Connect the points with lines*/ + LV_CHART_TYPE_COLUMN = 0x02, /*Draw columns*/ + LV_CHART_TYPE_POINT = 0x04, /*Draw circles on the points*/ + LV_CHART_TYPE_VERTICAL_LINE = 0x08, /*Draw vertical lines on points (useful when chart width == point count)*/ + LV_CHART_TYPE_AREA = 0x10, /*Draw area chart*/ }; typedef uint8_t lv_chart_type_t; /*Chart update mode*/ -enum -{ - LV_CHART_UPDATE_MODE_SHIFT, - LV_CHART_UPDATE_MODE_CIRCULAR, +enum { + LV_CHART_UPDATE_MODE_SHIFT, + LV_CHART_UPDATE_MODE_CIRCULAR, }; typedef uint8_t lv_chart_update_mode_t; - + typedef struct { lv_coord_t * points; @@ -89,7 +87,7 @@ typedef struct lv_chart_axis_cfg_t y_axis; lv_chart_axis_cfg_t x_axis; uint16_t margin; - uint8_t update_mode: 1; + uint8_t update_mode : 1; struct { lv_coord_t width; /*Line width or point radius*/ @@ -216,7 +214,7 @@ void lv_chart_set_next(lv_obj_t * chart, lv_chart_series_t * ser, lv_coord_t y); * @param update mode */ void lv_chart_set_update_mode(lv_obj_t * chart, lv_chart_update_mode_t update_mode); - + /** * Set the style of a chart * @param chart pointer to a chart object @@ -244,13 +242,11 @@ void lv_chart_set_margin(lv_obj_t * chart, uint16_t margin); * @param minor_tick_len the length of the minor tick, AUTO if 0 * @param options extra options */ -void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, - uint8_t major_tick_len, uint8_t minor_tick_len, - lv_chart_axis_options_t options); +void lv_chart_set_x_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len, + uint8_t minor_tick_len, lv_chart_axis_options_t options); -void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, - uint8_t major_tick_len, uint8_t minor_tick_len, - lv_chart_axis_options_t options); +void lv_chart_set_y_ticks(lv_obj_t * chart, const char * list_of_values, uint8_t num_tick_marks, uint8_t major_tick_len, + uint8_t minor_tick_len, lv_chart_axis_options_t options); /*===================== * Getter functions diff --git a/src/lv_objx/lv_cont.c b/src/lv_objx/lv_cont.c index 690d09cc6..79443fbf7 100644 --- a/src/lv_objx/lv_cont.c +++ b/src/lv_objx/lv_cont.c @@ -146,8 +146,7 @@ void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t t { lv_obj_invalidate(cont); lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont); - if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top && - ext->fit_bottom == bottom) { + if(ext->fit_left == left && ext->fit_right == right && ext->fit_top == top && ext->fit_bottom == bottom) { return; } @@ -245,8 +244,7 @@ static lv_res_t lv_cont_signal(lv_obj_t * cont, lv_signal_t sign, void * param) lv_cont_refr_layout(cont); lv_cont_refr_autofit(cont); } else if(sign == LV_SIGNAL_CORD_CHG) { - if(lv_obj_get_width(cont) != lv_area_get_width(param) || - lv_obj_get_height(cont) != lv_area_get_height(param)) { + if(lv_obj_get_width(cont) != lv_area_get_width(param) || lv_obj_get_height(cont) != lv_area_get_height(param)) { lv_cont_refr_layout(cont); lv_cont_refr_autofit(cont); } @@ -332,8 +330,7 @@ static void lv_cont_layout_col(lv_obj_t * cont) lv_coord_t last_cord = style->body.padding.top; LV_LL_READ_BACK(cont->child_ll, child) { - if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) - continue; + if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_obj_align(child, cont, align, hpad_corr, last_cord); last_cord += lv_obj_get_height(child) + style->body.padding.inner; @@ -383,8 +380,7 @@ static void lv_cont_layout_row(lv_obj_t * cont) lv_coord_t last_cord = style->body.padding.left; LV_LL_READ_BACK(cont->child_ll, child) { - if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) - continue; + if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_obj_align(child, cont, align, last_cord, vpad_corr); last_cord += lv_obj_get_width(child) + style->body.padding.inner; @@ -406,8 +402,7 @@ static void lv_cont_layout_center(lv_obj_t * cont) LV_LL_READ(cont->child_ll, child) { - if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) - continue; + if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; h_tot += lv_obj_get_height(child) + style->body.padding.inner; obj_num++; } @@ -424,8 +419,7 @@ static void lv_cont_layout_center(lv_obj_t * cont) lv_coord_t last_cord = -(h_tot / 2); LV_LL_READ_BACK(cont->child_ll, child) { - if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) - continue; + if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; lv_obj_align(child, cont, LV_ALIGN_CENTER, 0, last_cord + lv_obj_get_height(child) / 2); last_cord += lv_obj_get_height(child) + style->body.padding.inner; @@ -458,14 +452,13 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) child_rc = child_rs; /*Initially the the row starter and closer is the same*/ while(child_rs != NULL) { lv_coord_t h_row = 0; - lv_coord_t w_row = style->body.padding.left + - style->body.padding.right; /*The width is at least the left+right hpad*/ + lv_coord_t w_row = + style->body.padding.left + style->body.padding.right; /*The width is at least the left+right hpad*/ uint32_t obj_num = 0; /*Find the row closer object and collect some data*/ do { - if(lv_obj_get_hidden(child_rc) == false && - lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) { + if(lv_obj_get_hidden(child_rc) == false && lv_obj_is_protected(child_rc, LV_PROTECT_POS) == false) { /*If this object is already not fit then break*/ if(w_row + lv_obj_get_width(child_rc) > w_obj) { /*Step back one child because the last already not fit, so the previous is the @@ -475,10 +468,8 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) } break; } - w_row += lv_obj_get_width(child_rc) + - style->body.padding.inner; /*Add the object width + opad*/ - h_row = - LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/ + w_row += lv_obj_get_width(child_rc) + style->body.padding.inner; /*Add the object width + opad*/ + h_row = LV_MATH_MAX(h_row, lv_obj_get_height(child_rc)); /*Search the highest object*/ obj_num++; if(lv_obj_is_protected(child_rc, LV_PROTECT_FOLLOW)) break; /*If can not be followed by an other object then break here*/ @@ -493,8 +484,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) if(obj_num == 0) { if(child_rc != NULL) { lv_obj_align(child_rc, cont, LV_ALIGN_IN_TOP_MID, 0, act_y); - h_row = - lv_obj_get_height(child_rc); /*Not set previously because of the early break*/ + h_row = lv_obj_get_height(child_rc); /*Not set previously because of the early break*/ } } /*If there is only one object in the row then align it to the middle*/ @@ -507,10 +497,8 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) lv_obj_t * obj2 = lv_ll_get_prev(&cont->child_ll, child_rs); w_row = lv_obj_get_width(obj1) + lv_obj_get_width(obj2); lv_coord_t pad = (w_obj - w_row) / 3; - lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, - act_y + (h_row - lv_obj_get_height(obj1)) / 2); - lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, - act_y + (h_row - lv_obj_get_height(obj2)) / 2); + lv_obj_align(obj1, cont, LV_ALIGN_IN_TOP_LEFT, pad, act_y + (h_row - lv_obj_get_height(obj1)) / 2); + lv_obj_align(obj2, cont, LV_ALIGN_IN_TOP_RIGHT, -pad, act_y + (h_row - lv_obj_get_height(obj2)) / 2); } /* Align the children (from child_rs to child_rc)*/ else { @@ -519,8 +507,7 @@ static void lv_cont_layout_pretty(lv_obj_t * cont) lv_coord_t act_x = style->body.padding.left; /*x init*/ child_tmp = child_rs; while(child_tmp != NULL) { - if(lv_obj_get_hidden(child_tmp) == false && - lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) { + if(lv_obj_get_hidden(child_tmp) == false && lv_obj_is_protected(child_tmp, LV_PROTECT_POS) == false) { lv_obj_align(child_tmp, cont, LV_ALIGN_IN_TOP_LEFT, act_x, act_y + (h_row - lv_obj_get_height(child_tmp)) / 2); act_x += lv_obj_get_width(child_tmp) + new_opad; @@ -550,11 +537,10 @@ static void lv_cont_layout_grid(lv_obj_t * cont) lv_coord_t w_obj = lv_obj_get_width(lv_obj_get_child(cont, NULL)); lv_coord_t h_obj = lv_obj_get_height(lv_obj_get_child(cont, NULL)); uint16_t obj_row = (w_tot - style->body.padding.left - style->body.padding.right) / - (w_obj + style->body.padding.inner); /*Obj. num. in a row*/ + (w_obj + style->body.padding.inner); /*Obj. num. in a row*/ lv_coord_t x_ofs; if(obj_row > 1) { - x_ofs = (w_obj + (w_tot - style->body.padding.left - style->body.padding.right) - - (obj_row * w_obj)) / + x_ofs = (w_obj + (w_tot - style->body.padding.left - style->body.padding.right) - (obj_row * w_obj)) / (obj_row - 1); } else { x_ofs = w_tot / 2 - w_obj / 2; @@ -571,8 +557,7 @@ static void lv_cont_layout_grid(lv_obj_t * cont) uint16_t obj_cnt = 0; LV_LL_READ_BACK(cont->child_ll, child) { - if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) - continue; + if(lv_obj_get_hidden(child) != false || lv_obj_is_protected(child, LV_PROTECT_POS) != false) continue; if(obj_row > 1) { lv_obj_set_pos(child, act_x, act_y); @@ -600,8 +585,8 @@ static void lv_cont_refr_autofit(lv_obj_t * cont) { lv_cont_ext_t * ext = lv_obj_get_ext_attr(cont); - if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && - ext->fit_top == LV_FIT_NONE && ext->fit_bottom == LV_FIT_NONE) { + if(ext->fit_left == LV_FIT_NONE && ext->fit_right == LV_FIT_NONE && ext->fit_top == LV_FIT_NONE && + ext->fit_bottom == LV_FIT_NONE) { return; } @@ -652,42 +637,34 @@ static void lv_cont_refr_autofit(lv_obj_t * cont) switch(ext->fit_left) { case LV_FIT_TIGHT: new_area.x1 = tight_area.x1; break; case LV_FIT_FLOOD: new_area.x1 = flood_area.x1; break; - case LV_FIT_FILL: - new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; - break; + case LV_FIT_FILL: new_area.x1 = has_children ? LV_MATH_MIN(tight_area.x1, flood_area.x1) : flood_area.x1; break; default: break; } switch(ext->fit_right) { case LV_FIT_TIGHT: new_area.x2 = tight_area.x2; break; case LV_FIT_FLOOD: new_area.x2 = flood_area.x2; break; - case LV_FIT_FILL: - new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; - break; + case LV_FIT_FILL: new_area.x2 = has_children ? LV_MATH_MAX(tight_area.x2, flood_area.x2) : flood_area.x2; break; default: break; } switch(ext->fit_top) { case LV_FIT_TIGHT: new_area.y1 = tight_area.y1; break; case LV_FIT_FLOOD: new_area.y1 = flood_area.y1; break; - case LV_FIT_FILL: - new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; - break; + case LV_FIT_FILL: new_area.y1 = has_children ? LV_MATH_MIN(tight_area.y1, flood_area.y1) : flood_area.y1; break; default: break; } switch(ext->fit_bottom) { case LV_FIT_TIGHT: new_area.y2 = tight_area.y2; break; case LV_FIT_FLOOD: new_area.y2 = flood_area.y2; break; - case LV_FIT_FILL: - new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; - break; + case LV_FIT_FILL: new_area.y2 = has_children ? LV_MATH_MAX(tight_area.y2, flood_area.y2) : flood_area.y2; break; default: break; } /*Do nothing if the coordinates are not changed*/ - if(cont->coords.x1 != new_area.x1 || cont->coords.y1 != new_area.y1 || - cont->coords.x2 != new_area.x2 || cont->coords.y2 != new_area.y2) { + if(cont->coords.x1 != new_area.x1 || cont->coords.y1 != new_area.y1 || cont->coords.x2 != new_area.x2 || + cont->coords.y2 != new_area.y2) { lv_obj_invalidate(cont); lv_area_copy(&cont->coords, &new_area); diff --git a/src/lv_objx/lv_cont.h b/src/lv_objx/lv_cont.h index 0d44c81a9..a53b50245 100644 --- a/src/lv_objx/lv_cont.h +++ b/src/lv_objx/lv_cont.h @@ -98,8 +98,7 @@ void lv_cont_set_layout(lv_obj_t * cont, lv_layout_t layout); * @param top bottom fit policy from `lv_fit_t` * @param bottom bottom fit policy from `lv_fit_t` */ -void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, - lv_fit_t bottom); +void lv_cont_set_fit4(lv_obj_t * cont, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom); /** * Set the fit policy horizontally and vertically separately. diff --git a/src/lv_objx/lv_ddlist.c b/src/lv_objx/lv_ddlist.c index 004f03690..9d3ce58d1 100644 --- a/src/lv_objx/lv_ddlist.c +++ b/src/lv_objx/lv_ddlist.c @@ -43,10 +43,10 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * static lv_res_t release_handler(lv_obj_t * ddlist); static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en); static void lv_ddlist_pos_current_option(lv_obj_t * ddlist); -static void lv_ddlist_refr_width(lv_obj_t* ddlist); +static void lv_ddlist_refr_width(lv_obj_t * ddlist); #if LV_USE_ANIMATION static void lv_ddlist_anim_ready_cb(lv_anim_t * a); -static void lv_ddlist_anim_finish(lv_obj_t* ddlist); +static void lv_ddlist_anim_finish(lv_obj_t * ddlist); static void lv_ddlist_adjust_height(lv_obj_t * ddlist, lv_anim_value_t height); #endif @@ -82,8 +82,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy) if(new_ddlist == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_ddlist); - if(ancestor_scrl_signal == NULL) - ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_ddlist)); + if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_ddlist)); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_ddlist); /*Allocate the drop down list type specific extended data*/ @@ -184,15 +183,9 @@ void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options) lv_ddlist_refr_width(ddlist); switch(lv_label_get_align(ext->label)) { - case LV_LABEL_ALIGN_LEFT: - lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); - break; - case LV_LABEL_ALIGN_CENTER: - lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); - break; - case LV_LABEL_ALIGN_RIGHT: - lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); - break; + case LV_LABEL_ALIGN_LEFT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break; + case LV_LABEL_ALIGN_CENTER: lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); break; + case LV_LABEL_ALIGN_RIGHT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break; } lv_ddlist_refr_size(ddlist, false); @@ -317,17 +310,10 @@ void lv_ddlist_set_align(lv_obj_t * ddlist, lv_label_align_t align) lv_label_set_align(ext->label, align); switch(align) { - case LV_LABEL_ALIGN_LEFT: - lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); - break; - case LV_LABEL_ALIGN_CENTER: - lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); - break; - case LV_LABEL_ALIGN_RIGHT: - lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); - break; + case LV_LABEL_ALIGN_LEFT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_LEFT_MID, 0, 0); break; + case LV_LABEL_ALIGN_CENTER: lv_obj_align(ext->label, NULL, LV_ALIGN_CENTER, 0, 0); break; + case LV_LABEL_ALIGN_RIGHT: lv_obj_align(ext->label, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0); break; } - } /*===================== * Getter functions @@ -592,8 +578,8 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig new_style.text.color = sel_style->text.color; new_style.text.opa = sel_style->text.opa; lv_txt_flag_t flag = lv_ddlist_get_txt_flag(ddlist); - lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, - lv_label_get_text(ext->label), flag, NULL, -1, -1); + lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale, lv_label_get_text(ext->label), + flag, NULL, -1, -1); } } @@ -611,9 +597,8 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig new_style.text.opa = sel_style->text.opa; lv_area_t area_arrow; area_arrow.x2 = ddlist->coords.x2 - style->body.padding.right; - area_arrow.x1 = - area_arrow.x2 - lv_txt_get_width(LV_SYMBOL_DOWN, strlen(LV_SYMBOL_DOWN), - sel_style->text.font, 0, 0); + area_arrow.x1 = area_arrow.x2 - + lv_txt_get_width(LV_SYMBOL_DOWN, strlen(LV_SYMBOL_DOWN), sel_style->text.font, 0, 0); area_arrow.y1 = ddlist->coords.y1 + style->text.line_space; area_arrow.y2 = area_arrow.y1 + font_h; @@ -622,10 +607,9 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig bool area_ok; area_ok = lv_area_intersect(&mask_arrow, mask, &area_arrow); if(area_ok) { - lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale, LV_SYMBOL_DOWN, - LV_TXT_FLAG_NONE, NULL, -1, - -1); /*Use a down arrow in ddlist, you can replace it with your - custom symbol*/ + lv_draw_label(&area_arrow, &mask_arrow, &new_style, opa_scale, LV_SYMBOL_DOWN, LV_TXT_FLAG_NONE, + NULL, -1, -1); /*Use a down arrow in ddlist, you can replace it with your + custom symbol*/ } } } @@ -761,7 +745,7 @@ static lv_res_t lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * /* Because of the wider selected rectangle ext. size * In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/ const lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG); - lv_coord_t hpad = LV_MATH_MAX(style->body.padding.left, style->body.padding.right); + lv_coord_t hpad = LV_MATH_MAX(style->body.padding.left, style->body.padding.right); if(scrl->ext_draw_pad < hpad) scrl->ext_draw_pad = hpad; } else if(sign == LV_SIGNAL_RELEASED) { if(lv_indev_is_dragging(lv_indev_get_act()) == false) { @@ -794,15 +778,14 @@ static lv_res_t release_handler(lv_obj_t * ddlist) lv_indev_t * indev = lv_indev_get_act(); if(lv_indev_get_type(indev) == LV_INDEV_TYPE_ENCODER) { ext->sel_opt_id_ori = ext->sel_opt_id; - lv_group_t * g = lv_obj_get_group(ddlist); + lv_group_t * g = lv_obj_get_group(ddlist); if(lv_group_get_editing(g)) { lv_group_set_editing(g, false); } } /*Search the clicked option (For KEYPAD and ENCODER the new value should be already set)*/ - if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || - lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) { + if(lv_indev_get_type(indev) == LV_INDEV_TYPE_POINTER || lv_indev_get_type(indev) == LV_INDEV_TYPE_BUTTON) { lv_point_t p; lv_indev_get_point(indev, &p); p.y -= ext->label->coords.y1; @@ -822,7 +805,7 @@ static lv_res_t release_handler(lv_obj_t * ddlist) if(letter == '\n' && i != letter_i) new_opt++; } - ext->sel_opt_id = new_opt; + ext->sel_opt_id = new_opt; ext->sel_opt_id_ori = ext->sel_opt_id; } @@ -858,8 +841,8 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en) /*Open the list*/ if(ext->opened) { if(ext->fix_height == 0) { - new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + style->body.padding.top + - style->body.padding.bottom; + new_height = + lv_obj_get_height(lv_page_get_scrl(ddlist)) + style->body.padding.top + style->body.padding.bottom; } else { new_height = ext->fix_height; } @@ -892,7 +875,7 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en) a.var = ddlist; a.start = lv_obj_get_height(ddlist); a.end = new_height; - a.exec_cb = (lv_anim_exec_cb_t)lv_ddlist_adjust_height; + a.exec_cb = (lv_anim_exec_cb_t)lv_ddlist_adjust_height; a.path_cb = lv_anim_path_linear; a.ready_cb = lv_ddlist_anim_ready_cb; a.act_time = 0; @@ -925,7 +908,7 @@ static void lv_ddlist_anim_ready_cb(lv_anim_t * a) * Clean up after the open animation * @param ddlist */ -static void lv_ddlist_anim_finish(lv_obj_t* ddlist) +static void lv_ddlist_anim_finish(lv_obj_t * ddlist) { lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist); @@ -960,9 +943,9 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist) const lv_style_t * label_style = lv_obj_get_style(ext->label); lv_obj_t * scrl = lv_page_get_scrl(ddlist); - lv_coord_t h = lv_obj_get_height(ddlist); - lv_coord_t line_y1 = ext->sel_opt_id * (font_h + label_style->text.line_space) + - ext->label->coords.y1 - scrl->coords.y1; + lv_coord_t h = lv_obj_get_height(ddlist); + lv_coord_t line_y1 = + ext->sel_opt_id * (font_h + label_style->text.line_space) + ext->label->coords.y1 - scrl->coords.y1; lv_obj_set_y(scrl, -line_y1 + (h - font_h) / 2); lv_obj_invalidate(ddlist); @@ -972,7 +955,7 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist) * Be sure the width of the scrollable exactly fits the ddlist * @param ddlist pointer to a ddlist */ -static void lv_ddlist_refr_width(lv_obj_t* ddlist) +static void lv_ddlist_refr_width(lv_obj_t * ddlist) { /*Set the TIGHT fit horizontally the set the width to the content*/ lv_page_set_scrl_fit2(ddlist, LV_FIT_TIGHT, lv_page_get_scrl_fit_bottom(ddlist)); diff --git a/src/lv_objx/lv_ddlist.h b/src/lv_objx/lv_ddlist.h index 05ec32946..57e5a0c67 100644 --- a/src/lv_objx/lv_ddlist.h +++ b/src/lv_objx/lv_ddlist.h @@ -46,17 +46,17 @@ typedef struct { lv_page_ext_t page; /*Ext. of ancestor*/ /*New data for this type */ - lv_obj_t * label; /*Label for the options*/ - const lv_style_t * sel_style; /*Style of the selected option*/ - uint16_t option_cnt; /*Number of options*/ - uint16_t sel_opt_id; /*Index of the current option*/ - uint16_t sel_opt_id_ori; /*Store the original index on focus*/ - uint16_t anim_time; /*Open/Close animation time [ms]*/ - uint8_t opened : 1; /*1: The list is opened (handled by the library)*/ - uint8_t force_sel : 1; /*1: Keep the selection highlight even if the list is closed*/ - uint8_t draw_arrow : 1; /*1: Draw arrow*/ - uint8_t stay_open : 1; /*1: Don't close the list when a new item is selected*/ - lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/ + lv_obj_t * label; /*Label for the options*/ + const lv_style_t * sel_style; /*Style of the selected option*/ + uint16_t option_cnt; /*Number of options*/ + uint16_t sel_opt_id; /*Index of the current option*/ + uint16_t sel_opt_id_ori; /*Store the original index on focus*/ + uint16_t anim_time; /*Open/Close animation time [ms]*/ + uint8_t opened : 1; /*1: The list is opened (handled by the library)*/ + uint8_t force_sel : 1; /*1: Keep the selection highlight even if the list is closed*/ + uint8_t draw_arrow : 1; /*1: Draw arrow*/ + uint8_t stay_open : 1; /*1: Don't close the list when a new item is selected*/ + lv_coord_t fix_height; /*Height of the ddlist when opened. (0: auto-size)*/ } lv_ddlist_ext_t; enum { diff --git a/src/lv_objx/lv_gauge.c b/src/lv_objx/lv_gauge.c index 107390147..11bcf00d0 100644 --- a/src/lv_objx/lv_gauge.c +++ b/src/lv_objx/lv_gauge.c @@ -87,8 +87,7 @@ lv_obj_t * lv_gauge_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new gauge gauge*/ if(copy == NULL) { - lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, - LV_GAUGE_DEF_LABEL_COUNT); + lv_gauge_set_scale(new_gauge, LV_GAUGE_DEF_ANGLE, LV_GAUGE_DEF_LINE_COUNT, LV_GAUGE_DEF_LABEL_COUNT); lv_gauge_set_needle_count(new_gauge, 1, NULL); lv_gauge_set_critical_value(new_gauge, 80); lv_obj_set_size(new_gauge, 2 * LV_DPI, 2 * LV_DPI); @@ -350,15 +349,14 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask) lv_gauge_ext_t * ext = lv_obj_get_ext_attr(gauge); const lv_style_t * style = lv_obj_get_style(gauge); lv_opa_t opa_scale = lv_obj_get_opa_scale(gauge); - lv_coord_t r = - lv_obj_get_width(gauge) / 2 - (3 * style->body.padding.left) - style->body.padding.inner; - lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1; - lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1; - int16_t scale_angle = lv_lmeter_get_scale_angle(gauge); - uint16_t label_num = ext->label_count; - int16_t angle_ofs = 90 + (360 - scale_angle) / 2; - int16_t min = lv_gauge_get_min_value(gauge); - int16_t max = lv_gauge_get_max_value(gauge); + lv_coord_t r = lv_obj_get_width(gauge) / 2 - (3 * style->body.padding.left) - style->body.padding.inner; + lv_coord_t x_ofs = lv_obj_get_width(gauge) / 2 + gauge->coords.x1; + lv_coord_t y_ofs = lv_obj_get_height(gauge) / 2 + gauge->coords.y1; + int16_t scale_angle = lv_lmeter_get_scale_angle(gauge); + uint16_t label_num = ext->label_count; + int16_t angle_ofs = 90 + (360 - scale_angle) / 2; + int16_t min = lv_gauge_get_min_value(gauge); + int16_t max = lv_gauge_get_max_value(gauge); uint8_t i; for(i = 0; i < label_num; i++) { @@ -377,8 +375,8 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask) lv_area_t label_cord; lv_point_t label_size; - lv_txt_get_size(&label_size, scale_txt, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); + lv_txt_get_size(&label_size, scale_txt, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, LV_TXT_FLAG_NONE); /*Draw the label*/ label_cord.x1 = x - label_size.x / 2; @@ -386,8 +384,7 @@ static void lv_gauge_draw_scale(lv_obj_t * gauge, const lv_area_t * mask) label_cord.x2 = label_cord.x1 + label_size.x; label_cord.y2 = label_cord.y1 + label_size.y; - lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1, - -1); + lv_draw_label(&label_cord, mask, style, opa_scale, scale_txt, LV_TXT_FLAG_NONE, NULL, -1, -1); } } /** @@ -421,8 +418,8 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask) p_mid.y = y_ofs; for(i = 0; i < ext->needle_count; i++) { /*Calculate the end point of a needle*/ - int16_t needle_angle = (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) / - (max - min); //+ angle_ofs; + int16_t needle_angle = + (ext->values[i] - min) * angle * (1 << LV_GAUGE_INTERPOLATE_SHIFT) / (max - min); //+ angle_ofs; int16_t needle_angle_low = (needle_angle >> LV_GAUGE_INTERPOLATE_SHIFT) + angle_ofs; int16_t needle_angle_high = needle_angle_low + 1; @@ -433,11 +430,9 @@ static void lv_gauge_draw_needle(lv_obj_t * gauge, const lv_area_t * mask) p_end_high.y = (lv_trigo_sin(needle_angle_high) * r) / LV_TRIGO_SIN_MAX + y_ofs; p_end_high.x = (lv_trigo_sin(needle_angle_high + 90) * r) / LV_TRIGO_SIN_MAX + x_ofs; - uint16_t rem = needle_angle & ((1 << LV_GAUGE_INTERPOLATE_SHIFT) - 1); - int16_t x_mod = - ((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT; - int16_t y_mod = - ((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT; + uint16_t rem = needle_angle & ((1 << LV_GAUGE_INTERPOLATE_SHIFT) - 1); + int16_t x_mod = ((LV_MATH_ABS(p_end_high.x - p_end_low.x)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT; + int16_t y_mod = ((LV_MATH_ABS(p_end_high.y - p_end_low.y)) * rem) >> LV_GAUGE_INTERPOLATE_SHIFT; if(p_end_high.x < p_end_low.x) x_mod = -x_mod; if(p_end_high.y < p_end_low.y) y_mod = -y_mod; diff --git a/src/lv_objx/lv_img.c b/src/lv_objx/lv_img.c index f9eca884d..92b4a5cc5 100644 --- a/src/lv_objx/lv_img.c +++ b/src/lv_objx/lv_img.c @@ -127,12 +127,8 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) #if LV_USE_LOG && LV_LOG_LEVEL >= LV_LOG_LEVEL_INFO switch(src_type) { case LV_IMG_SRC_FILE: LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_FILE` type found"); break; - case LV_IMG_SRC_VARIABLE: - LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found"); - break; - case LV_IMG_SRC_SYMBOL: - LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_SYMBOL` type found"); - break; + case LV_IMG_SRC_VARIABLE: LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_VARIABLE` type found"); break; + case LV_IMG_SRC_SYMBOL: LV_LOG_TRACE("lv_img_set_src: `LV_IMG_SRC_SYMBOL` type found"); break; default: LV_LOG_WARN("lv_img_set_src: unknown type"); } #endif @@ -179,8 +175,8 @@ void lv_img_set_src(lv_obj_t * img, const void * src_img) /*`lv_img_dsc_get_info` couldn't set the with and height of a font so set it here*/ const lv_style_t * style = lv_img_get_style(img); lv_point_t size; - lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, LV_TXT_FLAG_NONE); + lv_txt_get_size(&size, src_img, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, LV_TXT_FLAG_NONE); header.w = size.x; header.h = size.y; } @@ -344,14 +340,13 @@ lv_coord_t lv_img_get_offset_y(lv_obj_t * img) static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode_t mode) { const lv_style_t * style = lv_obj_get_style(img); - lv_img_ext_t * ext = lv_obj_get_ext_attr(img); + lv_img_ext_t * ext = lv_obj_get_ext_attr(img); if(mode == LV_DESIGN_COVER_CHK) { bool cover = false; if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return false; - if(ext->cf == LV_IMG_CF_TRUE_COLOR || ext->cf == LV_IMG_CF_RAW) - cover = lv_area_is_in(mask, &img->coords); + if(ext->cf == LV_IMG_CF_TRUE_COLOR || ext->cf == LV_IMG_CF_RAW) cover = lv_area_is_in(mask, &img->coords); return cover; } else if(mode == LV_DESIGN_DRAW_MAIN) { @@ -382,8 +377,7 @@ static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode lv_style_t style_mod; lv_style_copy(&style_mod, style); style_mod.text.color = style->image.color; - lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, - -1, -1); + lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, -1, -1); } else { /*Trigger the error handler of image drawer*/ LV_LOG_WARN("lv_img_design: image source type is unknown"); diff --git a/src/lv_objx/lv_imgbtn.c b/src/lv_objx/lv_imgbtn.c index 952644087..b2e5cf6d8 100644 --- a/src/lv_objx/lv_imgbtn.c +++ b/src/lv_objx/lv_imgbtn.c @@ -131,8 +131,8 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src * @param src_right pointer to an image source for the right side of the button (a C array or path * to a file) */ -void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, - const void * src_mid, const void * src_right) +void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, + const void * src_right) { lv_imgbtn_ext_t * ext = lv_obj_get_ext_attr(imgbtn); diff --git a/src/lv_objx/lv_imgbtn.h b/src/lv_objx/lv_imgbtn.h index ff9d92c6b..850866335 100644 --- a/src/lv_objx/lv_imgbtn.h +++ b/src/lv_objx/lv_imgbtn.h @@ -103,8 +103,8 @@ void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src * @param src_right pointer to an image source for the right side of the button (a C array or path * to a file) */ -void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, - const void * src_mid, const void * src_right); +void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_btn_state_t state, const void * src_left, const void * src_mid, + const void * src_right); #endif diff --git a/src/lv_objx/lv_kb.c b/src/lv_objx/lv_kb.c index c1135fb2d..5c05c68a2 100644 --- a/src/lv_objx/lv_kb.c +++ b/src/lv_objx/lv_kb.c @@ -244,9 +244,7 @@ void lv_kb_set_style(lv_obj_t * kb, lv_kb_style_t type, const lv_style_t * style case LV_KB_STYLE_BG: lv_btnm_set_style(kb, LV_BTNM_STYLE_BG, style); break; case LV_KB_STYLE_BTN_REL: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_REL, style); break; case LV_KB_STYLE_BTN_PR: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_PR, style); break; - case LV_KB_STYLE_BTN_TGL_REL: - lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_REL, style); - break; + case LV_KB_STYLE_BTN_TGL_REL: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_REL, style); break; case LV_KB_STYLE_BTN_TGL_PR: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_TGL_PR, style); break; case LV_KB_STYLE_BTN_INA: lv_btnm_set_style(kb, LV_BTNM_STYLE_BTN_INA, style); break; } @@ -303,9 +301,7 @@ const lv_style_t * lv_kb_get_style(const lv_obj_t * kb, lv_kb_style_t type) case LV_KB_STYLE_BG: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BG); break; case LV_KB_STYLE_BTN_REL: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_REL); break; case LV_KB_STYLE_BTN_PR: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_PR); break; - case LV_KB_STYLE_BTN_TGL_REL: - style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL); - break; + case LV_KB_STYLE_BTN_TGL_REL: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_REL); break; case LV_KB_STYLE_BTN_TGL_PR: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_TGL_PR); break; case LV_KB_STYLE_BTN_INA: style = lv_btnm_get_style(kb, LV_BTNM_STYLE_BTN_INA); break; default: style = NULL; break; @@ -333,9 +329,7 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event) uint16_t btn_id = lv_btnm_get_active_btn(kb); if(btn_id == LV_BTNM_BTN_NONE) return; if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_HIDDEN | LV_BTNM_CTRL_INACTIVE)) return; - if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && - event == LV_EVENT_LONG_PRESSED_REPEAT) - return; + if(lv_btnm_get_btn_ctrl(kb, btn_id, LV_BTNM_CTRL_NO_REPEAT) && event == LV_EVENT_LONG_PRESSED_REPEAT) return; const char * txt = lv_btnm_get_active_btn_text(kb); if(txt == NULL) return; @@ -367,8 +361,7 @@ void lv_kb_def_event_cb(lv_obj_t * kb, lv_event_t event) if(kb->event_cb != lv_kb_def_event_cb) { lv_res_t res = lv_event_send(kb, LV_EVENT_APPLY, NULL); if(res != LV_RES_OK) return; - } - else { + } else { lv_kb_set_ta(kb, NULL); /*De-assign the text area to hide it cursor if needed*/ } return; diff --git a/src/lv_objx/lv_kb.h b/src/lv_objx/lv_kb.h index 0f34b93c0..8ea7c99a0 100644 --- a/src/lv_objx/lv_kb.h +++ b/src/lv_objx/lv_kb.h @@ -52,10 +52,9 @@ typedef struct { lv_btnm_ext_t btnm; /*Ext. of ancestor*/ /*New data for this type */ - lv_obj_t * ta; /*Pointer to the assigned text area*/ - lv_kb_mode_t mode; /*Key map type*/ - uint8_t - cursor_mng : 1; /*1: automatically show/hide cursor when a text area is assigned or left*/ + lv_obj_t * ta; /*Pointer to the assigned text area*/ + lv_kb_mode_t mode; /*Key map type*/ + uint8_t cursor_mng : 1; /*1: automatically show/hide cursor when a text area is assigned or left*/ } lv_kb_ext_t; enum { diff --git a/src/lv_objx/lv_label.c b/src/lv_objx/lv_label.c index 8d7c7461f..5ffaea4c2 100644 --- a/src/lv_objx/lv_label.c +++ b/src/lv_objx/lv_label.c @@ -42,9 +42,9 @@ static void lv_label_set_offset_x(lv_obj_t * label, lv_coord_t x); static void lv_label_set_offset_y(lv_obj_t * label, lv_coord_t y); #endif -static bool lv_label_set_dot_tmp(lv_obj_t *label, char *data, uint16_t len); -static char * lv_label_get_dot_tmp(lv_obj_t *label); -static void lv_label_dot_tmp_free(lv_obj_t *label); +static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len); +static char * lv_label_get_dot_tmp(lv_obj_t * label); +static void lv_label_dot_tmp_free(lv_obj_t * label); /********************** * STATIC VARIABLES @@ -83,23 +83,23 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->text = NULL; - ext->static_txt = 0; - ext->recolor = 0; - ext->body_draw = 0; - ext->align = LV_LABEL_ALIGN_LEFT; - ext->dot_end = LV_LABEL_DOT_END_INV; - ext->long_mode = LV_LABEL_LONG_EXPAND; + ext->text = NULL; + ext->static_txt = 0; + ext->recolor = 0; + ext->body_draw = 0; + ext->align = LV_LABEL_ALIGN_LEFT; + ext->dot_end = LV_LABEL_DOT_END_INV; + ext->long_mode = LV_LABEL_LONG_EXPAND; #if LV_USE_ANIMATION - ext->anim_speed = LV_LABEL_DEF_SCROLL_SPEED; + ext->anim_speed = LV_LABEL_DEF_SCROLL_SPEED; #endif - ext->offset.x = 0; - ext->offset.y = 0; + ext->offset.x = 0; + ext->offset.y = 0; #if LV_LABEL_TEXT_SEL ext->txt_sel_start = LV_LABEL_TEXT_SEL_OFF; ext->txt_sel_end = LV_LABEL_TEXT_SEL_OFF; #endif - ext->dot.tmp_ptr = NULL; + ext->dot.tmp_ptr = NULL; ext->dot_tmp_alloc = 0; lv_obj_set_design_cb(new_label, lv_label_design); @@ -132,15 +132,14 @@ lv_obj_t * lv_label_create(lv_obj_t * par, const lv_obj_t * copy) memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text)); } - if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr ){ + if(copy_ext->dot_tmp_alloc && copy_ext->dot.tmp_ptr) { int len = strlen(copy_ext->dot.tmp_ptr); lv_label_set_dot_tmp(new_label, ext->dot.tmp_ptr, len); - } - else{ + } else { memcpy(ext->dot.tmp, copy_ext->dot.tmp, sizeof(ext->dot.tmp)); } ext->dot_tmp_alloc = copy_ext->dot_tmp_alloc; - ext->dot_end = copy_ext->dot_end; + ext->dot_end = copy_ext->dot_end; /*Refresh the style with new signal function*/ lv_obj_refresh_style(new_label); @@ -274,8 +273,7 @@ void lv_label_set_long_mode(lv_obj_t * label, lv_label_long_mode_t long_mode) ext->offset.x = 0; ext->offset.y = 0; - if(long_mode == LV_LABEL_LONG_ROLL || long_mode == LV_LABEL_LONG_ROLL_CIRC || - long_mode == LV_LABEL_LONG_CROP) + if(long_mode == LV_LABEL_LONG_ROLL || long_mode == LV_LABEL_LONG_ROLL_CIRC || long_mode == LV_LABEL_LONG_CROP) ext->expand = 1; else ext->expand = 0; @@ -357,19 +355,20 @@ void lv_label_set_anim_speed(lv_obj_t * label, uint16_t anim_speed) #endif } -void lv_label_set_text_sel_start( lv_obj_t * label, uint16_t index ) { +void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index) +{ #if LV_LABEL_TEXT_SEL lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - ext->txt_sel_start = index; + ext->txt_sel_start = index; lv_obj_invalidate(label); #endif } -void lv_label_set_text_sel_end( lv_obj_t * label, uint16_t index ) +void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index) { #if LV_LABEL_TEXT_SEL lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - ext->txt_sel_end = index; + ext->txt_sel_end = index; lv_obj_invalidate(label); #endif } @@ -482,8 +481,7 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t /*Search the line of the index letter */; while(txt[new_line_start] != '\0') { - new_line_start += - lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); + new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); if(index < new_line_start || txt[new_line_start] == '\0') break; /*The line of 'index' letter begins at 'line_start'*/ @@ -500,21 +498,18 @@ void lv_label_get_letter_pos(const lv_obj_t * label, uint16_t index, lv_point_t } /*Calculate the x coordinate*/ - lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start, font, - style->text.letter_space, flag); + lv_coord_t x = lv_txt_get_width(&txt[line_start], index - line_start, font, style->text.letter_space, flag); if(index != line_start) x += style->text.letter_space; if(ext->align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, - style->text.letter_space, flag); + line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } else if(ext->align == LV_LABEL_ALIGN_RIGHT) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, - style->text.letter_space, flag); + line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) - line_w; } @@ -553,8 +548,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) /*Search the line of the index letter */; while(txt[line_start] != '\0') { - new_line_start += - lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); + new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/ y += letter_height + style->text.line_space; @@ -566,15 +560,14 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) lv_coord_t x = 0; if(ext->align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, - style->text.letter_space, flag); + line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t i = line_start; - uint32_t i_current = i; + uint32_t i = line_start; + uint32_t i_current = i; uint32_t letter; uint32_t letter_next; @@ -612,7 +605,8 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) * @param label pointer to a label object. * @return selection start index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected. */ -uint16_t lv_label_get_text_sel_start( const lv_obj_t * label ) { +uint16_t lv_label_get_text_sel_start(const lv_obj_t * label) +{ #if LV_LABEL_TEXT_SEL lv_label_ext_t * ext = lv_obj_get_ext_attr(label); return ext->txt_sel_start; @@ -627,17 +621,17 @@ uint16_t lv_label_get_text_sel_start( const lv_obj_t * label ) { * @param label pointer to a label object. * @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected. */ -uint16_t lv_label_get_text_sel_end( const lv_obj_t * label ) { +uint16_t lv_label_get_text_sel_end(const lv_obj_t * label) +{ #if LV_LABEL_TEXT_SEL lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - return ext->txt_sel_end; + return ext->txt_sel_end; #else - (void) label; /*Unused*/ + (void)label; /*Unused*/ return LV_LABEL_TEXT_SEL_OFF; #endif } - /** * Check if a character is drawn under a point. * @param label Label object @@ -668,8 +662,7 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) /*Search the line of the index letter */; while(txt[line_start] != '\0') { - new_line_start += - lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); + new_line_start += lv_txt_get_next_line(&txt[line_start], font, style->text.letter_space, max_w, flag); if(pos->y <= y + letter_height) break; /*The line is found (stored in 'line_start')*/ y += letter_height + style->text.line_space; @@ -682,15 +675,14 @@ bool lv_label_is_char_under_pos(const lv_obj_t * label, lv_point_t * pos) lv_coord_t last_x = 0; if(ext->align == LV_LABEL_ALIGN_CENTER) { lv_coord_t line_w; - line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, - style->text.letter_space, flag); + line_w = lv_txt_get_width(&txt[line_start], new_line_start - line_start, font, style->text.letter_space, flag); x += lv_obj_get_width(label) / 2 - line_w / 2; } lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t i = line_start; - uint32_t i_current = i; + uint32_t i = line_start; + uint32_t i_current = i; uint32_t letter; uint32_t letter_next; @@ -807,7 +799,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ else if(mode == LV_DESIGN_DRAW_MAIN) { lv_area_t coords; const lv_style_t * style = lv_obj_get_style(label); - lv_opa_t opa_scale = lv_obj_get_opa_scale(label); + lv_opa_t opa_scale = lv_obj_get_opa_scale(label); lv_obj_get_coords(label, &coords); #if LV_USE_GROUP @@ -844,8 +836,8 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ if((ext->long_mode == LV_LABEL_LONG_ROLL || ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) && (ext->align == LV_LABEL_ALIGN_CENTER || ext->align == LV_LABEL_ALIGN_RIGHT)) { lv_point_t size; - lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, flag); + lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, flag); if(size.x > lv_obj_get_width(label)) { flag &= ~LV_TXT_FLAG_RIGHT; flag &= ~LV_TXT_FLAG_CENTER; @@ -853,12 +845,12 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ } lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ext->offset, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) { lv_point_t size; - lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, - style->text.line_space, LV_COORD_MAX, flag); + lv_txt_get_size(&size, ext->text, style->text.font, style->text.letter_space, style->text.line_space, + LV_COORD_MAX, flag); lv_point_t ofs; @@ -869,7 +861,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ ofs.y = ext->offset.y; lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); } /*Draw the text again below the original to make an circular effect */ @@ -877,7 +869,7 @@ static bool lv_label_design(lv_obj_t * label, const lv_area_t * mask, lv_design_ ofs.x = ext->offset.x; ofs.y = ext->offset.y + size.y + lv_font_get_line_height(style->text.font); lv_draw_label(&coords, mask, style, opa_scale, ext->text, flag, &ofs, - lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); + lv_label_get_text_sel_start(label), lv_label_get_text_sel_end(label)); } } } @@ -921,10 +913,10 @@ static lv_res_t lv_label_signal(lv_obj_t * label, lv_signal_t sign, void * param if(ext->body_draw) { const lv_style_t * style = lv_label_get_style(label); - label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.left); - label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.right); - label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.top); - label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.bottom); + label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.left); + label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.right); + label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.top); + label->ext_draw_pad = LV_MATH_MAX(label->ext_draw_pad, style->body.padding.bottom); } } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; @@ -962,8 +954,7 @@ static void lv_label_refr_text(lv_obj_t * label) lv_txt_flag_t flag = LV_TXT_FLAG_NONE; if(ext->recolor != 0) flag |= LV_TXT_FLAG_RECOLOR; if(ext->expand != 0) flag |= LV_TXT_FLAG_EXPAND; - lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, - flag); + lv_txt_get_size(&size, ext->text, font, style->text.letter_space, style->text.line_space, max_w, flag); /*Set the full size in expand mode*/ if(ext->long_mode == LV_LABEL_LONG_EXPAND) { @@ -977,18 +968,20 @@ static void lv_label_refr_text(lv_obj_t * label) anim.repeat = 1; anim.playback = 1; anim.start = 0; - anim.ready_cb = NULL; - anim.path_cb = lv_anim_path_linear; - anim.playback_pause = (((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) / - ext->anim_speed) * LV_LABEL_WAIT_CHAR_COUNT; + anim.ready_cb = NULL; + anim.path_cb = lv_anim_path_linear; + anim.playback_pause = + (((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) / + ext->anim_speed) * + LV_LABEL_WAIT_CHAR_COUNT; anim.repeat_pause = anim.playback_pause; - anim.act_time = -anim.playback_pause; + anim.act_time = -anim.playback_pause; bool hor_anim = false; if(size.x > lv_obj_get_width(label)) { - anim.end = lv_obj_get_width(label) - size.x; - anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_x; - anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); + anim.end = lv_obj_get_width(label) - size.x; + anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_x; + anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); lv_anim_create(&anim); hor_anim = true; } else { @@ -998,8 +991,8 @@ static void lv_label_refr_text(lv_obj_t * label) } if(size.y > lv_obj_get_height(label) && hor_anim == false) { - anim.end = lv_obj_get_height(label) - size.y - (lv_font_get_line_height(font)); - anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y; + anim.end = lv_obj_get_height(label) - size.y - (lv_font_get_line_height(font)); + anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y; anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); lv_anim_create(&anim); @@ -1014,22 +1007,23 @@ static void lv_label_refr_text(lv_obj_t * label) else if(ext->long_mode == LV_LABEL_LONG_ROLL_CIRC) { #if LV_USE_ANIMATION lv_anim_t anim; - anim.var = label; - anim.repeat = 1; - anim.playback = 0; - anim.start = 0; - anim.act_time = -(((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) / - ext->anim_speed) * LV_LABEL_WAIT_CHAR_COUNT; - anim.ready_cb = NULL; - anim.path_cb = lv_anim_path_linear; + anim.var = label; + anim.repeat = 1; + anim.playback = 0; + anim.start = 0; + anim.act_time = -(((lv_font_get_glyph_width(style->text.font, ' ', ' ') + style->text.letter_space) * 1000) / + ext->anim_speed) * + LV_LABEL_WAIT_CHAR_COUNT; + anim.ready_cb = NULL; + anim.path_cb = lv_anim_path_linear; anim.playback_pause = 0; anim.repeat_pause = 0; bool hor_anim = false; if(size.x > lv_obj_get_width(label)) { - anim.end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT; - anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_x; - anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); + anim.end = -size.x - lv_font_get_glyph_width(font, ' ', ' ') * LV_LABEL_WAIT_CHAR_COUNT; + anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_x; + anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); lv_anim_create(&anim); hor_anim = true; } else { @@ -1039,9 +1033,9 @@ static void lv_label_refr_text(lv_obj_t * label) } if(size.y > lv_obj_get_height(label) && hor_anim == false) { - anim.end = -size.y - (lv_font_get_line_height(font)); - anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y; - anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); + anim.end = -size.y - (lv_font_get_line_height(font)); + anim.exec_cb = (lv_anim_exec_cb_t)lv_label_set_offset_y; + anim.time = lv_anim_speed_to_time(ext->anim_speed, anim.start, anim.end); lv_anim_create(&anim); } else { /*Delete the offset animation if not required*/ @@ -1052,8 +1046,7 @@ static void lv_label_refr_text(lv_obj_t * label) } else if(ext->long_mode == LV_LABEL_LONG_DOT) { if(size.y <= lv_obj_get_height(label)) { /*No dots are required, the text is short enough*/ ext->dot_end = LV_LABEL_DOT_END_INV; - } else if(lv_txt_get_encoded_length(ext->text) <= - LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/ + } else if(lv_txt_get_encoded_length(ext->text) <= LV_LABEL_DOT_NUM) { /*Don't turn to dots all the characters*/ ext->dot_end = LV_LABEL_DOT_END_INV; } else { lv_point_t p; @@ -1061,9 +1054,9 @@ static void lv_label_refr_text(lv_obj_t * label) (lv_font_get_glyph_width(style->text.font, '.', '.') + style->text.letter_space) * LV_LABEL_DOT_NUM; /*Shrink with dots*/ p.y = lv_obj_get_height(label); - p.y -= p.y % (lv_font_get_line_height(style->text.font) + - style->text.line_space); /*Round down to the last line*/ - p.y -= style->text.line_space; /*Trim the last line space*/ + p.y -= p.y % + (lv_font_get_line_height(style->text.font) + style->text.line_space); /*Round down to the last line*/ + p.y -= style->text.line_space; /*Trim the last line space*/ uint32_t letter_id = lv_label_get_letter_on(label, &p); /*Save letters under the dots and replace them with dots*/ @@ -1076,12 +1069,12 @@ static void lv_label_refr_text(lv_obj_t * label) lv_txt_encoded_next(ext->text, &byte_id); } - if( lv_label_set_dot_tmp(label, &ext->text[byte_id_ori], len ) ){ + if(lv_label_set_dot_tmp(label, &ext->text[byte_id_ori], len)) { for(i = 0; i < LV_LABEL_DOT_NUM; i++) { ext->text[byte_id_ori + i] = '.'; } ext->text[byte_id_ori + LV_LABEL_DOT_NUM] = '\0'; - ext->dot_end = letter_id + LV_LABEL_DOT_NUM; + ext->dot_end = letter_id + LV_LABEL_DOT_NUM; } } } @@ -1106,8 +1099,8 @@ static void lv_label_revert_dots(lv_obj_t * label) uint32_t byte_i = lv_txt_encoded_get_byte_id(ext->text, letter_i); /*Restore the characters*/ - uint8_t i = 0; - char* dot_tmp = lv_label_get_dot_tmp(label); + uint8_t i = 0; + char * dot_tmp = lv_label_get_dot_tmp(label); while(ext->text[byte_i + i] != '\0') { ext->text[byte_i + i] = dot_tmp[i]; i++; @@ -1141,22 +1134,22 @@ static void lv_label_set_offset_y(lv_obj_t * label, lv_coord_t y) * @param len Number of characters to store. * @return true on success. */ -static bool lv_label_set_dot_tmp(lv_obj_t *label, char *data, uint16_t len){ +static bool lv_label_set_dot_tmp(lv_obj_t * label, char * data, uint16_t len) +{ lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - lv_label_dot_tmp_free( label ); /* Deallocate any existing space */ - if( len > sizeof(char *) ){ + lv_label_dot_tmp_free(label); /* Deallocate any existing space */ + if(len > sizeof(char *)) { /* Memory needs to be allocated. Allocates an additional byte * for a NULL-terminator so it can be copied. */ ext->dot.tmp_ptr = lv_mem_alloc(len + 1); - if( ext->dot.tmp_ptr == NULL ){ + if(ext->dot.tmp_ptr == NULL) { LV_LOG_ERROR("Failed to allocate memory for dot_tmp_ptr"); return false; } memcpy(ext->dot.tmp_ptr, data, len); - ext->dot.tmp_ptr[len]='\0'; - ext->dot_tmp_alloc = true; - } - else { + ext->dot.tmp_ptr[len] = '\0'; + ext->dot_tmp_alloc = true; + } else { /* Characters can be directly stored in object */ ext->dot_tmp_alloc = false; memcpy(ext->dot.tmp, data, len); @@ -1169,12 +1162,12 @@ static bool lv_label_set_dot_tmp(lv_obj_t *label, char *data, uint16_t len){ * @param label pointer to label object * @return char pointer to a stored characters. Is *not* necessarily NULL-terminated. */ -static char * lv_label_get_dot_tmp(lv_obj_t *label){ +static char * lv_label_get_dot_tmp(lv_obj_t * label) +{ lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - if( ext->dot_tmp_alloc ){ + if(ext->dot_tmp_alloc) { return ext->dot.tmp_ptr; - } - else{ + } else { return ext->dot.tmp; } } @@ -1184,13 +1177,14 @@ static char * lv_label_get_dot_tmp(lv_obj_t *label){ * Always clears the field * @param label pointer to label object. */ -static void lv_label_dot_tmp_free(lv_obj_t *label){ +static void lv_label_dot_tmp_free(lv_obj_t * label) +{ lv_label_ext_t * ext = lv_obj_get_ext_attr(label); - if( ext->dot_tmp_alloc && ext->dot.tmp_ptr ){ + if(ext->dot_tmp_alloc && ext->dot.tmp_ptr) { lv_mem_free(ext->dot.tmp_ptr); } ext->dot_tmp_alloc = false; - ext->dot.tmp_ptr = NULL; + ext->dot.tmp_ptr = NULL; } #endif diff --git a/src/lv_objx/lv_label.h b/src/lv_objx/lv_label.h index 33b5c3c83..5a445015d 100644 --- a/src/lv_objx/lv_label.h +++ b/src/lv_objx/lv_label.h @@ -29,8 +29,8 @@ extern "C" { /********************* * DEFINES *********************/ -#define LV_LABEL_DOT_NUM 3 -#define LV_LABEL_POS_LAST 0xFFFF +#define LV_LABEL_DOT_NUM 3 +#define LV_LABEL_POS_LAST 0xFFFF #define LV_LABEL_TEXT_SEL_OFF 0xFFFF /********************** @@ -62,30 +62,33 @@ typedef struct { /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ /*New data for this type */ - char * text; /*Text of the label*/ - union{ - char * tmp_ptr; /* Pointer to the allocated memory containing the character which are replaced by dots (Handled by the library)*/ - char tmp[ sizeof(char *) ]; /* Directly store the characters if <=4 characters */ + char * text; /*Text of the label*/ + union + { + char * tmp_ptr; /* Pointer to the allocated memory containing the character which are replaced by dots (Handled + by the library)*/ + char tmp[sizeof(char *)]; /* Directly store the characters if <=4 characters */ } dot; - uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/ - lv_point_t offset; /*Text draw position offset*/ + uint16_t dot_end; /*The text end position in dot mode (Handled by the library)*/ + lv_point_t offset; /*Text draw position offset*/ #if LV_USE_ANIMATION - uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/ + uint16_t anim_speed; /*Speed of scroll and roll animation in px/sec unit*/ #endif #if LV_LABEL_TEXT_SEL - uint16_t txt_sel_start; /*Left-most selection character*/ - uint16_t txt_sel_end; /*Right-most selection character*/ + uint16_t txt_sel_start; /*Left-most selection character*/ + uint16_t txt_sel_end; /*Right-most selection character*/ #endif lv_label_long_mode_t long_mode : 3; /*Determinate what to do with the long texts*/ - uint8_t static_txt : 1; /*Flag to indicate the text is static*/ - uint8_t align : 2; /*Align type from 'lv_label_align_t'*/ - uint8_t recolor : 1; /*Enable in-line letter re-coloring*/ - uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_ROLL)*/ - uint8_t body_draw : 1; /*Draw background body*/ - uint8_t dot_tmp_alloc : 1; /*True if dot_tmp has been allocated. False if dot_tmp directly holds up to 4 bytes of characters */ + uint8_t static_txt : 1; /*Flag to indicate the text is static*/ + uint8_t align : 2; /*Align type from 'lv_label_align_t'*/ + uint8_t recolor : 1; /*Enable in-line letter re-coloring*/ + uint8_t expand : 1; /*Ignore real width (used by the library with LV_LABEL_LONG_ROLL)*/ + uint8_t body_draw : 1; /*Draw background body*/ + uint8_t dot_tmp_alloc : 1; /*True if dot_tmp has been allocated. False if dot_tmp directly holds up to 4 bytes of + characters */ } lv_label_ext_t; /********************** @@ -180,14 +183,14 @@ static inline void lv_label_set_style(lv_obj_t * label, const lv_style_t * style * @param label pointer to a label object. * @param index index to set. `LV_LABEL_TXT_SEL_OFF` to select nothing. */ -void lv_label_set_text_sel_start( lv_obj_t * label, uint16_t index ); +void lv_label_set_text_sel_start(lv_obj_t * label, uint16_t index); /** * @brief Set the selection end index. * @param label pointer to a label object. * @param index index to set. `LV_LABEL_TXT_SEL_OFF` to select nothing. */ -void lv_label_set_text_sel_end( lv_obj_t * label, uint16_t index ); +void lv_label_set_text_sel_end(lv_obj_t * label, uint16_t index); /*===================== * Getter functions @@ -276,15 +279,14 @@ static inline const lv_style_t * lv_label_get_style(const lv_obj_t * label) * @param label pointer to a label object. * @return selection start index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected. */ -uint16_t lv_label_get_text_sel_start( const lv_obj_t * label ); +uint16_t lv_label_get_text_sel_start(const lv_obj_t * label); /** * @brief Get the selection end index. * @param label pointer to a label object. * @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected. */ -uint16_t lv_label_get_text_sel_end( const lv_obj_t * label ); - +uint16_t lv_label_get_text_sel_end(const lv_obj_t * label); /*===================== * Other functions diff --git a/src/lv_objx/lv_led.c b/src/lv_objx/lv_led.c index 4f95cc3bc..5cd15bca8 100644 --- a/src/lv_objx/lv_led.c +++ b/src/lv_objx/lv_led.c @@ -186,7 +186,7 @@ static bool lv_led_design(lv_obj_t * led, const lv_area_t * mask, lv_design_mode return ancestor_design_f(led, mask, mode); } else if(mode == LV_DESIGN_DRAW_MAIN) { /*Make darker colors in a temporary style according to the brightness*/ - lv_led_ext_t * ext = lv_obj_get_ext_attr(led); + lv_led_ext_t * ext = lv_obj_get_ext_attr(led); const lv_style_t * style = lv_obj_get_style(led); /* Store the real pointer because of 'lv_group' @@ -199,18 +199,15 @@ static bool lv_led_design(lv_obj_t * led, const lv_area_t * mask, lv_design_mode memcpy(&leds_tmp, style, sizeof(leds_tmp)); /*Mix. the color with black proportionally with brightness*/ - leds_tmp.body.main_color = - lv_color_mix(leds_tmp.body.main_color, LV_COLOR_BLACK, ext->bright); - leds_tmp.body.grad_color = - lv_color_mix(leds_tmp.body.grad_color, LV_COLOR_BLACK, ext->bright); - leds_tmp.body.border.color = - lv_color_mix(leds_tmp.body.border.color, LV_COLOR_BLACK, ext->bright); + leds_tmp.body.main_color = lv_color_mix(leds_tmp.body.main_color, LV_COLOR_BLACK, ext->bright); + leds_tmp.body.grad_color = lv_color_mix(leds_tmp.body.grad_color, LV_COLOR_BLACK, ext->bright); + leds_tmp.body.border.color = lv_color_mix(leds_tmp.body.border.color, LV_COLOR_BLACK, ext->bright); /*Set the current swidth according to brightness proportionally between LV_LED_BRIGHT_OFF * and LV_LED_BRIGHT_ON*/ - uint16_t bright_tmp = ext->bright; - leds_tmp.body.shadow.width = ((bright_tmp - LV_LED_BRIGHT_OFF) * style->body.shadow.width) / - (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF); + uint16_t bright_tmp = ext->bright; + leds_tmp.body.shadow.width = + ((bright_tmp - LV_LED_BRIGHT_OFF) * style->body.shadow.width) / (LV_LED_BRIGHT_ON - LV_LED_BRIGHT_OFF); led->style_p = &leds_tmp; ancestor_design_f(led, mask, mode); diff --git a/src/lv_objx/lv_line.c b/src/lv_objx/lv_line.c index 4bac6bc0d..abe6f5a96 100644 --- a/src/lv_objx/lv_line.c +++ b/src/lv_objx/lv_line.c @@ -73,9 +73,8 @@ lv_obj_t * lv_line_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new line*/ if(copy == NULL) { - lv_obj_set_size( - new_line, LV_DPI, - LV_DPI); /*Auto size is enables, but set default size until no points are added*/ + lv_obj_set_size(new_line, LV_DPI, + LV_DPI); /*Auto size is enables, but set default size until no points are added*/ lv_obj_set_style(new_line, NULL); /*Inherit parent's style*/ lv_obj_set_click(new_line, false); } @@ -215,7 +214,7 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo if(ext->point_num == 0 || ext->point_array == NULL) return false; const lv_style_t * style = lv_obj_get_style(line); - lv_opa_t opa_scale = lv_obj_get_opa_scale(line); + lv_opa_t opa_scale = lv_obj_get_opa_scale(line); lv_area_t area; lv_obj_get_coords(line, &area); lv_coord_t x_ofs = area.x1; @@ -250,10 +249,8 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo /*Draw circle on the joints if enabled*/ if(style->line.rounded) { - circle_area.x1 = - p1.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); - circle_area.y1 = - p1.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.x1 = p1.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.y1 = p1.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); circle_area.x2 = p1.x + ((style->line.width - 1) >> 1); circle_area.y2 = p1.y + ((style->line.width - 1) >> 1); lv_draw_rect(&circle_area, mask, &circle_style_tmp, opa_scale); @@ -262,10 +259,8 @@ static bool lv_line_design(lv_obj_t * line, const lv_area_t * mask, lv_design_mo /*Draw circle on the last point too if enabled*/ if(style->line.rounded) { - circle_area.x1 = - p2.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); - circle_area.y1 = - p2.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.x1 = p2.x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); + circle_area.y1 = p2.y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1); circle_area.x2 = p2.x + ((style->line.width - 1) >> 1); circle_area.y2 = p2.y + ((style->line.width - 1) >> 1); lv_draw_rect(&circle_area, mask, &circle_style_tmp, opa_scale); diff --git a/src/lv_objx/lv_line.h b/src/lv_objx/lv_line.h index 3621731a5..9c89d96bc 100644 --- a/src/lv_objx/lv_line.h +++ b/src/lv_objx/lv_line.h @@ -35,10 +35,10 @@ extern "C" { typedef struct { /*Inherited from 'base_obj' so no inherited ext.*/ /*Ext. of ancestor*/ - const lv_point_t * point_array; /*Pointer to an array with the points of the line*/ - uint16_t point_num; /*Number of points in 'point_array' */ - uint8_t auto_size : 1; /*1: set obj. width to x max and obj. height to y max */ - uint8_t y_inv : 1; /*1: y == 0 will be on the bottom*/ + const lv_point_t * point_array; /*Pointer to an array with the points of the line*/ + uint16_t point_num; /*Number of points in 'point_array' */ + uint8_t auto_size : 1; /*1: set obj. width to x max and obj. height to y max */ + uint8_t y_inv : 1; /*1: y == 0 will be on the bottom*/ } lv_line_ext_t; /********************** @@ -82,8 +82,8 @@ void lv_line_set_auto_size(lv_obj_t * line, bool en); */ void lv_line_set_y_invert(lv_obj_t * line, bool en); -#define lv_line_set_y_inv \ - lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \ +#define lv_line_set_y_inv \ + lv_line_set_y_invert /*The name was inconsistent. In v.6.0 only `lv_line_set_y_invert`will \ work */ /** diff --git a/src/lv_objx/lv_list.c b/src/lv_objx/lv_list.c index 46a948975..30516df05 100644 --- a/src/lv_objx/lv_list.c +++ b/src/lv_objx/lv_list.c @@ -95,10 +95,10 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) ext->styles_btn[LV_BTN_STATE_TGL_PR] = &lv_style_btn_tgl_pr; ext->styles_btn[LV_BTN_STATE_INA] = &lv_style_btn_ina; #if LV_USE_ANIMATION - ext->anim_time = LV_LIST_DEF_ANIM_TIME; + ext->anim_time = LV_LIST_DEF_ANIM_TIME; #endif - ext->single_mode = false; - ext->size = 0; + ext->single_mode = false; + ext->size = 0; #if LV_USE_GROUP ext->last_sel = NULL; @@ -145,10 +145,8 @@ lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy) lv_list_set_style(new_list, LV_LIST_STYLE_BTN_REL, copy_ext->styles_btn[LV_BTN_STATE_REL]); lv_list_set_style(new_list, LV_LIST_STYLE_BTN_PR, copy_ext->styles_btn[LV_BTN_STATE_PR]); - lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, - copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]); - lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, - copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_REL, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]); + lv_list_set_style(new_list, LV_LIST_STYLE_BTN_TGL_PR, copy_ext->styles_btn[LV_BTN_STATE_TGL_REL]); lv_list_set_style(new_list, LV_LIST_STYLE_BTN_INA, copy_ext->styles_btn[LV_BTN_STATE_INA]); /*Refresh the style with new signal function*/ @@ -184,8 +182,7 @@ void lv_list_clean(lv_obj_t * obj) * @param event_cb specify the an event handler function. NULL if unused * @return pointer to the new list element which can be customized (a button) */ -lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, - lv_event_cb_t event_cb) +lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb) { lv_list_ext_t * ext = lv_obj_get_ext_attr(list); ext->size++; @@ -320,7 +317,7 @@ void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn) else if(s == LV_BTN_STATE_TGL_REL) lv_btn_set_state(ext->selected_btn, LV_BTN_STATE_TGL_PR); - lv_page_focus(list, ext->selected_btn, lv_list_get_anim_time(list) ); + lv_page_focus(list, ext->selected_btn, lv_list_get_anim_time(list)); } } @@ -335,7 +332,7 @@ void lv_list_set_anim_time(lv_obj_t * list, uint16_t anim_time) { #if LV_USE_ANIMATION lv_list_ext_t * ext = lv_obj_get_ext_attr(list); - anim_time = 0; + anim_time = 0; if(ext->anim_time == anim_time) return; ext->anim_time = anim_time; @@ -361,9 +358,7 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * break; case LV_LIST_STYLE_SCRL: lv_page_set_style(list, LV_PAGE_STYLE_SCRL, style); break; case LV_LIST_STYLE_SB: lv_page_set_style(list, LV_PAGE_STYLE_SB, style); break; - case LV_LIST_STYLE_EDGE_FLASH: - lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style); - break; + case LV_LIST_STYLE_EDGE_FLASH: lv_page_set_style(list, LV_PAGE_STYLE_EDGE_FLASH, style); break; case LV_LIST_STYLE_BTN_REL: ext->styles_btn[LV_BTN_STATE_REL] = style; btn_style_refr = LV_BTN_STYLE_REL; @@ -387,9 +382,8 @@ void lv_list_set_style(lv_obj_t * list, lv_list_style_t type, const lv_style_t * } /*Refresh existing buttons' style*/ - if(type == LV_LIST_STYLE_BTN_PR || type == LV_LIST_STYLE_BTN_REL || - type == LV_LIST_STYLE_BTN_TGL_REL || type == LV_LIST_STYLE_BTN_TGL_PR || - type == LV_LIST_STYLE_BTN_INA) { + if(type == LV_LIST_STYLE_BTN_PR || type == LV_LIST_STYLE_BTN_REL || type == LV_LIST_STYLE_BTN_TGL_REL || + type == LV_LIST_STYLE_BTN_TGL_PR || type == LV_LIST_STYLE_BTN_INA) { btn = lv_list_get_prev_btn(list, NULL); while(btn != NULL) { lv_btn_set_style(btn, btn_style_refr, ext->styles_btn[btn_style_refr]); @@ -587,16 +581,14 @@ uint16_t lv_list_get_anim_time(const lv_obj_t * list) * */ const lv_style_t * lv_list_get_style(const lv_obj_t * list, lv_list_style_t type) { - const lv_style_t * style = NULL; - lv_list_ext_t * ext = lv_obj_get_ext_attr(list); + const lv_style_t * style = NULL; + lv_list_ext_t * ext = lv_obj_get_ext_attr(list); switch(type) { case LV_LIST_STYLE_BG: style = lv_page_get_style(list, LV_PAGE_STYLE_BG); break; case LV_LIST_STYLE_SCRL: style = lv_page_get_style(list, LV_PAGE_STYLE_SCRL); break; case LV_LIST_STYLE_SB: style = lv_page_get_style(list, LV_PAGE_STYLE_SB); break; - case LV_LIST_STYLE_EDGE_FLASH: - style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH); - break; + case LV_LIST_STYLE_EDGE_FLASH: style = lv_page_get_style(list, LV_PAGE_STYLE_EDGE_FLASH); break; case LV_LIST_STYLE_BTN_REL: style = ext->styles_btn[LV_BTN_STATE_REL]; break; case LV_LIST_STYLE_BTN_PR: style = ext->styles_btn[LV_BTN_STATE_PR]; break; case LV_LIST_STYLE_BTN_TGL_REL: style = ext->styles_btn[LV_BTN_STATE_TGL_REL]; break; @@ -626,8 +618,7 @@ void lv_list_up(const lv_obj_t * list) while(e != NULL) { if(e->coords.y2 <= list->coords.y2) { if(e_prev != NULL) { - lv_coord_t new_y = - lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev)); + lv_coord_t new_y = lv_obj_get_height(list) - (lv_obj_get_y(e_prev) + lv_obj_get_height(e_prev)); if(lv_list_get_anim_time(list) == 0) { lv_obj_set_y(scrl, new_y); } else { @@ -669,7 +660,7 @@ void lv_list_down(const lv_obj_t * list) e = lv_list_get_prev_btn(list, NULL); while(e != NULL) { if(e->coords.y1 < list->coords.y1) { - lv_coord_t new_y = -lv_obj_get_y(e); + lv_coord_t new_y = -lv_obj_get_y(e); if(lv_list_get_anim_time(list) == 0) { lv_obj_set_y(scrl, new_y); } else { @@ -837,9 +828,8 @@ static lv_res_t lv_list_signal(lv_obj_t * list, lv_signal_t sign, void * param) else { lv_obj_t * btn = lv_list_get_next_btn(list, NULL); if(btn) - lv_list_set_btn_selected( - list, - btn); /*If there are no buttons on the list then there is no first button*/ + lv_list_set_btn_selected(list, + btn); /*If there are no buttons on the list then there is no first button*/ } } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) { lv_list_ext_t * ext = lv_obj_get_ext_attr(list); @@ -960,8 +950,7 @@ static bool lv_list_is_list_btn(lv_obj_t * list_btn) uint8_t cnt; for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) { if(type.type[cnt] == NULL) break; - if(!strcmp(type.type[cnt], "lv_btn")) - return true; + if(!strcmp(type.type[cnt], "lv_btn")) return true; } return false; } @@ -978,8 +967,7 @@ static bool lv_list_is_list_label(lv_obj_t * list_label) uint8_t cnt; for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) { if(type.type[cnt] == NULL) break; - if(!strcmp(type.type[cnt], "lv_label")) - return true; + if(!strcmp(type.type[cnt], "lv_label")) return true; } return false; } @@ -996,8 +984,7 @@ static bool lv_list_is_list_img(lv_obj_t * list_img) uint8_t cnt; for(cnt = 0; cnt < LV_MAX_ANCESTOR_NUM; cnt++) { if(type.type[cnt] == NULL) break; - if(!strcmp(type.type[cnt], "lv_img")) - return true; + if(!strcmp(type.type[cnt], "lv_img")) return true; } return false; } diff --git a/src/lv_objx/lv_list.h b/src/lv_objx/lv_list.h index 31797ddc1..811f2745e 100644 --- a/src/lv_objx/lv_list.h +++ b/src/lv_objx/lv_list.h @@ -56,13 +56,13 @@ typedef struct const lv_style_t * style_img; /*Style of the list element images on buttons*/ uint16_t size; /*the number of items(buttons) in the list*/ #if LV_USE_ANIMATION - uint16_t anim_time; /*Scroll animation time*/ + uint16_t anim_time; /*Scroll animation time*/ #endif - uint8_t single_mode:1; /* whether single selected mode is enabled */ + uint8_t single_mode : 1; /* whether single selected mode is enabled */ #if LV_USE_GROUP - lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */ + lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */ lv_obj_t * selected_btn; /* The button is currently being selected*/ #endif } lv_list_ext_t; @@ -110,8 +110,7 @@ void lv_list_clean(lv_obj_t * obj); * @param event_cb specify the an event handler function. NULL if unused * @return pointer to the new list element which can be customized (a button) */ -lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, - lv_event_cb_t event_cb); +lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_event_cb_t event_cb); /** * Remove the index of the button in the list diff --git a/src/lv_objx/lv_lmeter.c b/src/lv_objx/lv_lmeter.c index 563d139c9..d414c5cce 100644 --- a/src/lv_objx/lv_lmeter.c +++ b/src/lv_objx/lv_lmeter.c @@ -249,9 +249,9 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig } /*Draw the object*/ else if(mode == LV_DESIGN_DRAW_MAIN) { - lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); - const lv_style_t * style = lv_obj_get_style(lmeter); - lv_opa_t opa_scale = lv_obj_get_opa_scale(lmeter); + lv_lmeter_ext_t * ext = lv_obj_get_ext_attr(lmeter); + const lv_style_t * style = lv_obj_get_style(lmeter); + lv_opa_t opa_scale = lv_obj_get_opa_scale(lmeter); lv_style_t style_tmp; lv_style_copy(&style_tmp, style); @@ -269,8 +269,8 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig lv_coord_t x_ofs = lv_obj_get_width(lmeter) / 2 + lmeter->coords.x1; lv_coord_t y_ofs = lv_obj_get_height(lmeter) / 2 + lmeter->coords.y1; int16_t angle_ofs = 90 + (360 - ext->scale_angle) / 2; - int16_t level = (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / - (ext->max_value - ext->min_value); + int16_t level = + (int32_t)((int32_t)(ext->cur_value - ext->min_value) * ext->line_cnt) / (ext->max_value - ext->min_value); uint8_t i; style_tmp.line.color = style->body.main_color; @@ -284,10 +284,9 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig int16_t angle = (i * ext->scale_angle) / (ext->line_cnt - 1) + angle_ofs; lv_coord_t y_out = (int32_t)((int32_t)lv_trigo_sin(angle) * r_out) >> LV_TRIGO_SHIFT; - lv_coord_t x_out = - (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) >> LV_TRIGO_SHIFT; - lv_coord_t y_in = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) >> LV_TRIGO_SHIFT; - lv_coord_t x_in = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) >> LV_TRIGO_SHIFT; + lv_coord_t x_out = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_out) >> LV_TRIGO_SHIFT; + lv_coord_t y_in = (int32_t)((int32_t)lv_trigo_sin(angle) * r_in) >> LV_TRIGO_SHIFT; + lv_coord_t x_in = (int32_t)((int32_t)lv_trigo_sin(angle + 90) * r_in) >> LV_TRIGO_SHIFT; /*Rounding*/ x_out = lv_lmeter_coord_round(x_out); @@ -307,8 +306,8 @@ static bool lv_lmeter_design(lv_obj_t * lmeter, const lv_area_t * mask, lv_desig if(i >= level) style_tmp.line.color = style->line.color; else { - style_tmp.line.color = lv_color_mix(style->body.grad_color, style->body.main_color, - (255 * i) / ext->line_cnt); + style_tmp.line.color = + lv_color_mix(style->body.grad_color, style->body.main_color, (255 * i) / ext->line_cnt); } lv_draw_line(&p1, &p2, mask, &style_tmp, opa_scale); @@ -343,7 +342,7 @@ static lv_res_t lv_lmeter_signal(lv_obj_t * lmeter, lv_signal_t sign, void * par lv_obj_refresh_ext_draw_pad(lmeter); } else if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { const lv_style_t * style = lv_lmeter_get_style(lmeter); - lmeter->ext_draw_pad = LV_MATH_MAX(lmeter->ext_draw_pad, style->line.width); + lmeter->ext_draw_pad = LV_MATH_MAX(lmeter->ext_draw_pad, style->line.width); } else if(sign == LV_SIGNAL_GET_TYPE) { lv_obj_type_t * buf = param; uint8_t i; @@ -370,8 +369,7 @@ static lv_coord_t lv_lmeter_coord_round(int32_t x) x = -x; } - x = (x >> LV_LMETER_LINE_UPSCALE) + - ((x & LV_LMETER_LINE_UPSCALE_MASK) >> (LV_LMETER_LINE_UPSCALE - 1)); + x = (x >> LV_LMETER_LINE_UPSCALE) + ((x & LV_LMETER_LINE_UPSCALE_MASK) >> (LV_LMETER_LINE_UPSCALE - 1)); if(was_negative) x = -x; diff --git a/src/lv_objx/lv_mbox.c b/src/lv_objx/lv_mbox.c index e8ce978bf..c59dfc44e 100644 --- a/src/lv_objx/lv_mbox.c +++ b/src/lv_objx/lv_mbox.c @@ -77,8 +77,8 @@ lv_obj_t * lv_mbox_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->text = NULL; - ext->btnm = NULL; + ext->text = NULL; + ext->btnm = NULL; #if LV_USE_ANIMATION ext->anim_time = LV_MBOX_CLOSE_ANIM_TIME; #endif @@ -188,11 +188,11 @@ void lv_mbox_set_anim_time(lv_obj_t * mbox, uint16_t anim_time) { #if LV_USE_ANIMATION lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); - anim_time = 0; - ext->anim_time = anim_time; + anim_time = 0; + ext->anim_time = anim_time; #else - (void) mbox; - (void) anim_time; + (void)mbox; + (void)anim_time; #endif } @@ -207,22 +207,22 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay) if(lv_mbox_get_anim_time(mbox) != 0) { /*Add shrinking animations*/ lv_anim_t a; - a.var = mbox; - a.start = lv_obj_get_height(mbox); - a.end = 0; - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_height; - a.path_cb = lv_anim_path_linear; - a.ready_cb = NULL; - a.act_time = -delay; - a.time = lv_mbox_get_anim_time(mbox); - a.playback = 0; + a.var = mbox; + a.start = lv_obj_get_height(mbox); + a.end = 0; + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_height; + a.path_cb = lv_anim_path_linear; + a.ready_cb = NULL; + a.act_time = -delay; + a.time = lv_mbox_get_anim_time(mbox); + a.playback = 0; a.playback_pause = 0; - a.repeat = 0; - a.repeat_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; lv_anim_create(&a); - a.start = lv_obj_get_width(mbox); - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_width; + a.start = lv_obj_get_width(mbox); + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_width; a.ready_cb = lv_mbox_close_ready_cb; lv_anim_create(&a); @@ -231,18 +231,18 @@ void lv_mbox_start_auto_close(lv_obj_t * mbox, uint16_t delay) } else { /*Create an animation to delete the mbox `delay` ms later*/ lv_anim_t a; - a.var = mbox; - a.start = 0; - a.end = 1; - a.exec_cb = (lv_anim_exec_cb_t)NULL; - a.path_cb = lv_anim_path_linear; - a.ready_cb = lv_mbox_close_ready_cb; - a.act_time = -delay; - a.time = 0; - a.playback = 0; + a.var = mbox; + a.start = 0; + a.end = 1; + a.exec_cb = (lv_anim_exec_cb_t)NULL; + a.path_cb = lv_anim_path_linear; + a.ready_cb = lv_mbox_close_ready_cb; + a.act_time = -delay; + a.time = 0; + a.playback = 0; a.playback_pause = 0; - a.repeat = 0; - a.repeat_pause = 0; + a.repeat = 0; + a.repeat_pause = 0; lv_anim_create(&a); } #else @@ -277,19 +277,11 @@ void lv_mbox_set_style(lv_obj_t * mbox, lv_mbox_style_t type, const lv_style_t * switch(type) { case LV_MBOX_STYLE_BG: lv_obj_set_style(mbox, style); break; case LV_MBOX_STYLE_BTN_BG: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BG, style); break; - case LV_MBOX_STYLE_BTN_REL: - lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_REL, style); - break; + case LV_MBOX_STYLE_BTN_REL: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_REL, style); break; case LV_MBOX_STYLE_BTN_PR: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_PR, style); break; - case LV_MBOX_STYLE_BTN_TGL_REL: - lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL, style); - break; - case LV_MBOX_STYLE_BTN_TGL_PR: - lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR, style); - break; - case LV_MBOX_STYLE_BTN_INA: - lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_INA, style); - break; + case LV_MBOX_STYLE_BTN_TGL_REL: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL, style); break; + case LV_MBOX_STYLE_BTN_TGL_PR: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR, style); break; + case LV_MBOX_STYLE_BTN_INA: lv_btnm_set_style(ext->btnm, LV_BTNM_STYLE_BTN_INA, style); break; } mbox_realign(mbox); @@ -364,7 +356,7 @@ uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox) lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); return ext->anim_time; #else - (void) mbox; + (void)mbox; return 0; #endif } @@ -377,27 +369,17 @@ uint16_t lv_mbox_get_anim_time(const lv_obj_t * mbox) */ const lv_style_t * lv_mbox_get_style(const lv_obj_t * mbox, lv_mbox_style_t type) { - const lv_style_t * style = NULL; - lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); + const lv_style_t * style = NULL; + lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); switch(type) { case LV_MBOX_STYLE_BG: style = lv_obj_get_style(mbox); break; case LV_MBOX_STYLE_BTN_BG: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BG); break; - case LV_MBOX_STYLE_BTN_REL: - style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_REL); - break; - case LV_MBOX_STYLE_BTN_PR: - style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_PR); - break; - case LV_MBOX_STYLE_BTN_TGL_REL: - style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL); - break; - case LV_MBOX_STYLE_BTN_TGL_PR: - style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR); - break; - case LV_MBOX_STYLE_BTN_INA: - style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_INA); - break; + case LV_MBOX_STYLE_BTN_REL: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_REL); break; + case LV_MBOX_STYLE_BTN_PR: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_PR); break; + case LV_MBOX_STYLE_BTN_TGL_REL: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_REL); break; + case LV_MBOX_STYLE_BTN_TGL_PR: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_TGL_PR); break; + case LV_MBOX_STYLE_BTN_INA: style = lv_btnm_get_style(ext->btnm, LV_BTNM_STYLE_BTN_INA); break; default: style = NULL; break; } @@ -513,7 +495,7 @@ static void mbox_realign(lv_obj_t * mbox) lv_mbox_ext_t * ext = lv_obj_get_ext_attr(mbox); const lv_style_t * style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BG); - lv_coord_t w = lv_obj_get_width(mbox) - style->body.padding.left - style->body.padding.right; + lv_coord_t w = lv_obj_get_width(mbox) - style->body.padding.left - style->body.padding.right; if(ext->text) { lv_obj_set_width(ext->text, w); @@ -524,9 +506,8 @@ static void mbox_realign(lv_obj_t * mbox) const lv_style_t * btn_rel_style = lv_mbox_get_style(mbox, LV_MBOX_STYLE_BTN_REL); lv_coord_t font_h = lv_font_get_line_height(btn_rel_style->text.font); lv_obj_set_size(ext->btnm, w, - font_h + btn_rel_style->body.padding.top + - btn_rel_style->body.padding.bottom + btn_bg_style->body.padding.top + - btn_bg_style->body.padding.bottom); + font_h + btn_rel_style->body.padding.top + btn_rel_style->body.padding.bottom + + btn_bg_style->body.padding.top + btn_bg_style->body.padding.bottom); } } diff --git a/src/lv_objx/lv_mbox.h b/src/lv_objx/lv_mbox.h index ed1a88964..805bf190a 100644 --- a/src/lv_objx/lv_mbox.h +++ b/src/lv_objx/lv_mbox.h @@ -52,8 +52,8 @@ typedef struct { lv_cont_ext_t bg; /*Ext. of ancestor*/ /*New data for this type */ - lv_obj_t * text; /*Text of the message box*/ - lv_obj_t * btnm; /*Button matrix for the buttons*/ + lv_obj_t * text; /*Text of the message box*/ + lv_obj_t * btnm; /*Button matrix for the buttons*/ #if LV_USE_ANIMATION uint16_t anim_time; /*Duration of close animation [ms] (0: no animation)*/ #endif diff --git a/src/lv_objx/lv_page.c b/src/lv_objx/lv_page.c index 2470c87f3..17d3e9633 100644 --- a/src/lv_objx/lv_page.c +++ b/src/lv_objx/lv_page.c @@ -83,11 +83,11 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->scrl = NULL; - ext->sb.hor_draw = 0; - ext->sb.ver_draw = 0; - ext->sb.style = &lv_style_pretty; - ext->sb.mode = LV_SB_MODE_AUTO; + ext->scrl = NULL; + ext->sb.hor_draw = 0; + ext->sb.ver_draw = 0; + ext->sb.style = &lv_style_pretty; + ext->sb.mode = LV_SB_MODE_AUTO; #if LV_USE_ANIMATION ext->edge_flash.enabled = 0; ext->edge_flash.bottom_ip = 0; @@ -97,9 +97,9 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) ext->edge_flash.state = 0; ext->edge_flash.style = &lv_style_plain_color; #endif - ext->arrow_scroll = 0; - ext->scroll_prop = 0; - ext->scroll_prop_ip = 0; + ext->arrow_scroll = 0; + ext->scroll_prop = 0; + ext->scroll_prop_ip = 0; /*Init the new page object*/ if(copy == NULL) { @@ -146,8 +146,7 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy) lv_page_set_arrow_scroll(new_page, copy_ext->arrow_scroll); lv_page_set_style(new_page, LV_PAGE_STYLE_BG, lv_page_get_style(copy, LV_PAGE_STYLE_BG)); - lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, - lv_page_get_style(copy, LV_PAGE_STYLE_SCRL)); + lv_page_set_style(new_page, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy, LV_PAGE_STYLE_SCRL)); lv_page_set_style(new_page, LV_PAGE_STYLE_SB, lv_page_get_style(copy, LV_PAGE_STYLE_SB)); /* Add the signal function only if 'scrolling' is created @@ -241,8 +240,8 @@ void lv_page_set_edge_flash(lv_obj_t * page, bool en) lv_page_ext_t * ext = lv_obj_get_ext_attr(page); ext->edge_flash.enabled = en ? 1 : 0; #else - (void) page; - (void) en; + (void)page; + (void)en; #endif } @@ -333,7 +332,7 @@ bool lv_page_get_edge_flash(lv_obj_t * page) lv_page_ext_t * ext = lv_obj_get_ext_attr(page); return ext->edge_flash.enabled == 0 ? false : true; #else - (void) page; + (void)page; return false; #endif } @@ -374,8 +373,8 @@ lv_coord_t lv_page_get_fit_height(lv_obj_t * page) * */ const lv_style_t * lv_page_get_style(const lv_obj_t * page, lv_page_style_t type) { - const lv_style_t * style = NULL; - lv_page_ext_t * ext = lv_obj_get_ext_attr(page); + const lv_style_t * style = NULL; + lv_page_ext_t * ext = lv_obj_get_ext_attr(page); switch(type) { case LV_PAGE_STYLE_BG: style = lv_obj_get_style(page); break; @@ -412,14 +411,11 @@ bool lv_page_on_edge(lv_obj_t * page, lv_page_edge_t edge) if(edge == LV_PAGE_EDGE_TOP && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) return true; - else if(edge == LV_PAGE_EDGE_BOTTOM && - scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom) + else if(edge == LV_PAGE_EDGE_BOTTOM && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom) return true; - else if(edge == LV_PAGE_EDGE_LEFT && - scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) + else if(edge == LV_PAGE_EDGE_LEFT && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) return true; - else if(edge == LV_PAGE_EDGE_RIGHT && - scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right) + else if(edge == LV_PAGE_EDGE_RIGHT && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right) return true; return false; @@ -516,17 +512,17 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time) a.start = lv_obj_get_y(ext->scrl); a.end = scrlable_y; a.time = anim_time; - a.ready_cb = NULL; + a.ready_cb = NULL; a.playback = 0; a.repeat = 0; a.var = ext->scrl; - a.path_cb = lv_anim_path_linear; - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; + a.path_cb = lv_anim_path_linear; + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; lv_anim_create(&a); - a.start = lv_obj_get_x(ext->scrl); - a.end = scrlable_x; - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; + a.start = lv_obj_get_x(ext->scrl); + a.end = scrlable_x; + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; lv_anim_create(&a); #endif } @@ -711,8 +707,8 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo lv_style_t flash_style; lv_style_copy(&flash_style, ext->edge_flash.style); flash_style.body.radius = LV_RADIUS_CIRCLE; - uint32_t opa = (flash_style.body.opa * ext->edge_flash.state) / LV_PAGE_END_FLASH_SIZE; - flash_style.body.opa = opa; + uint32_t opa = (flash_style.body.opa * ext->edge_flash.state) / LV_PAGE_END_FLASH_SIZE; + flash_style.body.opa = opa; lv_draw_rect(&flash_area, mask, &flash_style, lv_obj_get_opa_scale(page)); } } @@ -792,13 +788,13 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param) lv_obj_t * child; if(sign == LV_SIGNAL_CHILD_CHG) { /*Automatically move children to the scrollable object*/ const lv_style_t * style = lv_page_get_style(page, LV_PAGE_STYLE_SCRL); - lv_fit_t fit_left = lv_page_get_scrl_fit_left(page); - lv_fit_t fit_top = lv_page_get_scrl_fit_top(page); - child = lv_obj_get_child(page, NULL); + lv_fit_t fit_left = lv_page_get_scrl_fit_left(page); + lv_fit_t fit_top = lv_page_get_scrl_fit_top(page); + child = lv_obj_get_child(page, NULL); while(child != NULL) { if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) { lv_obj_t * tmp = child; - child = lv_obj_get_child(page, child); /*Get the next child before move this*/ + child = lv_obj_get_child(page, child); /*Get the next child before move this*/ /* Reposition the child to take padding into account (Only if it's on (0;0) now) * It's required to keep new the object on the same coordinate if FIT is enabled.*/ @@ -891,9 +887,9 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi res = ancestor_signal(scrl, sign, param); if(res != LV_RES_OK) return res; - lv_obj_t * page = lv_obj_get_parent(scrl); - const lv_style_t * page_style = lv_obj_get_style(page); - lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page); + lv_obj_t * page = lv_obj_get_parent(scrl); + const lv_style_t * page_style = lv_obj_get_style(page); + lv_page_ext_t * page_ext = lv_obj_get_ext_attr(page); if(sign == LV_SIGNAL_CORD_CHG) { /*Limit the position of the scrollable object to be always visible @@ -921,19 +917,13 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi /* Start the scroll propagation if there is drag vector on the indev, but the drag is not * started yet and the scrollable is in a corner. It will enable the scroll propagation only * when a new scroll begins and not when the scrollable is already being scrolled.*/ - if(page_ext->scroll_prop && page_ext->scroll_prop_ip == 0 && - lv_indev_is_dragging(indev) == false) { - if(((drag_vect.y > 0 && - scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) || - (drag_vect.y < 0 && - scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)) && - ((drag_vect.x > 0 && - scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) || - (drag_vect.x < 0 && - scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right))) { + if(page_ext->scroll_prop && page_ext->scroll_prop_ip == 0 && lv_indev_is_dragging(indev) == false) { + if(((drag_vect.y > 0 && scrl_coords.y1 == page_coords.y1 + page_style->body.padding.top) || + (drag_vect.y < 0 && scrl_coords.y2 == page_coords.y2 - page_style->body.padding.bottom)) && + ((drag_vect.x > 0 && scrl_coords.x1 == page_coords.x1 + page_style->body.padding.left) || + (drag_vect.x < 0 && scrl_coords.x2 == page_coords.x2 - page_style->body.padding.right))) { - if(lv_obj_get_parent(page_parent) != - NULL) { /*Do not propagate the scroll to a screen*/ + if(lv_obj_get_parent(page_parent) != NULL) { /*Do not propagate the scroll to a screen*/ page_ext->scroll_prop_ip = 1; } } @@ -1080,17 +1070,10 @@ static void scrl_def_event_cb(lv_obj_t * scrl, lv_event_t event) lv_obj_t * page = lv_obj_get_parent(scrl); /*clang-format off*/ - if(event == LV_EVENT_PRESSED || - event == LV_EVENT_PRESSING || - event == LV_EVENT_PRESS_LOST || - event == LV_EVENT_RELEASED || - event == LV_EVENT_SHORT_CLICKED || - event == LV_EVENT_CLICKED || - event == LV_EVENT_LONG_PRESSED || - event == LV_EVENT_LONG_PRESSED_REPEAT || - event == LV_EVENT_FOCUSED || - event == LV_EVENT_DEFOCUSED) - { + if(event == LV_EVENT_PRESSED || event == LV_EVENT_PRESSING || event == LV_EVENT_PRESS_LOST || + event == LV_EVENT_RELEASED || event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_CLICKED || + event == LV_EVENT_LONG_PRESSED || event == LV_EVENT_LONG_PRESSED_REPEAT || event == LV_EVENT_FOCUSED || + event == LV_EVENT_DEFOCUSED) { lv_event_send(page, event, lv_event_get_data()); } /*clang-format on*/ @@ -1115,10 +1098,8 @@ static void lv_page_sb_refresh(lv_obj_t * page) * else: * - horizontal and vertical scrollbars can overlap on the corners * - if the page has radius the scrollbar can be out of the radius */ - lv_coord_t sb_hor_pad = - LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right); - lv_coord_t sb_ver_pad = - LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom); + lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right); + lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom); if(ext->sb.mode == LV_SB_MODE_OFF) return; @@ -1154,8 +1135,7 @@ static void lv_page_sb_refresh(lv_obj_t * page) } /*Full sized horizontal scrollbar*/ - if(scrl_w <= - obj_w - style->body.padding.left - style->body.padding.right) { + if(scrl_w <= obj_w - style->body.padding.left - style->body.padding.right) { lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad); lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad, obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom); @@ -1163,18 +1143,16 @@ static void lv_page_sb_refresh(lv_obj_t * page) } /*Smaller horizontal scrollbar*/ else { - size_tmp = (obj_w * (obj_w - (2 * sb_hor_pad))) / - (scrl_w + style->body.padding.left + style->body.padding.right); + size_tmp = + (obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + style->body.padding.left + style->body.padding.right); if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE; lv_area_set_width(&ext->sb.hor_area, size_tmp); - lv_area_set_pos( - &ext->sb.hor_area, - sb_hor_pad + - (-(lv_obj_get_x(scrl) - style->body.padding.left) * - (obj_w - size_tmp - 2 * sb_hor_pad)) / - (scrl_w + style->body.padding.left + style->body.padding.right - obj_w), - obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom); + lv_area_set_pos(&ext->sb.hor_area, + sb_hor_pad + + (-(lv_obj_get_x(scrl) - style->body.padding.left) * (obj_w - size_tmp - 2 * sb_hor_pad)) / + (scrl_w + style->body.padding.left + style->body.padding.right - obj_w), + obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom); if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1; } @@ -1183,24 +1161,21 @@ static void lv_page_sb_refresh(lv_obj_t * page) if(scrl_h <= obj_h - style->body.padding.top - style->body.padding.bottom) { lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad); lv_area_set_pos(&ext->sb.ver_area, - obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, - sb_ver_pad); + obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, sb_ver_pad); if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0; } /*Smaller vertical scroll bar*/ else { - size_tmp = (obj_h * (obj_h - (2 * sb_ver_pad))) / - (scrl_h + style->body.padding.top + style->body.padding.bottom); + size_tmp = + (obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + style->body.padding.top + style->body.padding.bottom); if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE; lv_area_set_height(&ext->sb.ver_area, size_tmp); - lv_area_set_pos( - &ext->sb.ver_area, - obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, - sb_ver_pad + - (-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) * - (obj_h - size_tmp - 2 * sb_ver_pad)) / - (scrl_h + style->body.padding.top + style->body.padding.bottom - obj_h)); + lv_area_set_pos(&ext->sb.ver_area, + obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, + sb_ver_pad + (-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) * + (obj_h - size_tmp - 2 * sb_ver_pad)) / + (scrl_h + style->body.padding.top + style->body.padding.bottom - obj_h)); if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1; } diff --git a/src/lv_objx/lv_page.h b/src/lv_objx/lv_page.h index c81db1616..337ea0a55 100644 --- a/src/lv_objx/lv_page.h +++ b/src/lv_objx/lv_page.h @@ -40,11 +40,10 @@ extern "C" { /*Scrollbar modes: shows when should the scrollbars be visible*/ enum { - LV_SB_MODE_OFF = 0x0, /*Never show scrollbars*/ - LV_SB_MODE_ON = 0x1, /*Always show scrollbars*/ - LV_SB_MODE_DRAG = 0x2, /*Show scrollbars when page is being dragged*/ - LV_SB_MODE_AUTO = - 0x3, /*Show scrollbars when the scrollable container is large enough to be scrolled*/ + LV_SB_MODE_OFF = 0x0, /*Never show scrollbars*/ + LV_SB_MODE_ON = 0x1, /*Always show scrollbars*/ + LV_SB_MODE_DRAG = 0x2, /*Show scrollbars when page is being dragged*/ + LV_SB_MODE_AUTO = 0x3, /*Show scrollbars when the scrollable container is large enough to be scrolled*/ LV_SB_MODE_HIDE = 0x4, /*Hide the scroll bar temporally*/ LV_SB_MODE_UNHIDE = 0x5, /*Unhide the previously hidden scrollbar. Recover it's type too*/ }; @@ -52,12 +51,7 @@ typedef uint8_t lv_sb_mode_t; /*Edges: describes the four edges of the page*/ -enum { - LV_PAGE_EDGE_LEFT = 0x0, - LV_PAGE_EDGE_TOP = 0x1, - LV_PAGE_EDGE_RIGHT = 0x2, - LV_PAGE_EDGE_BOTTOM = 0x3 -}; +enum { LV_PAGE_EDGE_LEFT = 0x0, LV_PAGE_EDGE_TOP = 0x1, LV_PAGE_EDGE_RIGHT = 0x2, LV_PAGE_EDGE_BOTTOM = 0x3 }; typedef uint8_t lv_page_edge_t; /*Data of page*/ @@ -69,28 +63,26 @@ typedef struct struct { const lv_style_t * style; /*Style of scrollbars*/ - lv_area_t - hor_area; /*Horizontal scrollbar area relative to the page. (Handled by the library) */ - lv_area_t - ver_area; /*Vertical scrollbar area relative to the page (Handled by the library)*/ - uint8_t hor_draw : 1; /*1: horizontal scrollbar is visible now (Handled by the library)*/ - uint8_t ver_draw : 1; /*1: vertical scrollbar is visible now (Handled by the library)*/ - lv_sb_mode_t mode : 3; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/ + lv_area_t hor_area; /*Horizontal scrollbar area relative to the page. (Handled by the library) */ + lv_area_t ver_area; /*Vertical scrollbar area relative to the page (Handled by the library)*/ + uint8_t hor_draw : 1; /*1: horizontal scrollbar is visible now (Handled by the library)*/ + uint8_t ver_draw : 1; /*1: vertical scrollbar is visible now (Handled by the library)*/ + lv_sb_mode_t mode : 3; /*Scrollbar visibility from 'lv_page_sb_mode_t'*/ } sb; #if LV_USE_ANIMATION struct { - lv_anim_value_t state; /*Store the current size of the edge flash effect*/ - const lv_style_t * style; /*Style of edge flash effect (usually homogeneous circle)*/ - uint8_t enabled : 1; /*1: Show a flash animation on the edge*/ - uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In - Progress)*/ - uint8_t bottom_ip : 1; /*Used internally to show that bottom most position is reached (flash - is In Progress)*/ - uint8_t right_ip : 1; /*Used internally to show that right most position is reached (flash - is In Progress)*/ - uint8_t left_ip : 1; /*Used internally to show that left most position is reached (flash is - In Progress)*/ + lv_anim_value_t state; /*Store the current size of the edge flash effect*/ + const lv_style_t * style; /*Style of edge flash effect (usually homogeneous circle)*/ + uint8_t enabled : 1; /*1: Show a flash animation on the edge*/ + uint8_t top_ip : 1; /*Used internally to show that top most position is reached (flash is In + Progress)*/ + uint8_t bottom_ip : 1; /*Used internally to show that bottom most position is reached (flash + is In Progress)*/ + uint8_t right_ip : 1; /*Used internally to show that right most position is reached (flash + is In Progress)*/ + uint8_t left_ip : 1; /*Used internally to show that left most position is reached (flash is + In Progress)*/ } edge_flash; #endif @@ -175,8 +167,7 @@ void lv_page_set_edge_flash(lv_obj_t * page, bool en); * @param top bottom fit policy from `lv_fit_t` * @param bottom bottom fit policy from `lv_fit_t` */ -static inline void lv_page_set_scrl_fit4(lv_obj_t * page, lv_fit_t left, lv_fit_t right, - lv_fit_t top, lv_fit_t bottom) +static inline void lv_page_set_scrl_fit4(lv_obj_t * page, lv_fit_t left, lv_fit_t right, lv_fit_t top, lv_fit_t bottom) { lv_cont_set_fit4(lv_page_get_scrl(page), left, right, top, bottom); } diff --git a/src/lv_objx/lv_preload.c b/src/lv_objx/lv_preload.c index d89c37aac..f63430405 100644 --- a/src/lv_objx/lv_preload.c +++ b/src/lv_objx/lv_preload.c @@ -80,7 +80,7 @@ lv_obj_t * lv_preload_create(lv_obj_t * par, const lv_obj_t * copy) /*Initialize the allocated 'ext' */ ext->arc_length = LV_PRELOAD_DEF_ARC_LENGTH; ext->anim_type = LV_PRELOAD_DEF_ANIM; - ext->anim_dir = LV_PRELOAD_DIR_FORWARD; + ext->anim_dir = LV_PRELOAD_DIR_FORWARD; /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_cb(new_preload, lv_preload_signal); @@ -178,15 +178,14 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type) case LV_PRELOAD_TYPE_FILLSPIN_ARC: { ext->anim_type = LV_PRELOAD_TYPE_FILLSPIN_ARC; lv_anim_t a; - a.var = preload; - if( ext->anim_dir == LV_PRELOAD_DIR_FORWARD ) { + a.var = preload; + if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) { /* Clockwise */ - a.start = 360; - a.end = 0; - } - else { - a.start = 0; - a.end = 360; + a.start = 360; + a.end = 0; + } else { + a.start = 0; + a.end = 360; } a.exec_cb = (lv_anim_exec_cb_t)lv_preload_spinner_anim; a.path_cb = lv_anim_path_ease_in_out; @@ -200,15 +199,14 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type) lv_anim_create(&a); lv_anim_t b; - b.var = preload; - if( ext->anim_dir == LV_PRELOAD_DIR_FORWARD ) { + b.var = preload; + if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) { /* Clockwise */ - b.start = 360 - ext->arc_length; - b.end = ext->arc_length; - } - else { - b.start = ext->arc_length; - b.end = 360 - ext->arc_length; + b.start = 360 - ext->arc_length; + b.end = ext->arc_length; + } else { + b.start = ext->arc_length; + b.end = 360 - ext->arc_length; } b.exec_cb = (lv_anim_exec_cb_t)lv_preload_set_arc_length; b.path_cb = lv_anim_path_ease_in_out; @@ -226,15 +224,14 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type) default: { ext->anim_type = LV_PRELOAD_TYPE_SPINNING_ARC; lv_anim_t a; - a.var = preload; - if( ext->anim_dir == LV_PRELOAD_DIR_FORWARD ) { + a.var = preload; + if(ext->anim_dir == LV_PRELOAD_DIR_FORWARD) { /* Clockwise */ - a.start = 360; - a.end = 0; - } - else { - a.start = 0; - a.end = 360; + a.start = 360; + a.end = 0; + } else { + a.start = 0; + a.end = 360; } a.exec_cb = (lv_anim_exec_cb_t)lv_preload_spinner_anim; a.path_cb = lv_anim_path_ease_in_out; @@ -251,7 +248,8 @@ void lv_preload_set_anim_type(lv_obj_t * preload, lv_preload_type_t type) } } -void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir) { +void lv_preload_set_anim_dir(lv_obj_t * preload, lv_preload_dir_t dir) +{ lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); ext->anim_dir = dir; @@ -311,7 +309,8 @@ lv_preload_type_t lv_preload_get_anim_type(lv_obj_t * preload) return ext->anim_type; } -lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload) { +lv_preload_dir_t lv_preload_get_anim_dir(lv_obj_t * preload) +{ lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); return ext->anim_dir; } @@ -330,8 +329,8 @@ void lv_preload_spinner_anim(void * ptr, lv_anim_value_t val) lv_obj_t * preload = ptr; lv_preload_ext_t * ext = lv_obj_get_ext_attr(preload); - int16_t angle_start = val - ext->arc_length / 2 + 180; - int16_t angle_end = angle_start + ext->arc_length; + int16_t angle_start = val - ext->arc_length / 2 + 180; + int16_t angle_end = angle_start + ext->arc_length; angle_start = angle_start % 360; angle_end = angle_end % 360; diff --git a/src/lv_objx/lv_preload.h b/src/lv_objx/lv_preload.h index 7d73eb373..45e0f620f 100644 --- a/src/lv_objx/lv_preload.h +++ b/src/lv_objx/lv_preload.h @@ -59,10 +59,10 @@ typedef struct { lv_arc_ext_t arc; /*Ext. of ancestor*/ /*New data for this type */ - lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/ - uint16_t time; /*Time of one round*/ - lv_preload_type_t anim_type:1; /*Type of the arc animation*/ - lv_preload_dir_t anim_dir:1; /*Animation Direction*/ + lv_anim_value_t arc_length; /*Length of the spinning indicator in degree*/ + uint16_t time; /*Time of one round*/ + lv_preload_type_t anim_type : 1; /*Type of the arc animation*/ + lv_preload_dir_t anim_dir : 1; /*Animation Direction*/ } lv_preload_ext_t; /*Styles*/ diff --git a/src/lv_objx/lv_roller.c b/src/lv_objx/lv_roller.c index 8698d4760..e8d80ef8c 100644 --- a/src/lv_objx/lv_roller.c +++ b/src/lv_objx/lv_roller.c @@ -72,8 +72,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(new_roller); if(new_roller == NULL) return NULL; - if(ancestor_scrl_signal == NULL) - ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller)); + if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_roller)); if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_roller); /*Allocate the roller type specific extended data*/ @@ -89,7 +88,7 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy) /*Init the new roller roller*/ if(copy == NULL) { lv_obj_t * scrl = lv_page_get_scrl(new_roller); - lv_obj_set_drag(scrl, true); /*In ddlist it might be disabled*/ + lv_obj_set_drag(scrl, true); /*In ddlist it might be disabled*/ lv_page_set_scrl_fit2(new_roller, LV_FIT_TIGHT, LV_FIT_NONE); /*Height is specified directly*/ lv_ddlist_open(new_roller, false); lv_ddlist_set_anim_time(new_roller, LV_ROLLER_DEF_ANIM_TIME); @@ -181,8 +180,7 @@ void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align) { lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); lv_mem_assert(ext); - if(ext->ddlist.label == NULL) - return; /*Probably the roller is being deleted if the label is NULL.*/ + if(ext->ddlist.label == NULL) return; /*Probably the roller is being deleted if the label is NULL.*/ lv_label_set_align(ext->ddlist.label, align); } @@ -323,10 +321,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller); lv_coord_t font_h = lv_font_get_line_height(font); lv_area_t rect_area; - rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - - style->text.line_space / 2; - if((font_h & 0x1) && (style->text.line_space & 0x1)) - rect_area.y1--; /*Compensate the two rounding error*/ + rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/ rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; @@ -343,10 +339,8 @@ static bool lv_roller_design(lv_obj_t * roller, const lv_area_t * mask, lv_desig /*Redraw the text on the selected area with a different color*/ lv_area_t rect_area; - rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - - style->text.line_space / 2; - if((font_h & 0x1) && (style->text.line_space & 0x1)) - rect_area.y1--; /*Compensate the two rounding error*/ + rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2; + if((font_h & 0x1) && (style->text.line_space & 0x1)) rect_area.y1--; /*Compensate the two rounding error*/ rect_area.y2 = rect_area.y1 + font_h + style->text.line_space - 1; rect_area.x1 = roller->coords.x1; rect_area.x2 = roller->coords.x2; @@ -435,9 +429,8 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; } } else { - ext->ddlist.sel_opt_id_ori = - ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if ENER - wont't be pressed*/ + ext->ddlist.sel_opt_id_ori = ext->ddlist.sel_opt_id; /*Save the current value. Used to revert this state if + ENER wont't be pressed*/ } #endif } else if(sign == LV_SIGNAL_DEFOCUS) { @@ -452,15 +445,13 @@ static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * par char c = *((char *)param); if(c == LV_KEY_RIGHT || c == LV_KEY_DOWN) { if(ext->ddlist.sel_opt_id + 1 < ext->ddlist.option_cnt) { - uint16_t ori_id = - ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/ + uint16_t ori_id = ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/ lv_roller_set_selected(roller, ext->ddlist.sel_opt_id + 1, true); ext->ddlist.sel_opt_id_ori = ori_id; } } else if(c == LV_KEY_LEFT || c == LV_KEY_UP) { if(ext->ddlist.sel_opt_id > 0) { - uint16_t ori_id = - ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/ + uint16_t ori_id = ext->ddlist.sel_opt_id_ori; /*lv_roller_set_selceted will overwrite this*/ lv_roller_set_selected(roller, ext->ddlist.sel_opt_id - 1, true); ext->ddlist.sel_opt_id_ori = ori_id; } @@ -529,12 +520,10 @@ static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, /*In edit mode go to navigate mode if an option is selected*/ lv_group_t * g = lv_obj_get_group(roller); bool editing = lv_group_get_editing(g); - if(editing) - lv_group_set_editing(g, false); + if(editing) lv_group_set_editing(g, false); #endif } - } - else if(sign == LV_SIGNAL_PRESSED) { + } else if(sign == LV_SIGNAL_PRESSED) { #if LV_USE_ANIMATION lv_anim_del(roller_scrl, (lv_anim_exec_cb_t)lv_obj_set_y); #endif @@ -582,8 +571,7 @@ static void draw_bg(lv_obj_t * roller, const lv_area_t * mask) half_roller.x2 += roller->ext_draw_pad; half_roller.y2 = roller->coords.y2 + roller->ext_draw_pad; half_roller.y1 = roller->coords.y1 + h / 2; - if((h & 0x1) == 0) - half_roller.y1++; /*With even height the pixels in the middle would be drawn twice*/ + if((h & 0x1) == 0) half_roller.y1++; /*With even height the pixels in the middle would be drawn twice*/ union_ok = lv_area_intersect(&half_mask, &half_roller, mask); @@ -620,24 +608,24 @@ static void refr_position(lv_obj_t * roller, bool anim_en) /* Normally the animtaion's `end_cb` sets correct position of the roller is infinite. * But without animations do it manually*/ - if(anim_en == false + if(anim_en == false #if LV_USE_ANIMATION - || ext->ddlist.anim_time == 0 + || ext->ddlist.anim_time == 0 #endif - ) { + ) { inf_normalize(roller_scrl); } - int32_t id = ext->ddlist.sel_opt_id; - lv_coord_t line_y1 = id * (font_h + style_label->text.line_space) + - ext->ddlist.label->coords.y1 - roller_scrl->coords.y1; + int32_t id = ext->ddlist.sel_opt_id; + lv_coord_t line_y1 = + id * (font_h + style_label->text.line_space) + ext->ddlist.label->coords.y1 - roller_scrl->coords.y1; lv_coord_t new_y = -line_y1 + (h - font_h) / 2; - if( anim_en == false + if(anim_en == false #if LV_USE_ANIMATION - || ext->ddlist.anim_time == 0 + || ext->ddlist.anim_time == 0 #endif - ) { + ) { lv_obj_set_y(roller_scrl, new_y); } else { #if LV_USE_ANIMATION @@ -675,8 +663,7 @@ static void refr_height(lv_obj_t * roller) obj_align = LV_ALIGN_IN_RIGHT_MID; } - lv_obj_set_height(lv_page_get_scrl(roller), - lv_obj_get_height(ext->ddlist.label) + lv_obj_get_height(roller)); + lv_obj_set_height(lv_page_get_scrl(roller), lv_obj_get_height(ext->ddlist.label) + lv_obj_get_height(roller)); lv_obj_align(ext->ddlist.label, NULL, obj_align, 0, 0); #if LV_USE_ANIMATION lv_anim_del(lv_page_get_scrl(roller), (lv_anim_exec_cb_t)lv_obj_set_y); @@ -699,8 +686,7 @@ static void inf_normalize(void * scrl) ext->ddlist.sel_opt_id = ext->ddlist.sel_opt_id % real_id_cnt; - ext->ddlist.sel_opt_id += - (LV_ROLLER_INF_PAGES / 2) * real_id_cnt; /*Select the middle page*/ + ext->ddlist.sel_opt_id += (LV_ROLLER_INF_PAGES / 2) * real_id_cnt; /*Select the middle page*/ /*Move to the new id*/ const lv_style_t * style_label = lv_obj_get_style(ext->ddlist.label); diff --git a/src/lv_objx/lv_roller.h b/src/lv_objx/lv_roller.h index c99b66524..869b3abe6 100644 --- a/src/lv_objx/lv_roller.h +++ b/src/lv_objx/lv_roller.h @@ -141,8 +141,7 @@ uint16_t lv_roller_get_selected(const lv_obj_t * roller); * @param buf pointer to an array to store the string * @param buf_size size of `buf` in bytes. 0: to ignore it. */ -static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, - uint16_t buf_size) +static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t buf_size) { lv_ddlist_get_selected_str(roller, buf, buf_size); } diff --git a/src/lv_objx/lv_slider.c b/src/lv_objx/lv_slider.c index e2e7666cd..a7fb4333b 100644 --- a/src/lv_objx/lv_slider.c +++ b/src/lv_objx/lv_slider.c @@ -18,8 +18,7 @@ /********************* * DEFINES *********************/ -#define LV_SLIDER_SIZE_MIN \ - 4 /*hor. pad and ver. pad cannot make the bar or indicator smaller then this [px]*/ +#define LV_SLIDER_SIZE_MIN 4 /*hor. pad and ver. pad cannot make the bar or indicator smaller then this [px]*/ #define LV_SLIDER_NOT_PRESSED INT16_MIN /********************** @@ -196,8 +195,8 @@ bool lv_slider_get_knob_in(const lv_obj_t * slider) */ const lv_style_t * lv_slider_get_style(const lv_obj_t * slider, lv_slider_style_t type) { - const lv_style_t * style = NULL; - lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider); + const lv_style_t * style = NULL; + lv_slider_ext_t * ext = lv_obj_get_ext_attr(slider); switch(type) { case LV_SLIDER_STYLE_BG: style = lv_bar_get_style(slider, LV_BAR_STYLE_BG); break; @@ -265,12 +264,11 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig area_bg.x2 -= pad_right_bg; area_bg.y1 += pad_top_bg; area_bg.y2 -= pad_bottom_bg; - } else { /*Let space only in the perpendicular directions*/ - area_bg.x1 += slider_w < slider_h ? pad_left_bg : 0; /*Pad only for vertical slider*/ - area_bg.x2 -= slider_w < slider_h ? pad_right_bg : 0; /*Pad only for vertical slider*/ - area_bg.y1 += slider_w > slider_h ? pad_top_bg : 0; /*Pad only for horizontal slider*/ - area_bg.y2 -= - slider_w > slider_h ? pad_bottom_bg : 0; /*Pad only for horizontal slider*/ + } else { /*Let space only in the perpendicular directions*/ + area_bg.x1 += slider_w < slider_h ? pad_left_bg : 0; /*Pad only for vertical slider*/ + area_bg.x2 -= slider_w < slider_h ? pad_right_bg : 0; /*Pad only for vertical slider*/ + area_bg.y1 += slider_w > slider_h ? pad_top_bg : 0; /*Pad only for horizontal slider*/ + area_bg.y2 -= slider_w > slider_h ? pad_bottom_bg : 0; /*Pad only for horizontal slider*/ } #if LV_USE_GROUP == 0 @@ -325,29 +323,23 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(ext->bar.anim_state != LV_BAR_ANIM_STATE_INV) { /*Calculate the coordinates of anim. start and end*/ lv_coord_t anim_start_x = - (int32_t)((int32_t)indic_w * (ext->bar.anim_start - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)indic_w * (ext->bar.anim_start - min_value)) / (max_value - min_value); lv_coord_t anim_end_x = - (int32_t)((int32_t)indic_w * (ext->bar.anim_end - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)indic_w * (ext->bar.anim_end - min_value)) / (max_value - min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ - area_indic.x2 = - anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); - } - else + area_indic.x2 = anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); + } else #endif { - area_indic.x2 = - (int32_t)((int32_t)indic_w * (cur_value - min_value)) / (max_value - min_value); + area_indic.x2 = (int32_t)((int32_t)indic_w * (cur_value - min_value)) / (max_value - min_value); } area_indic.x2 = area_indic.x1 + area_indic.x2 - 1; /*Draw the indicator but don't draw an ugly 1px wide rectangle on the left on min. * value*/ - if(area_indic.x1 != area_indic.x2) - lv_draw_rect(&area_indic, mask, style_indic, opa_scale); + if(area_indic.x1 != area_indic.x2) lv_draw_rect(&area_indic, mask, style_indic, opa_scale); } else { lv_coord_t indic_h = lv_area_get_height(&area_indic); @@ -355,29 +347,23 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(ext->bar.anim_state != LV_BAR_ANIM_STATE_INV) { /*Calculate the coordinates of anim. start and end*/ lv_coord_t anim_start_y = - (int32_t)((int32_t)indic_h * (ext->bar.anim_start - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)indic_h * (ext->bar.anim_start - min_value)) / (max_value - min_value); lv_coord_t anim_end_y = - (int32_t)((int32_t)indic_h * (ext->bar.anim_end - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)indic_h * (ext->bar.anim_end - min_value)) / (max_value - min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ - area_indic.y1 = - anim_start_y + (((anim_end_y - anim_start_y) * ext->bar.anim_state) >> 8); - } - else + area_indic.y1 = anim_start_y + (((anim_end_y - anim_start_y) * ext->bar.anim_state) >> 8); + } else #endif { - area_indic.y1 = - (int32_t)((int32_t)indic_h * (cur_value - min_value)) / (max_value - min_value); + area_indic.y1 = (int32_t)((int32_t)indic_h * (cur_value - min_value)) / (max_value - min_value); } area_indic.y1 = area_indic.y2 - area_indic.y1 + 1; /*Draw the indicator but don't draw an ugly 1px height rectangle on the bottom on min. * value*/ - if(area_indic.x1 != area_indic.x2) - lv_draw_rect(&area_indic, mask, style_indic, opa_scale); + if(area_indic.x1 != area_indic.x2) lv_draw_rect(&area_indic, mask, style_indic, opa_scale); } /*Before the knob add the border if required*/ @@ -407,22 +393,18 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(ext->bar.anim_state != LV_BAR_ANIM_STATE_INV) { lv_coord_t w = slider_w - slider_h - 1; lv_coord_t anim_start_x = - (int32_t)((int32_t)w * (ext->bar.anim_start - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)w * (ext->bar.anim_start - min_value)) / (max_value - min_value); lv_coord_t anim_end_x = - (int32_t)((int32_t)w * (ext->bar.anim_end - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)w * (ext->bar.anim_end - min_value)) / (max_value - min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ - knob_area.x1 = - anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); - } else + knob_area.x1 = anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); + } else #endif { - knob_area.x1 = - (int32_t)((int32_t)(slider_w - slider_h - 1) * (cur_value - min_value)) / - (max_value - min_value); + knob_area.x1 = (int32_t)((int32_t)(slider_w - slider_h - 1) * (cur_value - min_value)) / + (max_value - min_value); } knob_area.x1 += slider->coords.x1; @@ -440,22 +422,18 @@ static bool lv_slider_design(lv_obj_t * slider, const lv_area_t * mask, lv_desig if(ext->bar.anim_state != LV_BAR_ANIM_STATE_INV) { lv_coord_t h = slider_h - slider_w - 1; lv_coord_t anim_start_x = - (int32_t)((int32_t)h * (ext->bar.anim_start - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)h * (ext->bar.anim_start - min_value)) / (max_value - min_value); lv_coord_t anim_end_x = - (int32_t)((int32_t)h * (ext->bar.anim_end - min_value)) / - (max_value - min_value); + (int32_t)((int32_t)h * (ext->bar.anim_end - min_value)) / (max_value - min_value); /*Calculate the real position based on `anim_state` (between `anim_start` and * `anim_end`)*/ - knob_area.y2 = - anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); - } else + knob_area.y2 = anim_start_x + (((anim_end_x - anim_start_x) * ext->bar.anim_state) >> 8); + } else #endif { - knob_area.y2 = - (int32_t)((int32_t)(slider_h - slider_w - 1) * (cur_value - min_value)) / - (max_value - min_value); + knob_area.y2 = (int32_t)((int32_t)(slider_h - slider_w - 1) * (cur_value - min_value)) / + (max_value - min_value); } knob_area.y2 = slider->coords.y2 - knob_area.y2; @@ -501,18 +479,14 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par if(w > h) { lv_coord_t knob_w = h; p.x -= - slider->coords.x1 + - h / 2; /*Modify the point to shift with half knob (important on the start and end)*/ - tmp = (int32_t)((int32_t)p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / - (w - knob_w); + slider->coords.x1 + h / 2; /*Modify the point to shift with half knob (important on the start and end)*/ + tmp = (int32_t)((int32_t)p.x * (ext->bar.max_value - ext->bar.min_value + 1)) / (w - knob_w); tmp += ext->bar.min_value; } else { lv_coord_t knob_h = w; p.y -= - slider->coords.y1 + - w / 2; /*Modify the point to shift with half knob (important on the start and end)*/ - tmp = (int32_t)((int32_t)p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / - (h - knob_h); + slider->coords.y1 + w / 2; /*Modify the point to shift with half knob (important on the start and end)*/ + tmp = (int32_t)((int32_t)p.y * (ext->bar.max_value - ext->bar.min_value + 1)) / (h - knob_h); tmp = ext->bar.max_value - tmp; /*Invert the value: smaller value means higher y*/ } @@ -528,8 +502,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par if(res != LV_RES_OK) return res; } } else if(sign == LV_SIGNAL_RELEASED || sign == LV_SIGNAL_PRESS_LOST) { - if(ext->drag_value != LV_SLIDER_NOT_PRESSED) - lv_slider_set_value(slider, ext->drag_value, false); + if(ext->drag_value != LV_SLIDER_NOT_PRESSED) lv_slider_set_value(slider, ext->drag_value, false); ext->drag_value = LV_SLIDER_NOT_PRESSED; #if LV_USE_GROUP @@ -553,7 +526,7 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par const lv_style_t * style = lv_slider_get_style(slider, LV_SLIDER_STYLE_BG); const lv_style_t * knob_style = lv_slider_get_style(slider, LV_SLIDER_STYLE_KNOB); - lv_coord_t shadow_w = knob_style->body.shadow.width; + lv_coord_t shadow_w = knob_style->body.shadow.width; if(ext->knob_in == 0) { /* The smaller size is the knob diameter*/ lv_coord_t x = LV_MATH_MIN(w / 2 + 1 + shadow_w, h / 2 + 1 + shadow_w); diff --git a/src/lv_objx/lv_slider.h b/src/lv_objx/lv_slider.h index e82525672..2f602ed3c 100644 --- a/src/lv_objx/lv_slider.h +++ b/src/lv_objx/lv_slider.h @@ -42,8 +42,8 @@ typedef struct lv_bar_ext_t bar; /*Ext. of ancestor*/ /*New data for this type */ const lv_style_t * style_knob; /*Style of the knob*/ - int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/ - uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/ + int16_t drag_value; /*Store a temporal value during press until release (Handled by the library)*/ + uint8_t knob_in : 1; /*1: Draw the knob inside the bar*/ } lv_slider_ext_t; /*Built-in styles of slider*/ diff --git a/src/lv_objx/lv_spinbox.c b/src/lv_objx/lv_spinbox.c index 8dfd9d872..c6b1ccc61 100644 --- a/src/lv_objx/lv_spinbox.c +++ b/src/lv_objx/lv_spinbox.c @@ -138,16 +138,14 @@ void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i) * @param separator_position number of digit before the decimal point. If 0, decimal point is not * shown */ -void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, - uint8_t separator_position) +void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); if(ext == NULL) return; if(digit_count > LV_SPINBOX_MAX_DIGIT_COUNT) digit_count = LV_SPINBOX_MAX_DIGIT_COUNT; - if(separator_position > LV_SPINBOX_MAX_DIGIT_COUNT) - separator_position = LV_SPINBOX_MAX_DIGIT_COUNT; + if(separator_position > LV_SPINBOX_MAX_DIGIT_COUNT) separator_position = LV_SPINBOX_MAX_DIGIT_COUNT; ext->digit_count = digit_count; ext->dec_point_pos = separator_position; @@ -249,8 +247,7 @@ void lv_spinbox_step_previous(lv_obj_t * spinbox) { lv_spinbox_ext_t * ext = lv_obj_get_ext_attr(spinbox); int32_t step_limit; - step_limit = - LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min)); + step_limit = LV_MATH_MAX(ext->range_max, (ext->range_min < 0 ? (-ext->range_min) : ext->range_min)); int32_t new_step = ext->step * 10; if(new_step <= step_limit) ext->step = new_step; diff --git a/src/lv_objx/lv_spinbox.h b/src/lv_objx/lv_spinbox.h index 484457f27..b5fcee042 100644 --- a/src/lv_objx/lv_spinbox.h +++ b/src/lv_objx/lv_spinbox.h @@ -82,8 +82,7 @@ lv_obj_t * lv_spinbox_create(lv_obj_t * par, const lv_obj_t * copy); * @param type which style should be set * @param style pointer to a style */ -static inline void lv_spinbox_set_style(lv_obj_t * spinbox, lv_spinbox_style_t type, - lv_style_t * style) +static inline void lv_spinbox_set_style(lv_obj_t * spinbox, lv_spinbox_style_t type, lv_style_t * style) { lv_ta_set_style(spinbox, type, style); } @@ -102,8 +101,7 @@ void lv_spinbox_set_value(lv_obj_t * spinbox, int32_t i); * @param separator_position number of digit before the decimal point. If 0, decimal point is not * shown */ -void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, - uint8_t separator_position); +void lv_spinbox_set_digit_format(lv_obj_t * spinbox, uint8_t digit_count, uint8_t separator_position); /** * Set spinbox step diff --git a/src/lv_objx/lv_sw.c b/src/lv_objx/lv_sw.c index 5468dd9dd..0d2ac9ce4 100644 --- a/src/lv_objx/lv_sw.c +++ b/src/lv_objx/lv_sw.c @@ -203,8 +203,8 @@ void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time) lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw); ext->anim_time = anim_time; #else - (void) sw; - (void) anim_time; + (void)sw; + (void)anim_time; #endif } @@ -221,7 +221,7 @@ void lv_sw_set_anim_time(lv_obj_t * sw, uint16_t anim_time) const lv_style_t * lv_sw_get_style(const lv_obj_t * sw, lv_sw_style_t type) { const lv_style_t * style = NULL; - lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw); + lv_sw_ext_t * ext = lv_obj_get_ext_attr(sw); switch(type) { case LV_SW_STYLE_BG: style = lv_slider_get_style(sw, LV_SLIDER_STYLE_BG); break; diff --git a/src/lv_objx/lv_sw.h b/src/lv_objx/lv_sw.h index 1b4e73e25..386f1ef33 100644 --- a/src/lv_objx/lv_sw.h +++ b/src/lv_objx/lv_sw.h @@ -43,8 +43,7 @@ typedef struct lv_slider_ext_t slider; /*Ext. of ancestor*/ /*New data for this type */ const lv_style_t * style_knob_off; /*Style of the knob when the switch is OFF*/ - const lv_style_t * - style_knob_on; /*Style of the knob when the switch is ON (NULL to use the same as OFF)*/ + const lv_style_t * style_knob_on; /*Style of the knob when the switch is ON (NULL to use the same as OFF)*/ lv_coord_t start_x; uint8_t changed : 1; /*Indicates the switch state explicitly changed by drag*/ uint8_t slided : 1; diff --git a/src/lv_objx/lv_ta.c b/src/lv_objx/lv_ta.c index e6b7ebb24..acad1d7f4 100644 --- a/src/lv_objx/lv_ta.c +++ b/src/lv_objx/lv_ta.c @@ -54,8 +54,7 @@ static bool char_is_accepted(lv_obj_t * ta, uint32_t c); static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res); static void refr_cursor_area(lv_obj_t * ta); static void placeholder_update(lv_obj_t * ta); -static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, - lv_indev_t * click_source); +static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_indev_t * click_source); /********************** * STATIC VARIABLES @@ -99,24 +98,24 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; - ext->cursor.state = 1; - ext->pwd_mode = 0; - ext->pwd_tmp = NULL; - ext->pwd_show_time = LV_TA_DEF_PWD_SHOW_TIME; - ext->accapted_chars = NULL; - ext->max_length = 0; - ext->cursor.style = NULL; + ext->cursor.state = 1; + ext->pwd_mode = 0; + ext->pwd_tmp = NULL; + ext->pwd_show_time = LV_TA_DEF_PWD_SHOW_TIME; + ext->accapted_chars = NULL; + ext->max_length = 0; + ext->cursor.style = NULL; ext->cursor.blink_time = LV_TA_DEF_CURSOR_BLINK_TIME; - ext->cursor.pos = 0; - ext->cursor.type = LV_CURSOR_LINE; - ext->cursor.valid_x = 0; - ext->one_line = 0; - ext->text_sel_en = 0; - ext->label = NULL; - ext->placeholder = NULL; + ext->cursor.pos = 0; + ext->cursor.type = LV_CURSOR_LINE; + ext->cursor.valid_x = 0; + ext->one_line = 0; + ext->text_sel_en = 0; + ext->label = NULL; + ext->placeholder = NULL; #if LV_USE_ANIMATION == 0 - ext->pwd_show_time = 0; + ext->pwd_show_time = 0; ext->cursor.blink_time = 0; #endif @@ -183,7 +182,7 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy) a.repeat_pause = 0; a.playback = 1; a.playback_pause = 0; - a.path_cb = lv_anim_path_step; + a.path_cb = lv_anim_path_step; lv_anim_create(&a); } #endif @@ -242,14 +241,12 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c) if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/ - lv_label_ins_text(ext->label, ext->cursor.pos, - (const char *)letter_buf); /*Insert the character*/ - lv_ta_clear_selection(ta); /*Clear selection*/ + lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/ + lv_ta_clear_selection(ta); /*Clear selection*/ if(ext->pwd_mode != 0) { - ext->pwd_tmp = - lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */ + ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */ lv_mem_assert(ext->pwd_tmp); if(ext->pwd_tmp == NULL) return; @@ -269,7 +266,7 @@ void lv_ta_add_char(lv_obj_t * ta, uint32_t c) a.repeat_pause = 0; a.playback = 0; a.playback_pause = 0; - a.path_cb = lv_anim_path_step; + a.path_cb = lv_anim_path_step; lv_anim_create(&a); #else @@ -337,21 +334,21 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt) lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, txt); #if LV_USE_ANIMATION - /*Auto hide characters*/ - lv_anim_t a; - a.var = ta; - a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim; - a.time = ext->pwd_show_time; - a.act_time = 0; - a.ready_cb = pwd_char_hider_anim_ready; - a.start = 0; - a.end = 1; - a.repeat = 0; - a.repeat_pause = 0; - a.playback = 0; - a.playback_pause = 0; - a.path_cb = lv_anim_path_step; - lv_anim_create(&a); + /*Auto hide characters*/ + lv_anim_t a; + a.var = ta; + a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim; + a.time = ext->pwd_show_time; + a.act_time = 0; + a.ready_cb = pwd_char_hider_anim_ready; + a.start = 0; + a.end = 1; + a.repeat = 0; + a.repeat_pause = 0; + a.playback = 0; + a.playback_pause = 0; + a.path_cb = lv_anim_path_step; + lv_anim_create(&a); #else pwd_char_hider(ta); #endif @@ -477,21 +474,21 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt) strcpy(ext->pwd_tmp, txt); #if LV_USE_ANIMATION - /*Auto hide characters*/ - lv_anim_t a; - a.var = ta; - a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim; - a.time = ext->pwd_show_time; - a.act_time = 0; - a.ready_cb = pwd_char_hider_anim_ready; - a.start = 0; - a.end = 1; - a.repeat = 0; - a.repeat_pause = 0; - a.playback = 0; - a.playback_pause = 0; - a.path_cb = lv_anim_path_step; - lv_anim_create(&a); + /*Auto hide characters*/ + lv_anim_t a; + a.var = ta; + a.exec_cb = (lv_anim_exec_cb_t)pwd_char_hider_anim; + a.time = ext->pwd_show_time; + a.act_time = 0; + a.ready_cb = pwd_char_hider_anim_ready; + a.start = 0; + a.end = 1; + a.repeat = 0; + a.repeat_pause = 0; + a.playback = 0; + a.playback_pause = 0; + a.path_cb = lv_anim_path_step; + lv_anim_create(&a); #else pwd_char_hider(ta); #endif @@ -566,8 +563,8 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) /*Check the bottom*/ if(label_cords.y1 + cur_pos.y + font_h + style->body.padding.bottom > ta_cords.y2) { - lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) + font_h + - style->body.padding.top + style->body.padding.bottom)); + lv_obj_set_y(label_par, -(cur_pos.y - lv_obj_get_height(ta) + font_h + style->body.padding.top + + style->body.padding.bottom)); } /*Check the left (use the font_h as general unit)*/ if(lv_obj_get_x(label_par) + cur_pos.x < font_h) { @@ -576,8 +573,8 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) /*Check the right (use the font_h as general unit)*/ if(label_cords.x1 + cur_pos.x + font_h + style->body.padding.right > ta_cords.x2) { - lv_obj_set_x(label_par, -(cur_pos.x - lv_obj_get_width(ta) + font_h + - style->body.padding.left + style->body.padding.right)); + lv_obj_set_x(label_par, -(cur_pos.x - lv_obj_get_width(ta) + font_h + style->body.padding.left + + style->body.padding.right)); } ext->cursor.valid_x = cur_pos.x; @@ -597,7 +594,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos) a.repeat_pause = 0; a.playback = 1; a.playback_pause = 0; - a.path_cb = lv_anim_path_step; + a.path_cb = lv_anim_path_step; lv_anim_create(&a); } #endif @@ -685,8 +682,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en) style_scrl->body.padding.top + style_scrl->body.padding.bottom); lv_label_set_long_mode(ext->label, LV_LABEL_LONG_EXPAND); if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_EXPAND); - lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.padding.left, - style_ta->body.padding.top); + lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.padding.left, style_ta->body.padding.top); } else { const lv_style_t * style_ta = lv_obj_get_style(ta); @@ -696,8 +692,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en) if(ext->placeholder) lv_label_set_long_mode(ext->placeholder, LV_LABEL_LONG_BREAK); lv_obj_set_height(ta, LV_TA_DEF_HEIGHT); - lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.padding.left, - style_ta->body.padding.top); + lv_obj_set_pos(lv_page_get_scrl(ta), style_ta->body.padding.left, style_ta->body.padding.top); } placeholder_update(ta); @@ -792,8 +787,7 @@ void lv_ta_set_style(lv_obj_t * ta, lv_ta_style_t type, const lv_style_t * style case LV_TA_STYLE_EDGE_FLASH: lv_page_set_style(ta, LV_PAGE_STYLE_EDGE_FLASH, style); break; case LV_TA_STYLE_CURSOR: ext->cursor.style = style; - lv_obj_refresh_ext_draw_pad( - lv_page_get_scrl(ta)); /*Refresh ext. size because of cursor drawing*/ + lv_obj_refresh_ext_draw_pad(lv_page_get_scrl(ta)); /*Refresh ext. size because of cursor drawing*/ refr_cursor_area(ta); break; case LV_TA_STYLE_PLACEHOLDER: @@ -812,12 +806,12 @@ void lv_ta_set_text_sel(lv_obj_t * ta, bool en) #if LV_LABEL_TEXT_SEL lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); - ext->text_sel_en = en; + ext->text_sel_en = en; if(!en) lv_ta_clear_selection(ta); #else - (void) ta; /*Unused*/ - (void) en; /*Unused*/ + (void)ta; /*Unused*/ + (void)en; /*Unused*/ #endif } @@ -832,7 +826,7 @@ void lv_ta_set_pwd_show_time(lv_obj_t * ta, uint16_t time) time = 0; #endif - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); ext->pwd_show_time = time; } @@ -847,7 +841,7 @@ void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time) time = 0; #endif - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); ext->cursor.blink_time = time; #if LV_USE_ANIMATION @@ -865,7 +859,7 @@ void lv_ta_set_cursor_blink_time(lv_obj_t * ta, uint16_t time) a.repeat_pause = 0; a.playback = 1; a.playback_pause = 0; - a.path_cb = lv_anim_path_step; + a.path_cb = lv_anim_path_step; lv_anim_create(&a); } else { ext->cursor.state = 1; @@ -1001,7 +995,7 @@ uint16_t lv_ta_get_max_length(lv_obj_t * ta) const lv_style_t * lv_ta_get_style(const lv_obj_t * ta, lv_ta_style_t type) { const lv_style_t * style = NULL; - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); switch(type) { case LV_TA_STYLE_BG: style = lv_page_get_style(ta, LV_PAGE_STYLE_BG); break; @@ -1028,13 +1022,13 @@ bool lv_ta_text_is_selected(const lv_obj_t * ta) lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); if((lv_label_get_text_sel_start(ext->label) == LV_LABEL_TEXT_SEL_OFF || - lv_label_get_text_sel_end(ext->label) == LV_LABEL_TEXT_SEL_OFF)){ + lv_label_get_text_sel_end(ext->label) == LV_LABEL_TEXT_SEL_OFF)) { return true; } else { return false; } #else - (void) ta; /*Unused*/ + (void)ta; /*Unused*/ return false; #endif } @@ -1050,7 +1044,7 @@ bool lv_ta_get_text_sel_en(lv_obj_t * ta) lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); return ext->text_sel_en; #else - (void) ta; /*Unused*/ + (void)ta; /*Unused*/ return false; #endif } @@ -1089,15 +1083,15 @@ uint16_t lv_ta_get_cursor_blink_time(lv_obj_t * ta) void lv_ta_clear_selection(lv_obj_t * ta) { #if LV_LABEL_TEXT_SEL - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); if(lv_label_get_text_sel_start(ext->label) != LV_LABEL_TEXT_SEL_OFF || - lv_label_get_text_sel_end(ext->label) != LV_LABEL_TEXT_SEL_OFF){ + lv_label_get_text_sel_end(ext->label) != LV_LABEL_TEXT_SEL_OFF) { lv_label_set_text_sel_start(ext->label, LV_LABEL_TEXT_SEL_OFF); lv_label_set_text_sel_end(ext->label, LV_LABEL_TEXT_SEL_OFF); } #else - (void) ta; /*Unused*/ + (void)ta; /*Unused*/ #endif } @@ -1149,8 +1143,7 @@ void lv_ta_cursor_down(lv_obj_t * ta) /*Get the letter index on the new cursor position and set it*/ uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos); - lv_coord_t cur_valid_x_tmp = - ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */ + lv_coord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */ lv_ta_set_cursor_pos(ta, new_cur_pos); ext->cursor.valid_x = cur_valid_x_tmp; } @@ -1176,9 +1169,8 @@ void lv_ta_cursor_up(lv_obj_t * ta) pos.x = ext->cursor.valid_x; /*Get the letter index on the new cursor position and set it*/ - uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos); - lv_coord_t cur_valid_x_tmp = - ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */ + uint16_t new_cur_pos = lv_label_get_letter_on(ext->label, &pos); + lv_coord_t cur_valid_x_tmp = ext->cursor.valid_x; /*Cursor position set overwrites the valid positon */ lv_ta_set_cursor_pos(ta, new_cur_pos); ext->cursor.valid_x = cur_valid_x_tmp; } @@ -1237,8 +1229,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_ lv_obj_t * ta = lv_obj_get_parent(scrl); lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); - if(ext->cursor.type == LV_CURSOR_NONE || (ext->cursor.type & LV_CURSOR_HIDDEN) || - ext->cursor.state == 0) { + if(ext->cursor.type == LV_CURSOR_NONE || (ext->cursor.type & LV_CURSOR_HIDDEN) || ext->cursor.state == 0) { return true; /*The cursor is not visible now*/ } @@ -1264,8 +1255,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_ lv_draw_rect(&cur_area, mask, &cur_style, opa_scale); char letter_buf[8] = {0}; - memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], - lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); + memcpy(letter_buf, &txt[ext->cursor.txt_byte_pos], lv_txt_encoded_size(&txt[ext->cursor.txt_byte_pos])); cur_area.x1 += cur_style.body.padding.left; cur_area.y1 += cur_style.body.padding.top; @@ -1274,8 +1264,7 @@ static bool lv_ta_scrollable_design(lv_obj_t * scrl, const lv_area_t * mask, lv_ } else if(ext->cursor.type == LV_CURSOR_OUTLINE) { cur_style.body.opa = LV_OPA_TRANSP; - if(cur_style.body.border.width == 0) - cur_style.body.border.width = 1; /*Be sure the border will be drawn*/ + if(cur_style.body.border.width == 0) cur_style.body.border.width = 1; /*Be sure the border will be drawn*/ lv_draw_rect(&cur_area, mask, &cur_style, opa_scale); } else if(ext->cursor.type == LV_CURSOR_UNDERLINE) { lv_draw_rect(&cur_area, mask, &cur_style, opa_scale); @@ -1314,21 +1303,18 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) /*In one line mode refresh the Text Area height because 'vpad' can modify it*/ const lv_style_t * style_label = lv_obj_get_style(ext->label); lv_coord_t font_h = lv_font_get_line_height(style_label->text.font); - lv_obj_set_height( - ta, font_h + style_ta->body.padding.top + style_ta->body.padding.bottom + - style_scrl->body.padding.top + style_scrl->body.padding.bottom); + lv_obj_set_height(ta, font_h + style_ta->body.padding.top + style_ta->body.padding.bottom + + style_scrl->body.padding.top + style_scrl->body.padding.bottom); } else { /*In not one line mode refresh the Label width because 'hpad' can modify it*/ lv_obj_set_width(ext->label, lv_page_get_fit_width(ta)); lv_obj_set_pos(ext->label, style_scrl->body.padding.left, - style_scrl->body.padding - .right); /*Be sure the Label is in the correct position*/ + style_scrl->body.padding.right); /*Be sure the Label is in the correct position*/ if(ext->placeholder) { lv_obj_set_width(ext->placeholder, lv_page_get_fit_width(ta)); lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, - style_scrl->body.padding - .top); /*Be sure the placeholder is in the correct position*/ + style_scrl->body.padding.top); /*Be sure the placeholder is in the correct position*/ } } lv_label_set_text(ext->label, NULL); @@ -1336,13 +1322,11 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) } else if(sign == LV_SIGNAL_CORD_CHG) { /*Set the label width according to the text area width*/ if(ext->label) { - if(lv_obj_get_width(ta) != lv_area_get_width(param) || - lv_obj_get_height(ta) != lv_area_get_height(param)) { + if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) { lv_obj_t * scrl = lv_page_get_scrl(ta); const lv_style_t * style_scrl = lv_obj_get_style(scrl); lv_obj_set_width(ext->label, lv_page_get_fit_width(ta)); - lv_obj_set_pos(ext->label, style_scrl->body.padding.left, - style_scrl->body.padding.top); + lv_obj_set_pos(ext->label, style_scrl->body.padding.left, style_scrl->body.padding.top); lv_label_set_text(ext->label, NULL); /*Refresh the label*/ refr_cursor_area(ta); @@ -1350,13 +1334,11 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) } /*Set the placeholder width according to the text area width*/ if(ext->placeholder) { - if(lv_obj_get_width(ta) != lv_area_get_width(param) || - lv_obj_get_height(ta) != lv_area_get_height(param)) { + if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) { lv_obj_t * scrl = lv_page_get_scrl(ta); const lv_style_t * style_scrl = lv_obj_get_style(scrl); lv_obj_set_width(ext->placeholder, lv_page_get_fit_width(ta)); - lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, - style_scrl->body.padding.top); + lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, style_scrl->body.padding.top); lv_label_set_text(ext->placeholder, NULL); /*Refresh the label*/ refr_cursor_area(ta); @@ -1415,8 +1397,8 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param) lv_ta_set_cursor_type(ta, cur_type & (~LV_CURSOR_HIDDEN)); } #endif - } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || - sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_RELEASED) { + } else if(sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESS_LOST || + sign == LV_SIGNAL_RELEASED) { update_cursor_position_on_click(ta, sign, (lv_indev_t *)param); } return res; @@ -1443,25 +1425,23 @@ static lv_res_t lv_ta_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, void if(sign == LV_SIGNAL_REFR_EXT_DRAW_PAD) { /*Set ext. size because the cursor might be out of this object*/ const lv_style_t * style_label = lv_obj_get_style(ext->label); - lv_coord_t font_h = lv_font_get_line_height(style_label->text.font); - scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, style_label->text.line_space + font_h); + lv_coord_t font_h = lv_font_get_line_height(style_label->text.font); + scrl->ext_draw_pad = LV_MATH_MAX(scrl->ext_draw_pad, style_label->text.line_space + font_h); } else if(sign == LV_SIGNAL_CORD_CHG) { /*Set the label width according to the text area width*/ if(ext->label) { - if(lv_obj_get_width(ta) != lv_area_get_width(param) || - lv_obj_get_height(ta) != lv_area_get_height(param)) { + if(lv_obj_get_width(ta) != lv_area_get_width(param) || lv_obj_get_height(ta) != lv_area_get_height(param)) { const lv_style_t * style_scrl = lv_obj_get_style(scrl); lv_obj_set_width(ext->label, lv_page_get_fit_width(ta)); - lv_obj_set_pos(ext->label, style_scrl->body.padding.left, - style_scrl->body.padding.top); + lv_obj_set_pos(ext->label, style_scrl->body.padding.left, style_scrl->body.padding.top); lv_label_set_text(ext->label, NULL); /*Refresh the label*/ refr_cursor_area(ta); } } - } else if(sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESSED || - sign == LV_SIGNAL_PRESS_LOST || sign == LV_SIGNAL_RELEASED) { + } else if(sign == LV_SIGNAL_PRESSING || sign == LV_SIGNAL_PRESSED || sign == LV_SIGNAL_PRESS_LOST || + sign == LV_SIGNAL_RELEASED) { update_cursor_position_on_click(ta, sign, (lv_indev_t *)param); } @@ -1585,8 +1565,7 @@ static void get_cursor_style(lv_obj_t * ta, lv_style_t * style_res) lv_style_copy(style_res, label_style); lv_color_t clv_color_tmp = style_res->text.color; /*Make letter color to cursor color*/ style_res->text.color = - style_res->body - .main_color; /*In block mode the letter color will be current background color*/ + style_res->body.main_color; /*In block mode the letter color will be current background color*/ style_res->body.main_color = clv_color_tmp; style_res->body.grad_color = clv_color_tmp; style_res->body.border.color = clv_color_tmp; @@ -1635,8 +1614,8 @@ static void refr_cursor_area(lv_obj_t * ta) lv_label_get_letter_pos(ext->label, cur_pos, &letter_pos); /*If the cursor is out of the text (most right) draw it to the next line*/ - if(letter_pos.x + ext->label->coords.x1 + letter_w > ext->label->coords.x2 && - ext->one_line == 0 && lv_label_get_align(ext->label) != LV_LABEL_ALIGN_RIGHT) { + if(letter_pos.x + ext->label->coords.x1 + letter_w > ext->label->coords.x2 && ext->one_line == 0 && + lv_label_get_align(ext->label) != LV_LABEL_ALIGN_RIGHT) { letter_pos.x = 0; letter_pos.y += letter_h + label_style->text.line_space; @@ -1659,8 +1638,8 @@ static void refr_cursor_area(lv_obj_t * ta) lv_area_t cur_area; if(ext->cursor.type == LV_CURSOR_LINE) { - cur_area.x1 = letter_pos.x + cur_style.body.padding.left - (cur_style.line.width >> 1) - - (cur_style.line.width & 0x1); + cur_area.x1 = + letter_pos.x + cur_style.body.padding.left - (cur_style.line.width >> 1) - (cur_style.line.width & 0x1); cur_area.y1 = letter_pos.y + cur_style.body.padding.top; cur_area.x2 = letter_pos.x + cur_style.body.padding.right + (cur_style.line.width >> 1); cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h; @@ -1677,11 +1656,10 @@ static void refr_cursor_area(lv_obj_t * ta) cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h; } else if(ext->cursor.type == LV_CURSOR_UNDERLINE) { cur_area.x1 = letter_pos.x + cur_style.body.padding.left; - cur_area.y1 = - letter_pos.y + cur_style.body.padding.top + letter_h - (cur_style.line.width >> 1); + cur_area.y1 = letter_pos.y + cur_style.body.padding.top + letter_h - (cur_style.line.width >> 1); cur_area.x2 = letter_pos.x + cur_style.body.padding.right + letter_w; - cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h + - (cur_style.line.width >> 1) + (cur_style.line.width & 0x1); + cur_area.y2 = letter_pos.y + cur_style.body.padding.bottom + letter_h + (cur_style.line.width >> 1) + + (cur_style.line.width & 0x1); } /*Save the new area*/ @@ -1717,8 +1695,7 @@ static void placeholder_update(lv_obj_t * ta) /*Be sure the main label and the placeholder has the same coordinates*/ lv_obj_t * scrl = lv_page_get_scrl(ta); const lv_style_t * style_scrl = lv_obj_get_style(scrl); - lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, - style_scrl->body.padding.top); + lv_obj_set_pos(ext->placeholder, style_scrl->body.padding.left, style_scrl->body.padding.top); lv_obj_set_pos(ext->label, style_scrl->body.padding.left, style_scrl->body.padding.top); lv_obj_set_width(ext->placeholder, lv_page_get_fit_width(ta)); @@ -1728,8 +1705,7 @@ static void placeholder_update(lv_obj_t * ta) } } -static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, - lv_indev_t * click_source) +static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, lv_indev_t * click_source) { if(click_source == NULL) return; @@ -1738,7 +1714,7 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, return; } - lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); + lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta); lv_area_t label_coords; lv_obj_get_coords(ext->label, &label_coords); @@ -1756,7 +1732,6 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, uint16_t index_of_char_at_position; - #if LV_LABEL_TEXT_SEL lv_label_ext_t * ext_label = lv_obj_get_ext_attr(ext->label); bool click_outside_label; @@ -1777,9 +1752,9 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, if(ext->text_sel_en) { if(!ext->text_sel_in_prog && !click_outside_label && sign == LV_SIGNAL_PRESSED) { /*Input device just went down. Store the selection start position*/ - ext->tmp_sel_start = index_of_char_at_position; - ext->tmp_sel_end = LV_LABEL_TEXT_SEL_OFF; - ext->text_sel_in_prog = 1; + ext->tmp_sel_start = index_of_char_at_position; + ext->tmp_sel_end = LV_LABEL_TEXT_SEL_OFF; + ext->text_sel_in_prog = 1; lv_obj_set_drag(lv_page_get_scrl(ta), false); } else if(ext->text_sel_in_prog && sign == LV_SIGNAL_PRESSING) { /*Input device may be moving. Store the end position */ @@ -1790,30 +1765,26 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, } } - if(ext->text_sel_in_prog || sign == LV_SIGNAL_PRESSED) - lv_ta_set_cursor_pos(ta, index_of_char_at_position); + if(ext->text_sel_in_prog || sign == LV_SIGNAL_PRESSED) lv_ta_set_cursor_pos(ta, index_of_char_at_position); if(ext->text_sel_in_prog) { /*If the selected area has changed then update the real values and*/ /*invalidate the text area.*/ if(ext->tmp_sel_start > ext->tmp_sel_end) { - if(ext_label->txt_sel_start != ext->tmp_sel_end || - ext_label->txt_sel_end != ext->tmp_sel_start) { + if(ext_label->txt_sel_start != ext->tmp_sel_end || ext_label->txt_sel_end != ext->tmp_sel_start) { ext_label->txt_sel_start = ext->tmp_sel_end; ext_label->txt_sel_end = ext->tmp_sel_start; lv_obj_invalidate(ta); } } else if(ext->tmp_sel_start < ext->tmp_sel_end) { - if(ext_label->txt_sel_start != ext->tmp_sel_start || - ext_label->txt_sel_end != ext->tmp_sel_end) { + if(ext_label->txt_sel_start != ext->tmp_sel_start || ext_label->txt_sel_end != ext->tmp_sel_end) { ext_label->txt_sel_start = ext->tmp_sel_start; ext_label->txt_sel_end = ext->tmp_sel_end; lv_obj_invalidate(ta); } } else { - if(ext_label->txt_sel_start != LV_LABEL_TEXT_SEL_OFF || - ext_label->txt_sel_end != LV_LABEL_TEXT_SEL_OFF) { + if(ext_label->txt_sel_start != LV_LABEL_TEXT_SEL_OFF || ext_label->txt_sel_end != LV_LABEL_TEXT_SEL_OFF) { ext_label->txt_sel_start = LV_LABEL_TEXT_SEL_OFF; ext_label->txt_sel_end = LV_LABEL_TEXT_SEL_OFF; lv_obj_invalidate(ta); @@ -1836,8 +1807,7 @@ static void update_cursor_position_on_click(lv_obj_t * ta, lv_signal_t sign, index_of_char_at_position = lv_label_get_letter_on(ext->label, &relative_position); } - if(sign == LV_SIGNAL_PRESSED) - lv_ta_set_cursor_pos(ta, index_of_char_at_position); + if(sign == LV_SIGNAL_PRESSED) lv_ta_set_cursor_pos(ta, index_of_char_at_position); #endif } diff --git a/src/lv_objx/lv_ta.h b/src/lv_objx/lv_ta.h index 56d4963a4..cb2c1ca8c 100644 --- a/src/lv_objx/lv_ta.h +++ b/src/lv_objx/lv_ta.h @@ -58,33 +58,33 @@ typedef struct { lv_page_ext_t page; /*Ext. of ancestor*/ /*New data for this type */ - lv_obj_t * label; /*Label of the text area*/ - lv_obj_t * placeholder; /*Place holder label. only visible if text is an empty string*/ - char * pwd_tmp; /*Used to store the original text in password mode*/ + lv_obj_t * label; /*Label of the text area*/ + lv_obj_t * placeholder; /*Place holder label. only visible if text is an empty string*/ + char * pwd_tmp; /*Used to store the original text in password mode*/ const char * accapted_chars; /*Only these characters will be accepted. NULL: accept all*/ uint16_t max_length; /*The max. number of characters. 0: no limit*/ uint16_t pwd_show_time; /*Time to show characters in password mode before change them to '*' */ struct { - const lv_style_t * style; /* Style of the cursor (NULL to use label's style)*/ - lv_coord_t valid_x; /* Used when stepping up/down to a shorter line. - * (Used by the library)*/ - uint16_t pos; /* The current cursor position - * (0: before 1st letter; 1: before 2nd letter ...)*/ - uint16_t blink_time; /*Blink period*/ - lv_area_t area; /* Cursor area relative to the Text Area*/ - uint16_t txt_byte_pos; /* Byte index of the letter after (on) the cursor*/ - lv_cursor_type_t type : 4; /* Shape of the cursor*/ - uint8_t state : 1; /*Cursor is visible now or not (Handled by the library)*/ + const lv_style_t * style; /* Style of the cursor (NULL to use label's style)*/ + lv_coord_t valid_x; /* Used when stepping up/down to a shorter line. + * (Used by the library)*/ + uint16_t pos; /* The current cursor position + * (0: before 1st letter; 1: before 2nd letter ...)*/ + uint16_t blink_time; /*Blink period*/ + lv_area_t area; /* Cursor area relative to the Text Area*/ + uint16_t txt_byte_pos; /* Byte index of the letter after (on) the cursor*/ + lv_cursor_type_t type : 4; /* Shape of the cursor*/ + uint8_t state : 1; /*Cursor is visible now or not (Handled by the library)*/ } cursor; #if LV_LABEL_TEXT_SEL - uint16_t tmp_sel_start; /*Temporary value*/ - uint16_t tmp_sel_end; /*Temporary value*/ + uint16_t tmp_sel_start; /*Temporary value*/ + uint16_t tmp_sel_end; /*Temporary value*/ uint8_t text_sel_in_prog : 1; /*User is in process of selecting */ - uint8_t text_sel_en : 1; /*Text can be selected on this text area*/ + uint8_t text_sel_en : 1; /*Text can be selected on this text area*/ #endif - uint8_t pwd_mode : 1; /*Replace characters with '*' */ - uint8_t one_line : 1; /*One line mode (ignore line breaks)*/ + uint8_t pwd_mode : 1; /*Replace characters with '*' */ + uint8_t one_line : 1; /*One line mode (ignore line breaks)*/ } lv_ta_ext_t; enum { diff --git a/src/lv_objx/lv_table.c b/src/lv_objx/lv_table.c index a20d45b7a..9ecacac30 100644 --- a/src/lv_objx/lv_table.c +++ b/src/lv_objx/lv_table.c @@ -152,9 +152,8 @@ void lv_table_set_cell_value(lv_obj_t * table, uint16_t row, uint16_t col, const format.s.crop = 0; } - ext->cell_data[cell] = - lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/ - strcpy(ext->cell_data[cell] + 1, txt); /*Leave the format byte*/ + ext->cell_data[cell] = lv_mem_realloc(ext->cell_data[cell], strlen(txt) + 2); /*+1: trailing '\0; +1: format byte*/ + strcpy(ext->cell_data[cell] + 1, txt); /*Leave the format byte*/ ext->cell_data[cell][0] = format.format_byte; refr_size(table); } @@ -171,15 +170,13 @@ void lv_table_set_row_cnt(lv_obj_t * table, uint16_t row_cnt) ext->row_cnt = row_cnt; if(ext->row_cnt > 0 && ext->col_cnt > 0) { - ext->cell_data = - lv_mem_realloc(ext->cell_data, ext->row_cnt * ext->col_cnt * sizeof(char *)); + ext->cell_data = lv_mem_realloc(ext->cell_data, ext->row_cnt * ext->col_cnt * sizeof(char *)); /*Initilize the new fields*/ if(old_row_cnt < row_cnt) { uint16_t old_cell_cnt = old_row_cnt * ext->col_cnt; uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt; - memset(&ext->cell_data[old_cell_cnt], 0, - (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); + memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); } } else { lv_mem_free(ext->cell_data); @@ -207,14 +204,12 @@ void lv_table_set_col_cnt(lv_obj_t * table, uint16_t col_cnt) ext->col_cnt = col_cnt; if(ext->row_cnt > 0 && ext->col_cnt > 0) { - ext->cell_data = - lv_mem_realloc(ext->cell_data, ext->row_cnt * ext->col_cnt * sizeof(char *)); + ext->cell_data = lv_mem_realloc(ext->cell_data, ext->row_cnt * ext->col_cnt * sizeof(char *)); /*Initilize the new fields*/ if(old_col_cnt < col_cnt) { uint16_t old_cell_cnt = old_col_cnt * ext->row_cnt; uint32_t new_cell_cnt = ext->col_cnt * ext->row_cnt; - memset(&ext->cell_data[old_cell_cnt], 0, - (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); + memset(&ext->cell_data[old_cell_cnt], 0, (new_cell_cnt - old_cell_cnt) * sizeof(ext->cell_data[0])); } } else { @@ -567,8 +562,8 @@ bool lv_table_get_cell_merge_right(lv_obj_t * table, uint16_t row, uint16_t col) */ const lv_style_t * lv_table_get_style(const lv_obj_t * table, lv_table_style_t type) { - lv_table_ext_t * ext = lv_obj_get_ext_attr(table); - const lv_style_t * style = NULL; + lv_table_ext_t * ext = lv_obj_get_ext_attr(table); + const lv_style_t * style = NULL; switch(type) { case LV_TABLE_STYLE_BG: style = lv_obj_get_style(table); break; @@ -695,8 +690,8 @@ static bool lv_table_design(lv_obj_t * table, const lv_area_t * mask, lv_design_ bool label_mask_ok; label_mask_ok = lv_area_intersect(&label_mask, mask, &cell_area); if(label_mask_ok) { - lv_draw_label(&txt_area, &label_mask, cell_style, opa_scale, - ext->cell_data[cell] + 1, txt_flags, NULL, -1, -1); + lv_draw_label(&txt_area, &label_mask, cell_style, opa_scale, ext->cell_data[cell] + 1, + txt_flags, NULL, -1, -1); } /*Draw lines after '\n's*/ lv_point_t p1; @@ -707,9 +702,8 @@ static bool lv_table_design(lv_obj_t * table, const lv_area_t * mask, lv_design_ for(i = 1; ext->cell_data[cell][i] != '\0'; i++) { if(ext->cell_data[cell][i] == '\n') { ext->cell_data[cell][i] = '\0'; - lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, - cell_style->text.font, cell_style->text.letter_space, - cell_style->text.line_space, + lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, cell_style->text.font, + cell_style->text.letter_space, cell_style->text.line_space, lv_area_get_width(&txt_area), txt_flags); p1.y = txt_area.y1 + txt_size.y + cell_style->text.line_space / 2; @@ -804,8 +798,7 @@ static lv_coord_t get_row_height(lv_obj_t * table, uint16_t row_id) uint16_t row_start = row_id * ext->col_cnt; uint16_t cell; uint16_t col; - lv_coord_t h_max = lv_font_get_line_height(ext->cell_style[0]->text.font) + - ext->cell_style[0]->body.padding.top + + lv_coord_t h_max = lv_font_get_line_height(ext->cell_style[0]->text.font) + ext->cell_style[0]->body.padding.top + ext->cell_style[0]->body.padding.bottom; for(cell = row_start, col = 0; cell < row_start + ext->col_cnt; cell++, col++) { @@ -833,22 +826,18 @@ static lv_coord_t get_row_height(lv_obj_t * table, uint16_t row_id) /*With text crop assume 1 line*/ if(format.s.crop) { - h_max = - LV_MATH_MAX(lv_font_get_line_height(cell_style->text.font) + - cell_style->body.padding.top + cell_style->body.padding.bottom, - h_max); + h_max = LV_MATH_MAX(lv_font_get_line_height(cell_style->text.font) + cell_style->body.padding.top + + cell_style->body.padding.bottom, + h_max); } /*Without text crop calculate the height of the text in the cell*/ else { txt_w -= cell_style->body.padding.left + cell_style->body.padding.right; lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, cell_style->text.font, - cell_style->text.letter_space, cell_style->text.line_space, txt_w, - LV_TXT_FLAG_NONE); + cell_style->text.letter_space, cell_style->text.line_space, txt_w, LV_TXT_FLAG_NONE); - h_max = LV_MATH_MAX(txt_size.y + cell_style->body.padding.top + - cell_style->body.padding.bottom, - h_max); + h_max = LV_MATH_MAX(txt_size.y + cell_style->body.padding.top + cell_style->body.padding.bottom, h_max); cell += col_merge; col += col_merge; } diff --git a/src/lv_objx/lv_tabview.c b/src/lv_objx/lv_tabview.c index 0b2c27695..d4b1a3062 100644 --- a/src/lv_objx/lv_tabview.c +++ b/src/lv_objx/lv_tabview.c @@ -19,8 +19,7 @@ *********************/ #if LV_USE_ANIMATION #ifndef LV_TABVIEW_DEF_ANIM_TIME -#define LV_TABVIEW_DEF_ANIM_TIME \ - 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */ +#define LV_TABVIEW_DEF_ANIM_TIME 300 /*Animation time of focusing to the a list element [ms] (0: no animation) */ #endif #else #undef LV_TABVIEW_DEF_ANIM_TIME @@ -94,9 +93,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->btns = NULL; ext->btns_pos = LV_TABVIEW_BTNS_POS_TOP; #if LV_USE_ANIMATION - ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME; + ext->anim_time = LV_TABVIEW_DEF_ANIM_TIME; #endif - ext->btns_hide = 0; + ext->btns_hide = 0; /*The signal and design functions are not copied so set them here*/ lv_obj_set_signal_cb(new_tabview, lv_tabview_signal); @@ -116,22 +115,21 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_obj_get_height_fit(lv_obj_get_parent(new_tabview))); ext->content = lv_cont_create(new_tabview, NULL); - ext->btns = lv_btnm_create(new_tabview, NULL); - ext->indic = lv_obj_create(ext->btns, NULL); + ext->btns = lv_btnm_create(new_tabview, NULL); + ext->indic = lv_obj_create(ext->btns, NULL); lv_obj_set_height(ext->btns, 3 * LV_DPI / 4); lv_btnm_set_map(ext->btns, tab_def); lv_obj_set_event_cb(ext->btns, tab_btnm_event_cb); - + lv_obj_set_width(ext->indic, LV_DPI); lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); lv_obj_set_click(ext->indic, false); - + lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); lv_cont_set_style(ext->content, &lv_style_transp_tight); - lv_obj_set_height(ext->content, - lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns)); + lv_obj_set_height(ext->content, lv_obj_get_height(new_tabview) - lv_obj_get_height(ext->btns)); lv_obj_align(ext->content, ext->btns, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); /*Set the default styles*/ @@ -142,10 +140,8 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, th->style.tabview.btn.bg); lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_REL, th->style.tabview.btn.rel); lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_PR, th->style.tabview.btn.pr); - lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, - th->style.tabview.btn.tgl_rel); - lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, - th->style.tabview.btn.tgl_pr); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_REL, th->style.tabview.btn.tgl_rel); + lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_TGL_PR, th->style.tabview.btn.tgl_pr); } else { lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BG, &lv_style_plain); lv_tabview_set_style(new_tabview, LV_TABVIEW_STYLE_BTN_BG, &lv_style_transp); @@ -161,7 +157,7 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) ext->indic = lv_obj_create(ext->btns, copy_ext->indic); ext->content = lv_cont_create(new_tabview, copy_ext->content); #if LV_USE_ANIMATION - ext->anim_time = copy_ext->anim_time; + ext->anim_time = copy_ext->anim_time; #endif ext->tab_name_ptr = lv_mem_alloc(sizeof(char *)); @@ -176,12 +172,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) for(i = 0; i < copy_ext->tab_cnt; i++) { new_tab = lv_tabview_add_tab(new_tabview, copy_ext->tab_name_ptr[i]); copy_tab = lv_tabview_get_tab(copy, i); - lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, - lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG)); - lv_page_set_style(new_tab, LV_PAGE_STYLE_SCRL, - lv_page_get_style(copy_tab, LV_PAGE_STYLE_SCRL)); - lv_page_set_style(new_tab, LV_PAGE_STYLE_SB, - lv_page_get_style(copy_tab, LV_PAGE_STYLE_SB)); + lv_page_set_style(new_tab, LV_PAGE_STYLE_BG, lv_page_get_style(copy_tab, LV_PAGE_STYLE_BG)); + lv_page_set_style(new_tab, LV_PAGE_STYLE_SCRL, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SCRL)); + lv_page_set_style(new_tab, LV_PAGE_STYLE_SB, lv_page_get_style(copy_tab, LV_PAGE_STYLE_SB)); } /*Refresh the style with new signal function*/ @@ -248,7 +241,7 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt * 2)); break; } - + lv_mem_assert(ext->tab_name_ptr); if(ext->tab_name_ptr == NULL) return NULL; @@ -265,15 +258,15 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: if(ext->tab_cnt == 1) { - ext->tab_name_ptr[0] = name_dm; - ext->tab_name_ptr[1] = ""; + ext->tab_name_ptr[0] = name_dm; + ext->tab_name_ptr[1] = ""; } else { - ext->tab_name_ptr[ext->tab_cnt * 2 - 3] = "\n"; - ext->tab_name_ptr[ext->tab_cnt * 2 - 2] = name_dm; - ext->tab_name_ptr[ext->tab_cnt * 2 - 1] = ""; + ext->tab_name_ptr[ext->tab_cnt * 2 - 3] = "\n"; + ext->tab_name_ptr[ext->tab_cnt * 2 - 2] = name_dm; + ext->tab_name_ptr[ext->tab_cnt * 2 - 1] = ""; } break; - } + } /* The button matrix's map still points to the old `tab_name_ptr` which might be freed by * `lv_mem_realloc`. So make its current map invalid*/ @@ -291,14 +284,12 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name) switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - indic_size = - (lv_obj_get_width(tabview) - style_tabs->body.padding.inner * (ext->tab_cnt - 1) - - style_tabs->body.padding.left - style_tabs->body.padding.right) / - ext->tab_cnt; + indic_size = (lv_obj_get_width(tabview) - style_tabs->body.padding.inner * (ext->tab_cnt - 1) - + style_tabs->body.padding.left - style_tabs->body.padding.right) / + ext->tab_cnt; lv_obj_set_width(ext->indic, indic_size); - lv_obj_set_x(ext->indic, indic_size * ext->tab_cur + - style_tabs->body.padding.inner * ext->tab_cur + - style_tabs->body.padding.left); + lv_obj_set_x(ext->indic, indic_size * ext->tab_cur + style_tabs->body.padding.inner * ext->tab_cur + + style_tabs->body.padding.left); break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: @@ -359,27 +350,24 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en) switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - cont_x = -(lv_obj_get_width(tabview) * id + style->body.padding.inner * id + - style->body.padding.left); + cont_x = -(lv_obj_get_width(tabview) * id + style->body.padding.inner * id + style->body.padding.left); break; case LV_TABVIEW_BTNS_POS_LEFT: - cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + - style->body.padding.inner * id + - style->body.padding.left) + - lv_obj_get_width(ext->btns); + cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + style->body.padding.inner * id + + style->body.padding.left) + + lv_obj_get_width(ext->btns); break; case LV_TABVIEW_BTNS_POS_RIGHT: - cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + - style->body.padding.inner * id + - style->body.padding.left); + cont_x = -((lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)) * id + style->body.padding.inner * id + + style->body.padding.left); break; } - if( anim_en == false + if(anim_en == false #if LV_USE_ANIMATION - || ext->anim_time == 0 + || ext->anim_time == 0 #endif - ) { + ) { lv_obj_set_x(ext->content, cont_x); } else { #if LV_USE_ANIMATION @@ -411,45 +399,41 @@ void lv_tabview_set_tab_act(lv_obj_t * tabview, uint16_t id, bool anim_en) indic_size = lv_obj_get_width(ext->indic); indic_pos = indic_size * id + tabs_style->body.padding.inner * id + tabs_style->body.padding.left; break; - case LV_TABVIEW_BTNS_POS_LEFT: - case LV_TABVIEW_BTNS_POS_RIGHT: + case LV_TABVIEW_BTNS_POS_LEFT: + case LV_TABVIEW_BTNS_POS_RIGHT: indic_size = lv_obj_get_height(ext->indic); indic_pos = tabs_style->body.padding.top + id * (indic_size + tabs_style->body.padding.inner); break; } - if( anim_en == false + if(anim_en == false #if LV_USE_ANIMATION - || ext->anim_time == 0 + || ext->anim_time == 0 #endif - ) { + ) { switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: - case LV_TABVIEW_BTNS_POS_BOTTOM: - lv_obj_set_x(ext->indic, indic_pos); - break; + case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_x(ext->indic, indic_pos); break; case LV_TABVIEW_BTNS_POS_LEFT: - case LV_TABVIEW_BTNS_POS_RIGHT: - lv_obj_set_y(ext->indic, indic_pos); - break; - } + case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_y(ext->indic, indic_pos); break; + } } else { #if LV_USE_ANIMATION lv_anim_t a; - a.var = ext->indic; + a.var = ext->indic; switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - a.start = lv_obj_get_x(ext->indic); - a.end = indic_pos; - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; + a.start = lv_obj_get_x(ext->indic); + a.end = indic_pos; + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_x; break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: - a.start = lv_obj_get_y(ext->indic); - a.end = indic_pos; - a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; + a.start = lv_obj_get_y(ext->indic); + a.end = indic_pos; + a.exec_cb = (lv_anim_exec_cb_t)lv_obj_set_y; break; } @@ -488,10 +472,10 @@ void lv_tabview_set_anim_time(lv_obj_t * tabview, uint16_t anim_time) { #if LV_USE_ANIMATION lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); - ext->anim_time = anim_time; + ext->anim_time = anim_time; #else - (void) tabview; - (void) anim_time; + (void)tabview; + (void)anim_time; #endif } @@ -515,29 +499,19 @@ void lv_tabview_set_style(lv_obj_t * tabview, lv_tabview_style_t type, const lv_ lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_REL, style); tabview_realign(tabview); break; - case LV_TABVIEW_STYLE_BTN_PR: - lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_PR, style); - break; - case LV_TABVIEW_STYLE_BTN_TGL_REL: - lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_REL, style); - break; - case LV_TABVIEW_STYLE_BTN_TGL_PR: - lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR, style); - break; + case LV_TABVIEW_STYLE_BTN_PR: lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_PR, style); break; + case LV_TABVIEW_STYLE_BTN_TGL_REL: lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_REL, style); break; + case LV_TABVIEW_STYLE_BTN_TGL_PR: lv_btnm_set_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR, style); break; case LV_TABVIEW_STYLE_INDIC: lv_obj_set_style(ext->indic, style); switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: - case LV_TABVIEW_BTNS_POS_BOTTOM: - lv_obj_set_height(ext->indic, style->body.padding.inner); - break; + case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_set_height(ext->indic, style->body.padding.inner); break; case LV_TABVIEW_BTNS_POS_LEFT: - case LV_TABVIEW_BTNS_POS_RIGHT: - lv_obj_set_width(ext->indic, style->body.padding.inner); - break; + case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_width(ext->indic, style->body.padding.inner); break; } - + tabview_realign(tabview); break; } @@ -639,7 +613,7 @@ uint16_t lv_tabview_get_anim_time(const lv_obj_t * tabview) lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview); return ext->anim_time; #else - (void) tabview; + (void)tabview; return 0; #endif } @@ -658,18 +632,10 @@ const lv_style_t * lv_tabview_get_style(const lv_obj_t * tabview, lv_tabview_sty switch(type) { case LV_TABVIEW_STYLE_BG: style = lv_obj_get_style(tabview); break; case LV_TABVIEW_STYLE_BTN_BG: style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BG); break; - case LV_TABVIEW_STYLE_BTN_REL: - style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_REL); - break; - case LV_TABVIEW_STYLE_BTN_PR: - style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_PR); - break; - case LV_TABVIEW_STYLE_BTN_TGL_REL: - style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_REL); - break; - case LV_TABVIEW_STYLE_BTN_TGL_PR: - style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR); - break; + case LV_TABVIEW_STYLE_BTN_REL: style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_REL); break; + case LV_TABVIEW_STYLE_BTN_PR: style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_PR); break; + case LV_TABVIEW_STYLE_BTN_TGL_REL: style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_REL); break; + case LV_TABVIEW_STYLE_BTN_TGL_PR: style = lv_btnm_get_style(ext->btns, LV_BTNM_STYLE_BTN_TGL_PR); break; default: style = NULL; break; } @@ -737,8 +703,7 @@ static lv_res_t lv_tabview_signal(lv_obj_t * tabview, lv_signal_t sign, void * p lv_indev_t * indev = lv_indev_get_act(); lv_indev_type_t indev_type = lv_indev_get_type(indev); if(indev_type == LV_INDEV_TYPE_KEYPAD || - (indev_type == LV_INDEV_TYPE_ENCODER && - lv_group_get_editing(lv_obj_get_group(tabview)))) { + (indev_type == LV_INDEV_TYPE_ENCODER && lv_group_get_editing(lv_obj_get_group(tabview)))) { lv_event_send(ext->btns, LV_EVENT_CLICKED, lv_event_get_data()); } } else if(sign == LV_SIGNAL_FOCUS || sign == LV_SIGNAL_DEFOCUS || sign == LV_SIGNAL_CONTROL) { @@ -871,8 +836,7 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage) lv_coord_t x_diff = point_act.x - ext->point_last.x; lv_coord_t y_diff = point_act.y - ext->point_last.y; - if(!ext->scroll_ver && - (x_diff >= LV_INDEV_DEF_DRAG_LIMIT || x_diff <= -LV_INDEV_DEF_DRAG_LIMIT)) { + if(!ext->scroll_ver && (x_diff >= LV_INDEV_DEF_DRAG_LIMIT || x_diff <= -LV_INDEV_DEF_DRAG_LIMIT)) { ext->draging = 1; /*Check if the page is on the edge */ if((lv_page_on_edge(tabpage, LV_PAGE_EDGE_LEFT) && x_diff > 0) || @@ -900,7 +864,7 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage) ext->point_last.y = point_act.y; /*Move the indicator*/ - const lv_style_t * tabs_style = lv_obj_get_style(ext->btns); + const lv_style_t * tabs_style = lv_obj_get_style(ext->btns); lv_coord_t indic_size; lv_coord_t p; lv_coord_t indic_y; @@ -911,19 +875,16 @@ static void tabpage_pressing_handler(lv_obj_t * tabview, lv_obj_t * tabpage) case LV_TABVIEW_BTNS_POS_BOTTOM: indic_size = lv_obj_get_width(ext->indic); indic_style = lv_obj_get_style(ext->indic); - p = ((tabpage->coords.x1 - tabview->coords.x1) * - (indic_size + tabs_style->body.padding.inner)) / - lv_obj_get_width(tabview); + p = ((tabpage->coords.x1 - tabview->coords.x1) * (indic_size + tabs_style->body.padding.inner)) / + lv_obj_get_width(tabview); - lv_obj_set_x(ext->indic, indic_size * ext->tab_cur + - tabs_style->body.padding.inner * ext->tab_cur + - indic_style->body.padding.left - p); + lv_obj_set_x(ext->indic, indic_size * ext->tab_cur + tabs_style->body.padding.inner * ext->tab_cur + + indic_style->body.padding.left - p); break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: indic_size = lv_obj_get_height(ext->indic); - indic_y = tabs_style->body.padding.top + - ext->tab_cur * (indic_size + tabs_style->body.padding.inner); + indic_y = tabs_style->body.padding.top + ext->tab_cur * (indic_size + tabs_style->body.padding.inner); lv_obj_set_y(ext->indic, indic_y); break; } @@ -1018,17 +979,17 @@ static void tabview_realign(lv_obj_t * tabview) switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - indic_size = - (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) - - style_btn_bg->body.padding.left - style_btn_bg->body.padding.right) / - ext->tab_cnt; + indic_size = (lv_obj_get_width(tabview) - style_btn_bg->body.padding.inner * (ext->tab_cnt - 1) - + style_btn_bg->body.padding.left - style_btn_bg->body.padding.right) / + ext->tab_cnt; lv_obj_set_width(ext->indic, indic_size); break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_height(ext->btns, lv_obj_get_height(tabview)); - max_h = lv_obj_get_height(ext->btns) - style_btn_bg->body.padding.top - style_btn_bg->body.padding.bottom; + max_h = + lv_obj_get_height(ext->btns) - style_btn_bg->body.padding.top - style_btn_bg->body.padding.bottom; indic_size = max_h - ((ext->tab_cnt - 1) * style_btn_bg->body.padding.inner); indic_size = indic_size / ext->tab_cnt; indic_size--; /*-1 because e.g. height = 100 means 101 pixels (0..100)*/ @@ -1042,17 +1003,15 @@ static void tabview_realign(lv_obj_t * tabview) switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - btns_size = lv_font_get_line_height(style_btn_rel->text.font) + - style_btn_rel->body.padding.top + - style_btn_rel->body.padding.bottom + - style_btn_bg->body.padding.top + style_btn_bg->body.padding.bottom; + btns_size = lv_font_get_line_height(style_btn_rel->text.font) + style_btn_rel->body.padding.top + + style_btn_rel->body.padding.bottom + style_btn_bg->body.padding.top + + style_btn_bg->body.padding.bottom; lv_obj_set_height(ext->btns, btns_size); break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: btns_size = lv_font_get_glyph_width(style_btn_rel->text.font, 'A', '\0') + - style_btn_rel->body.padding.left + - style_btn_rel->body.padding.right + + style_btn_rel->body.padding.left + style_btn_rel->body.padding.right + style_btn_bg->body.padding.left + style_btn_bg->body.padding.right; lv_obj_set_width(ext->btns, btns_size); break; @@ -1064,9 +1023,7 @@ static void tabview_realign(lv_obj_t * tabview) lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); break; case LV_TABVIEW_BTNS_POS_LEFT: - case LV_TABVIEW_BTNS_POS_RIGHT: - lv_obj_set_height(ext->content, lv_obj_get_height(tabview)); - break; + case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_set_height(ext->content, lv_obj_get_height(tabview)); break; } switch(ext->btns_pos) { @@ -1077,8 +1034,7 @@ static void tabview_realign(lv_obj_t * tabview) lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); - lv_obj_set_height(ext->content, - lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); + lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); // lv_obj_set_height(ext->btns, 3 * LV_DPI / 4); @@ -1091,8 +1047,7 @@ static void tabview_realign(lv_obj_t * tabview) lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); - lv_obj_set_height(ext->content, - lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); + lv_obj_set_height(ext->content, lv_obj_get_height(tabview) - lv_obj_get_height(ext->btns)); break; case LV_TABVIEW_BTNS_POS_LEFT: lv_obj_align(ext->btns, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); @@ -1101,8 +1056,7 @@ static void tabview_realign(lv_obj_t * tabview) lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); - lv_obj_set_width(ext->content, - lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)); + lv_obj_set_width(ext->content, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)); lv_obj_set_height(ext->btns, lv_obj_get_height(tabview)); lv_obj_set_width(ext->indic, style_btn_bg->body.padding.inner); @@ -1114,8 +1068,7 @@ static void tabview_realign(lv_obj_t * tabview) lv_cont_set_fit2(ext->content, LV_FIT_TIGHT, LV_FIT_NONE); lv_cont_set_layout(ext->content, LV_LAYOUT_ROW_T); - lv_obj_set_width(ext->content, - lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)); + lv_obj_set_width(ext->content, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns)); lv_obj_set_height(ext->btns, lv_obj_get_height(tabview)); lv_obj_set_width(ext->indic, style_btn_bg->body.padding.inner); @@ -1125,45 +1078,29 @@ static void tabview_realign(lv_obj_t * tabview) lv_obj_t * pages = lv_obj_get_child(ext->content, NULL); while(pages != NULL) { - if(lv_obj_get_signal_cb(pages) == - tabpage_signal) { /*Be sure adjust only the pages (user can other things)*/ + if(lv_obj_get_signal_cb(pages) == tabpage_signal) { /*Be sure adjust only the pages (user can other things)*/ switch(ext->btns_pos) { case LV_TABVIEW_BTNS_POS_TOP: case LV_TABVIEW_BTNS_POS_BOTTOM: - lv_obj_set_size( - pages, - lv_obj_get_width(tabview), - lv_obj_get_height(ext->content) - ); + lv_obj_set_size(pages, lv_obj_get_width(tabview), lv_obj_get_height(ext->content)); break; case LV_TABVIEW_BTNS_POS_LEFT: case LV_TABVIEW_BTNS_POS_RIGHT: - lv_obj_set_size( - pages, - lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns), - lv_obj_get_height(ext->content) - ); + lv_obj_set_size(pages, lv_obj_get_width(tabview) - lv_obj_get_width(ext->btns), + lv_obj_get_height(ext->content)); break; - } + } } pages = lv_obj_get_child(ext->content, pages); } if(!ext->btns_hide) { switch(ext->btns_pos) { - case LV_TABVIEW_BTNS_POS_TOP: - lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); - break; - case LV_TABVIEW_BTNS_POS_BOTTOM: - lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); - break; - case LV_TABVIEW_BTNS_POS_LEFT: - lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_RIGHT, 0, 0); - break; - case LV_TABVIEW_BTNS_POS_RIGHT: - lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); - break; - } + case LV_TABVIEW_BTNS_POS_TOP: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); break; + case LV_TABVIEW_BTNS_POS_BOTTOM: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); break; + case LV_TABVIEW_BTNS_POS_LEFT: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_RIGHT, 0, 0); break; + case LV_TABVIEW_BTNS_POS_RIGHT: lv_obj_align(ext->indic, ext->btns, LV_ALIGN_IN_TOP_LEFT, 0, 0); break; + } } lv_tabview_set_tab_act(tabview, ext->tab_cur, false); diff --git a/src/lv_objx/lv_tabview.h b/src/lv_objx/lv_tabview.h index 9482d7bff..225f204e5 100644 --- a/src/lv_objx/lv_tabview.h +++ b/src/lv_objx/lv_tabview.h @@ -42,12 +42,7 @@ extern "C" { * TYPEDEFS **********************/ -enum { - LV_TABVIEW_BTNS_POS_TOP, - LV_TABVIEW_BTNS_POS_BOTTOM, - LV_TABVIEW_BTNS_POS_LEFT, - LV_TABVIEW_BTNS_POS_RIGHT -}; +enum { LV_TABVIEW_BTNS_POS_TOP, LV_TABVIEW_BTNS_POS_BOTTOM, LV_TABVIEW_BTNS_POS_LEFT, LV_TABVIEW_BTNS_POS_RIGHT }; typedef uint8_t lv_tabview_btns_pos_t; /*Data of tab*/ diff --git a/src/lv_objx/lv_tileview.c b/src/lv_objx/lv_tileview.c index 5e2103148..f72742cb9 100644 --- a/src/lv_objx/lv_tileview.c +++ b/src/lv_objx/lv_tileview.c @@ -73,11 +73,10 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) lv_mem_assert(ext); if(ext == NULL) return NULL; if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_cb(new_tileview); - if(ancestor_scrl_signal == NULL) - ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview)); + if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_cb(lv_page_get_scrl(new_tileview)); if(ancestor_design == NULL) ancestor_design = lv_obj_get_design_cb(new_tileview); - /*Initialize the allocated 'ext' */ + /*Initialize the allocated 'ext' */ #if LV_USE_ANIMATION ext->anim_time = LV_TILEVIEW_DEF_ANIM_TIME; #endif @@ -112,7 +111,7 @@ lv_obj_t * lv_tileview_create(lv_obj_t * par, const lv_obj_t * copy) ext->act_id.x = copy_ext->act_id.x; ext->act_id.y = copy_ext->act_id.y; #if LV_USE_ANIMATION - ext->anim_time = copy_ext->anim_time; + ext->anim_time = copy_ext->anim_time; #endif /*Refresh the style with new signal function*/ @@ -354,19 +353,16 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void /*Set horizontal drag constraint if no vertical constraint an dragged to valid x * direction */ - if(ext->drag_ver == 0 && ((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= - -LV_INDEV_DEF_DRAG_LIMIT) || - (ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= - LV_INDEV_DEF_DRAG_LIMIT))) { + if(ext->drag_ver == 0 && + ((ext->drag_right_en && indev->proc.types.pointer.drag_sum.x <= -LV_INDEV_DEF_DRAG_LIMIT) || + (ext->drag_left_en && indev->proc.types.pointer.drag_sum.x >= LV_INDEV_DEF_DRAG_LIMIT))) { ext->drag_hor = 1; } /*Set vertical drag constraint if no horizontal constraint an dragged to valid y * direction */ if(ext->drag_hor == 0 && - ((ext->drag_bottom_en && - indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DEF_DRAG_LIMIT) || - (ext->drag_top_en && - indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DEF_DRAG_LIMIT))) { + ((ext->drag_bottom_en && indev->proc.types.pointer.drag_sum.y <= -LV_INDEV_DEF_DRAG_LIMIT) || + (ext->drag_top_en && indev->proc.types.pointer.drag_sum.y >= LV_INDEV_DEF_DRAG_LIMIT))) { ext->drag_ver = 1; } @@ -387,8 +383,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_coord_t h = lv_obj_get_height(tileview); lv_coord_t w = lv_obj_get_width(tileview); if(ext->drag_top_en == 0) { - if(y > -(ext->act_id.y * h) && indev->proc.types.pointer.vect.y > 0 && - ext->drag_hor == 0) { + if(y > -(ext->act_id.y * h) && indev->proc.types.pointer.vect.y > 0 && ext->drag_hor == 0) { #if LV_USE_ANIMATION if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && @@ -401,8 +396,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_y(scrl, -ext->act_id.y * h + style_bg->body.padding.top); } } - if(ext->drag_bottom_en == 0 && indev->proc.types.pointer.vect.y < 0 && - ext->drag_hor == 0) { + if(ext->drag_bottom_en == 0 && indev->proc.types.pointer.vect.y < 0 && ext->drag_hor == 0) { if(y < -(ext->act_id.y * h)) { #if LV_USE_ANIMATION if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && @@ -417,8 +411,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_y(scrl, -ext->act_id.y * h + style_bg->body.padding.top); } if(ext->drag_left_en == 0) { - if(x > -(ext->act_id.x * w) && indev->proc.types.pointer.vect.x > 0 && - ext->drag_ver == 0) { + if(x > -(ext->act_id.x * w) && indev->proc.types.pointer.vect.x > 0 && ext->drag_ver == 0) { #if LV_USE_ANIMATION if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && ext->page.edge_flash.right_ip == 0 && ext->page.edge_flash.top_ip == 0 && @@ -431,8 +424,7 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void lv_obj_set_x(scrl, -ext->act_id.x * w + style_bg->body.padding.left); } } - if(ext->drag_right_en == 0 && indev->proc.types.pointer.vect.x < 0 && - ext->drag_ver == 0) { + if(ext->drag_right_en == 0 && indev->proc.types.pointer.vect.x < 0 && ext->drag_ver == 0) { if(x < -(ext->act_id.x * w)) { #if LV_USE_ANIMATION if(ext->page.edge_flash.enabled && ext->page.edge_flash.left_ip == 0 && @@ -449,11 +441,9 @@ static lv_res_t lv_tileview_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void /*Apply the drag constraints*/ if(ext->drag_ver == 0) - lv_obj_set_y(scrl, -ext->act_id.y * lv_obj_get_height(tileview) + - style_bg->body.padding.top); + lv_obj_set_y(scrl, -ext->act_id.y * lv_obj_get_height(tileview) + style_bg->body.padding.top); if(ext->drag_hor == 0) - lv_obj_set_x(scrl, -ext->act_id.x * lv_obj_get_width(tileview) + - style_bg->body.padding.left); + lv_obj_set_x(scrl, -ext->act_id.x * lv_obj_get_width(tileview) + style_bg->body.padding.left); } } return res; @@ -554,14 +544,10 @@ static bool set_valid_drag_dirs(lv_obj_t * tileview) uint16_t i; for(i = 0; ext->valid_pos[i].x != LV_COORD_MIN; i++) { - if(ext->valid_pos[i].x == ext->act_id.x && ext->valid_pos[i].y == ext->act_id.y - 1) - ext->drag_top_en = 1; - if(ext->valid_pos[i].x == ext->act_id.x && ext->valid_pos[i].y == ext->act_id.y + 1) - ext->drag_bottom_en = 1; - if(ext->valid_pos[i].x == ext->act_id.x - 1 && ext->valid_pos[i].y == ext->act_id.y) - ext->drag_left_en = 1; - if(ext->valid_pos[i].x == ext->act_id.x + 1 && ext->valid_pos[i].y == ext->act_id.y) - ext->drag_right_en = 1; + if(ext->valid_pos[i].x == ext->act_id.x && ext->valid_pos[i].y == ext->act_id.y - 1) ext->drag_top_en = 1; + if(ext->valid_pos[i].x == ext->act_id.x && ext->valid_pos[i].y == ext->act_id.y + 1) ext->drag_bottom_en = 1; + if(ext->valid_pos[i].x == ext->act_id.x - 1 && ext->valid_pos[i].y == ext->act_id.y) ext->drag_left_en = 1; + if(ext->valid_pos[i].x == ext->act_id.x + 1 && ext->valid_pos[i].y == ext->act_id.y) ext->drag_right_en = 1; } return true; diff --git a/src/lv_objx/lv_win.c b/src/lv_objx/lv_win.c index 54fb1f74a..31c3ba322 100644 --- a/src/lv_objx/lv_win.c +++ b/src/lv_objx/lv_win.c @@ -270,9 +270,7 @@ void lv_win_set_style(lv_obj_t * win, lv_win_style_t type, const lv_style_t * st lv_win_realign(win); break; case LV_WIN_STYLE_CONTENT_BG: lv_page_set_style(ext->page, LV_PAGE_STYLE_BG, style); break; - case LV_WIN_STYLE_CONTENT_SCRL: - lv_page_set_style(ext->page, LV_PAGE_STYLE_SCRL, style); - break; + case LV_WIN_STYLE_CONTENT_SCRL: lv_page_set_style(ext->page, LV_PAGE_STYLE_SCRL, style); break; case LV_WIN_STYLE_SB: lv_page_set_style(ext->page, LV_PAGE_STYLE_SB, style); break; case LV_WIN_STYLE_HEADER: lv_obj_set_style(ext->header, style); @@ -411,9 +409,7 @@ const lv_style_t * lv_win_get_style(const lv_obj_t * win, lv_win_style_t type) switch(type) { case LV_WIN_STYLE_BG: style = lv_obj_get_style(win); break; case LV_WIN_STYLE_CONTENT_BG: style = lv_page_get_style(ext->page, LV_PAGE_STYLE_BG); break; - case LV_WIN_STYLE_CONTENT_SCRL: - style = lv_page_get_style(ext->page, LV_PAGE_STYLE_SCRL); - break; + case LV_WIN_STYLE_CONTENT_SCRL: style = lv_page_get_style(ext->page, LV_PAGE_STYLE_SCRL); break; case LV_WIN_STYLE_SB: style = lv_page_get_style(ext->page, LV_PAGE_STYLE_SB); break; case LV_WIN_STYLE_HEADER: style = lv_obj_get_style(ext->header); break; case LV_WIN_STYLE_BTN_REL: style = ext->style_btn_rel; break; @@ -468,7 +464,7 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param) while(child != NULL) { if(lv_obj_is_protected(child, LV_PROTECT_PARENT) == false) { lv_obj_t * tmp = child; - child = lv_obj_get_child(win, child); /*Get the next child before move this*/ + child = lv_obj_get_child(win, child); /*Get the next child before move this*/ lv_obj_set_parent(tmp, page); } else { child = lv_obj_get_child(win, child); @@ -479,8 +475,7 @@ static lv_res_t lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param) lv_win_realign(win); } else if(sign == LV_SIGNAL_CORD_CHG) { /*If the size is changed refresh the window*/ - if(lv_area_get_width(param) != lv_obj_get_width(win) || - lv_area_get_height(param) != lv_obj_get_height(win)) { + if(lv_area_get_width(param) != lv_obj_get_width(win) || lv_area_get_height(param) != lv_obj_get_height(win)) { lv_win_realign(win); } } else if(sign == LV_SIGNAL_CLEANUP) { @@ -514,8 +509,7 @@ static void lv_win_realign(lv_obj_t * win) const lv_style_t * header_style = lv_win_get_style(win, LV_WIN_STYLE_HEADER); lv_obj_set_size(ext->header, lv_obj_get_width(win), - ext->btn_size + header_style->body.padding.top + - header_style->body.padding.bottom); + ext->btn_size + header_style->body.padding.top + header_style->body.padding.bottom); bool first_btn = true; lv_obj_t * btn; @@ -526,24 +520,21 @@ static void lv_win_realign(lv_obj_t * win) while(btn != NULL) { lv_obj_set_size(btn, ext->btn_size, ext->btn_size); if(first_btn) { - lv_obj_align(btn, ext->header, LV_ALIGN_IN_RIGHT_MID, -header_style->body.padding.right, - 0); + lv_obj_align(btn, ext->header, LV_ALIGN_IN_RIGHT_MID, -header_style->body.padding.right, 0); first_btn = false; } else { - lv_obj_align(btn, btn_prev, LV_ALIGN_OUT_LEFT_MID, -header_style->body.padding.inner, - 0); + lv_obj_align(btn, btn_prev, LV_ALIGN_OUT_LEFT_MID, -header_style->body.padding.inner, 0); } btn_prev = btn; btn = lv_obj_get_child_back(ext->header, btn); } - const lv_style_t * style_header = lv_win_get_style(win, LV_WIN_STYLE_HEADER); + const lv_style_t * style_header = lv_win_get_style(win, LV_WIN_STYLE_HEADER); lv_obj_align(ext->title, NULL, LV_ALIGN_IN_LEFT_MID, style_header->body.padding.left, 0); lv_obj_set_pos(ext->header, 0, 0); - lv_obj_set_size(ext->page, lv_obj_get_width(win), - lv_obj_get_height(win) - lv_obj_get_height(ext->header)); + lv_obj_set_size(ext->page, lv_obj_get_width(win), lv_obj_get_height(win) - lv_obj_get_height(ext->header)); lv_obj_align(ext->page, ext->header, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0); } diff --git a/src/lv_themes/lv_theme_alien.c b/src/lv_themes/lv_theme_alien.c index dceed68ca..43747038f 100644 --- a/src/lv_themes/lv_theme_alien.c +++ b/src/lv_themes/lv_theme_alien.c @@ -855,8 +855,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/src/lv_themes/lv_theme_default.c b/src/lv_themes/lv_theme_default.c index 46a9e0a68..0d33fdb0d 100644 --- a/src/lv_themes/lv_theme_default.c +++ b/src/lv_themes/lv_theme_default.c @@ -358,8 +358,7 @@ static void style_mod(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_ORANGE; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_ORANGE, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_ORANGE, LV_OPA_70); @@ -382,8 +381,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index 23317973a..2437de779 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -806,18 +806,13 @@ static void style_mod(lv_group_t * group, lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 90, 70); /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; - style->body.main_color = - lv_color_mix(style->body.main_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); - style->body.grad_color = - lv_color_mix(style->body.grad_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); - style->body.shadow.color = - lv_color_mix(style->body.shadow.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_60); + style->body.main_color = lv_color_mix(style->body.main_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); + style->body.grad_color = lv_color_mix(style->body.grad_color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); + style->body.shadow.color = lv_color_mix(style->body.shadow.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_60); - style->text.color = - lv_color_mix(style->text.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); + style->text.color = lv_color_mix(style->text.color, lv_color_hsv_to_rgb(_hue, 90, 70), LV_OPA_70); #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -834,8 +829,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 99095efdb..f6b0c2a73 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -413,8 +413,7 @@ static void style_mod(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -431,8 +430,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_BLACK; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/src/lv_themes/lv_theme_nemo.c b/src/lv_themes/lv_theme_nemo.c index 544f80682..2fd2df939 100644 --- a/src/lv_themes/lv_theme_nemo.c +++ b/src/lv_themes/lv_theme_nemo.c @@ -828,8 +828,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70); diff --git a/src/lv_themes/lv_theme_night.c b/src/lv_themes/lv_theme_night.c index 1d743ce19..79a17f645 100644 --- a/src/lv_themes/lv_theme_night.c +++ b/src/lv_themes/lv_theme_night.c @@ -732,8 +732,7 @@ static void style_mod(lv_group_t * group, lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 80, 70); /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -750,8 +749,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; diff --git a/src/lv_themes/lv_theme_zen.c b/src/lv_themes/lv_theme_zen.c index e0eee0ce5..5d02c2260 100644 --- a/src/lv_themes/lv_theme_zen.c +++ b/src/lv_themes/lv_theme_zen.c @@ -781,8 +781,7 @@ static void style_mod(lv_group_t * group, lv_style_t * style) style->body.border.color = lv_color_hsv_to_rgb(_hue, 40, 50); /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; #else style->body.border.opa = LV_OPA_COVER; style->body.border.color = LV_COLOR_BLACK; @@ -800,8 +799,7 @@ static void style_mod_edit(lv_group_t * group, lv_style_t * style) style->body.border.color = LV_COLOR_GREEN; /*If not empty or has border then emphasis the border*/ - if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) - style->body.border.width = LV_DPI / 20; + if(style->body.opa != LV_OPA_TRANSP || style->body.border.width != 0) style->body.border.width = LV_DPI / 20; style->body.main_color = lv_color_mix(style->body.main_color, LV_COLOR_GREEN, LV_OPA_70); style->body.grad_color = lv_color_mix(style->body.grad_color, LV_COLOR_GREEN, LV_OPA_70);