Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
format run code-formtter.sh
related to #2543
  • Loading branch information
kisvegabor committed Sep 13, 2021
1 parent 8abd060 commit d67dd94
Show file tree
Hide file tree
Showing 124 changed files with 3,519 additions and 3,260 deletions.
11 changes: 5 additions & 6 deletions src/core/lv_disp.c
Expand Up @@ -126,14 +126,13 @@ lv_obj_t * lv_disp_get_layer_sys(lv_disp_t * disp)
*/
void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) disp = lv_disp_get_default();
disp->theme = th;

if(disp->screen_cnt == 3 &&
lv_obj_get_child_cnt(disp->screens[0]) == 0 &&
lv_obj_get_child_cnt(disp->screens[1]) == 0 &&
lv_obj_get_child_cnt(disp->screens[2]) == 0)
{
lv_obj_get_child_cnt(disp->screens[0]) == 0 &&
lv_obj_get_child_cnt(disp->screens[1]) == 0 &&
lv_obj_get_child_cnt(disp->screens[2]) == 0) {
lv_theme_apply(disp->screens[0]);
}
}
Expand All @@ -144,7 +143,7 @@ void lv_disp_set_theme(lv_disp_t * disp, lv_theme_t * th)
*/
lv_theme_t * lv_disp_get_theme(lv_disp_t * disp)
{
if(disp == NULL) disp = lv_disp_get_default();
if(disp == NULL) disp = lv_disp_get_default();
return disp->theme;
}

Expand Down
160 changes: 86 additions & 74 deletions src/core/lv_event.c
Expand Up @@ -17,11 +17,11 @@
/**********************
* TYPEDEFS
**********************/
typedef struct _lv_event_dsc_t{
typedef struct _lv_event_dsc_t {
lv_event_cb_t cb;
void * user_data;
lv_event_code_t filter :8;
}lv_event_dsc_t;
lv_event_code_t filter : 8;
} lv_event_dsc_t;

/**********************
* STATIC PROTOTYPES
Expand All @@ -39,9 +39,9 @@ static lv_event_t * event_head;
* MACROS
**********************/
#if LV_LOG_TRACE_EVENT
# define EVENT_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
#define EVENT_TRACE(...) LV_LOG_TRACE( __VA_ARGS__)
#else
# define EVENT_TRACE(...)
#define EVENT_TRACE(...)
#endif

