lv_tree.h

Tree. The tree nodes are dynamically allocated by the 'lv_mem' module.

Defines

LV_TREE_NODE(n)

Typedefs

typedef struct _lv_tree_class_t lv_tree_class_t

Describe the common methods of every object. Similar to a C++ class.

typedef struct _lv_tree_node_t lv_tree_node_t

Description of a tree node

typedef uint8_t lv_tree_walk_mode_t
typedef bool (*lv_tree_traverse_cb_t)(const lv_tree_node_t *node, void *user_data)
typedef bool (*lv_tree_before_cb_t)(const lv_tree_node_t *node, void *user_data)
typedef void (*lv_tree_after_cb_t)(const lv_tree_node_t *node, void *user_data)

Enums

enum [anonymous]

Values:

enumerator LV_TREE_WALK_PRE_ORDER
enumerator LV_TREE_WALK_POST_ORDER

Functions

lv_tree_node_t *lv_tree_node_create(const lv_tree_class_t *class_p, lv_tree_node_t *parent)

Create a tree node.

参数:
  • class_p -- pointer to a class of the node

  • parent -- pointer to the parent node (or NULL if it's the root node)

返回:

pointer to the new node

void lv_tree_node_delete(lv_tree_node_t *node)

Delete a tree node and all its children recursively.

参数:

node -- pointer to the node to delete

bool lv_tree_walk(const lv_tree_node_t *node, lv_tree_walk_mode_t mode, lv_tree_traverse_cb_t cb, lv_tree_before_cb_t bcb, lv_tree_after_cb_t acb, void *user_data)

Walk the tree recursively and call a callback function on each node.

参数:
  • node -- pointer to the root node of the tree

  • mode -- LV_TREE_WALK_PRE_ORDER or LV_TREE_WALK_POST_ORDER

  • cb -- callback function to call on each node

  • bcb -- callback function to call before visiting a node

  • acb -- callback function to call after visiting a node

  • user_data -- user data to pass to the callback functions

返回:

true: traversal is finished; false: traversal breaked

Variables

const lv_tree_class_t lv_tree_node_class
struct _lv_tree_class_t
#include <lv_tree.h>

Describe the common methods of every object. Similar to a C++ class.

Public Members

const struct _lv_tree_class_t *base_class
uint32_t instance_size
void (*constructor_cb)(const struct _lv_tree_class_t *class_p, struct _lv_tree_node_t *node)
void (*destructor_cb)(const struct _lv_tree_class_t *class_p, struct _lv_tree_node_t *node)
struct _lv_tree_node_t
#include <lv_tree.h>

Description of a tree node

Public Members

struct _lv_tree_node_t *parent
struct _lv_tree_node_t **children
uint32_t child_cnt
uint32_t child_cap
const struct _lv_tree_class_t *class_p