svghmi/widget_list.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Wed, 10 Mar 2021 19:29:49 +0100
branchsvghmi
changeset 3181 50d0fef791d5
parent 3175 b2ba6eeb61ec
child 3185 9038655c1b18
permissions -rw-r--r--
SVGHMI: Add generic action buttons to JSON table, with an example in tests/svghmi: wipe alar list.
// 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»",
    }
    |     },
}