/**********************
Expand Down Expand Up @@ -147,13 +147,15 @@ void _lv_event_mark_deleted(lv_obj_t * obj)
}


struct _lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data)
struct _lv_event_dsc_t * lv_obj_add_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter,
void * user_data)
{
LV_ASSERT_OBJ(obj, MY_CLASS);
lv_obj_allocate_spec_attr(obj);

obj->spec_attr->event_dsc_cnt++;
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);

obj->spec_attr->event_dsc[obj->spec_attr->event_dsc_cnt - 1].cb = event_cb;
Expand All @@ -172,11 +174,12 @@ bool lv_obj_remove_event_cb(lv_obj_t * obj, lv_event_cb_t event_cb)
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
if(event_cb == NULL || obj->spec_attr->event_dsc[i].cb == event_cb) {
/*Shift the remaining event handlers forward*/
for(; i < (obj->spec_attr->event_dsc_cnt-1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i+1];
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
}
obj->spec_attr->event_dsc_cnt--;
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
return true;
}
Expand All @@ -194,14 +197,14 @@ bool lv_obj_remove_event_cb_with_user_data(lv_obj_t * obj, lv_event_cb_t event_c
int32_t i = 0;
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
if((event_cb == NULL || obj->spec_attr->event_dsc[i].cb) &&
obj->spec_attr->event_dsc[i].user_data == user_data)
{
obj->spec_attr->event_dsc[i].user_data == user_data) {
/*Shift the remaining event handlers forward*/
for(; i < (obj->spec_attr->event_dsc_cnt-1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i+1];
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
}
obj->spec_attr->event_dsc_cnt--;
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
return true;
}
Expand All @@ -221,11 +224,12 @@ bool lv_obj_remove_event_dsc(lv_obj_t * obj, struct _lv_event_dsc_t * event_dsc)
for(i = 0; i < obj->spec_attr->event_dsc_cnt; i++) {
if(&obj->spec_attr->event_dsc[i] == event_dsc) {
/*Shift the remaining event handlers forward*/
for(; i < (obj->spec_attr->event_dsc_cnt-1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i+1];
for(; i < (obj->spec_attr->event_dsc_cnt - 1); i++) {
obj->spec_attr->event_dsc[i] = obj->spec_attr->event_dsc[i + 1];
}
obj->spec_attr->event_dsc_cnt--;
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc, obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
obj->spec_attr->event_dsc = lv_mem_realloc(obj->spec_attr->event_dsc,
obj->spec_attr->event_dsc_cnt * sizeof(lv_event_dsc_t));
LV_ASSERT_MALLOC(obj->spec_attr->event_dsc);
return true;
}
Expand All @@ -239,36 +243,36 @@ lv_indev_t * lv_event_get_indev(lv_event_t * e)
{

if(e->code == LV_EVENT_PRESSED ||
e->code == LV_EVENT_PRESSING ||
e->code == LV_EVENT_PRESS_LOST ||
e->code == LV_EVENT_SHORT_CLICKED ||
e->code == LV_EVENT_LONG_PRESSED ||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
e->code == LV_EVENT_CLICKED ||
e->code == LV_EVENT_RELEASED ||
e->code == LV_EVENT_SCROLL_BEGIN ||
e->code == LV_EVENT_SCROLL_END ||
e->code == LV_EVENT_SCROLL ||
e->code == LV_EVENT_GESTURE ||
e->code == LV_EVENT_KEY ||
e->code == LV_EVENT_FOCUSED ||
e->code == LV_EVENT_DEFOCUSED ||
e->code == LV_EVENT_LEAVE)
{
e->code == LV_EVENT_PRESSING ||
e->code == LV_EVENT_PRESS_LOST ||
e->code == LV_EVENT_SHORT_CLICKED ||
e->code == LV_EVENT_LONG_PRESSED ||
e->code == LV_EVENT_LONG_PRESSED_REPEAT ||
e->code == LV_EVENT_CLICKED ||
e->code == LV_EVENT_RELEASED ||
e->code == LV_EVENT_SCROLL_BEGIN ||
e->code == LV_EVENT_SCROLL_END ||
e->code == LV_EVENT_SCROLL ||
e->code == LV_EVENT_GESTURE ||
e->code == LV_EVENT_KEY ||
e->code == LV_EVENT_FOCUSED ||
e->code == LV_EVENT_DEFOCUSED ||
e->code == LV_EVENT_LEAVE) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return NULL;
}
}

lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
{
if(e->code == LV_EVENT_DRAW_PART_BEGIN||
e->code == LV_EVENT_DRAW_PART_END)
{
if(e->code == LV_EVENT_DRAW_PART_BEGIN ||
e->code == LV_EVENT_DRAW_PART_END) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return NULL;
}
Expand All @@ -277,14 +281,14 @@ lv_obj_draw_part_dsc_t * lv_event_get_draw_part_dsc(lv_event_t * e)
const lv_area_t * lv_event_get_clip_area(lv_event_t * e)
{
if(e->code == LV_EVENT_DRAW_MAIN ||
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
e->code == LV_EVENT_DRAW_MAIN_END ||
e->code == LV_EVENT_DRAW_POST ||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
e->code == LV_EVENT_DRAW_POST_END)
{
e->code == LV_EVENT_DRAW_MAIN_BEGIN ||
e->code == LV_EVENT_DRAW_MAIN_END ||
e->code == LV_EVENT_DRAW_POST ||
e->code == LV_EVENT_DRAW_POST_BEGIN ||
e->code == LV_EVENT_DRAW_POST_END) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return NULL;
}
Expand All @@ -294,7 +298,8 @@ const lv_area_t * lv_event_get_old_size(lv_event_t * e)
{
if(e->code == LV_EVENT_SIZE_CHANGED) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return NULL;
}
Expand All @@ -306,7 +311,8 @@ uint32_t lv_event_get_key(lv_event_t * e)
uint32_t * k = lv_event_get_param(e);
if(k) return *k;
else return 0;
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return 0;
}
Expand All @@ -316,7 +322,8 @@ lv_anim_t * lv_event_get_scroll_anim(lv_event_t * e)
{
if(e->code == LV_EVENT_SCROLL_BEGIN) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return 0;
}
Expand All @@ -327,7 +334,8 @@ void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size)
if(e->code == LV_EVENT_REFR_EXT_DRAW_SIZE) {
lv_coord_t * cur_size = lv_event_get_param(e);
*cur_size = LV_MAX(*cur_size, size);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
}
}
Expand All @@ -336,7 +344,8 @@ lv_point_t * lv_event_get_self_size_info(lv_event_t * e)
{
if(e->code == LV_EVENT_GET_SELF_SIZE) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return 0;
}
Expand All @@ -346,7 +355,8 @@ lv_hit_test_info_t * lv_event_get_hit_test_info(lv_event_t * e)
{
if(e->code == LV_EVENT_HIT_TEST) {
return lv_event_get_param(e);
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return 0;
}
Expand All @@ -357,7 +367,8 @@ const lv_area_t * lv_event_get_cover_area(lv_event_t * e)
if(e->code == LV_EVENT_COVER_CHECK) {
lv_cover_check_info_t * p = lv_event_get_param(e);
return p->area;
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
return NULL;
}
Expand All @@ -368,7 +379,8 @@ void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res)
if(e->code == LV_EVENT_COVER_CHECK) {
lv_cover_check_info_t * p = lv_event_get_param(e);
if(res > p->res) p->res = res; /*Save only "stronger" results*/
} else {
}
else {
LV_LOG_WARN("Not interpreted with this event code");
}
}
Expand Down Expand Up @@ -429,25 +441,25 @@ static lv_res_t event_send_core(lv_event_t * e)
static bool event_is_bubbled(lv_event_code_t e)
{
switch(e) {
case LV_EVENT_HIT_TEST:
case LV_EVENT_COVER_CHECK:
case LV_EVENT_REFR_EXT_DRAW_SIZE:
case LV_EVENT_DRAW_MAIN_BEGIN:
case LV_EVENT_DRAW_MAIN:
case LV_EVENT_DRAW_MAIN_END:
case LV_EVENT_DRAW_POST_BEGIN:
case LV_EVENT_DRAW_POST:
case LV_EVENT_DRAW_POST_END:
case LV_EVENT_DRAW_PART_BEGIN:
case LV_EVENT_DRAW_PART_END:
case LV_EVENT_REFRESH:
case LV_EVENT_DELETE:
case LV_EVENT_CHILD_CHANGED:
case LV_EVENT_SIZE_CHANGED:
case LV_EVENT_STYLE_CHANGED:
case LV_EVENT_GET_SELF_SIZE:
return false;
default:
return true;
case LV_EVENT_HIT_TEST:
case LV_EVENT_COVER_CHECK:
case LV_EVENT_REFR_EXT_DRAW_SIZE:
case LV_EVENT_DRAW_MAIN_BEGIN:
case LV_EVENT_DRAW_MAIN:
case LV_EVENT_DRAW_MAIN_END:
case LV_EVENT_DRAW_POST_BEGIN:
case LV_EVENT_DRAW_POST:
case LV_EVENT_DRAW_POST_END:
case LV_EVENT_DRAW_PART_BEGIN:
case LV_EVENT_DRAW_PART_END:
case LV_EVENT_REFRESH:
case LV_EVENT_DELETE:
case LV_EVENT_CHILD_CHANGED:
case LV_EVENT_SIZE_CHANGED:
case LV_EVENT_STYLE_CHANGED:
case LV_EVENT_GET_SELF_SIZE:
return false;
default:
return true;
}
}
12 changes: 7 additions & 5 deletions src/core/lv_event.h
Expand Up @@ -79,7 +79,7 @@ typedef enum {
LV_EVENT_GET_SELF_SIZE, /**< Get the internal size of a widget*/

_LV_EVENT_LAST /** Number of default events*/
}lv_event_code_t;
} lv_event_code_t;

