svghmi/widget_scrollbar.ysl2
author Edouard Tisserant
Tue, 13 Jul 2021 16:19:07 +0200
branchsvghmi
changeset 3280 09133b155f0c
parent 3241 fe945f1f48b7
child 3325 3930916a2e0d
permissions -rw-r--r--
SVGHMI: Widget lib: small doc fix.
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
     1
// widget_scrollbar.ysl2
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
     2
widget_desc("ScrollBar") {
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
    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
     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
    ScrollBar - documentation to be written
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
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
    shortdesc > ScrollBar
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
    path name="value" accepts="HMI_INT" > value
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
    path name="range" accepts="HMI_INT" > range
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
    path name="visible" accepts="HMI_INT" > visible
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
    
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
}
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    15
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: 3178
diff changeset
    16
widget_class("ScrollBar") {
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    17
    ||
3139
1f5ca646ce6e SVGHMI: Add inhibition to widget's apply_hmi_value() so that it does not change variable more frquently than given widget's frequency. This prevents flooding network with many update if browser is producing events at high rate, as for exemple when dragging ScrollBar's cursor.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3138
diff changeset
    18
        frequency = 10;
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    19
        position = undefined;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    20
        range = undefined;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    21
        size = undefined;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    22
        mincursize = 0.1;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    23
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    24
        dispatch(value,oldval, index) {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    25
            switch(index) {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    26
                case 0:
3178
21cb76012c78 SVGHMI: Make ScrollBar's variables order match JsonTable's variables order to avoid confusion
Edouard Tisserant
parents: 3151
diff changeset
    27
                    this.range = Math.max(1,value);
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    28
                    break;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    29
                case 1:
3178
21cb76012c78 SVGHMI: Make ScrollBar's variables order match JsonTable's variables order to avoid confusion
Edouard Tisserant
parents: 3151
diff changeset
    30
                    this.position = value;
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    31
                    break;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    32
                case 2:
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    33
                    this.size = value;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    34
                    break;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    35
            }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    36
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    37
            this.request_animate();
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    38
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    39
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    40
        get_ratios() {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    41
            let range = this.range;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    42
            let size = Math.max(this.range * this.mincursize, Math.min(this.size, range));
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    43
            let maxh = this.range_elt.height.baseVal.value;
3151
8e5d383a58cb SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents: 3143
diff changeset
    44
            let pixels = maxh;
8e5d383a58cb SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents: 3143
diff changeset
    45
            let units = range;
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    46
            return [size, maxh, range, pixels, units];
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    47
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    48
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    49
        animate(){
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    50
            if(this.position == undefined || this.range == undefined || this.size == undefined)
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    51
                return;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    52
            let [size, maxh, range, pixels, units] = this.get_ratios();
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    53
3151
8e5d383a58cb SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents: 3143
diff changeset
    54
            let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / units);
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    55
            let new_height = Math.round(maxh * size/range);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    56
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    57
            this.cursor_elt.y.baseVal.value = new_y;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    58
            this.cursor_elt.height.baseVal.value = new_height;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    59
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    60
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    61
        init_mandatory() {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    62
            this.cursor_elt.onpointerdown = () => this.on_cursor_down();
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    63
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    64
            this.bound_drag = this.drag.bind(this);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    65
            this.bound_drop = this.drop.bind(this);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    66
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    67
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    68
        apply_position(position){
3151
8e5d383a58cb SVGHMI: Fixed HMI:ScrollBar to exclude cursor size from accessible range ( position is now 0->range-size instead of 0->range ). Fixed and extended tests/svghmi to have working ScrollBar on two alarm pages. Includes generated XSLT update.
Edouard Tisserant
parents: 3143
diff changeset
    69
            this.position = Math.round(Math.max(Math.min(position, this.range - this.size), 0));
3178
21cb76012c78 SVGHMI: Make ScrollBar's variables order match JsonTable's variables order to avoid confusion
Edouard Tisserant
parents: 3151
diff changeset
    70
            this.apply_hmi_value(1, this.position);
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    71
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    72
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    73
        on_page_click(is_up){
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    74
            this.apply_position(is_up ? this.position-this.size
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    75
                                      : this.position+this.size);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    76
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    77
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    78
        on_cursor_down(e){
3138
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    79
            // get scrollbar -> root transform
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    80
            let ctm = this.range_elt.getCTM();
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    81
            // relative motion -> discard translation
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    82
            ctm.e = 0;
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    83
            ctm.f = 0;
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    84
            // root -> scrollbar transform
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
    85
            this.invctm = ctm.inverse();
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    86
            svg_root.addEventListener("pointerup", this.bound_drop, true);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    87
            svg_root.addEventListener("pointermove", this.bound_drag, true);
3143
8388e6d4aa61 SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents: 3139
diff changeset
    88
            this.dragpos = this.position;
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    89
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    90
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    91
        drop(e) {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    92
            svg_root.removeEventListener("pointerup", this.bound_drop, true);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    93
            svg_root.removeEventListener("pointermove", this.bound_drag, true);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    94
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    95
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    96
        drag(e) {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    97
            let [size, maxh, range, pixels, units] = this.get_ratios();
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    98
            if(pixels == 0) return;
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
    99
            let point = new DOMPoint(e.movementX, e.movementY);
3138
1d724e8d5592 SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents: 3137
diff changeset
   100
            let movement = point.matrixTransform(this.invctm).y;
3143
8388e6d4aa61 SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents: 3139
diff changeset
   101
            this.dragpos += movement * units / pixels;
8388e6d4aa61 SVGHMI: more straightforward implementation of dragging position computation in Scrollbar + some little fix about boundaries.
Edouard Tisserant
parents: 3139
diff changeset
   102
            this.apply_position(this.dragpos);
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   103
        }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   104
    ||
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   105
}
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   106
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: 3178
diff changeset
   107
widget_defs("ScrollBar") {
3136
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   108
    labels("cursor range");
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   109
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   110
    const "pagebuttons" optional_labels("pageup pagedown");
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   111
    const "have_pagebuttons","string-length($pagebuttons)>0";
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   112
    value "$pagebuttons";
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   113
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   114
    |     init: function() {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   115
    |         this.init_mandatory();
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   116
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   117
    if "$have_pagebuttons" {
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   118
    |         this.pageup_elt.onclick = () => this.on_page_click(true);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   119
    |         this.pagedown_elt.onclick = () => this.on_page_click(false);
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   120
    }
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   121
    |     },
784c839d4259 SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff changeset
   122
}