mirror of
https://github.com/lvgl/lvgl.git
synced 2026-06-01 16:58:33 +08:00
fix(xml): minor fixes in parsers
This commit is contained in:
committed by
Felipe Neves
parent
b4c9d2e690
commit
dea37bd32f
@@ -372,7 +372,7 @@ integer value:
|
|||||||
- Drop-Down
|
- Drop-Down
|
||||||
- Roller
|
- Roller
|
||||||
- Slider
|
- Slider
|
||||||
+ - Scale Section Min/Max values
|
- Scale Section Min/Max values
|
||||||
|
|
||||||
Any number of Observers can be created for a single Widget, each bound to ONE of
|
Any number of Observers can be created for a single Widget, each bound to ONE of
|
||||||
the above properties.
|
the above properties.
|
||||||
|
|||||||
@@ -545,7 +545,7 @@ lv_observer_t * lv_obj_bind_checked(lv_obj_t * obj, lv_subject_t * subject);
|
|||||||
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt);
|
lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const char * fmt);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LV_USE_LABEL
|
#if LV_USE_SPAN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bind an integer, string, or pointer Subject to a Spangroup's Span.
|
* Bind an integer, string, or pointer Subject to a Spangroup's Span.
|
||||||
@@ -556,8 +556,8 @@ lv_observer_t * lv_label_bind_text(lv_obj_t * obj, lv_subject_t * subject, const
|
|||||||
* or NULL to bind to the value directly.
|
* or NULL to bind to the value directly.
|
||||||
* @return pointer to newly-created Observer
|
* @return pointer to newly-created Observer
|
||||||
* @note `fmt == NULL` can be used only with string and pointer Subjects.
|
* @note `fmt == NULL` can be used only with string and pointer Subjects.
|
||||||
* @note If Subject is a pointer and `fmt == NULL`, pointer must point
|
* @note If `fmt == NULL` strings and pointers (`\0` terminated string) will be shown
|
||||||
* to a `\0` terminated string.
|
* as text as they are, integers as %d, floats as %0.1f
|
||||||
*/
|
*/
|
||||||
lv_observer_t * lv_spangroup_bind_span_text(lv_obj_t * obj, lv_span_t * span, lv_subject_t * subject, const char * fmt);
|
lv_observer_t * lv_spangroup_bind_span_text(lv_obj_t * obj, lv_span_t * span, lv_subject_t * subject, const char * fmt);
|
||||||
|
|
||||||
|
|||||||
@@ -290,6 +290,8 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char *
|
|||||||
if(value[c] == ' ') item_cnt++;
|
if(value[c] == ' ') item_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*This not freed automatically as the styles doesn't have any mechanisms to detect
|
||||||
|
* removal of properties. It's assumed that the styles are created once and never freed. */
|
||||||
int32_t * dsc_array = lv_malloc((item_cnt + 2) * sizeof(int32_t)); /*+2 for LV_GRID_TEMPLATE_LAST*/
|
int32_t * dsc_array = lv_malloc((item_cnt + 2) * sizeof(int32_t)); /*+2 for LV_GRID_TEMPLATE_LAST*/
|
||||||
|
|
||||||
char * value_buf = (char *)value;
|
char * value_buf = (char *)value;
|
||||||
|
|||||||
@@ -83,8 +83,8 @@ int32_t lv_xml_atoi_split(const char ** str, char delimiter)
|
|||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
|
||||||
/* Skip leading whitespace */
|
/* Skip leading whitespace and repeated delimiters */
|
||||||
while(*s == ' ' || *s == '\t') s++;
|
while(*s == delimiter || *s == ' ' || *s == '\t') s++;
|
||||||
|
|
||||||
/* Handle optional sign */
|
/* Handle optional sign */
|
||||||
if(*s == '-') {
|
if(*s == '-') {
|
||||||
@@ -128,8 +128,8 @@ float lv_xml_atof_split(const char ** str, char delimiter)
|
|||||||
float result = 0.0f;
|
float result = 0.0f;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
|
||||||
/* Skip leading whitespace */
|
/* Skip leading whitespace and repeated delimiters */
|
||||||
while(*s == ' ' || *s == '\t') s++;
|
while(*s == delimiter || *s == ' ' || *s == '\t') s++;
|
||||||
|
|
||||||
/* Handle optional sign */
|
/* Handle optional sign */
|
||||||
if(*s == '-') {
|
if(*s == '-') {
|
||||||
@@ -263,6 +263,11 @@ int32_t lv_xml_strtol(const char * str, char ** endptr, int32_t base)
|
|||||||
|
|
||||||
char * lv_xml_split_str(char ** src, char delimiter)
|
char * lv_xml_split_str(char ** src, char delimiter)
|
||||||
{
|
{
|
||||||
|
/*Skip multiple delimiters*/
|
||||||
|
while(*src[0] == delimiter) {
|
||||||
|
src++;
|
||||||
|
}
|
||||||
|
|
||||||
if(*src[0] == '\0') return NULL;
|
if(*src[0] == '\0') return NULL;
|
||||||
|
|
||||||
char * src_first = *src;
|
char * src_first = *src;
|
||||||
|
|||||||
@@ -98,13 +98,14 @@ void * lv_xml_tabview_tab_button_create(lv_xml_parser_state_t * state, const cha
|
|||||||
|
|
||||||
const char * index_str = lv_xml_get_value_of(attrs, "index");
|
const char * index_str = lv_xml_get_value_of(attrs, "index");
|
||||||
int32_t index_int = index_str ? lv_xml_atoi(index_str) : 0;
|
int32_t index_int = index_str ? lv_xml_atoi(index_str) : 0;
|
||||||
if(LV_ABS(index_int) >= btn_cnt) {
|
|
||||||
LV_LOG_WARN("tabindex is out of range, using the first tab instead");
|
|
||||||
index_int = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void * item = lv_tabview_get_tab_button(tv, index_int);
|
void * item = lv_tabview_get_tab_button(tv, index_int);
|
||||||
|
|
||||||
|
if(item == NULL) {
|
||||||
|
LV_LOG_WARN("tabindex is out of range, using the first tab instead");
|
||||||
|
item = lv_tabview_get_tab_button(tv, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user