author | Edouard Tisserant |
Tue, 08 Nov 2022 11:00:42 +0100 | |
changeset 3661 | 62860665fa94 |
parent 3357 | 595603d80b5b |
permissions | -rw-r--r-- |
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 |
|| |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
5 |
ScrollBar - svg:rect based scrollbar |
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
|
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; |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
42 |
let size = Math.max(range * this.mincursize, Math.min(this.size, range)); |
3136
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; |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
45 |
return [size, maxh, range, pixels]; |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
46 |
} |
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 |
animate(){ |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
49 |
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
|
50 |
return; |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
51 |
let [size, maxh, range, pixels] = this.get_ratios(); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
52 |
|
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
53 |
let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / range); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
54 |
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
|
55 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
} |
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 |
init_mandatory() { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
61 |
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
|
62 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
63 |
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
|
64 |
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
|
65 |
} |
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 |
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
|
68 |
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
|
69 |
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
|
70 |
} |
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 |
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
|
73 |
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
|
74 |
: 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 |
} |
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 |
on_cursor_down(e){ |
3138
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
78 |
// get scrollbar -> root transform |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
79 |
let ctm = this.range_elt.getCTM(); |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
80 |
// relative motion -> discard translation |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
81 |
ctm.e = 0; |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
82 |
ctm.f = 0; |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
83 |
// root -> scrollbar transform |
1d724e8d5592
SVGHMI: fix scrollbar not behaving when rotated.
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3137
diff
changeset
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
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
|
88 |
} |
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 |
drop(e) { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
91 |
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
|
92 |
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
|
93 |
} |
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 |
drag(e) { |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
96 |
let [size, maxh, range, pixels] = this.get_ratios(); |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
97 |
if(pixels == 0) return; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
98 |
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
|
99 |
let movement = point.matrixTransform(this.invctm).y; |
3357
595603d80b5b
SVGHMI: simplication in ScrollBar widget JS code
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
3241
diff
changeset
|
100 |
this.dragpos += movement * range / pixels; |
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.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
|
102 |
} |
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 |
|
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
|
106 |
widget_defs("ScrollBar") { |
3136
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
107 |
labels("cursor range"); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
108 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
109 |
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
|
110 |
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
|
111 |
value "$pagebuttons"; |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
112 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
113 |
| init: function() { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
114 |
| this.init_mandatory(); |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
115 |
|
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
116 |
if "$have_pagebuttons" { |
784c839d4259
SVGHMI: Add a robust ScrollBar widget. HMI:ScrollBar@positionrange@size
Edouard Tisserant <edouard.tisserant@gmail.com>
parents:
diff
changeset
|
117 |
| 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
|
118 |
| 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
|
119 |
} |
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 |
} |