chore(group): add some missing assertions (#5941)
This commit is contained in:
@@ -71,6 +71,8 @@ lv_group_t * lv_group_create(void)
|
|||||||
|
|
||||||
void lv_group_del(lv_group_t * group)
|
void lv_group_del(lv_group_t * group)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
/*Defocus the currently focused object*/
|
/*Defocus the currently focused object*/
|
||||||
if(group->obj_focus != NULL) {
|
if(group->obj_focus != NULL) {
|
||||||
lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||||
@@ -216,6 +218,8 @@ void lv_group_remove_obj(lv_obj_t * obj)
|
|||||||
|
|
||||||
void lv_group_remove_all_objs(lv_group_t * group)
|
void lv_group_remove_all_objs(lv_group_t * group)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
/*Defocus the currently focused object*/
|
/*Defocus the currently focused object*/
|
||||||
if(group->obj_focus != NULL) {
|
if(group->obj_focus != NULL) {
|
||||||
lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
lv_event_send(*group->obj_focus, LV_EVENT_DEFOCUSED, get_indev(group));
|
||||||
@@ -267,6 +271,8 @@ void lv_group_focus_obj(lv_obj_t * obj)
|
|||||||
|
|
||||||
void lv_group_focus_next(lv_group_t * group)
|
void lv_group_focus_next(lv_group_t * group)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
bool focus_changed = focus_next_core(group, _lv_ll_get_head, _lv_ll_get_next);
|
bool focus_changed = focus_next_core(group, _lv_ll_get_head, _lv_ll_get_next);
|
||||||
if(group->edge_cb) {
|
if(group->edge_cb) {
|
||||||
if(!focus_changed)
|
if(!focus_changed)
|
||||||
@@ -276,6 +282,8 @@ void lv_group_focus_next(lv_group_t * group)
|
|||||||
|
|
||||||
void lv_group_focus_prev(lv_group_t * group)
|
void lv_group_focus_prev(lv_group_t * group)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
bool focus_changed = focus_next_core(group, _lv_ll_get_tail, _lv_ll_get_prev);
|
bool focus_changed = focus_next_core(group, _lv_ll_get_tail, _lv_ll_get_prev);
|
||||||
if(group->edge_cb) {
|
if(group->edge_cb) {
|
||||||
if(!focus_changed)
|
if(!focus_changed)
|
||||||
@@ -285,6 +293,8 @@ void lv_group_focus_prev(lv_group_t * group)
|
|||||||
|
|
||||||
void lv_group_focus_freeze(lv_group_t * group, bool en)
|
void lv_group_focus_freeze(lv_group_t * group, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
if(en == false) group->frozen = 0;
|
if(en == false) group->frozen = 0;
|
||||||
else group->frozen = 1;
|
else group->frozen = 1;
|
||||||
}
|
}
|
||||||
@@ -301,11 +311,15 @@ lv_res_t lv_group_send_data(lv_group_t * group, uint32_t c)
|
|||||||
|
|
||||||
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
|
void lv_group_set_focus_cb(lv_group_t * group, lv_group_focus_cb_t focus_cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
group->focus_cb = focus_cb;
|
group->focus_cb = focus_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_group_set_edge_cb(lv_group_t * group, lv_group_edge_cb_t edge_cb)
|
void lv_group_set_edge_cb(lv_group_t * group, lv_group_edge_cb_t edge_cb)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
group->edge_cb = edge_cb;
|
group->edge_cb = edge_cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,11 +343,15 @@ void lv_group_set_editing(lv_group_t * group, bool edit)
|
|||||||
|
|
||||||
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy)
|
void lv_group_set_refocus_policy(lv_group_t * group, lv_group_refocus_policy_t policy)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
group->refocus_policy = policy & 0x01;
|
group->refocus_policy = policy & 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_group_set_wrap(lv_group_t * group, bool en)
|
void lv_group_set_wrap(lv_group_t * group, bool en)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
group->wrap = en ? 1 : 0;
|
group->wrap = en ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +389,8 @@ bool lv_group_get_wrap(lv_group_t * group)
|
|||||||
|
|
||||||
uint32_t lv_group_get_obj_count(lv_group_t * group)
|
uint32_t lv_group_get_obj_count(lv_group_t * group)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
return _lv_ll_get_len(&group->obj_ll);
|
return _lv_ll_get_len(&group->obj_ll);
|
||||||
}
|
}
|
||||||
/**********************
|
/**********************
|
||||||
@@ -379,6 +399,8 @@ uint32_t lv_group_get_obj_count(lv_group_t * group)
|
|||||||
|
|
||||||
static void lv_group_refocus(lv_group_t * g)
|
static void lv_group_refocus(lv_group_t * g)
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(g);
|
||||||
|
|
||||||
/*Refocus must temporarily allow wrapping to work correctly*/
|
/*Refocus must temporarily allow wrapping to work correctly*/
|
||||||
uint8_t temp_wrap = g->wrap;
|
uint8_t temp_wrap = g->wrap;
|
||||||
g->wrap = 1;
|
g->wrap = 1;
|
||||||
@@ -394,6 +416,8 @@ static void lv_group_refocus(lv_group_t * g)
|
|||||||
static bool focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
static bool focus_next_core(lv_group_t * group, void * (*begin)(const lv_ll_t *),
|
||||||
void * (*move)(const lv_ll_t *, const void *))
|
void * (*move)(const lv_ll_t *, const void *))
|
||||||
{
|
{
|
||||||
|
LV_ASSERT_NULL(group);
|
||||||
|
|
||||||
bool focus_changed = false;
|
bool focus_changed = false;
|
||||||
if(group->frozen) return focus_changed;
|
if(group->frozen) return focus_changed;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user