feat: add config set LV_WIDGETS_HAS_DEAFULT_VALUE (#4371)
Signed-off-by: yushuailong1 <yushuailong1@xiaomi.com> Co-authored-by: yushuailong1 <yushuailong1@xiaomi.com>
This commit is contained in:
3
Kconfig
3
Kconfig
@@ -775,6 +775,9 @@ menu "LVGL configuration"
|
||||
endmenu
|
||||
|
||||
menu "Widget usage"
|
||||
config LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
bool "Widgets has default value."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
config LV_USE_ARC
|
||||
bool "Arc."
|
||||
default y if !LV_CONF_MINIMAL
|
||||
|
||||
@@ -409,6 +409,8 @@
|
||||
|
||||
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE 1
|
||||
|
||||
#define LV_USE_ANIMIMG 1
|
||||
|
||||
#define LV_USE_ARC 1
|
||||
|
||||
@@ -1167,6 +1167,18 @@
|
||||
|
||||
/*Documentation of the widgets: https://docs.lvgl.io/latest/en/html/widgets/index.html*/
|
||||
|
||||
#ifndef LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE CONFIG_LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
#else
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE 0
|
||||
#endif
|
||||
#else
|
||||
#define LV_WIDGETS_HAS_DEFAULT_VALUE 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef LV_USE_ANIMIMG
|
||||
#ifdef _LV_KCONFIG_PRESENT
|
||||
#ifdef CONFIG_LV_USE_ANIMIMG
|
||||
|
||||
@@ -57,7 +57,9 @@ static bool has_popovers_in_top_row(lv_obj_t * obj);
|
||||
/**********************
|
||||
* STATIC VARIABLES
|
||||
**********************/
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
static const char * lv_btnmatrix_def_map[] = {"Btn1", "Btn2", "Btn3", "\n", "Btn4", "Btn5", ""};
|
||||
#endif
|
||||
|
||||
const lv_obj_class_t lv_btnmatrix_class = {
|
||||
.constructor_cb = lv_btnmatrix_constructor,
|
||||
@@ -367,7 +369,9 @@ static void lv_btnmatrix_constructor(const lv_obj_class_t * class_p, lv_obj_t *
|
||||
btnm->map_p = NULL;
|
||||
btnm->one_check = 0;
|
||||
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
lv_btnmatrix_set_map(obj, lv_btnmatrix_def_map);
|
||||
#endif
|
||||
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
}
|
||||
|
||||
@@ -243,6 +243,8 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
lv_calendar_t * calendar = (lv_calendar_t *)obj;
|
||||
|
||||
/*Initialize the allocated 'ext'*/
|
||||
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
calendar->today.year = 2020;
|
||||
calendar->today.month = 1;
|
||||
calendar->today.day = 1;
|
||||
@@ -250,6 +252,7 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
calendar->showed_date.year = 2020;
|
||||
calendar->showed_date.month = 1;
|
||||
calendar->showed_date.day = 1;
|
||||
#endif
|
||||
|
||||
calendar->highlighted_dates = NULL;
|
||||
calendar->highlighted_dates_num = 0;
|
||||
@@ -282,8 +285,10 @@ static void lv_calendar_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
lv_obj_set_flex_flow(obj, LV_FLEX_FLOW_COLUMN);
|
||||
lv_obj_set_flex_grow(calendar->btnm, 1);
|
||||
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
lv_calendar_set_showed_date(obj, calendar->showed_date.year, calendar->showed_date.month);
|
||||
lv_calendar_set_today_date(obj, calendar->today.year, calendar->today.month, calendar->today.day);
|
||||
#endif
|
||||
|
||||
lv_obj_add_flag(calendar->btnm, LV_OBJ_FLAG_EVENT_BUBBLE);
|
||||
}
|
||||
|
||||
@@ -132,8 +132,14 @@ static void lv_checkbox_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
|
||||
lv_checkbox_t * cb = (lv_checkbox_t *)obj;
|
||||
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
cb->txt = (char *)"Check box";
|
||||
cb->static_txt = 1;
|
||||
#else
|
||||
cb->txt = (char *)"";
|
||||
cb->static_txt = 1;
|
||||
#endif
|
||||
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_CLICKABLE);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
|
||||
@@ -598,7 +598,9 @@ static void lv_dropdown_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
dropdown->dir = LV_DIR_BOTTOM;
|
||||
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
lv_dropdown_set_options_static(obj, "Option 1\nOption 2\nOption 3");
|
||||
#endif
|
||||
|
||||
dropdown->list = lv_dropdown_list_create(lv_obj_get_screen(obj));
|
||||
lv_dropdown_list_t * list = (lv_dropdown_list_t *)dropdown->list;
|
||||
|
||||
@@ -663,7 +663,6 @@ static void lv_label_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj)
|
||||
lv_label_set_long_mode(obj, LV_LABEL_LONG_WRAP);
|
||||
lv_label_set_text(obj, LV_LABEL_DEFAULT_TEXT);
|
||||
|
||||
|
||||
LV_TRACE_OBJ_CREATE("finished");
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ extern "C" {
|
||||
#define LV_LABEL_DOT_NUM 3
|
||||
#define LV_LABEL_POS_LAST 0xFFFF
|
||||
#define LV_LABEL_TEXT_SELECTION_OFF LV_DRAW_LABEL_NO_TXT_SEL
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
#define LV_LABEL_DEFAULT_TEXT "Text"
|
||||
#else
|
||||
#define LV_LABEL_DEFAULT_TEXT ""
|
||||
#endif
|
||||
|
||||
LV_EXPORT_CONST_INT(LV_LABEL_DOT_NUM);
|
||||
LV_EXPORT_CONST_INT(LV_LABEL_POS_LAST);
|
||||
|
||||
@@ -317,8 +317,9 @@ static void lv_roller_constructor(const lv_obj_class_t * class_p, lv_obj_t * obj
|
||||
LV_LOG_INFO("begin");
|
||||
lv_obj_t * label = lv_obj_class_create_obj(&lv_roller_label_class, obj);
|
||||
lv_obj_class_init_obj(label);
|
||||
#if LV_WIDGETS_HAS_DEFAULT_VALUE
|
||||
lv_roller_set_options(obj, "Option 1\nOption 2\nOption 3\nOption 4\nOption 5", LV_ROLLER_MODE_NORMAL);
|
||||
|
||||
#endif
|
||||
LV_LOG_TRACE("finshed");
|
||||
}
|
||||
|
||||
|
||||
@@ -848,6 +848,7 @@ static void lv_textarea_constructor(const lv_obj_class_t * class_p, lv_obj_t * o
|
||||
lv_obj_add_event(ta->label, label_event_cb, LV_EVENT_ALL, NULL);
|
||||
lv_obj_add_flag(obj, LV_OBJ_FLAG_SCROLL_ON_FOCUS);
|
||||
lv_obj_clear_flag(obj, LV_OBJ_FLAG_SCROLL_WITH_ARROW);
|
||||
|
||||
lv_textarea_set_cursor_pos(obj, 0);
|
||||
|
||||
start_cursor_blink(obj);
|
||||
|
||||
Reference in New Issue
Block a user