svghmi/widget_foreach.ysl2
author Edouard Tisserant <edouard.tisserant@gmail.com>
Tue, 03 Dec 2024 21:22:45 +0100
changeset 4057 cf42c3dbdd5c
parent 4048 b3ea419a4d47
permissions -rw-r--r--
IDE: Fix PLCOpenEditor (wxPython4 menus) and drop broken PDF doc support.
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     1
// widget_foreach.ysl2
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     2
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     3
widget_desc("ForEach") {
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     4
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     5
    longdesc
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     6
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     7
    ForEach widget is used to span a small set of widget over a larger set of
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     8
    repeated HMI_NODEs. 
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
     9
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    10
    Idea is somewhat similar to relative page, but it all happens inside the
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    11
    ForEach widget, no page involved.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    12
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    13
    Together with relative Jump widgets it can be used to build a menu to reach
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    14
    relative pages covering many identical HMI_NODES siblings.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    15
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    16
    ForEach widget takes a HMI_CLASS name as argument and a HMI_NODE path as
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    17
    variable.
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    18
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    19
    Direct sub-elements can be either groups of widget to be spanned, labeled
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    20
    "ClassName:offset", or buttons to control the spanning, labeled
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    21
    "ClassName:+/-number".
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    22
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    23
    In case of "ClassName:offset", offset for first element is 1.
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    24
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    25
    ||
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    26
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    27
    shortdesc > span widgets over a set of repeated HMI_NODEs
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    28
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    29
    arg name="class_name" accepts="string" > HMI_CLASS name
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    30
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    31
    path name="root" accepts="HMI_NODE" >  where to find HMI_NODEs whose HMI_CLASS is class_name
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
    32
    path name="position" accepts="HMI_INT" > position of HMI_NODE mapped to first item, among similar siblings
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
    33
    path name="range" accepts="HMI_INT" count="optional" >  count of HMI_NODE siblings
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
    34
    path name="size" accepts="HMI_INT" count="optional" >  count of visible items
3241
fe945f1f48b7 SVGHMI: WIP on Widget DnD UI : Added documentation to widgets, that is injected in widget parse tree during widget analysis
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3232
diff changeset
    35
}
2891
8927ae8326b2 SVGHMI: add widget_foreach.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
    37