typedef struct _lv_event_t {
struct _lv_obj_t * target;
Expand All @@ -88,8 +88,8 @@ typedef struct _lv_event_t {
void * user_data;
void * param;
struct _lv_event_t * prev;
uint8_t deleted :1;
}lv_event_t;
uint8_t deleted : 1;
} lv_event_t;

/**
* @brief Event callback.
Expand Down Expand Up @@ -209,7 +209,8 @@ void _lv_event_mark_deleted(struct _lv_obj_t * obj);
* @param user_data custom data data will be available in `event_cb`
* @return a pointer the event descriptor. Can be used in ::lv_obj_remove_event_dsc
*/
struct _lv_event_dsc_t * lv_obj_add_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter, void * user_data);
struct _lv_event_dsc_t * lv_obj_add_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb, lv_event_code_t filter,
void * user_data);

/**
* Remove an event handler function for an object.
Expand All @@ -226,7 +227,8 @@ bool lv_obj_remove_event_cb(struct _lv_obj_t * obj, lv_event_cb_t event_cb);
* @param event_user_data the user_data specified in ::lv_obj_add_event_cb
* @return true if any event handlers were removed
*/
bool lv_obj_remove_event_cb_with_user_data(struct _lv_obj_t * obj, lv_event_cb_t event_cb, const void * event_user_data);
bool lv_obj_remove_event_cb_with_user_data(struct _lv_obj_t * obj, lv_event_cb_t event_cb,
const void * event_user_data);

