mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-28 07:03:00 +08:00
add lv_obj_get_child_by_id
This commit is contained in:
parent
68058eeff1
commit
7b48464241
@ -1139,6 +1139,24 @@ lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child)
|
|||||||
return child ? _lv_ll_get_prev(&obj->child_ll, child) : _lv_ll_get_tail(&obj->child_ll);
|
return child ? _lv_ll_get_prev(&obj->child_ll, child) : _lv_ll_get_tail(&obj->child_ll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Nth child of a an object. 0th is the lastly created.
|
||||||
|
* @param obj pointer to an object whose children should be get
|
||||||
|
* @param id of a child
|
||||||
|
* @return the child or `NULL` if `id` was greater then the `number of children - 1`
|
||||||
|
*/
|
||||||
|
lv_obj_t * lv_obj_get_child_by_id(const lv_obj_t * obj, uint32_t id)
|
||||||
|
{
|
||||||
|
LV_ASSERT_OBJ(obj, LV_OBJX_NAME);
|
||||||
|
|
||||||
|
lv_obj_t * child = lv_obj_get_child(obj, NULL);
|
||||||
|
uint32_t i;
|
||||||
|
for(i = 0; i < id; i++) {
|
||||||
|
child = lv_obj_get_child(obj, child);
|
||||||
|
}
|
||||||
|
|
||||||
|
return child;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Count the children of an object (only children directly on 'obj')
|
* Count the children of an object (only children directly on 'obj')
|
||||||
* @param obj pointer to an object
|
* @param obj pointer to an object
|
||||||
|
@ -592,6 +592,14 @@ lv_obj_t * lv_obj_get_child(const lv_obj_t * obj, const lv_obj_t * child);
|
|||||||
*/
|
*/
|
||||||
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child);
|
lv_obj_t * lv_obj_get_child_back(const lv_obj_t * obj, const lv_obj_t * child);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Nth child of a an object. 0th is the lastly created.
|
||||||
|
* @param obj pointer to an object whose children should be get
|
||||||
|
* @param id of a child
|
||||||
|
* @return the child or `NULL` if `id` was greater then the `number of children - 1`
|
||||||
|
*/
|
||||||
|
lv_obj_t * lv_obj_get_child_by_id(const lv_obj_t * obj, uint32_t id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the children of an object (only children directly on 'obj')
|
* Count the children of an object (only children directly on 'obj')
|
||||||
* @param obj pointer to an object
|
* @param obj pointer to an object
|
||||||
|
@ -315,57 +315,57 @@ void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_co
|
|||||||
|
|
||||||
case LV_ALIGN_OUT_TOP_LEFT:
|
case LV_ALIGN_OUT_TOP_LEFT:
|
||||||
x = 0;
|
x = 0;
|
||||||
y = -lv_obj_get_height_fit(obj);
|
y = -lv_obj_get_height(obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_TOP_MID:
|
case LV_ALIGN_OUT_TOP_MID:
|
||||||
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
|
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||||
y = -lv_obj_get_height_fit(obj);
|
y = -lv_obj_get_height(obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_TOP_RIGHT:
|
case LV_ALIGN_OUT_TOP_RIGHT:
|
||||||
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
|
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||||
y = -lv_obj_get_height_fit(obj);
|
y = -lv_obj_get_height(obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
case LV_ALIGN_OUT_BOTTOM_LEFT:
|
||||||
x = 0;
|
x = 0;
|
||||||
y = lv_obj_get_height_fit(base);
|
y = lv_obj_get_height(base);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_BOTTOM_MID:
|
case LV_ALIGN_OUT_BOTTOM_MID:
|
||||||
x = lv_obj_get_width_fit(base) / 2 - lv_obj_get_width_fit(obj) / 2;
|
x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
|
||||||
y = lv_obj_get_height_fit(base);
|
y = lv_obj_get_height(base);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
case LV_ALIGN_OUT_BOTTOM_RIGHT:
|
||||||
x = lv_obj_get_width_fit(base) - lv_obj_get_width_fit(obj);
|
x = lv_obj_get_width(base) - lv_obj_get_width(obj);
|
||||||
y = lv_obj_get_height_fit(base);
|
y = lv_obj_get_height(base);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_LEFT_TOP:
|
case LV_ALIGN_OUT_LEFT_TOP:
|
||||||
x = -lv_obj_get_width_fit(obj);
|
x = -lv_obj_get_width(obj);
|
||||||
y = 0;
|
y = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_LEFT_MID:
|
case LV_ALIGN_OUT_LEFT_MID:
|
||||||
x = -lv_obj_get_width_fit(obj);
|
x = -lv_obj_get_width(obj);
|
||||||
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
|
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
case LV_ALIGN_OUT_LEFT_BOTTOM:
|
||||||
x = -lv_obj_get_width_fit(obj);
|
x = -lv_obj_get_width(obj);
|
||||||
y = lv_obj_get_height_fit(base) - lv_obj_get_height_fit(obj);
|
y = lv_obj_get_height(base) - lv_obj_get_height(obj);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_RIGHT_TOP:
|
case LV_ALIGN_OUT_RIGHT_TOP:
|
||||||
x = lv_obj_get_width_fit(base);
|
x = lv_obj_get_width(base);
|
||||||
y = 0;
|
y = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_RIGHT_MID:
|
case LV_ALIGN_OUT_RIGHT_MID:
|
||||||
x = lv_obj_get_width_fit(base);
|
x = lv_obj_get_width(base);
|
||||||
y = lv_obj_get_height_fit(base) / 2 - lv_obj_get_height_fit(obj) / 2;
|
y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
case LV_ALIGN_OUT_RIGHT_BOTTOM:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user