widget_defs("ForEach") {
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    38
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    39
    if "count(path) < 1" error > ForEach widget «$hmi_element/@id» must have one HMI path given.
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
    40
    if "count(arg) != 1" error > ForEach widget «$hmi_element/@id» must have one argument given : a class name.
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
    41
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    42
    const "class","arg[1]/@value";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    43
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    44
    const "base_path","path/@value";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    45
    const "hmi_index_base", "$indexed_hmitree/*[@hmipath = $base_path]";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    46
    const "hmi_tree_base", "$hmitree/descendant-or-self::*[@path = $hmi_index_base/@path]";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    47
    const "hmi_tree_items", "$hmi_tree_base/*[@class = $class]";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    48
    const "hmi_index_items", "$indexed_hmitree/*[@path = $hmi_tree_items/@path]"; 
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    49
    const "items_paths", "$hmi_index_items/@hmipath"; 
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    50
    |     index_pool: [
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    51
    foreach "$hmi_index_items" {
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    52
    |       «@index»`if "position()!=last()" > ,`
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    53
    }
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    54
    |     ],
2896
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    55
    |     init: function() {
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    56
    const "prefix","concat($class,':')";
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    57
    const "buttons_regex","concat('^',$prefix,'[+\-][0-9]+')";
2896
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    58
    const "buttons", "$hmi_element/*[regexp:test(@inkscape:label, $buttons_regex)]"; 
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    59
    foreach "$buttons" {
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    60
        const "op","substring-after(@inkscape:label, $prefix)";
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    61
    |         id("«@id»").setAttribute("onclick", "hmi_widgets['«$hmi_element/@id»'].on_click('«$op»', evt)");
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    62
    }
2896
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    63
    |
2895
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    64
    |         this.items = [
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    65
    const "items_regex","concat('^',$prefix,'[0-9]+')";
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    66
    const "unordered_items","$hmi_element//*[regexp:test(@inkscape:label, $items_regex)]";
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    67
    foreach "$unordered_items" {
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    68
        const "elt_label","concat($prefix, string(position()))"; 
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    69
        const "elt","$unordered_items[@inkscape:label = $elt_label]";
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    70
        const "pos","position()";
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    71
        const "item_path", "$items_paths[$pos]";
2895
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    72
    |           [ /* item="«$elt_label»" path="«$item_path»" */
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    73
        if "count($elt)=0" error > Missing item labeled «$elt_label» in ForEach widget «$hmi_element/@id»
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    74
        if "count($elt)>1" error > Duplicate item labeled «$elt_label» in ForEach widget «$hmi_element/@id»
2893
d57a12b8f5db SVGHMI: added func:get_hmi_tree_elt to match HMI tree node from path. Continue implementing ForEach widget : force order and completeness of items list. Now also collecting ForEach buttons.
Edouard Tisserant
parents: 2892
diff changeset
    75
        foreach "func:refered_elements($elt)[@id = $hmi_elements/@id][not(@id = $elt/@id)]" {
2894
4cf9ad35e6d0 SVGHMI: Easier way to match HMI tree elements to paths. ForEach widget now looks for paths and indexes of all items, and enforce path to be consistent with ForEach items sub widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2893
diff changeset
    76
            if "not(func:is_descendant_path(func:widget(@id)/path/@value, $item_path))"
2896
99c5335ed59f SVGHMI: Widget ForEach buttons now call corresponding methods.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2895
diff changeset
    77
                error > Widget id="«@id»" label="«@inkscape:label»" is having wrong path. Accroding to ForEach widget ancestor id="«$hmi_element/@id»", path should be descendant of "«$item_path»".
2895
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    78
    |             hmi_widgets["«@id»"]`if "position()!=last()" > ,`
2892
27dd409fba1d SVGHMI: ForEach knows its own widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2891
diff changeset
    79
        }
2895
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    80
    |           ]`if "position()!=last()" > ,`
2892
27dd409fba1d SVGHMI: ForEach knows its own widgets
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2891
diff changeset
    81
    }
2895
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    82
    |         ]
89c02b452717 SVGHMI: ForEach now has working (un)subscribe. Fixed PageSwitch that wasn't behaving when jumping to current page with another path.
Edouard Tisserant
parents: 2894
diff changeset
    83
    |     },
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    84
    |     range: «count($hmi_index_items)»,
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    85
    |     size: «count($unordered_items)»,
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    86
    |     position: 0,
2891
8927ae8326b2 SVGHMI: add widget_foreach.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    87
}
8927ae8326b2 SVGHMI: add widget_foreach.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    88
3232
7bdb766c2a4d SVGHMI: In order to allow widget signature and description to coexist in same ysl2 file, introduced widget_class, widget_defs to declare widget codegen templates and gen_index_xhtml to mark templates that are only usefull in gen_index_xhtml.xslt.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3005
diff changeset
    89
widget_class("ForEach")
2952
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
    90
||
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    91
    items_subscribed = false;
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
    92
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
    93
    unsub_items(){
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    94
        if(this.items_subscribed){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    95
            for(let item of this.items){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    96
                for(let widget of item) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    97
                    widget.unsub();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    98
                }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
    99
            }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   100
            this.items_subscribed = false;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   101
        }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   102
    }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   103
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   104
    unsub(){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   105
        super.unsub()
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   106
        this.unsub_items();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   107
    }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   108
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   109
    sub_items(){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   110
        if(!this.items_subscribed){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   111
            for(let i = 0; i < this.size; i++) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   112
                let item = this.items[i];
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   113
                let orig_item_index = this.index_pool[i];
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   114
                let item_index = this.index_pool[i+this.position];
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   115
                let item_index_offset = item_index - orig_item_index;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   116
                if(this.relativeness[0])
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   117
                    item_index_offset += this.offset;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   118
                for(let widget of item) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   119
                    /* all variables of all widgets in a ForEach are all relative. 
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   120
                       Really.
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   121
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   122
                       TODO: allow absolute variables in ForEach widgets
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   123
                    */
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   124
                    widget.sub(item_index_offset, widget.indexes.map(_=>true));
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   125
                }
2952
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
   126
            }
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
   127
        }
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
   128
    }
