svghmi/widget_list.ysl2
author Edouard Tisserant
Tue, 02 Mar 2021 17:30:13 +0100
branchsvghmi
changeset 3175 b2ba6eeb61ec
parent 3031 440d74319a74
child 3185 9038655c1b18
permissions -rw-r--r--
SVGHMI: attempt to prevent crazy styling with HMI:TextStyleList when inkscape store style in tspan instead of text element.
// widget_list.ysl2

template "widget[@type='List']", mode="widget_defs" {
    param "hmi_element";
    |     items: {
    foreach "$hmi_element/*[@inkscape:label]" {
    |         «@inkscape:label»: "«@id»",
    }
    |     },
}

template "widget[@type='TextStyleList']", mode="widget_defs" {
    param "hmi_element";
    |     styles: {
    foreach "$hmi_element/*[@inkscape:label]" {
        const "text", "func:refered_elements(.)[self::svg:text][1]";
        const "tspan", "$text/svg:tspan[1]";
        const "style" choose {
            when "$text/@style and $tspan/@style" > «$text/@style»;«$tspan/@style»
            otherwise > «$text/@style»«$tspan/@style»

        }
    |         «@inkscape:label»: "«$style»",
    }
    |     },
}