/**
* DEPRACTED because doesn't work if multiple event handlers are added to an object.
Expand Down
8 changes: 4 additions & 4 deletions src/core/lv_group.c
Expand Up @@ -79,7 +79,7 @@ void lv_group_del(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
_LV_LL_READ(&group->obj_ll, obj) {
if((*obj)->spec_attr) (*obj)->spec_attr->group_p = NULL;
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
}

_lv_ll_clear(&(group->obj_ll));
Expand Down Expand Up @@ -149,8 +149,8 @@ void lv_group_swap_obj(lv_obj_t * obj1, lv_obj_t * obj2)
/*Do not add the object twice*/
lv_obj_t ** obj_i;
_LV_LL_READ(&g1->obj_ll, obj_i) {
if((*obj_i) == obj1) (*obj_i) = obj2;
else if((*obj_i) == obj2) (*obj_i) = obj1;
if((*obj_i) == obj1)(*obj_i) = obj2;
else if((*obj_i) == obj2)(*obj_i) = obj1;
}

if(*g1->obj_focus == obj1) lv_group_focus_obj(obj2);
Expand Down Expand Up @@ -211,7 +211,7 @@ void lv_group_remove_all_objs(lv_group_t * group)
/*Remove the objects from the group*/
lv_obj_t ** obj;
_LV_LL_READ(&group->obj_ll, obj) {
if((*obj)->spec_attr) (*obj)->spec_attr->group_p = NULL;
if((*obj)->spec_attr)(*obj)->spec_attr->group_p = NULL;
}

_lv_ll_clear(&(group->obj_ll));
Expand Down

0 comments on commit d67dd94

Please sign in to comment.