begin indexed interface

This commit is contained in:
Gabor Kiss-Vamosi
2018-08-14 01:20:18 +02:00
22 changed files with 422 additions and 146 deletions

View File

@@ -389,14 +389,12 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
}
else if(mode == LV_DESIGN_DRAW_MAIN) {
ancestor_design(btn, mask, mode);
#if USE_LV_ANIMATION
if(btn != ink_obj) {
lv_style_t * style = lv_obj_get_style(btn);
lv_draw_rect(&btn->coords, mask, style, LV_OPA_COVER);
ancestor_design(btn, mask, mode);
} else {
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
lv_opa_t opa_scale = lv_obj_get_opa_scale(btn);
lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn);
/*Draw the normal button*/
lv_draw_rect(&btn->coords, mask, ext->styles[ink_bg_state], opa_scale);
@@ -436,6 +434,8 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode
/*Draw the circle*/
lv_draw_rect(&cir_area, mask, &cir_style, opa_scale);
}
#else
ancestor_design(btn, mask, mode);
#endif
}
else if(mode == LV_DESIGN_DRAW_POST) {

View File

@@ -108,6 +108,7 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, const lv_obj_t * copy)
lv_cont_set_fit(new_ddlist, true, false);
lv_page_set_rel_action(new_ddlist, lv_ddlist_release_action);
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_DRAG);
lv_page_set_sb_mode(new_ddlist, LV_SB_MODE_HIDE);
lv_page_set_style(new_ddlist, LV_PAGE_STYLE_SCRL, &lv_style_transp_tight);
lv_ddlist_set_options(new_ddlist, "Option 1\nOption 2\nOption 3");
@@ -465,39 +466,40 @@ static bool lv_ddlist_design(lv_obj_t * ddlist, const lv_area_t * mask, lv_desig
}
/*Post draw when the children are drawn*/
else if(mode == LV_DESIGN_DRAW_POST) {
ancestor_design(ddlist, mask, mode);
/*Redraw the text on the selected area with a different color*/
lv_ddlist_ext_t * ext = lv_obj_get_ext_attr(ddlist);
lv_opa_t opa_scale = lv_obj_get_opa_scale(ddlist);
/*Redraw only in opened state*/
if(ext->opened == 0) return true;
if(ext->opened) {
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_style_t * style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_BG);
const lv_font_t * font = style->text.font;
lv_coord_t font_h = lv_font_get_height(font);
lv_area_t area_sel;
area_sel.y1 = ext->label->coords.y1;
area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
area_sel.y1 -= style->text.line_space / 2;
lv_area_t area_sel;
area_sel.y1 = ext->label->coords.y1;
area_sel.y1 += ext->sel_opt_id * (font_h + style->text.line_space);
area_sel.y1 -= style->text.line_space / 2;
area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1;
area_sel.x1 = ddlist->coords.x1;
area_sel.x2 = ddlist->coords.x2;
lv_area_t mask_sel;
bool area_ok;
area_ok = lv_area_intersect(&mask_sel, mask, &area_sel);
if(area_ok) {
lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL);
lv_style_t new_style;
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
new_style.text.opa = sel_style->text.opa;
lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale,
lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL);
area_sel.y2 = area_sel.y1 + font_h + style->text.line_space - 1;
area_sel.x1 = ddlist->coords.x1;
area_sel.x2 = ddlist->coords.x2;
lv_area_t mask_sel;
bool area_ok;
area_ok = lv_area_intersect(&mask_sel, mask, &area_sel);
if(area_ok) {
lv_style_t * sel_style = lv_ddlist_get_style(ddlist, LV_DDLIST_STYLE_SEL);
lv_style_t new_style;
lv_style_copy(&new_style, style);
new_style.text.color = sel_style->text.color;
new_style.text.opa = sel_style->text.opa;
lv_draw_label(&ext->label->coords, &mask_sel, &new_style, opa_scale,
lv_label_get_text(ext->label), LV_TXT_FLAG_NONE, NULL);
}
}
/*Draw the scrollbar in the ancestor page design function*/
ancestor_design(ddlist, mask, mode);
}
return true;
@@ -682,11 +684,15 @@ static void lv_ddlist_refr_size(lv_obj_t * ddlist, bool anim_en)
if(ext->opened) { /*Open the list*/
if(ext->fix_height == 0) new_height = lv_obj_get_height(lv_page_get_scrl(ddlist)) + 2 * style->body.padding.ver;
else new_height = ext->fix_height;
lv_page_set_sb_mode(ddlist, LV_SB_MODE_UNHIDE);
} else { /*Close the list*/
const lv_font_t * font = style->text.font;
lv_style_t * label_style = lv_obj_get_style(ext->label);
lv_coord_t font_h = lv_font_get_height(font);
new_height = font_h + 2 * label_style->text.line_space;
lv_page_set_sb_mode(ddlist, LV_SB_MODE_HIDE);
}
if(anim_en == 0) {

View File

@@ -220,7 +220,7 @@ void lv_ddlist_open(lv_obj_t * ddlist, bool anim);
* @param ddlist pointer to drop down list object
* @param anim true: use animation; false: not use animations
*/
void lv_ddlist_close_en(lv_obj_t * ddlist, bool anim);
void lv_ddlist_close(lv_obj_t * ddlist, bool anim);
/**********************
* MACROS

View File

@@ -20,7 +20,7 @@
* DEFINES
*********************/
#define LV_PAGE_SB_MIN_SIZE (LV_DPI / 8)
#define LV_PAGE_GROUP_SCROLL_ANIM_TIME 200
#define LV_PAGE_SCROLL_ANIM_TIME 200 /*[ms] Scroll anim time on `lv_page_scroll_up/down/left/rigth`*/
/**********************
* TYPEDEFS
@@ -193,9 +193,16 @@ void lv_page_set_sb_mode(lv_obj_t * page, lv_sb_mode_t sb_mode)
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
if(ext->sb.mode == sb_mode) return;
ext->sb.mode = sb_mode;
if(sb_mode == LV_SB_MODE_HIDE) ext->sb.mode |= LV_SB_MODE_HIDE; /*Set the hidden flag*/
else if (sb_mode == LV_SB_MODE_UNHIDE) ext->sb.mode &= (~LV_SB_MODE_HIDE); /*Clear the hidden flag*/
else {
if(ext->sb.mode & LV_SB_MODE_HIDE) sb_mode |= LV_SB_MODE_HIDE;
ext->sb.mode = sb_mode;
}
ext->sb.hor_draw = 0;
ext->sb.ver_draw = 0;
lv_page_sb_refresh(page);
lv_obj_invalidate(page);
}
@@ -255,6 +262,28 @@ lv_obj_t * lv_page_get_scrl(const lv_obj_t * page)
return ext->scrl;
}
/**
* Get the press action of the page
* @param page pointer to a page object
* @return a function to call when the page is pressed
*/
lv_action_t lv_page_get_pr_action(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->pr_action;
}
/**
* Get the release action of the page
* @param page pointer to a page object
* @return a function to call when the page is released
*/
lv_action_t lv_page_get_rel_action(lv_obj_t * page)
{
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
return ext->rel_action;
}
/**
* Set the scroll bar mode on a page
* @param page pointer to a page object
@@ -389,58 +418,60 @@ void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time)
}
/**
* Scroll down the page a little
* Scroll the page horizontally
* @param page pointer to a page object
* @param dist the distance to scroll (< 0: scroll right; > 0 scroll left)
*/
void lv_page_scroll_down(lv_obj_t * page)
void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist)
{
lv_obj_t * scrl = lv_page_get_scrl(page);
#if USE_LV_ANIMATION
lv_anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = a.start - lv_obj_get_height(page) / 4;
a.fp = (lv_anim_fp_t)lv_obj_set_y;
a.start = lv_obj_get_x(scrl);
a.end = a.start + dist;
a.fp = (lv_anim_fp_t)lv_obj_set_x;
a.path = lv_anim_path_linear;
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME;
a.time = LV_PAGE_SCROLL_ANIM_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
lv_anim_create(&a);
#else
lv_obj_set_y(scrl, lv_obj_get_y(scrl) - lv_obj_get_height(page) / 4);
lv_obj_set_x(scrl, lv_obj_get_x(scrl) + dist);
#endif
}
/**
*Scroll up the page a little
* Scroll the page vertically
* @param page pointer to a page object
* @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
*/
void lv_page_scroll_up(lv_obj_t * page)
void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist)
{
lv_obj_t * scrl = lv_page_get_scrl(page);
#if USE_LV_ANIMATION
lv_anim_t a;
a.var = scrl;
a.start = lv_obj_get_y(scrl);
a.end = a.start + lv_obj_get_height(page) / 4;
a.end = a.start + dist;
a.fp = (lv_anim_fp_t)lv_obj_set_y;
a.path = lv_anim_path_linear;
a.end_cb = NULL;
a.act_time = 0;
a.time = LV_PAGE_GROUP_SCROLL_ANIM_TIME;
a.time = LV_PAGE_SCROLL_ANIM_TIME;
a.playback = 0;
a.playback_pause = 0;
a.repeat = 0;
a.repeat_pause = 0;
lv_anim_create(&a);
#else
lv_obj_set_y(scrl, lv_obj_get_y(scrl) + lv_obj_get_height(page) / 4);
lv_obj_set_y(scrl, lv_obj_get_x(scrl) + dist);
#endif
}
@@ -482,12 +513,11 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
style->body.shadow.width = shadow_width_tmp;
style->body.empty = empty_tmp;
lv_page_ext_t * ext = lv_obj_get_ext_attr(page);
/*Draw the scrollbars*/
lv_area_t sb_area;
if(ext->sb.hor_draw) {
if(ext->sb.hor_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
/*Convert the relative coordinates to absolute*/
lv_area_copy(&sb_area, &ext->sb.hor_area);
sb_area.x1 += page->coords.x1;
@@ -497,7 +527,7 @@ static bool lv_page_design(lv_obj_t * page, const lv_area_t * mask, lv_design_mo
lv_draw_rect(&sb_area, mask, ext->sb.style, lv_obj_get_opa_scale(page));
}
if(ext->sb.ver_draw) {
if(ext->sb.ver_draw && (ext->sb.mode & LV_SB_MODE_HIDE) == 0) {
/*Convert the relative coordinates to absolute*/
lv_area_copy(&sb_area, &ext->sb.ver_area);
sb_area.x1 += page->coords.x1;
@@ -627,11 +657,14 @@ static lv_res_t lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
} else if(sign == LV_SIGNAL_CONTROLL) {
uint32_t c = *((uint32_t *) param);
if((c == LV_GROUP_KEY_DOWN || c == LV_GROUP_KEY_RIGHT) && ext->arrow_scroll) {
lv_page_scroll_down(page);
} else if((c == LV_GROUP_KEY_UP || c == LV_GROUP_KEY_LEFT) && ext->arrow_scroll) {
lv_page_scroll_up(page);
if((c == LV_GROUP_KEY_DOWN) && ext->arrow_scroll) {
lv_page_scroll_ver(page, - lv_obj_get_height(page) / 4);
} else if((c == LV_GROUP_KEY_UP) && ext->arrow_scroll) {
lv_page_scroll_ver(page, lv_obj_get_height(page) / 4);
} else if((c == LV_GROUP_KEY_RIGHT) && ext->arrow_scroll) {
lv_page_scroll_hor(page, - lv_obj_get_width(page) / 4);
} else if((c == LV_GROUP_KEY_LEFT) && ext->arrow_scroll) {
lv_page_scroll_hor(page, lv_obj_get_width(page) / 4);
}
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;

View File

@@ -40,10 +40,12 @@ extern "C" {
/*Scrollbar modes: shows when should the scrollbars be visible*/
typedef enum
{
LV_SB_MODE_OFF, /*Never show scrollbars*/
LV_SB_MODE_ON, /*Always show scrollbars*/
LV_SB_MODE_DRAG, /*Show scrollbars when page is being dragged*/
LV_SB_MODE_AUTO, /*Show scrollbars when the scrollable container is large enough to be scrolled*/
LV_SB_MODE_OFF = 0x0, /*Never show scrollbars*/
LV_SB_MODE_ON = 0x1, /*Always show scrollbars*/
LV_SB_MODE_DRAG = 0x2, /*Show scrollbars when page is being dragged*/
LV_SB_MODE_AUTO = 0x3, /*Show scrollbars when the scrollable container is large enough to be scrolled*/
LV_SB_MODE_HIDE = 0x4, /*Hide the scroll bar temporally*/
LV_SB_MODE_UNHIDE = 0x5, /*Unhide the previously hidden scrollbar. Recover it's type too*/
} lv_sb_mode_t;
/*Data of page*/
@@ -76,7 +78,6 @@ typedef enum {
* GLOBAL PROTOTYPES
**********************/
/**
* Create a page objects
* @param par pointer to an object, it will be the parent of the new page
@@ -91,6 +92,20 @@ lv_obj_t * lv_page_create(lv_obj_t * par, const lv_obj_t * copy);
*/
void lv_page_clean(lv_obj_t *obj);
/**
* Get the press action of the page
* @param page pointer to a page object
* @return a function to call when the page is pressed
*/
lv_action_t lv_page_get_pr_action(lv_obj_t * page);
/**
* Get the release action of the page
* @param page pointer to a page object
* @return a function to call when the page is released
*/
lv_action_t lv_page_get_rel_action(lv_obj_t * page);
/**
* Get the scrollable object of a page
* @param page pointer to a page object
@@ -279,16 +294,18 @@ void lv_page_glue_obj(lv_obj_t * obj, bool glue);
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, uint16_t anim_time);
/**
* Scroll down the page a little
* Scroll the page horizontally
* @param page pointer to a page object
* @param dist the distance to scroll (< 0: scroll left; > 0 scroll right)
*/
void lv_page_scroll_down(lv_obj_t * page);
void lv_page_scroll_hor(lv_obj_t * page, lv_coord_t dist);
/**
* Scroll up the page a little
* Scroll the page vertically
* @param page pointer to a page object
* @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
*/
void lv_page_scroll_up(lv_obj_t * page);
void lv_page_scroll_ver(lv_obj_t * page, lv_coord_t dist);
/**********************
* MACROS

View File

@@ -178,11 +178,12 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy)
*=====================*/
/**
* Insert a character to the current cursor position
* Insert a character to the current cursor position.
* To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')`
* @param ta pointer to a text area object
* @param c a character
* @param c a character (e.g. 'a')
*/
void lv_ta_add_char(lv_obj_t * ta, char c)
void lv_ta_add_char(lv_obj_t * ta, uint32_t c)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
@@ -191,17 +192,19 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
return;
}
if(char_is_accepted(ta, c) == false) {
uint32_t c_uni = lv_txt_encoded_next((const char *)&c, NULL);
if(char_is_accepted(ta, c_uni) == false) {
LV_LOG_INFO("Character is no accepted by the text area (too long text or not in the accepted list)");
return;
}
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
char letter_buf[2];
uint32_t letter_buf[2];
letter_buf[0] = c;
letter_buf[1] = '\0';
lv_label_ins_text(ext->label, ext->cursor.pos, letter_buf); /*Insert the character*/
lv_label_ins_text(ext->label, ext->cursor.pos, (const char *)letter_buf); /*Insert the character*/
if(ext->pwd_mode != 0) {
@@ -209,7 +212,7 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
lv_mem_assert(ext->pwd_tmp);
if(ext->pwd_tmp== NULL) return;
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, letter_buf);
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, (const char *)letter_buf);
#if USE_LV_ANIMATION
/*Auto hide characters*/
@@ -247,13 +250,14 @@ void lv_ta_add_text(lv_obj_t * ta, const char * txt)
if(ext->pwd_mode != 0) pwd_char_hider(ta); /*Make sure all the current text contains only '*'*/
/*If only one character is added check if it is accepted*/
if(lv_txt_get_encoded_length(txt) == 1) {
uint32_t c = lv_txt_encoded_next(txt, NULL);
if(char_is_accepted(ta, c) == false) {
LV_LOG_INFO("Character is no accepted by the text area (too long text or not in the accepted list)");
return;
/*Add the character one-by-one if not all characters are accepted or there is character limit.*/
if(lv_ta_get_accepted_chars(ta) || lv_ta_get_max_length(ta)) {
uint32_t i = 0;
while(txt[i] != '\0') {
uint32_t c = lv_txt_encoded_next(txt, &i);
lv_ta_add_char(ta,lv_txt_unicode_to_encoded(c));
}
return;
}
/*Insert the text*/
@@ -342,10 +346,23 @@ void lv_ta_del_char(lv_obj_t * ta)
void lv_ta_set_text(lv_obj_t * ta, const char * txt)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);
lv_label_set_text(ext->label, txt);
lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
/*Don't let 'width == 0' because cursor will not be visible*/
/*Add the character one-by-one if not all characters are accepted or there is character limit.*/
if(lv_ta_get_accepted_chars(ta) || lv_ta_get_max_length(ta)) {
lv_label_set_text(ext->label, "");
lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
uint32_t i = 0;
while(txt[i] != '\0') {
uint32_t c = lv_txt_encoded_next(txt, &i);
lv_ta_add_char(ta,lv_txt_unicode_to_encoded(c));
}
} else {
lv_label_set_text(ext->label, txt);
lv_ta_set_cursor_pos(ta, LV_TA_CURSOR_LAST);
}
/*Don't let 'width == 0' because the cursor will not be visible*/
if(lv_obj_get_width(ext->label) == 0) {
lv_style_t * style = lv_obj_get_style(ext->label);
lv_obj_set_width(ext->label, lv_font_get_width(style->text.font, ' '));
@@ -1029,32 +1046,13 @@ static lv_res_t lv_ta_signal(lv_obj_t * ta, lv_signal_t sign, void * param)
}
} else if(sign == LV_SIGNAL_CONTROLL) {
uint32_t c = *((uint32_t *)param); /*uint32_t because can be UTF-8*/
if(c == LV_GROUP_KEY_RIGHT) lv_ta_cursor_right(ta);
else if(c == LV_GROUP_KEY_LEFT) lv_ta_cursor_left(ta);
else if(c == LV_GROUP_KEY_UP) lv_ta_cursor_up(ta);
if(c == LV_GROUP_KEY_RIGHT) lv_ta_cursor_right(ta);
else if(c == LV_GROUP_KEY_LEFT) lv_ta_cursor_left(ta);
else if(c == LV_GROUP_KEY_UP) lv_ta_cursor_up(ta);
else if(c == LV_GROUP_KEY_DOWN) lv_ta_cursor_down(ta);
else if(c == LV_GROUP_KEY_DEL) lv_ta_del_char(ta);
else if(c == LV_GROUP_KEY_DEL) lv_ta_del_char(ta);
else {
#if LV_TXT_UTF8 != 0
/*Swap the bytes (UTF-8 is big endian, but the MCUs are little endian)*/
if((c & 0x80) == 0) { /*ASCII*/
lv_ta_add_char(ta, (char)c);
} else {
uint32_t swapped[2] = {0, 0}; /*the 2. element is the closing '\0'*/
uint8_t c8[4];
memcpy(c8, &c, 4);
swapped[0] = (c8[0] << 24) + (c8[1] << 16) + (c8[2] << 8) + (c8[3]);
char * p = (char *)swapped;
uint8_t i;
for(i = 0; i < 4; i++) {
if(p[0] == 0) p++; /*Ignore leading zeros (they were in the end originally)*/
}
lv_ta_add_text(ta, p);
}
#else
lv_ta_add_char(ta, (char)c);
#endif
lv_ta_add_char(ta, c);
}
} else if(sign == LV_SIGNAL_GET_EDITABLE) {
bool * editable = (bool *)param;
@@ -1156,6 +1154,12 @@ static void pwd_char_hider(lv_obj_t * ta)
}
}
/**
* Test an unicode character if it is accepted or not. Checks max length and accepted char list.
* @param ta pointer to a test area object
* @param c an unicode character
* @return true: accapted; false: rejected
*/
static bool char_is_accepted(lv_obj_t * ta, uint32_t c)
{
lv_ta_ext_t * ext = lv_obj_get_ext_attr(ta);

View File

@@ -97,11 +97,12 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, const lv_obj_t * copy);
*=====================*/
/**
* Insert a character to the current cursor position
* Insert a character to the current cursor position.
* To add a wide char, e.g. 'Á' use `lv_txt_encoded_conv_wc('Á')`
* @param ta pointer to a text area object
* @param c a character
* @param c a character (e.g. 'a')
*/
void lv_ta_add_char(lv_obj_t * ta, char c);
void lv_ta_add_char(lv_obj_t * ta, uint32_t c);
/**
* Insert a text to the current cursor position
@@ -142,6 +143,7 @@ void lv_ta_set_cursor_pos(lv_obj_t * ta, int16_t pos);
* @param cur_type: element of 'lv_cursor_type_t'
*/
void lv_ta_set_cursor_type(lv_obj_t * ta, lv_cursor_type_t cur_type);
/**
* Enable/Disable password mode
* @param ta pointer to a text area object
@@ -162,6 +164,7 @@ void lv_ta_set_one_line(lv_obj_t * ta, bool en);
* @param list list of characters. Only the pointer is saved. E.g. "+-.,0123456789"
*/
void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list);
/**
* Set max length of a Text Area.
* @param ta pointer to Text Area
@@ -169,6 +172,16 @@ void lv_ta_set_accepted_chars(lv_obj_t * ta, const char * list);
*/
void lv_ta_set_max_length(lv_obj_t * ta, uint16_t num);
/**
* Set an action to call when the Text area is clicked
* @param ta pointer to a Text area
* @param action a function pointer
*/
static inline void lv_ta_set_action(lv_obj_t * ta, lv_action_t action)
{
lv_page_set_rel_action(ta, action);
}
/**
* Set the scroll bar mode of a text area
* @param ta pointer to a text area object
@@ -254,6 +267,16 @@ const char * lv_ta_get_accepted_chars(lv_obj_t * ta);
*/
uint16_t lv_ta_get_max_length(lv_obj_t * ta);
/**
* Set an action to call when the Text area is clicked
* @param ta pointer to a Text area
* @param action a function pointer
*/
static inline lv_action_t lv_ta_get_action(lv_obj_t * ta)
{
return lv_page_get_rel_action(ta);
}
/**
* Get the scroll bar mode of a text area
* @param ta pointer to a text area object

View File

@@ -223,17 +223,25 @@ lv_style_t * lv_win_get_style(const lv_obj_t *win, lv_win_style_t type);
*/
void lv_win_focus(lv_obj_t * win, lv_obj_t * obj, uint16_t anim_time);
static inline void lv_win_scroll_down(lv_obj_t * win)
/**
* Scroll the window horizontally
* @param win pointer to a window object
* @param dist the distance to scroll (< 0: scroll right; > 0 scroll left)
*/
static inline void lv_win_scroll_hor(lv_obj_t * win, lv_coord_t dist)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_scroll_down(ext->page);
lv_page_scroll_hor(ext->page, dist);
}
static inline void lv_win_scroll_up(lv_obj_t * win)
/**
* Scroll the window vertically
* @param win pointer to a window object
* @param dist the distance to scroll (< 0: scroll down; > 0 scroll up)
*/
static inline void lv_win_scroll_ver(lv_obj_t * win, lv_coord_t dist)
{
lv_win_ext_t * ext = lv_obj_get_ext_attr(win);
lv_page_scroll_up(ext->page);
lv_page_scroll_ver(ext->page, dist);
}
/**********************