1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

lv_roller: API added

This commit is contained in:
Gabor Kiss-Vamosi 2017-11-05 22:37:03 +01:00
parent 8eb4317e37
commit 1246878f00
5 changed files with 302 additions and 127 deletions

View File

@ -40,7 +40,6 @@ static void lv_ddlist_pos_current_option(lv_obj_t * ddlist);
static lv_signal_func_t ancestor_signal;
static lv_signal_func_t ancestor_scrl_signal;
static lv_design_func_t ancestor_design;
static const char * def_options[] = {"Option 1", "Option 2", "Option 3", ""};
/**********************
* MACROS
**********************/
@ -98,7 +97,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy)
lv_page_set_release_action(new_ddlist, lv_ddlist_rel_action);
lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG);
lv_ddlist_set_style(new_ddlist, &lv_style_pretty, NULL, &lv_style_plain_color);
lv_ddlist_set_options(new_ddlist, def_options);
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
}
/*Copy an existing drop down list*/
else {
@ -187,36 +186,12 @@ bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param)
* Setter functions
*====================*/
/**
* Set the options in a drop down list from an array
* @param ddlist pointer to drop down list object
* @param options an array of strings with the text of the options.
* The lest element has to be "" (empty string)
* E.g. const char * opts[] = {"apple", "banana", "orange", ""};
*/
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_label_set_text(ext->options_label, "");
uint16_t i = 0;
while(options[i][0] != '\0') {
lv_label_ins_text(ext->options_label, LV_LABEL_POS_LAST, options[i]);
if(options[i + 1][0] != '\0') lv_label_ins_text(ext->options_label, LV_LABEL_POS_LAST, "\n");
i++;
}
ext->option_cnt = i;
lv_ddlist_refr_size(ddlist, 0);
}
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options)
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
@ -254,7 +229,7 @@ void lv_ddlist_set_selected(lv_obj_t * ddlist, uint16_t sel_opt)
/**
* Set a function to call when a new option is chosen
* @param ddlist pointer to a drop down list
* @param cb pointer to a call back function
* @param action pointer to a call back function
*/
void lv_ddlist_set_action(lv_obj_t * ddlist, lv_action_t action)
{
@ -326,7 +301,6 @@ void lv_ddlist_set_style(lv_obj_t * ddlist, lv_style_t *bg, lv_style_t *sb, lv_s
lv_obj_set_style(ext->options_label, bg);
lv_page_set_style(ddlist, bg, &lv_style_transp_tight, sb);
}
/*=====================
@ -381,6 +355,17 @@ void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf)
buf[c] = '\0';
}
/**
* Get the "option selected" callback function
* @param ddlist pointer to a drop down list
* @return pointer to the call back function
*/
lv_action_t lv_ddlist_get_action(lv_obj_t * ddlist)
{
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
return ext->callback;
}
/**
* Get the fix height value.
* @param ddlist pointer to a drop down list object
@ -404,6 +389,7 @@ lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist)
return ext->selected_style;
}
/**
* Get the open/close animation time.
* @param ddlist pointer to a drop down list
@ -443,7 +429,6 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
if(ext->opened != 0) {
lv_style_t *style = lv_ddlist_get_style_bg(ddlist);
lv_obj_t *scrl = lv_page_get_scrl(ddlist);
const font_t * font = style->text.font;
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
area_t rect_area;
@ -452,8 +437,8 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const area_t * mask, lv_design_m
rect_area.y1 -= style->text.line_space / 2;
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
rect_area.x1 = scrl->coords.x1 - (style->body.padding.hor >> 1); /*Draw a littlebit wider rectangle then the text*/
rect_area.x2 = scrl->coords.x2 + (style->body.padding.hor >> 1);
rect_area.x1 = ddlist->coords.x1;
rect_area.x2 = ddlist->coords.x2;
lv_draw_rect(&rect_area, mask, ext->selected_style);
}
@ -485,10 +470,10 @@ static bool lv_ddlist_scrl_signal(lv_obj_t * scrl, lv_signal_t sign, void * para
if(valid != false) {
if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
/* Because of the wider selected rectangle ext. size
* In this way by dragging the scrollable part the wider rectangle area will be redrawn too*/
* In this way by dragging the scrollable part the wider rectangle area can be redrawn too*/
lv_obj_t *ddlist = lv_obj_get_parent(scrl);
lv_style_t *style = lv_ddlist_get_style_bg(ddlist);
if(scrl->ext_size < (style->body.padding.hor >> 1)) scrl->ext_size = style->body.padding.hor >> 1;
if(scrl->ext_size < style->body.padding.hor) scrl->ext_size = style->body.padding.hor;
}
}

