/**1* @file lv_roller.h2*3*/45#ifndef LV_ROLLER_H6#define LV_ROLLER_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_ROLLER != 02223/*Testing of dependencies*/24#if USE_LV_DDLIST == 025#error "lv_roller: lv_ddlist is required. Enable it in lv_conf.h (USE_LV_DDLIST 1) "26#endif2728#include "../lv_core/lv_obj.h"29#include "lv_ddlist.h"30#include "lv_label.h"3132/*********************33* DEFINES34*********************/3536/**********************37* TYPEDEFS38**********************/39/*Data of roller*/40typedef struct {41lv_ddlist_ext_t ddlist; /*Ext. of ancestor*/42/*New data for this type */43} lv_roller_ext_t;4445enum {46LV_ROLLER_STYLE_BG,47LV_ROLLER_STYLE_SEL,48};49typedef uint8_t lv_roller_style_t;5051/**********************52* GLOBAL PROTOTYPES53**********************/5455/**56* Create a roller object57* @param par pointer to an object, it will be the parent of the new roller58* @param copy pointer to a roller object, if not NULL then the new object will be copied from it59* @return pointer to the created roller60*/61lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy);6263/*=====================64* Setter functions65*====================*/6667/**68* Set the align of the roller's options (left, right or center[default])69* @param roller - pointer to a roller object70* @param align - one of lv_label_align_t values (left, right, center)71*/72void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align);7374/**75* Set the options on a roller76* @param roller pointer to roller object77* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"78*/79static inline void lv_roller_set_options(lv_obj_t * roller, const char * options)80{81lv_ddlist_set_options(roller, options);82}8384/**85* Set the selected option86* @param roller pointer to a roller object87* @param sel_opt id of the selected option (0 ... number of option - 1);88* @param anim_en true: set with animation; false set immediately89*/90void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt, bool anim_en);9192/**93* Set a function to call when a new option is chosen94* @param roller pointer to a roller95* @param action pointer to a callback function96*/97static inline void lv_roller_set_action(lv_obj_t * roller, lv_action_t action)98{99lv_ddlist_set_action(roller, action);100}101102/**103* Set the height to show the given number of rows (options)104* @param roller pointer to a roller object105* @param row_cnt number of desired visible rows106*/107void lv_roller_set_visible_row_count(lv_obj_t *roller, uint8_t row_cnt);108109/**110* Enable or disable the horizontal fit to the content111* @param roller pointer to a roller112* @param en true: enable auto fit; false: disable auto fit113*/114static inline void lv_roller_set_hor_fit(lv_obj_t * roller, bool en)115{116lv_ddlist_set_hor_fit(roller, en);117}118119/**120* Set the open/close animation time.121* @param roller pointer to a roller object122* @param anim_time: open/close animation time [ms]123*/124static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)125{126lv_ddlist_set_anim_time(roller, anim_time);127}128129/**130* Set a style of a roller131* @param roller pointer to a roller object132* @param type which style should be set133* @param style pointer to a style134*/135void lv_roller_set_style(lv_obj_t *roller, lv_roller_style_t type, lv_style_t *style);136137/*=====================138* Getter functions139*====================*/140141/**142* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER143* @param roller pointer to a roller object144* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER145*/146lv_label_align_t lv_roller_get_align(const lv_obj_t * roller);147148/**149* Get the options of a roller150* @param roller pointer to roller object151* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")152*/153static inline const char * lv_roller_get_options(const lv_obj_t *roller)154{155return lv_ddlist_get_options(roller);156}157158/**159* Get the id of the selected option160* @param roller pointer to a roller object161* @return id of the selected option (0 ... number of option - 1);162*/163static inline uint16_t lv_roller_get_selected(const lv_obj_t *roller)164{165return lv_ddlist_get_selected(roller);166}167168/**169* Get the current selected option as a string170* @param roller pointer to roller object171* @param buf pointer to an array to store the string172*/173static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf)174{175lv_ddlist_get_selected_str(roller, buf);176}177178/**179* Get the "option selected" callback function180* @param roller pointer to a roller181* @return pointer to the call back function182*/183static inline lv_action_t lv_roller_get_action(const lv_obj_t * roller)184{185return lv_ddlist_get_action(roller);186}187188/**189* Get the open/close animation time.190* @param roller pointer to a roller191* @return open/close animation time [ms]192*/193static inline uint16_t lv_roller_get_anim_time(const lv_obj_t * roller)194{195return lv_ddlist_get_anim_time(roller);196}197198/**199* Get the auto width set attribute200* @param roller pointer to a roller object201* @return true: auto size enabled; false: manual width settings enabled202*/203bool lv_roller_get_hor_fit(const lv_obj_t *roller);204205/**206* Get a style of a roller207* @param roller pointer to a roller object208* @param type which style should be get209* @return style pointer to a style210* */211lv_style_t * lv_roller_get_style(const lv_obj_t *roller, lv_roller_style_t type);212213/**********************214* MACROS215**********************/216217#endif /*USE_LV_ROLLER*/218219#ifdef __cplusplus220} /* extern "C" */221#endif222223#endif /*LV_ROLLER_H*/224225226