fix(xml): find constants in styles in the global scope

This commit is contained in:
Gabor Kiss-Vamosi
2025-07-02 22:02:58 +02:00
committed by Felipe Neves
parent 8599e9be77
commit 84acb67dca
2 changed files with 19 additions and 1 deletions
+18
View File
@@ -124,13 +124,31 @@ lv_result_t lv_xml_style_register(lv_xml_component_scope_t * scope, const char *
if(value[0] == '#') {
const char * value_clean = &value[1];
bool const_found = false;
lv_xml_const_t * c;
LV_LL_READ(&scope->const_ll, c) {
if(lv_streq(c->name, value_clean)) {
value = c->value;
const_found = true;
break;
}
}
if(!const_found) {
lv_xml_component_scope_t * global_scope = lv_xml_component_get_scope("globals");
if(global_scope) {
LV_LL_READ(&global_scope->const_ll, c) {
if(lv_streq(c->name, value_clean)) {
value = c->value;
const_found = true;
break;
}
}
}
}
if(!const_found) {
LV_LOG_WARN("Constant `%s` is not found", value_clean);
continue;
}
}
if(lv_streq(value, "remove")) {
+1 -1
View File
@@ -9,7 +9,7 @@
<style name="blue" text_color="#dark_blue" text_font="lv_montserrat_30"/>
<style name="scale_main" bg_opa="50%" pad_all="32" radius="8"/>
<style name="scale_indic" length="20" />
<style name="scale_sectoion_indic" text_color="#00ff00" line_width="6"/>
<style name="scale_sectoion_indic" text_color="0x00ff00" line_width="6"/>
</styles>
<view width="700" height="470" style_bg_color="#light_blue" flex_flow="column_wrap">