View File

@ -73,21 +73,12 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy);
*/
bool lv_ddlist_signal(lv_obj_t * ddlist, lv_signal_t sign, void * param);
/**
* Set the options in a drop down list from an array
* @param ddlist pointer to drop down list object
* @param options an array of strings with the text of the options.
* The lest element has to be "" (empty string)
* E.g. const char * opts[] = {"apple", "banana", "orange", ""};
*/
void lv_ddlist_set_options(lv_obj_t * ddlist, const char ** options);
/**
* Set the options in a drop down list from a string
* @param ddlist pointer to drop down list object
* @param options a string with '\n' separated options. E.g. "One\nTwo\nThree"
*/
void lv_ddlist_set_options_str(lv_obj_t * ddlist, const char * options);
void lv_ddlist_set_options(lv_obj_t * ddlist, const char * options);
/**
* Set the selected option
@ -162,6 +153,13 @@ uint16_t lv_ddlist_get_selected(lv_obj_t * ddlist);
*/
void lv_ddlist_get_selected_str(lv_obj_t * ddlist, char * buf);
/**
* Get the "option selected" callback function
* @param ddlist pointer to a drop down list
* @return pointer to the call back function
*/
lv_action_t lv_ddlist_get_action(lv_obj_t * ddlist);
/**
* Get the fix height value.
* @param ddlist pointer to a drop down list object
@ -210,7 +208,7 @@ static inline lv_page_sb_mode_t lv_ddlist_get_sb_mode(lv_obj_t * ta)
/**
* Get the style of the drop down list background
* @param ddlist pointer to a text area object
* @param ddlist pointer to a drop down list object
* @return pointer to the style of the background
*/
static inline lv_style_t * lv_ddlist_get_style_bg(lv_obj_t * ddlist)

View File

@ -435,6 +435,8 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
/*The scrollbars are important only if they are visible now*/
if(ext->sb.hor_draw || ext->sb.ver_draw) lv_page_sb_refresh(page);
/*Refresh the ext. size because the scrollbars might be positioned out of the page*/
lv_obj_refresh_ext_size(page);
}
else if(sign == LV_SIGNAL_CORD_CHG) {
/*Refresh the scrollbar and notify the scrl if the size is changed*/
@ -464,6 +466,11 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
}
}
}
else if(sign == LV_SIGNAL_REFR_EXT_SIZE) {
/*Ensure ext. size for the scrollbars if they are out of the page*/
if(page->ext_size < (-ext->sb.style->body.padding.hor)) page->ext_size = -ext->sb.style->body.padding.hor;
if(page->ext_size < (-ext->sb.style->body.padding.ver)) page->ext_size = -ext->sb.style->body.padding.ver;
}
}
return res;

View File