2891
8927ae8326b2 SVGHMI: add widget_foreach.ysl2
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   129
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   130
    sub(new_offset, relativeness, container_id){
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   131
        let position_given = this.indexes.length > 1;
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   132
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   133
        // sub() will call apply_cache() and then dispatch()
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   134
        // undefining position forces dispatch() to call apply_position()
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   135
        if(position_given)
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   136
            this.position = undefined;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   137
        
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   138
        super.sub(new_offset, relativeness, container_id);
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   139
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   140
        // if position isn't given as a variable
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   141
        // dispatch() to call apply_position() aren't called
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   142
        // and items must be subscibed now.
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   143
        if(!position_given)
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   144
            this.sub_items();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   145
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   146
        // as soon as subribed apply range and size once for all
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   147
        if(this.indexes.length > 2)
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   148
            this.apply_hmi_value(2, this.range);
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   149
        if(this.indexes.length > 3)
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   150
            this.apply_hmi_value(3, this.size);
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
   151
    }
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
   152
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   153
    apply_position(new_position){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   154
        let old_position = this.position;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   155
        let limited_position = Math.round(Math.max(Math.min(new_position, this.range - this.size), 0));
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   156
        if(this.position == limited_position){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   157
            return false;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   158
        }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   159
        this.unsub_items();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   160
        this.position = limited_position;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   161
        this.sub_items();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   162
        request_subscriptions_update();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   163
        jumps_need_update = true;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   164
        this.request_animate();
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   165
        return true;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   166
    }
3005
ff9ae4f4e3be SVGHMI: widgets are not anymore binary relative or absolute, but have a "relativeness".
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3003
diff changeset
   167
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   168
    on_click(opstr, evt) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   169
        let new_position = eval(String(this.position)+opstr);
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   170
        if(new_position + this.size > this.range) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   171
            if(this.position + this.size == this.range)
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   172
                new_position = 0;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   173
            else
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   174
                new_position = this.range - this.size;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   175
        } else if(new_position < 0) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   176
            if(this.position == 0)
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   177
                new_position = this.range - this.size;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   178
            else
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   179
                new_position = 0;
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   180
        }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   181
        if(this.apply_position(new_position)){
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   182
            this.apply_hmi_value(1, this.position);
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   183
        }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   184
    }
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   185
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   186
    dispatch(value, oldval, index) {
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   187
        // Only care about position, others are constants
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   188
        if(index == 1){
4025
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   189
            this.apply_position(value);
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   190
            if(this.position != value){
92b3701fceed SVGHMI: Extend ForEach widget to expose range, position and size in a way comparable with ScrollBar widget.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3603
diff changeset
   191
                // widget refused or apply different value, force it back
4048
b3ea419a4d47 SVGHMI: swap position and range of ForEach widget so that both range and size can be optional.
Edouard Tisserant <edouard@beremiz.fr>
parents: 4025
diff changeset
   192
                this.apply_hmi_value(1, this.position);
2952
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
   193
            }
2942
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   194
        }
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   195
    }
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   196
2952
2adfce8908b4 SVGHMI: apply per class overloading of sub/unsub to ForEach widget
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2943
diff changeset
   197
||
2942
b07ad97e6019 SVGHMI: moved JS code of foreach and jump widget in corresponding widget_*.ysl2. To be continued.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 2897
diff changeset
   198