feat(style): add lv_obj_bind_style_prop (#9173)

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Liam Howatt <30486941+liamHowatt@users.noreply.github.com>
This commit is contained in:
Gabor Kiss-Vamosi
2025-11-13 20:02:43 +01:00
committed by GitHub
parent 483cb38f60
commit ebc48b5c56
14 changed files with 279 additions and 60 deletions
+36
View File
@@ -208,4 +208,40 @@ void test_xml_style_binding(void)
lv_subject_set_int(subject, 5);
TEST_ASSERT_EQUAL_COLOR(lv_color_hex(0xff0000), lv_obj_get_style_bg_color(obj, LV_PART_SCROLLBAR));
}
void test_xml_style_prop_binding(void)
{
const char * comp1_xml = {
"<component>"
" <subjects>"
" <int name=\"subject1\" value=\"128\"/>"
" <color name=\"subject2\" value=\"0xff0000\"/>"
" </subjects>"
" <view>"
" <bind_style_prop prop=\"bg_opa\" selector=\"scrollbar|checked\" subject=\"subject1\"/>"
" <bind_style_prop prop=\"bg_color\" selector=\"scrollbar|checked\" subject=\"subject2\"/>"
" </view>"
"</component>"
};
lv_xml_register_component_from_data("comp1", comp1_xml);
lv_obj_t * obj = lv_xml_create(lv_screen_active(), "comp1", NULL);
lv_obj_add_state(obj, LV_STATE_CHECKED);
lv_test_wait(1000); /*Wait for transitions*/
TEST_ASSERT_EQUAL_INT(128, lv_obj_get_style_bg_opa(obj, LV_PART_SCROLLBAR | LV_STATE_CHECKED));
TEST_ASSERT_EQUAL_COLOR(lv_color_hex(0xff0000), lv_obj_get_style_bg_color(obj, LV_PART_SCROLLBAR));
lv_subject_t * subject1 = lv_xml_get_subject(lv_xml_component_get_scope("comp1"), "subject1");
lv_subject_t * subject2 = lv_xml_get_subject(lv_xml_component_get_scope("comp1"), "subject2");
lv_subject_set_int(subject1, 20);
lv_subject_set_color(subject2, lv_color_hex(0xff00ff));
lv_test_wait(1000); /*Wait for transitions*/
TEST_ASSERT_EQUAL_INT(20, lv_obj_get_style_bg_opa(obj, LV_PART_SCROLLBAR | LV_STATE_CHECKED));
TEST_ASSERT_EQUAL_COLOR(lv_color_hex(0xff00ff), lv_obj_get_style_bg_color(obj, LV_PART_SCROLLBAR | LV_STATE_CHECKED));
}
#endif