diff --git a/docs/src/details/auxiliary-modules/observer/observer.rst b/docs/src/details/auxiliary-modules/observer/observer.rst index 9fcca7dc30..86c0a41ebe 100644 --- a/docs/src/details/auxiliary-modules/observer/observer.rst +++ b/docs/src/details/auxiliary-modules/observer/observer.rst @@ -573,9 +573,6 @@ It support only integer subjects. - :cpp:expr:`lv_dropdown_bind_value(dropdown, &subject)` - -.. _change_subject_on_event: - Scale's Section ~~~~~~~~~~~~~~~ diff --git a/src/others/xml/lv_xml_style.c b/src/others/xml/lv_xml_style.c index 18c6200726..c16d764e6b 100644 --- a/src/others/xml/lv_xml_style.c +++ b/src/others/xml/lv_xml_style.c @@ -82,7 +82,8 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char * lv_style_t * style = &xml_style->style; - for(int i = 0; attrs[i]; i += 2) { + int32_t i; + for(i = 0; attrs[i]; i += 2) { const char * name = attrs[i]; const char * value = attrs[i + 1]; if(lv_streq(name, "name")) continue; @@ -280,7 +281,40 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char * else SET_STYLE_IF(grid_cell_row_pos, lv_xml_atoi(value)); else SET_STYLE_IF(grid_cell_row_span, lv_xml_atoi(value)); else SET_STYLE_IF(grid_cell_y_align, lv_xml_grid_align_to_enum(value)); + else if(lv_streq(name, "style_grid_column_dsc_array") || + lv_streq(name, "style_grid_row_dsc_array")) { + uint32_t item_cnt = 0; + uint32_t c; + for(c = 0; value[c] != '\0'; c++) { + if(value[c] == ' ') item_cnt++; + } + + int32_t * dsc_array = lv_malloc((item_cnt + 1) * sizeof(int32_t)); /*+1 for LV_GRID_TEMPLATE_LAST*/ + + char * value_buf = (char *)value; + item_cnt = 0; + const char * sub_value = lv_xml_split_str(&value_buf, ' '); + while(sub_value) { + if(sub_value[0] == 'f' && sub_value[1] == 'r') { + dsc_array[item_cnt] = LV_GRID_FR(lv_xml_atoi(sub_value + 3)); /*+3 to skip "fr("*/ + } + else { + dsc_array[item_cnt] = lv_xml_atoi(sub_value); + } + + item_cnt++; + sub_value = lv_xml_split_str(&value_buf, ' '); + } + dsc_array[item_cnt] = LV_GRID_TEMPLATE_LAST; + + if(lv_streq(name, "style_grid_column_dsc_array")) { + lv_style_set_grid_column_dsc_array(style, dsc_array); + } + else { + lv_style_set_grid_row_dsc_array(style, dsc_array); + } + } else { LV_LOG_WARN("%s style property is not supported", name); diff --git a/src/others/xml/parsers/lv_xml_obj_parser.c b/src/others/xml/parsers/lv_xml_obj_parser.c index fcfb8df0d5..a1fc975d08 100644 --- a/src/others/xml/parsers/lv_xml_obj_parser.c +++ b/src/others/xml/parsers/lv_xml_obj_parser.c @@ -891,6 +891,43 @@ static void apply_styles(lv_xml_parser_state_t * state, lv_obj_t * obj, const ch else SET_STYLE_IF(grid_cell_row_pos, lv_xml_atoi(value)); else SET_STYLE_IF(grid_cell_row_span, lv_xml_atoi(value)); else SET_STYLE_IF(grid_cell_y_align, lv_xml_grid_align_to_enum(value)); + else if(lv_streq(prop_name, "style_grid_column_dsc_array") || + lv_streq(prop_name, "style_grid_row_dsc_array")) { + + uint32_t item_cnt = 0; + uint32_t i; + for(i = 0; value[i] != '\0'; i++) { + if(value[i] == ' ') item_cnt++; + } + + int32_t * dsc_array = lv_malloc((item_cnt + 1) * sizeof(int32_t)); /*+1 for LV_GRID_TEMPLATE_LAST*/ + + char * value_buf = (char *)value; + item_cnt = 0; + const char * sub_value = lv_xml_split_str(&value_buf, ' '); + while(sub_value) { + if(sub_value[0] == 'f' && sub_value[1] == 'r') { + dsc_array[item_cnt] = LV_GRID_FR(lv_xml_atoi(sub_value + 3)); /*+3 to skip "fr("*/ + } + else { + dsc_array[item_cnt] = lv_xml_atoi(sub_value); + } + + item_cnt++; + sub_value = lv_xml_split_str(&value_buf, ' '); + } + + dsc_array[item_cnt] = LV_GRID_TEMPLATE_LAST; + + lv_obj_add_event_cb(obj, lv_event_free_user_data_cb, LV_EVENT_DELETE, dsc_array); + + if(lv_streq(prop_name, "style_grid_column_dsc_array")) { + lv_obj_set_style_grid_column_dsc_array(obj, dsc_array, selector); + } + else { + lv_obj_set_style_grid_row_dsc_array(obj, dsc_array, selector); + } + } } diff --git a/xmls/globals.xml b/xmls/globals.xml index aa8fcc716b..9625f418b5 100644 --- a/xmls/globals.xml +++ b/xmls/globals.xml @@ -311,6 +311,9 @@ + + + diff --git a/xmls/lv_obj.xml b/xmls/lv_obj.xml index 32fb0eb504..71d3cc1d91 100644 --- a/xmls/lv_obj.xml +++ b/xmls/lv_obj.xml @@ -296,6 +296,8 @@ Example + +