@ -24,12 +24,16 @@
* STATIC PROTOTYPES
**********************/
static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_mode_t mode);
static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * indev);
static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param);
static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param);
static void refr_position(lv_obj_t *roller, bool anim_en);
static void draw_bg(lv_obj_t *roller, const area_t *mask);
/**********************
* STATIC VARIABLES
**********************/
static lv_signal_func_t ancestor_scr_signal_f;
static lv_signal_func_t ancestor_signal;
static lv_signal_func_t ancestor_scrl_signal;
/**********************
* MACROS
@ -54,6 +58,8 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
/*Create the ancestor of roller*/
lv_obj_t * new_roller = lv_ddlist_create(par, copy);
dm_assert(new_roller);
if(ancestor_scrl_signal == NULL) ancestor_scrl_signal = lv_obj_get_signal_func(lv_page_get_scrl(new_roller));
if(ancestor_signal == NULL) ancestor_signal = lv_obj_get_signal_func(new_roller);
/*Allocate the roller type specific extended data*/
lv_roller_ext_t * ext = lv_obj_allocate_ext_attr(new_roller, sizeof(lv_roller_ext_t));
@ -65,7 +71,6 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_signal_func(new_roller, lv_roller_signal);
lv_obj_set_design_func(new_roller, lv_roller_design);
if(ancestor_scr_signal_f == NULL) ancestor_scr_signal_f = lv_obj_get_signal_func(lv_page_get_scrl(new_roller));
/*Init the new roller roller*/
if(copy == NULL) {
@ -73,9 +78,11 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
lv_obj_set_drag(scrl, true); /*In ddlist is might be disabled*/
lv_page_set_release_action(new_roller, NULL); /*Handle roller specific actions*/
lv_cont_set_fit(lv_page_get_scrl(new_roller), true, false); /*Height is specified directly*/
lv_obj_set_signal_func(scrl, roller_scrl_signal);
lv_obj_set_signal_func(scrl, lv_roller_scrl_signal);
lv_ddlist_open(new_roller, false);
lv_label_set_align(ext->ddlist.options_label, LV_LABEL_ALIGN_CENTER);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
lv_ddlist_set_fix_height(new_roller, (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) * 3
+ style_label->text.line_space * 4);
@ -92,41 +99,6 @@ lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy)
return new_roller;
}
/**
* Signal function of the roller
* @param roller pointer to a roller object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param)
{
bool valid;
/* Include the ancient signal function */
valid = lv_ddlist_signal(roller, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
} else if(sign == LV_SIGNAL_CORD_CHG) {
lv_ddlist_set_fix_height(roller, lv_obj_get_height(roller));
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
}
}
return valid;
}
/*======================
* Add/remove functions
*=====================*/
@ -184,17 +156,18 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
}
/*Draw the object*/
else if(mode == LV_DESIGN_DRAW_MAIN) {
lv_style_t * style = lv_obj_get_style(roller);
lv_draw_rect(&roller->coords, mask, style);
draw_bg(roller, mask);
lv_style_t *style = lv_ddlist_get_style_bg(roller);
const font_t * font = style->text.font;
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
area_t rect_area;
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space - 2;
rect_area.y1 = roller->coords.y1 + lv_obj_get_height(roller) / 2 - font_h / 2 - style->text.line_space / 2;
rect_area.y2 = rect_area.y1 + font_h + style->text.line_space;
rect_area.x1 = ext->ddlist.options_label->coords.x1 - style->body.padding.hor;
rect_area.x2 = rect_area.x1 + lv_obj_get_width(lv_page_get_scrl(roller));
rect_area.x1 = roller->coords.x1;
rect_area.x2 = roller->coords.x2;
lv_draw_rect(&rect_area, mask, ext->ddlist.selected_style);
}
@ -206,23 +179,60 @@ static bool lv_roller_design(lv_obj_t * roller, const area_t * mask, lv_design_m
return true;
}
/**
* Signal function of the roller
* @param roller pointer to a roller object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static lv_res_t lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param)
{
lv_res_t res;
/* Include the ancient signal function */
res = ancestor_signal(roller, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(res == LV_RES_OK) {
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
if(sign == LV_SIGNAL_STYLE_CHG) {
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
refr_position(roller, false);
} else if(sign == LV_SIGNAL_CORD_CHG) {
lv_ddlist_set_fix_height(roller, lv_obj_get_height(roller));
lv_obj_set_height(lv_page_get_scrl(roller),
lv_obj_get_height(ext->ddlist.options_label) + lv_obj_get_height(roller));
lv_obj_align(ext->ddlist.options_label, NULL, LV_ALIGN_CENTER, 0, 0);
lv_ddlist_set_selected(roller, ext->ddlist.selected_option_id);
refr_position(roller, false);
}
}
return res;
}
/**
* Signal function of the scrollable part of the roller.
* @param roller_scrl ointer to the scrollable part of roller (page)
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
* @return LV_RES_OK: the object is not deleted in the function; LV_RES_INV: the object is deleted
*/
static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param)
static lv_res_t lv_roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void * param)
{
bool valid;
lv_res_t res;
/* Include the ancient signal function */
valid = ancestor_scr_signal_f(roller_scrl, sign, param);
res = ancestor_scrl_signal(roller_scrl, sign, param);
/* The object can be deleted so check its validity and then
* make the object specific signal handling */
if(valid != false) {
if(res == LV_RES_OK) {
lv_indev_t * indev = lv_indev_get_act();
int32_t id = -1;
lv_obj_t * roller = lv_obj_get_parent(roller_scrl);
@ -233,9 +243,9 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
if(sign == LV_SIGNAL_DRAG_END) {
/*If dragged then align the list to there be an element in the middle*/
cord_t label_y1 = ext->ddlist.options_label->coords.y1 - roller->coords.y1;
cord_t label_unit = (font_get_height(style_label->text.font) >> FONT_ANTIALIAS) + style_label->text.line_space / 2;
cord_t label_unit = font_h + style_label->text.line_space;
cord_t mid = (roller->coords.y2 - roller->coords.y1) / 2;
id = (mid - label_y1) / label_unit;
id = (mid - label_y1 + style_label->text.line_space / 2) / label_unit;
if(id < 0) id = 0;
if(id >= ext->ddlist.option_cnt) id = ext->ddlist.option_cnt - 1;
ext->ddlist.selected_option_id = id;
@ -255,34 +265,104 @@ static bool roller_scrl_signal(lv_obj_t * roller_scrl, lv_signal_t sign, void *
/*Position the scrollable according to the new selected option*/
if(id != -1) {
cord_t h = lv_obj_get_height(roller);
cord_t line_y1 = id * (font_h + style_label->text.line_space) + ext->ddlist.options_label->coords.y1 - roller_scrl->coords.y1;
cord_t new_y = - line_y1 + (h - font_h) / 2;
if(ext->ddlist.anim_time == 0) {
lv_obj_set_y(roller_scrl, new_y);
} else {
anim_t a;
a.var = roller_scrl;
a.start = lv_obj_get_y(roller_scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = ext->ddlist.anim_time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
refr_position(roller, true);
}
}
return valid;
return res;
}
/**
* Draw a rectangle which has gradient on its top and bottom
* @param roller pointer to a roller object
* @param mask pointer to the current mask (from the design function)
*/
static void draw_bg(lv_obj_t *roller, const area_t *mask)
{
lv_style_t *style = lv_ddlist_get_style_bg(roller);
area_t half_mask;
area_t half_roller;
cord_t h = lv_obj_get_height(roller);
bool union_ok;
area_cpy(&half_roller, &roller->coords);
half_roller.x1 -= roller->ext_size; /*Add ext size too (e.g. because of shadow draw) */
half_roller.x2 += roller->ext_size;
half_roller.y1 -= roller->ext_size;
half_roller.y2 = roller->coords.y1 + h / 2;
union_ok = area_union(&half_mask, &half_roller, mask);
half_roller.x1 += roller->ext_size; /*Revert ext. size adding*/
half_roller.x2 -= roller->ext_size;
half_roller.y1 += roller->ext_size;
half_roller.y2 += style->body.radius;
if(union_ok) {
lv_draw_rect(&half_roller, &half_mask, style);
}
half_roller.x1 -= roller->ext_size; /*Add ext size too (e.g. because of shadow draw) */
half_roller.x2 += roller->ext_size;
half_roller.y2 = roller->coords.y2 + roller->ext_size;
half_roller.y1 = roller->coords.y1 + h / 2;
if((h & 0x1) == 0) half_roller.y1++; /*With even height the pixels in the middle would be drawn twice*/
union_ok = area_union(&half_mask, &half_roller, mask);
half_roller.x1 += roller->ext_size; /*Revert ext. size adding*/
half_roller.x2 -= roller->ext_size;
half_roller.y2 -= roller->ext_size;
half_roller.y1 -= style->body.radius;
if(union_ok){
color_t main_tmp = style->body.color_main;
color_t grad_tmp = style->body.color_gradient;
style->body.color_main = grad_tmp;
style->body.color_gradient = main_tmp;
lv_draw_rect(&half_roller, &half_mask, style);
style->body.color_main = main_tmp;
style->body.color_gradient = grad_tmp;
}
}
/**
* Refresh the position of the roller. It uses the id stored in: ext->ddlist.selected_option_id
* @param roller pointer to a roller object
* @param anim_en true: refresh with animation; false: without animation
*/
static void refr_position(lv_obj_t *roller, bool anim_en)
{
lv_obj_t *roller_scrl = lv_page_get_scrl(roller);
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
lv_style_t * style_label = lv_obj_get_style(ext->ddlist.options_label);
const font_t * font = style_label->text.font;
cord_t font_h = font_get_height(font) >> FONT_ANTIALIAS;
cord_t h = lv_obj_get_height(roller);
int32_t id = ext->ddlist.selected_option_id;
cord_t line_y1 = id * (font_h + style_label->text.line_space) + ext->ddlist.options_label->coords.y1 - roller_scrl->coords.y1;
cord_t new_y = - line_y1 + (h - font_h) / 2;
if(ext->ddlist.anim_time == 0 || anim_en == false) {
lv_obj_set_y(roller_scrl, new_y);
} else {
anim_t a;
a.var = roller_scrl;
a.start = lv_obj_get_y(roller_scrl);
a.end = new_y;
a.fp = (anim_fp_t)lv_obj_set_y;
a.path = anim_get_path(ANIM_PATH_LIN);
a.end_cb = NULL;
a.act_time = 0;
a.time = ext->ddlist.anim_time;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
anim_create(&a);
}
}
#endif

View File

@ -44,15 +44,120 @@ typedef struct {
*/
lv_obj_t * lv_roller_create(lv_obj_t * par, lv_obj_t * copy);
/**
* Signal function of the roller
* @param roller pointer to a roller object
* @param sign a signal type from lv_signal_t enum
* @param param pointer to a signal specific variable
* @return true: the object is still valid (not deleted), false: the object become invalid
*/
bool lv_roller_signal(lv_obj_t * roller, lv_signal_t sign, void * param);
/****************************
* TRANSPARENT API FUNCTIONS
***************************/
/**
* 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"
*/
static inline void lv_roller_set_options(lv_obj_t * roller, const char * options)
{
lv_ddlist_set_options(roller, options);
}
/**
* Set the selected option
* @param roller pointer to a roller object
* @param sel_opt id of the selected option (0 ... number of option - 1);
*/
static inline void lv_roller_set_selected(lv_obj_t *roller, uint16_t sel_opt)
{
lv_ddlist_set_selected(roller, sel_opt);
}
/**
* Set the open/close animation time.
* @param roller pointer to a roller object
* @param anim_time: open/close animation time [ms]
*/
static inline void lv_roller_set_anim_time(lv_obj_t *roller, uint16_t anim_time)
{
lv_ddlist_set_anim_time(roller, anim_time);
}
/**
* Set the style of a roller
* @param roller pointer to a roller object
* @param bg pointer to the new style of the background
* @param sel pointer to the new style of the select rectangle
*/
static inline void lv_roller_set_style(lv_obj_t *roller, lv_style_t *bg, lv_style_t *sel)
{
lv_ddlist_set_style(roller, bg, NULL, sel);
}
/**
* Get the options of a roller
* @param roller pointer to roller object
* @return the options separated by '\n'-s (E.g. "Option1\nOption2\nOption3")
*/
static inline const char * lv_roller_get_options(lv_obj_t *roller)
{
return lv_ddlist_get_options(roller);
}
/**
* 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);
*/
static inline uint16_t lv_roller_get_selected(lv_obj_t *roller)
{
return lv_ddlist_get_selected(roller);
}
/**
* Get the current selected option as a string
* @param roller pointer to roller object
* @param buf pointer to an array to store the string
*/
static inline void lv_roller_get_selected_str(lv_obj_t * roller, char * buf)
{
lv_roller_get_selected_str(roller, buf);
}
/**
* Get the "option selected" callback function
* @param roller pointer to a roller
* @return pointer to the call back function
*/
static inline lv_action_t lv_roller_get_action(lv_obj_t * roller)
{
return lv_ddlist_get_action(roller);
}
/**
* Get the open/close animation time.
* @param roller pointer to a roller
* @return open/close animation time [ms]
*/
static inline uint16_t lv_roller_get_anim_time(lv_obj_t * roller)
{
return lv_ddlist_get_anim_time(roller);
}
/**
* Get the style of the roller's background
* @param roller pointer to a roller object
* @return pointer to the background's style
*/
static inline lv_style_t * lv_roller_get_style_bg(lv_obj_t *roller)
{
return lv_ddlist_get_style_bg(roller);
}
/**
* Get the style of the roller's selected rectangle
* @param roller pointer to a roller object
* @return pointer to the selected rectangle's style
*/
static inline lv_style_t * lv_roller_get_style_selected(lv_obj_t *roller)
{
return lv_ddlist_get_style_select(roller);
}
/**********************
* MACROS