lv_obj_tree.h
API reference for lv_obj_tree.h
Functions
lv_obj_set_parent
Move the parent of an object. The relative coordinates will be kept.
void lv_obj_set_parent(lv_obj_t *obj, lv_obj_t *parent)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object whose parent needs to be changed |
parent | lv_obj_t * | pointer to the new parent |
lv_obj_set_name
Set a name for a widget. The name will be allocated and freed when the widget is deleted or a new name is set.
void lv_obj_set_name(lv_obj_t *obj, const char *name)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object |
name | const char * | the name to set. May be NULL. When NULL the default "<widget_type>_#" name is used. |
If the name ends with a #, older siblings with the same name will be counted, and the # will be replaced by the index of the given widget. For example, creating multiple widgets with the name "mybtn_#" will result in resolved names like "mybtn_0", "mybtn_1", "mybtn_2", etc. The name is resolved when lv_obj_get_name_resolved is called, so the result reflects the currently existing widgets at that time.
lv_obj_set_name_static
Set a name for a widget. Only a pointer will be saved.
void lv_obj_set_name_static(lv_obj_t *obj, const char *name)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object |
name | const char * | the name to set. If set to NULL the default "<widget_type>_#" name will be used. |
If the name ends with a #, older siblings with the same name will be counted, and the # will be replaced by the index of the given widget. For example, creating multiple widgets with the name "mybtn_#" will result in resolved names like "mybtn_0", "mybtn_1", "mybtn_2", etc. The name is resolved when lv_obj_get_name_resolved is called, so the result reflects the currently existing widgets at that time.
lv_obj_get_screen
Get the screen of an object
lv_obj_t * lv_obj_get_screen(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: lv_obj_t * — pointer to the object's screen
lv_obj_get_display
Get the display of the object
lv_display_t * lv_obj_get_display(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: lv_display_t * — pointer to the object's display
lv_obj_get_parent
Get the parent of an object
lv_obj_t * lv_obj_get_parent(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: lv_obj_t * — the parent of the object. (NULL if obj was a screen)
lv_obj_get_child
Get the child of an object by the child's index.
lv_obj_t * lv_obj_get_child(const lv_obj_t *obj, int32_t idx)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object whose child should be get |
idx | int32_t | the index of the child. 0: the oldest (firstly created) child 1: the second oldest child count-1: the youngest -1: the youngest -2: the second youngest |
Returns: lv_obj_t * — pointer to the child or NULL if the index was invalid
lv_obj_get_child_by_type
Get the child of an object by the child's index. Consider the children only with a given type.
lv_obj_t * lv_obj_get_child_by_type(const lv_obj_t *obj, int32_t idx, const lv_obj_class_t *class_p)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object whose child should be get |
idx | int32_t | the index of the child. 0: the oldest (firstly created) child 1: the second oldest child count-1: the youngest -1: the youngest -2: the second youngest |
class_p | const lv_obj_class_t * | the type of the children to check |
Returns: lv_obj_t * — pointer to the child or NULL if the index was invalid
lv_obj_get_sibling
Return a sibling of an object
lv_obj_t * lv_obj_get_sibling(const lv_obj_t *obj, int32_t idx)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object whose sibling should be get. The object needs to be registered as a child of its parent. |
idx | int32_t | 0: obj itself -1: the first older sibling -2: the next older sibling 1: the first younger sibling 2: the next younger sibling etc |
Returns: lv_obj_t * — pointer to the requested sibling or NULL if there is no such sibling - would navigate outside the array of children using the index (get the -3rd sibling of the second child of the parent)
lv_obj_get_sibling_by_type
Return a sibling of an object. Consider the siblings only with a given type.
lv_obj_t * lv_obj_get_sibling_by_type(const lv_obj_t *obj, int32_t idx, const lv_obj_class_t *class_p)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object whose sibling should be get. The object needs to be registered as a child of its parent. |
idx | int32_t | 0: obj itself -1: the first older sibling -2: the next older sibling 1: the first younger sibling 2: the next younger sibling etc |
class_p | const lv_obj_class_t * | the type of the children to check |
Returns: lv_obj_t * — pointer to the requested sibling or NULL if there is no such sibling or would navigate outside the array of children using the index (get the -3rd sibling of the second child of the parent)
lv_obj_get_child_count
Get the number of children
uint32_t lv_obj_get_child_count(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: uint32_t — the number of children
lv_obj_get_child_count_by_type
Get the number of children having a given type.
uint32_t lv_obj_get_child_count_by_type(const lv_obj_t *obj, const lv_obj_class_t *class_p)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
class_p | const lv_obj_class_t * | the type of the children to check |
Returns: uint32_t — the number of children
lv_obj_get_name
Get the set name as it was set.
const char * lv_obj_get_name(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: const char * — get the set name or NULL if it wasn't set yet
lv_obj_get_name_resolved
Get the set name or craft a name automatically.
void lv_obj_get_name_resolved(const lv_obj_t *obj, char buf[], size_t buf_size)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
buf | char | buffer to store the name |
buf_size | size_t | the size of the buffer in bytes |
If the name ends with a #, older siblings with the same name will be counted, and the # will be replaced by the index of the given widget. For example, creating multiple widgets with the name "mybtn_#" will result in resolved names like "mybtn_0", "mybtn_1", "mybtn_2", etc. The name is resolved when lv_obj_get_name_resolved is called, so the result reflects the currently existing widgets at that time.
lv_obj_get_child_by_name
Get an object by name. The name can be a path too, for example "main_container/lv_button_1/label". In this case the first part of the name-path should be the direct child of the parent, the second part, should the direct child of first one, etc.
If the name of a widget was not set a name like "lv_button_1" will be created for it using lv_obj_get_name_resolved.
lv_obj_t * lv_obj_get_child_by_name(const lv_obj_t *parent, const char *name_path)| Name | Type | Description |
|---|---|---|
parent | const lv_obj_t * | the widget where the search should start |
name_path | const char * | the widget name path |
Returns: lv_obj_t * — the found widget or NULL if not found.
lv_obj_get_index
Get the index of a child.
int32_t lv_obj_get_index(const lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
Returns: int32_t — the child index of the object. E.g. 0: the oldest (firstly created child). (-1 if child could not be found or no parent exists)
lv_obj_get_index_by_type
Get the index of a child. Consider the children only with a given type.
int32_t lv_obj_get_index_by_type(const lv_obj_t *obj, const lv_obj_class_t *class_p)| Name | Type | Description |
|---|---|---|
obj | const lv_obj_t * | pointer to an object |
class_p | const lv_obj_class_t * | the type of the children to check |
Returns: int32_t — the child index of the object. E.g. 0: the oldest (firstly created child with the given class). (-1 if child could not be found or no parent exists)
lv_obj_delete
Delete an object and all of its children. Also remove the objects from their group and remove all animations (if any). Send LV_EVENT_DELETE to deleted objects.
void lv_obj_delete(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object May be NULL. |
lv_obj_clean
Delete all children of an object. Also remove the objects from their group and remove all animations (if any). Send LV_EVENT_DELETE to deleted objects.
void lv_obj_clean(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object |
lv_obj_delete_delayed
Delete an object after some delay
void lv_obj_delete_delayed(lv_obj_t *obj, uint32_t delay_ms)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to an object May be NULL. |
delay_ms | uint32_t | time to wait before delete in milliseconds |
lv_obj_delete_anim_completed_cb
A function to be easily used in animation ready callback to delete an object when the animation is ready
void lv_obj_delete_anim_completed_cb(lv_anim_t *a)| Name | Type | Description |
|---|---|---|
a | lv_anim_t * | pointer to the animation |
lv_obj_delete_async
Helper function for asynchronously deleting objects. Useful for cases where you can't delete an object directly in an LV_EVENT_DELETE handler (i.e. parent).
void lv_obj_delete_async(lv_obj_t *obj)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | object to delete May be NULL. |
See also: lv_async_call
lv_obj_swap
Swap the positions of two objects. When used in listboxes, it can be used to sort the listbox items.
void lv_obj_swap(lv_obj_t *obj1, lv_obj_t *obj2)| Name | Type | Description |
|---|---|---|
obj1 | lv_obj_t * | pointer to the first object |
obj2 | lv_obj_t * | pointer to the second object |
lv_obj_move_to_index
moves the object to the given index in its parent. When used in listboxes, it can be used to sort the listbox items.
void lv_obj_move_to_index(lv_obj_t *obj, int32_t index)| Name | Type | Description |
|---|---|---|
obj | lv_obj_t * | pointer to the object to be moved. |
index | int32_t | new index in parent. -1 to count from the back |
to move to the background: lv_obj_move_to_index(obj, 0)
to move forward (up): lv_obj_move_to_index(obj, lv_obj_get_index(obj) - 1)
lv_obj_find_by_name
Find a child with a given name on a parent. This child doesn't have to be the direct child of the parent. First direct children of the parent will be checked, and the direct children of the first child, etc. (Breadth-first search).
If the name of a widget was not set a name like "lv_button_1" will be created for it using lv_obj_get_name_resolved.
lv_obj_t * lv_obj_find_by_name(const lv_obj_t *parent, const char *name)| Name | Type | Description |
|---|---|---|
parent | const lv_obj_t * | the widget where the search should start. May be NULL. When NULL the active screen is used. |
name | const char * | the name of the widget |
Returns: lv_obj_t * — the found widget or NULL if not found.
lv_obj_tree_walk
Iterate through all children of any object.
void lv_obj_tree_walk(lv_obj_t *start_obj, lv_obj_tree_walk_cb_t cb, void *user_data)| Name | Type | Description |
|---|---|---|
start_obj | lv_obj_t * | start integrating from this object. May be NULL. When NULL every screen of every display is walked. |
cb | lv_obj_tree_walk_cb_t | call this callback on the objects |
user_data | void * | pointer to any user related data (will be passed to cb) May be NULL. |
lv_obj_dump_tree
Iterate through all children of any object and print their ID.
void lv_obj_dump_tree(lv_obj_t *start_obj)| Name | Type | Description |
|---|---|---|
start_obj | lv_obj_t * | start integrating from this object. May be NULL. When NULL every screen of every display is dumped. |
Enums
lv_obj_tree_walk_res_t
| Name |
|---|
LV_OBJ_TREE_WALK_NEXT |
LV_OBJ_TREE_WALK_SKIP_CHILDREN |
LV_OBJ_TREE_WALK_END |
Typedefs
lv_obj_tree_walk_cb_t
typedef lv_obj_tree_walk_res_t(* lv_obj_tree_walk_cb_t) (lv_obj_t *, void *)Used by 1 function
lv_obj_tree_walk— paramcb
Dependencies
Last updated on