refactor(label, text area) rename functions of text_sel to text_selection
This commit is contained in:
@@ -390,7 +390,7 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||||||
|
|
||||||
#define LV_USE_LABEL 1
|
#define LV_USE_LABEL 1
|
||||||
#if LV_USE_LABEL
|
#if LV_USE_LABEL
|
||||||
# define LV_LABEL_TEXT_SEL 1 /*Enable selecting text of the label*/
|
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||||
# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
# define LV_LABEL_LONG_TXT_HINT 1 /*Store some extra info in labels to speed up drawing of very long texts*/
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -1152,11 +1152,11 @@ e.g. "stm32f769xx.h" or "stm32f429xx.h"*/
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#if LV_USE_LABEL
|
#if LV_USE_LABEL
|
||||||
#ifndef LV_LABEL_TEXT_SEL
|
#ifndef LV_LABEL_TEXT_SELECTION
|
||||||
# ifdef CONFIG_LV_LABEL_TEXT_SEL
|
# ifdef CONFIG_LV_LABEL_TEXT_SELECTION
|
||||||
# define LV_LABEL_TEXT_SEL CONFIG_LV_LABEL_TEXT_SEL
|
# define LV_LABEL_TEXT_SELECTION CONFIG_LV_LABEL_TEXT_SELECTION
|
||||||
# else
|
# else
|
||||||
# define LV_LABEL_TEXT_SEL 1 /*Enable selecting text of the label*/
|
# define LV_LABEL_TEXT_SELECTION 1 /*Enable selecting text of the label*/
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef LV_LABEL_LONG_TXT_HINT
|
#ifndef LV_LABEL_LONG_TXT_HINT
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_label_t * label = (lv_label_t *)obj;
|
lv_label_t * label = (lv_label_t *)obj;
|
||||||
label->sel_start = index;
|
label->sel_start = index;
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
@@ -247,7 +247,7 @@ void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_label_t * label = (lv_label_t *)obj;
|
lv_label_t * label = (lv_label_t *)obj;
|
||||||
label->sel_end = index;
|
label->sel_end = index;
|
||||||
lv_obj_invalidate(obj);
|
lv_obj_invalidate(obj);
|
||||||
@@ -603,30 +603,30 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos)
|
|||||||
return (pos->x >= (last_x - letter_space) && pos->x <= (last_x + max_diff));
|
return (pos->x >= (last_x - letter_space) && pos->x <= (last_x + max_diff));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t lv_label_get_text_sel_start(const lv_obj_t * obj)
|
uint32_t lv_label_get_text_selection_start(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_label_t * label = (lv_label_t *)obj;
|
lv_label_t * label = (lv_label_t *)obj;
|
||||||
return label->sel_start;
|
return label->sel_start;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
(void)obj; /*Unused*/
|
(void)obj; /*Unused*/
|
||||||
return LV_LABEL_TEXT_SEL_OFF;
|
return LV_LABEL_TEXT_SELECTION_OFF;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t lv_label_get_text_sel_end(const lv_obj_t * obj)
|
uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_label_t * label = (lv_label_t *)obj;
|
lv_label_t * label = (lv_label_t *)obj;
|
||||||
return label->sel_end;
|
return label->sel_end;
|
||||||
#else
|
#else
|
||||||
(void)obj; /*Unused*/
|
(void)obj; /*Unused*/
|
||||||
return LV_LABEL_TEXT_SEL_OFF;
|
return LV_LABEL_TEXT_SELECTION_OFF;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -717,7 +717,7 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
|||||||
label->hint.y = 0;
|
label->hint.y = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
label->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
|
label->sel_start = LV_DRAW_LABEL_NO_TXT_SEL;
|
||||||
label->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
|
label->sel_end = LV_DRAW_LABEL_NO_TXT_SEL;
|
||||||
#endif
|
#endif
|
||||||
@@ -820,8 +820,8 @@ static void draw_main(lv_event_t * e)
|
|||||||
label_draw_dsc.flag = flag;
|
label_draw_dsc.flag = flag;
|
||||||
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_draw_dsc);
|
lv_obj_init_draw_label_dsc(obj, LV_PART_MAIN, &label_draw_dsc);
|
||||||
|
|
||||||
label_draw_dsc.sel_start = lv_label_get_text_sel_start(obj);
|
label_draw_dsc.sel_start = lv_label_get_text_selection_start(obj);
|
||||||
label_draw_dsc.sel_end = lv_label_get_text_sel_end(obj);
|
label_draw_dsc.sel_end = lv_label_get_text_selection_end(obj);
|
||||||
if(label_draw_dsc.sel_start != LV_DRAW_LABEL_NO_TXT_SEL && label_draw_dsc.sel_end != LV_DRAW_LABEL_NO_TXT_SEL) {
|
if(label_draw_dsc.sel_start != LV_DRAW_LABEL_NO_TXT_SEL && label_draw_dsc.sel_end != LV_DRAW_LABEL_NO_TXT_SEL) {
|
||||||
label_draw_dsc.sel_color = lv_obj_get_style_text_color_filtered(obj, LV_PART_SELECTED);
|
label_draw_dsc.sel_color = lv_obj_get_style_text_color_filtered(obj, LV_PART_SELECTED);
|
||||||
label_draw_dsc.sel_bg_color = lv_obj_get_style_bg_color(obj, LV_PART_SELECTED);
|
label_draw_dsc.sel_bg_color = lv_obj_get_style_bg_color(obj, LV_PART_SELECTED);
|
||||||
|
|||||||
@@ -30,11 +30,11 @@ extern "C" {
|
|||||||
#define LV_LABEL_WAIT_CHAR_COUNT 3
|
#define LV_LABEL_WAIT_CHAR_COUNT 3
|
||||||
#define LV_LABEL_DOT_NUM 3
|
#define LV_LABEL_DOT_NUM 3
|
||||||
#define LV_LABEL_POS_LAST 0xFFFF
|
#define LV_LABEL_POS_LAST 0xFFFF
|
||||||
#define LV_LABEL_TEXT_SEL_OFF LV_DRAW_LABEL_NO_TXT_SEL
|
#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SEL
|
||||||
|
|
||||||
LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM);
|
LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM);
|
||||||
LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST);
|
LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST);
|
||||||
LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SEL_OFF);
|
LV_EXPORT_CONST_INT(LV_LABEL_TEXT_SELECTION_OFF);
|
||||||
|
|
||||||
/**********************
|
/**********************
|
||||||
* TYPEDEFS
|
* TYPEDEFS
|
||||||
@@ -63,7 +63,7 @@ typedef struct {
|
|||||||
lv_draw_label_hint_t hint;
|
lv_draw_label_hint_t hint;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
uint32_t sel_start; uint32_t sel_end;
|
uint32_t sel_start; uint32_t sel_end;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -134,14 +134,14 @@ void lv_label_set_recolor(lv_obj_t * obj, bool en);
|
|||||||
/**
|
/**
|
||||||
* Set where text selection should start
|
* Set where text selection should start
|
||||||
* @param obj pointer to a label object
|
* @param obj pointer to a label object
|
||||||
* @param index character index from where selection should start. `LV_LABEL_TEXT_SEL_OFF` for no selection
|
* @param index character index from where selection should start. `LV_LABEL_TEXT_SELECTION_OFF` for no selection
|
||||||
*/
|
*/
|
||||||
void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index);
|
void lv_label_set_text_sel_start(lv_obj_t * obj, uint32_t index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set where text selection should end
|
* Set where text selection should end
|
||||||
* @param obj pointer to a label object
|
* @param obj pointer to a label object
|
||||||
* @param index character index where selection should end. `LV_LABEL_TEXT_SEL_OFF` for no selection
|
* @param index character index where selection should end. `LV_LABEL_TEXT_SELECTION_OFF` for no selection
|
||||||
*/
|
*/
|
||||||
void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index);
|
void lv_label_set_text_sel_end(lv_obj_t * obj, uint32_t index);
|
||||||
|
|
||||||
@@ -199,16 +199,16 @@ bool lv_label_is_char_under_pos(const lv_obj_t * obj, lv_point_t * pos);
|
|||||||
/**
|
/**
|
||||||
* @brief Get the selection start index.
|
* @brief Get the selection start index.
|
||||||
* @param obj pointer to a label object.
|
* @param obj pointer to a label object.
|
||||||
* @return selection start index. `LV_LABEL_TEXT_SEL_OFF` if nothing is selected.
|
* @return selection start index. `LV_LABEL_TEXT_SELECTION_OFF` if nothing is selected.
|
||||||
*/
|
*/
|
||||||
uint32_t lv_label_get_text_sel_start(const lv_obj_t * obj);
|
uint32_t lv_label_get_text_selection_start(const lv_obj_t * obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get the selection end index.
|
* @brief Get the selection end index.
|
||||||
* @param obj pointer to a label object.
|
* @param obj pointer to a label object.
|
||||||
* @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
* @return selection end index. `LV_LABEL_TXT_SEL_OFF` if nothing is selected.
|
||||||
*/
|
*/
|
||||||
uint32_t lv_label_get_text_sel_end(const lv_obj_t * obj);
|
uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj);
|
||||||
|
|
||||||
/*=====================
|
/*=====================
|
||||||
* Other functions
|
* Other functions
|
||||||
|
|||||||
@@ -520,11 +520,11 @@ void lv_textarea_set_insert_replace(lv_obj_t * obj, const char * txt)
|
|||||||
ta_insert_replace = txt;
|
ta_insert_replace = txt;
|
||||||
}
|
}
|
||||||
|
|
||||||
void lv_textarea_set_text_sel(lv_obj_t * obj, bool en)
|
void lv_textarea_set_text_selection(lv_obj_t * obj, bool en)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||||
|
|
||||||
ta->text_sel_en = en;
|
ta->text_sel_en = en;
|
||||||
@@ -653,11 +653,11 @@ bool lv_textarea_text_is_selected(const lv_obj_t * obj)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||||
|
|
||||||
if((lv_label_get_text_sel_start(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL ||
|
if((lv_label_get_text_selection_start(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL ||
|
||||||
lv_label_get_text_sel_end(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL)) {
|
lv_label_get_text_selection_end(ta->label) == LV_DRAW_LABEL_NO_TXT_SEL)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -669,11 +669,11 @@ bool lv_textarea_text_is_selected(const lv_obj_t * obj)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lv_textarea_get_text_sel_en(lv_obj_t * obj)
|
bool lv_textarea_get_text_selection(lv_obj_t * obj)
|
||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||||
return ta->text_sel_en;
|
return ta->text_sel_en;
|
||||||
#else
|
#else
|
||||||
@@ -699,11 +699,11 @@ void lv_textarea_clear_selection(lv_obj_t * obj)
|
|||||||
{
|
{
|
||||||
LV_ASSERT_OBJ(obj, MY_CLASS);
|
LV_ASSERT_OBJ(obj, MY_CLASS);
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
lv_textarea_t * ta = (lv_textarea_t *)obj;
|
||||||
|
|
||||||
if(lv_label_get_text_sel_start(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL ||
|
if(lv_label_get_text_selection_start(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL ||
|
||||||
lv_label_get_text_sel_end(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL) {
|
lv_label_get_text_selection_end(ta->label) != LV_DRAW_LABEL_NO_TXT_SEL) {
|
||||||
lv_label_set_text_sel_start(ta->label, LV_DRAW_LABEL_NO_TXT_SEL);
|
lv_label_set_text_sel_start(ta->label, LV_DRAW_LABEL_NO_TXT_SEL);
|
||||||
lv_label_set_text_sel_end(ta->label, LV_DRAW_LABEL_NO_TXT_SEL);
|
lv_label_set_text_sel_end(ta->label, LV_DRAW_LABEL_NO_TXT_SEL);
|
||||||
}
|
}
|
||||||
@@ -806,7 +806,7 @@ static void lv_textarea_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
|||||||
ta->cursor.click_pos = 1;
|
ta->cursor.click_pos = 1;
|
||||||
ta->cursor.valid_x = 0;
|
ta->cursor.valid_x = 0;
|
||||||
ta->one_line = 0;
|
ta->one_line = 0;
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
ta->text_sel_en = 0;
|
ta->text_sel_en = 0;
|
||||||
#endif
|
#endif
|
||||||
ta->label = NULL;
|
ta->label = NULL;
|
||||||
@@ -1154,7 +1154,7 @@ static void update_cursor_position_on_click(lv_event_t * e)
|
|||||||
|
|
||||||
uint16_t char_id_at_click;
|
uint16_t char_id_at_click;
|
||||||
|
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
lv_label_t * label_data = (lv_label_t *)ta->label;
|
lv_label_t * label_data = (lv_label_t *)ta->label;
|
||||||
bool click_outside_label;
|
bool click_outside_label;
|
||||||
/*Check if the click happened on the left side of the area outside the label*/
|
/*Check if the click happened on the left side of the area outside the label*/
|
||||||
@@ -1176,7 +1176,7 @@ static void update_cursor_position_on_click(lv_event_t * e)
|
|||||||
if(!ta->text_sel_in_prog && !click_outside_label && code == LV_EVENT_PRESSED) {
|
if(!ta->text_sel_in_prog && !click_outside_label && code == LV_EVENT_PRESSED) {
|
||||||
/*Input device just went down. Store the selection start position*/
|
/*Input device just went down. Store the selection start position*/
|
||||||
ta->sel_start = char_id_at_click;
|
ta->sel_start = char_id_at_click;
|
||||||
ta->sel_end = LV_LABEL_TEXT_SEL_OFF;
|
ta->sel_end = LV_LABEL_TEXT_SELECTION_OFF;
|
||||||
ta->text_sel_in_prog = 1;
|
ta->text_sel_in_prog = 1;
|
||||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN);
|
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_CHAIN);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ typedef struct {
|
|||||||
uint8_t show : 1; /*Cursor is visible now or not (Handled by the library)*/
|
uint8_t show : 1; /*Cursor is visible now or not (Handled by the library)*/
|
||||||
uint8_t click_pos : 1; /*1: Enable positioning the cursor by clicking the text area*/
|
uint8_t click_pos : 1; /*1: Enable positioning the cursor by clicking the text area*/
|
||||||
} cursor;
|
} cursor;
|
||||||
#if LV_LABEL_TEXT_SEL
|
#if LV_LABEL_TEXT_SELECTION
|
||||||
uint32_t sel_start; /*Temporary values for text selection*/
|
uint32_t sel_start; /*Temporary values for text selection*/
|
||||||
uint32_t sel_end;
|
uint32_t sel_end;
|
||||||
uint8_t text_sel_in_prog : 1; /*User is in process of selecting*/
|
uint8_t text_sel_in_prog : 1; /*User is in process of selecting*/
|
||||||
@@ -189,7 +189,7 @@ void lv_textarea_set_insert_replace(lv_obj_t * obj, const char * txt);
|
|||||||
* @param obj pointer to a text area object
|
* @param obj pointer to a text area object
|
||||||
* @param en true or false to enable/disable selection mode
|
* @param en true or false to enable/disable selection mode
|
||||||
*/
|
*/
|
||||||
void lv_textarea_set_text_sel(lv_obj_t * obj, bool en);
|
void lv_textarea_set_text_selection(lv_obj_t * obj, bool en);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set how long show the password before changing it to '*'
|
* Set how long show the password before changing it to '*'
|
||||||
@@ -286,7 +286,7 @@ bool lv_textarea_text_is_selected(const lv_obj_t * obj);
|
|||||||
* @param obj pointer to a text area object
|
* @param obj pointer to a text area object
|
||||||
* @return true: selection mode is enabled, false: disabled
|
* @return true: selection mode is enabled, false: disabled
|
||||||
*/
|
*/
|
||||||
bool lv_textarea_get_text_sel_en(lv_obj_t * obj);
|
bool lv_textarea_get_text_selection(lv_obj_t * obj);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set how long show the password before changing it to '*'
|
* Set how long show the password before changing it to '*'
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ full_32bit = {
|
|||||||
"LV_USE_PERF_MONITOR":1,
|
"LV_USE_PERF_MONITOR":1,
|
||||||
"LV_USE_MEM_MONITOR":1,
|
"LV_USE_MEM_MONITOR":1,
|
||||||
|
|
||||||
"LV_LABEL_TEXT_SEL":1,
|
"LV_LABEL_TEXT_SELECTION":1,
|
||||||
|
|
||||||
"LV_BUILD_EXAMPLES":1,
|
"LV_BUILD_EXAMPLES":1,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user