2017-09-03 16:01:51 +02:00
|
|
|
/**
|
|
|
|
* @file lv_roller.h
|
2018-06-19 09:49:58 +02:00
|
|
|
*
|
2017-09-03 16:01:51 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LV_ROLLER_H
|
|
|
|
#define LV_ROLLER_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*********************
|
|
|
|
* INCLUDES
|
|
|
|
*********************/
|
2019-12-26 02:49:30 +01:00
|
|
|
#include "../lv_conf_internal.h"
|
2018-07-07 11:53:22 +02:00
|
|
|
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_ROLLER != 0
|
2017-09-03 16:01:51 +02:00
|
|
|
|
2018-01-19 15:40:22 +01:00
|
|
|
/*Testing of dependencies*/
|
2019-03-07 00:05:16 +01:00
|
|
|
#if LV_USE_DDLIST == 0
|
|
|
|
#error "lv_roller: lv_ddlist is required. Enable it in lv_conf.h (LV_USE_DDLIST 1) "
|
2018-01-19 15:40:22 +01:00
|
|
|
#endif
|
|
|
|
|
2017-11-30 11:35:33 +01:00
|
|
|
#include "../lv_core/lv_obj.h"
|
2017-09-03 16:01:51 +02:00
|
|
|
#include "lv_ddlist.h"
|
2018-12-05 11:46:37 +02:00
|
|
|
#include "lv_label.h"
|
2017-09-03 16:01:51 +02:00
|
|
|
|
|
|
|
/*********************
|
|
|
|
* DEFINES
|
|
|
|
*********************/
|
|
|
|
|
|
|
|
/**********************
|
|
|
|
* TYPEDEFS
|
|
|
|
**********************/
|
2019-06-25 15:14:47 +02:00
|
|
|
|
2019-06-27 18:07:26 -04:00
|
|
|
/** Roller mode. */
|
2019-06-25 15:14:47 +02:00
|
|
|
enum {
|
2019-06-27 18:07:26 -04:00
|
|
|
LV_ROLLER_MODE_NORMAL, /**< Normal mode (roller ends at the end of the options). */
|
|
|
|
LV_ROLLER_MODE_INIFINITE, /**< Infinite mode (roller can be scrolled forever). */
|
2019-06-25 15:14:47 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef uint8_t lv_roller_mode_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-09-03 16:01:51 +02:00
|
|
|
/*Data of roller*/
|
2019-04-04 07:15:40 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
2017-09-03 16:01:51 +02:00
|
|
|
lv_ddlist_ext_t ddlist; /*Ext. of ancestor*/
|
|
|
|
/*New data for this type */
|
2019-06-25 15:14:47 +02:00
|
|
|
lv_roller_mode_t mode : 1;
|
2018-06-19 09:49:58 +02:00
|
|
|
} lv_roller_ext_t;
|
2017-09-03 16:01:51 +02:00
|
|
|
|
2018-09-18 13:59:40 +02:00
|
|
|
enum {
|
2017-11-15 15:50:33 +01:00
|
|
|
LV_ROLLER_STYLE_BG,
|
2017-11-16 10:20:30 +01:00
|
|
|
LV_ROLLER_STYLE_SEL,
|
2018-09-18 13:59:40 +02:00
|
|
|
};
|
|
|
|
typedef uint8_t lv_roller_style_t;
|
2017-11-15 15:50:33 +01:00
|
|
|
|
2017-09-03 16:01:51 +02:00
|
|
|
/**********************
|
|
|
|
* GLOBAL PROTOTYPES
|
|
|
|
**********************/
|
|
|
|
|
|
|
|
/**
|
2017-11-10 15:01:40 +01:00
|
|
|
* Create a roller object
|
2017-09-03 16:01:51 +02:00
|
|
|
* @param par pointer to an object, it will be the parent of the new roller
|
|
|
|
* @param copy pointer to a roller object, if not NULL then the new object will be copied from it
|
|
|
|
* @return pointer to the created roller
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
lv_obj_t * lv_roller_create(lv_obj_t * par, const lv_obj_t * copy);
|
2017-09-03 16:01:51 +02:00
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/*=====================
|
|
|
|
* Setter functions
|
|
|
|
*====================*/
|
2017-11-05 22:37:03 +01:00
|
|
|
|
2019-03-17 04:32:37 +01:00
|
|
|
/**
|
|
|
|
* Set the options on a roller
|
|
|
|
* @param roller pointer to roller object
|
|
|
|
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
|
2019-06-25 15:14:47 +02:00
|
|
|
* @param mode `LV_ROLLER_MODE_NORMAL` or `LV_ROLLER_MODE_INFINITE`
|
2019-03-17 04:32:37 +01:00
|
|
|
*/
|
2019-06-25 15:14:47 +02:00
|
|
|
void lv_roller_set_options(lv_obj_t * roller, const char * options, lv_roller_mode_t mode);
|
2019-03-17 04:32:37 +01:00
|
|
|
|
2018-12-05 11:46:37 +02:00
|
|
|
/**
|
|
|
|
* Set the align of the roller's options (left, right or center[default])
|
|
|
|
* @param roller - pointer to a roller object
|
|
|
|
* @param align - one of lv_label_align_t values (left, right, center)
|
|
|
|
*/
|
|
|
|
void lv_roller_set_align(lv_obj_t * roller, lv_label_align_t align);
|
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
|
|
|
* Set the selected option
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @param sel_opt id of the selected option (0 ... number of option - 1);
|
2019-06-11 13:51:14 +02:00
|
|
|
* @param anim LV_ANOM_ON: set with animation; LV_ANIM_OFF set immediately
|
2017-11-10 15:01:40 +01:00
|
|
|
*/
|
2019-06-11 13:51:14 +02:00
|
|
|
void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, lv_anim_enable_t anim);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
2017-12-17 20:11:14 +01:00
|
|
|
/**
|
|
|
|
* Set the height to show the given number of rows (options)
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @param row_cnt number of desired visible rows
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
void lv_roller_set_visible_row_count(lv_obj_t * roller, uint8_t row_cnt);
|
2017-11-18 00:18:19 +01:00
|
|
|
|
2017-11-17 15:43:08 +01:00
|
|
|
/**
|
2019-06-17 16:05:30 +02:00
|
|
|
* Set a fix width for the drop down list
|
|
|
|
* @param roller pointer to a roller obejct
|
|
|
|
* @param w the width when the list is opened (0: auto size)
|
2017-11-17 15:43:08 +01:00
|
|
|
*/
|
2019-06-17 16:05:30 +02:00
|
|
|
static inline void lv_roller_set_fix_width(lv_obj_t * roller, lv_coord_t w)
|
2017-11-17 15:43:08 +01:00
|
|
|
{
|
2019-06-17 16:05:30 +02:00
|
|
|
lv_ddlist_set_fix_width(roller, w);
|
2017-11-17 15:43:08 +01:00
|
|
|
}
|
|
|
|
|
2017-11-05 22:37:03 +01:00
|
|
|
/**
|
|
|
|
* Set the open/close animation time.
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @param anim_time: open/close animation time [ms]
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
static inline void lv_roller_set_anim_time(lv_obj_t * roller, uint16_t anim_time)
|
2017-11-05 22:37:03 +01:00
|
|
|
{
|
|
|
|
lv_ddlist_set_anim_time(roller, anim_time);
|
|
|
|
}
|
|
|
|
|
2017-11-15 15:50:33 +01:00
|
|
|
/**
|
|
|
|
* Set a style of a roller
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @param type which style should be set
|
|
|
|
* @param style pointer to a style
|
|
|
|
*/
|
2019-04-11 19:59:55 +08:00
|
|
|
void lv_roller_set_style(lv_obj_t * roller, lv_roller_style_t type, const lv_style_t * style);
|
2017-11-15 15:50:33 +01:00
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/*=====================
|
|
|
|
* Getter functions
|
|
|
|
*====================*/
|
2019-03-17 05:07:16 +01:00
|
|
|
/**
|
|
|
|
* Get the id of the selected option
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @return id of the selected option (0 ... number of option - 1);
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
uint16_t lv_roller_get_selected(const lv_obj_t * roller);
|
2019-03-17 05:07:16 +01:00
|
|
|
|
2019-12-19 16:34:10 -05:00
|
|
|
/**
|
|
|
|
* Get the total number of options
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @return the total number of options in the list
|
|
|
|
*/
|
|
|
|
uint16_t lv_roller_get_option_cnt(const lv_obj_t * roller);
|
|
|
|
|
2019-03-17 05:07:16 +01:00
|
|
|
/**
|
|
|
|
* Get the current selected option as a string
|
|
|
|
* @param roller pointer to roller object
|
|
|
|
* @param buf pointer to an array to store the string
|
2019-03-29 16:10:18 +01:00
|
|
|
* @param buf_size size of `buf` in bytes. 0: to ignore it.
|
2019-03-17 05:07:16 +01:00
|
|
|
*/
|
2019-06-06 06:05:40 +02:00
|
|
|
static inline void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t buf_size)
|
2019-03-29 16:10:18 +01:00
|
|
|
{
|
|
|
|
lv_ddlist_get_selected_str(roller, buf, buf_size);
|
|
|
|
}
|
2017-11-05 22:37:03 +01:00
|
|
|
|
2018-12-05 11:46:37 +02:00
|
|
|
/**
|
|
|
|
* Get the align attribute. Default alignment after _create is LV_LABEL_ALIGN_CENTER
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @return LV_LABEL_ALIGN_LEFT, LV_LABEL_ALIGN_RIGHT or LV_LABEL_ALIGN_CENTER
|
|
|
|
*/
|
|
|
|
lv_label_align_t lv_roller_get_align(const lv_obj_t * roller);
|
|
|
|
|
2017-11-05 22:37:03 +01:00
|
|
|
/**
|
|
|
|
* Get the options of a roller
|
|
|
|
* @param roller pointer to roller object
|
|
|
|
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
|
2017-09-03 16:01:51 +02:00
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
static inline const char * lv_roller_get_options(const lv_obj_t * roller)
|
2017-11-05 22:37:03 +01:00
|
|
|
{
|
|
|
|
return lv_ddlist_get_options(roller);
|
|
|
|
}
|
2017-09-03 16:01:51 +02:00
|
|
|
|
2017-11-05 22:37:03 +01:00
|
|
|
/**
|
|
|
|
* Get the open/close animation time.
|
|
|
|
* @param roller pointer to a roller
|
|
|
|
* @return open/close animation time [ms]
|
|
|
|
*/
|
2018-07-30 06:52:29 +02:00
|
|
|
static inline uint16_t lv_roller_get_anim_time(const lv_obj_t * roller)
|
2017-11-05 22:37:03 +01:00
|
|
|
{
|
|
|
|
return lv_ddlist_get_anim_time(roller);
|
|
|
|
}
|
|
|
|
|
2017-11-10 15:01:40 +01:00
|
|
|
/**
|
|
|
|
* Get the auto width set attribute
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @return true: auto size enabled; false: manual width settings enabled
|
|
|
|
*/
|
2019-04-04 07:15:40 +02:00
|
|
|
bool lv_roller_get_hor_fit(const lv_obj_t * roller);
|
2017-11-10 15:01:40 +01:00
|
|
|
|
2017-11-05 22:37:03 +01:00
|
|
|
/**
|
2017-11-15 15:50:33 +01:00
|
|
|
* Get a style of a roller
|
|
|
|
* @param roller pointer to a roller object
|
|
|
|
* @param type which style should be get
|
|
|
|
* @return style pointer to a style
|
|
|
|
* */
|
2019-04-11 19:59:55 +08:00
|
|
|
const lv_style_t * lv_roller_get_style(const lv_obj_t * roller, lv_roller_style_t type);
|
2017-11-05 22:37:03 +01:00
|
|
|
|
2017-09-03 16:01:51 +02:00
|
|
|
/**********************
|
|
|
|
* MACROS
|
|
|
|
**********************/
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_USE_ROLLER*/
|
2017-09-03 16:01:51 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /* extern "C" */
|
|
|
|
#endif
|
|
|
|
|
2019-04-04 07:15:40 +02:00
|
|
|
#endif /*LV_ROLLER_H*/
|