From 3951ea4b95c2f29c71bc70756b7d9dbef77129a2 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Sat, 7 Jun 2025 18:23:01 +0200 Subject: [PATCH] feat(xml): add remove_style and remove_style_all support --- examples/others/xml/lv_example_xml_2.c | 40 ++++++++- examples/others/xml/my_button.xml | 7 +- examples/others/xml/view.xml | 47 +++++++++-- src/others/xml/lv_xml.c | 5 ++ src/others/xml/parsers/lv_xml_obj_parser.c | 84 +++++++++++++++---- src/others/xml/parsers/lv_xml_obj_parser.h | 6 ++ .../test_cases/xml/test_xml_screen_event.c | 2 +- tests/src/test_cases/xml/test_xml_style.c | 43 +++++++++- tests/unity/unity_support.h | 5 ++ xmls/lv_obj.xml | 7 ++ 10 files changed, 211 insertions(+), 35 deletions(-) diff --git a/examples/others/xml/lv_example_xml_2.c b/examples/others/xml/lv_example_xml_2.c index b4fae5b899..f037a54ac3 100644 --- a/examples/others/xml/lv_example_xml_2.c +++ b/examples/others/xml/lv_example_xml_2.c @@ -3,10 +3,44 @@ void lv_example_xml_2(void) { - lv_xml_component_register_from_file("A:lvgl/examples/others/xml/view.xml"); + lv_result_t res; + res = lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_h3.xml"); + if(res != LV_RESULT_OK) { + lv_obj_t * label = lv_label_create(lv_screen_active()); + lv_label_set_text(label, "Couldn't open the XML files."); + lv_obj_center(label); + return; + } + lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_card.xml"); lv_xml_component_register_from_file("A:lvgl/examples/others/xml/my_button.xml"); + lv_xml_component_register_from_file("A:lvgl/examples/others/xml/view.xml"); - lv_obj_t * obj = (lv_obj_t *) lv_xml_create(NULL, "view", NULL); - lv_screen_load(obj); + lv_xml_register_font(NULL, "lv_montserrat_18", &lv_font_montserrat_18); + + lv_obj_t * obj = (lv_obj_t *) lv_xml_create(lv_screen_active(), "view", NULL); + lv_obj_set_pos(obj, 10, 10); + + const char * my_button_attrs[] = { + "x", "10", + "y", "-10", + "align", "bottom_left", + "btn_text", "New button", + NULL, NULL, + }; + + lv_xml_component_unregister("my_button"); + + lv_xml_create(lv_screen_active(), "my_button", my_button_attrs); + + const char * slider_attrs[] = { + "x", "200", + "y", "-15", + "align", "bottom_left", + "value", "30", + NULL, NULL, + }; + + lv_obj_t * slider = (lv_obj_t *) lv_xml_create(lv_screen_active(), "lv_slider", slider_attrs); + lv_obj_set_width(slider, 100); } #endif diff --git a/examples/others/xml/my_button.xml b/examples/others/xml/my_button.xml index cb4519a176..bcfb69a394 100644 --- a/examples/others/xml/my_button.xml +++ b/examples/others/xml/my_button.xml @@ -8,11 +8,8 @@ - - - - - + + diff --git a/examples/others/xml/view.xml b/examples/others/xml/view.xml index ee743705dd..6eea106786 100644 --- a/examples/others/xml/view.xml +++ b/examples/others/xml/view.xml @@ -1,8 +1,39 @@ - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + +