/**1* @file lv_list.h2*3*/45#ifndef LV_LIST_H6#define LV_LIST_H78#ifdef __cplusplus9extern "C" {10#endif1112/*********************13* INCLUDES14*********************/15#ifdef LV_CONF_INCLUDE_SIMPLE16#include "lv_conf.h"17#else18#include "../../lv_conf.h"19#endif2021#if USE_LV_LIST != 02223/*Testing of dependencies*/24#if USE_LV_PAGE == 025#error "lv_list: lv_page is required. Enable it in lv_conf.h (USE_LV_PAGE 1) "26#endif2728#if USE_LV_BTN == 029#error "lv_list: lv_btn is required. Enable it in lv_conf.h (USE_LV_BTN 1) "30#endif3132#if USE_LV_LABEL == 033#error "lv_list: lv_label is required. Enable it in lv_conf.h (USE_LV_LABEL 1) "34#endif353637#include "../lv_core/lv_obj.h"38#include "lv_page.h"39#include "lv_btn.h"40#include "lv_label.h"41#include "lv_img.h"4243/*********************44* DEFINES45*********************/4647/**********************48* TYPEDEFS49**********************/50/*Data of list*/51typedef struct52{53lv_page_ext_t page; /*Ext. of ancestor*/54/*New data for this type */55uint16_t anim_time; /*Scroll animation time*/56lv_style_t *styles_btn[LV_BTN_STATE_NUM]; /*Styles of the list element buttons*/57lv_style_t *style_img; /*Style of the list element images on buttons*/58uint32_t size; /*the number of items(buttons) in the list*/59bool single_mode; /* whether single selected mode is enabled */60#if USE_LV_GROUP61lv_obj_t * last_sel; /* The last selected button. It will be reverted when the list is focused again */62lv_obj_t * selected_btn; /* The button is currently being selected*/63#endif64} lv_list_ext_t;6566enum {67LV_LIST_STYLE_BG,68LV_LIST_STYLE_SCRL,69LV_LIST_STYLE_SB,70LV_LIST_STYLE_EDGE_FLASH,71LV_LIST_STYLE_BTN_REL,72LV_LIST_STYLE_BTN_PR,73LV_LIST_STYLE_BTN_TGL_REL,74LV_LIST_STYLE_BTN_TGL_PR,75LV_LIST_STYLE_BTN_INA,76};77typedef uint8_t lv_list_style_t;787980/**********************81* GLOBAL PROTOTYPES82**********************/8384/**85* Create a list objects86* @param par pointer to an object, it will be the parent of the new list87* @param copy pointer to a list object, if not NULL then the new object will be copied from it88* @return pointer to the created list89*/90lv_obj_t * lv_list_create(lv_obj_t * par, const lv_obj_t * copy);9192/**93* Delete all children of the scrl object, without deleting scrl child.94* @param obj pointer to an object95*/96void lv_list_clean(lv_obj_t *obj);9798/*======================99* Add/remove functions100*=====================*/101102/**103* Add a list element to the list104* @param list pointer to list object105* @param img_fn file name of an image before the text (NULL if unused)106* @param txt text of the list element (NULL if unused)107* @param rel_action pointer to release action function (like with lv_btn)108* @return pointer to the new list element which can be customized (a button)109*/110lv_obj_t * lv_list_add(lv_obj_t * list, const void * img_src, const char * txt, lv_action_t rel_action);111112/**113* Remove the index of the button in the list114* @param list pointer to a list object115* @param index pointer to a the button's index in the list, index must be 0 <= index < lv_list_ext_t.size116* @return true: successfully deleted117*/118bool lv_list_remove(const lv_obj_t * list, uint32_t index);119120/*=====================121* Setter functions122*====================*/123124/**125* Set single button selected mode, only one button will be selected if enabled.126* @param list pointer to the currently pressed list object127* @param mode, enable(true)/disable(false) single selected mode.128*/129void lv_list_set_single_mode(lv_obj_t *list, bool mode);130131#if USE_LV_GROUP132133/**134* Make a button selected. Can be used while navigating in the list with a keypad.135* @param list pointer to a list object136* @param btn pointer to a button to select137*/138void lv_list_set_btn_selected(lv_obj_t * list, lv_obj_t * btn);139#endif140141/**142* Set scroll animation duration on 'list_up()' 'list_down()' 'list_focus()'143* @param list pointer to a list object144* @param anim_time duration of animation [ms]145*/146void lv_list_set_anim_time(lv_obj_t *list, uint16_t anim_time);147148/**149* Set the scroll bar mode of a list150* @param list pointer to a list object151* @param sb_mode the new mode from 'lv_page_sb_mode_t' enum152*/153static inline void lv_list_set_sb_mode(lv_obj_t * list, lv_sb_mode_t mode)154{155lv_page_set_sb_mode(list, mode);156}157158/**159* Enable the scroll propagation feature. If enabled then the List will move its parent if there is no more space to scroll.160* @param list pointer to a List161* @param en true or false to enable/disable scroll propagation162*/163static inline void lv_list_set_scroll_propagation(lv_obj_t * list, bool en)164{165lv_page_set_scroll_propagation(list, en);166}167168/**169* Enable the edge flash effect. (Show an arc when the an edge is reached)170* @param list pointer to a List171* @param en true or false to enable/disable end flash172*/173static inline void lv_list_set_edge_flash(lv_obj_t * list, bool en)174{175lv_page_set_edge_flash(list, en);176}177178/**179* Set a style of a list180* @param list pointer to a list object181* @param type which style should be set182* @param style pointer to a style183*/184void lv_list_set_style(lv_obj_t *list, lv_list_style_t type, lv_style_t *style);185186/*=====================187* Getter functions188*====================*/189190/**191* Get single button selected mode.192* @param list pointer to the currently pressed list object.193*/194bool lv_list_get_single_mode(lv_obj_t *list);195196/**197* Get the text of a list element198* @param btn pointer to list element199* @return pointer to the text200*/201const char * lv_list_get_btn_text(const lv_obj_t * btn);202/**203* Get the label object from a list element204* @param btn pointer to a list element (button)205* @return pointer to the label from the list element or NULL if not found206*/207lv_obj_t * lv_list_get_btn_label(const lv_obj_t * btn);208209/**210* Get the image object from a list element211* @param btn pointer to a list element (button)212* @return pointer to the image from the list element or NULL if not found213*/214lv_obj_t * lv_list_get_btn_img(const lv_obj_t * btn);215216/**217* Get the next button from list. (Starts from the bottom button)218* @param list pointer to a list object219* @param prev_btn pointer to button. Search the next after it.220* @return pointer to the next button or NULL when no more buttons221*/222lv_obj_t * lv_list_get_prev_btn(const lv_obj_t * list, lv_obj_t * prev_btn);223224/**225* Get the previous button from list. (Starts from the top button)226* @param list pointer to a list object227* @param prev_btn pointer to button. Search the previous before it.228* @return pointer to the previous button or NULL when no more buttons229*/230lv_obj_t * lv_list_get_next_btn(const lv_obj_t * list, lv_obj_t * prev_btn);231232/**233* Get the index of the button in the list234* @param list pointer to a list object. If NULL, assumes btn is part of a list.235* @param btn pointer to a list element (button)236* @return the index of the button in the list, or -1 of the button not in this list237*/238int32_t lv_list_get_btn_index(const lv_obj_t * list, const lv_obj_t * btn);239240/**241* Get the number of buttons in the list242* @param list pointer to a list object243* @return the number of buttons in the list244*/245uint32_t lv_list_get_size(const lv_obj_t * list);246247#if USE_LV_GROUP248/**249* Get the currently selected button. Can be used while navigating in the list with a keypad.250* @param list pointer to a list object251* @return pointer to the selected button252*/253lv_obj_t * lv_list_get_btn_selected(const lv_obj_t * list);254#endif255256257/**258* Get scroll animation duration259* @param list pointer to a list object260* @return duration of animation [ms]261*/262uint16_t lv_list_get_anim_time(const lv_obj_t *list);263264265/**266* Get the scroll bar mode of a list267* @param list pointer to a list object268* @return scrollbar mode from 'lv_page_sb_mode_t' enum269*/270static inline lv_sb_mode_t lv_list_get_sb_mode(const lv_obj_t * list)271{272return lv_page_get_sb_mode(list);273}274275/**276* Get the scroll propagation property277* @param list pointer to a List278* @return true or false279*/280static inline bool lv_list_get_scroll_propagation(lv_obj_t * list)281{282return lv_page_get_scroll_propagation(list);283}284285/**286* Get the scroll propagation property287* @param list pointer to a List288* @return true or false289*/290static inline bool lv_list_get_edge_flash(lv_obj_t * list)291{292return lv_page_get_edge_flash(list);293}294295/**296* Get a style of a list297* @param list pointer to a list object298* @param type which style should be get299* @return style pointer to a style300* */301lv_style_t * lv_list_get_style(const lv_obj_t *list, lv_list_style_t type);302303/*=====================304* Other functions305*====================*/306307/**308* Move the list elements up by one309* @param list pointer a to list object310*/311void lv_list_up(const lv_obj_t * list);312/**313* Move the list elements down by one314* @param list pointer to a list object315*/316void lv_list_down(const lv_obj_t * list);317318/**319* Focus on a list button. It ensures that the button will be visible on the list.320* @param btn pointer to a list button to focus321* @param anim_en true: scroll with animation, false: without animation322*/323void lv_list_focus(const lv_obj_t *btn, bool anim_en);324325/**********************326* MACROS327**********************/328329#endif /*USE_LV_LIST*/330331#ifdef __cplusplus332} /* extern "C" */333#endif334335#endif /*LV_LIST_H*/336337338