# HG changeset patch # User Edouard Tisserant # Date 1613646148 -3600 # Node ID 8e5d383a58cb17104c4894a8cc6b58b4fa4b79a8 # Parent 5a1bb6ec48a0ab34f5561f60e7625cc1096f691f 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. diff -r 5a1bb6ec48a0 -r 8e5d383a58cb svghmi/gen_index_xhtml.xslt --- a/svghmi/gen_index_xhtml.xslt Thu Feb 18 10:43:10 2021 +0100 +++ b/svghmi/gen_index_xhtml.xslt Thu Feb 18 12:02:28 2021 +0100 @@ -5733,9 +5733,9 @@ let maxh = this.range_elt.height.baseVal.value; - let pixels = (range - size) * maxh; - - let units = range*range; + let pixels = maxh; + + let units = range; return [size, maxh, range, pixels, units]; @@ -5753,7 +5753,7 @@ - let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range) * pixels / units); + let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / units); let new_height = Math.round(maxh * size/range); @@ -5783,7 +5783,7 @@ apply_position(position){ - this.position = Math.round(Math.max(Math.min(position, this.range), 0)); + this.position = Math.round(Math.max(Math.min(position, this.range - this.size), 0)); this.apply_hmi_value(0, this.position); diff -r 5a1bb6ec48a0 -r 8e5d383a58cb svghmi/widget_scrollbar.ysl2 --- a/svghmi/widget_scrollbar.ysl2 Thu Feb 18 10:43:10 2021 +0100 +++ b/svghmi/widget_scrollbar.ysl2 Thu Feb 18 12:02:28 2021 +0100 @@ -29,8 +29,8 @@ let range = this.range; let size = Math.max(this.range * this.mincursize, Math.min(this.size, range)); let maxh = this.range_elt.height.baseVal.value; - let pixels = (range - size) * maxh; - let units = range*range; + let pixels = maxh; + let units = range; return [size, maxh, range, pixels, units]; } @@ -39,7 +39,7 @@ return; let [size, maxh, range, pixels, units] = this.get_ratios(); - let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range) * pixels / units); + let new_y = this.range_elt.y.baseVal.value + Math.round(Math.min(this.position,range-size) * pixels / units); let new_height = Math.round(maxh * size/range); this.cursor_elt.y.baseVal.value = new_y; @@ -54,7 +54,7 @@ } apply_position(position){ - this.position = Math.round(Math.max(Math.min(position, this.range), 0)); + this.position = Math.round(Math.max(Math.min(position, this.range - this.size), 0)); this.apply_hmi_value(0, this.position); } diff -r 5a1bb6ec48a0 -r 8e5d383a58cb tests/svghmi/py_ext_0@py_ext/pyfile.xml --- a/tests/svghmi/py_ext_0@py_ext/pyfile.xml Thu Feb 18 10:43:10 2021 +0100 +++ b/tests/svghmi/py_ext_0@py_ext/pyfile.xml Thu Feb 18 12:02:28 2021 +0100 @@ -50,7 +50,8 @@ if len(extra) > 0 and extra[0] != "": fAlarms = [alrm for alrm in Alarms if alrm[1].find(extra[0])!=-1] else: - fAlarms = Alarms + fAlarms = Alarms[:] + fAlarms.reverse() new_range = len(fAlarms) delta = new_range - visible new_position = 0 if delta <= 0 else delta if old_position > delta else old_position diff -r 5a1bb6ec48a0 -r 8e5d383a58cb tests/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi/svghmi_0@svghmi/svghmi.svg Thu Feb 18 10:43:10 2021 +0100 +++ b/tests/svghmi/svghmi_0@svghmi/svghmi.svg Thu Feb 18 12:02:28 2021 +0100 @@ -125,12 +125,12 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="hmi0" + inkscape:current-layer="g971" showgrid="false" units="px" - inkscape:zoom="0.10544454" - inkscape:cx="4437.8566" - inkscape:cy="-1150.1415" + inkscape:zoom="0.42177816" + inkscape:cx="-596.64145" + inkscape:cy="136.19693" inkscape:window-width="1600" inkscape:window-height="836" inkscape:window-x="0" @@ -5108,7 +5108,7 @@ inkscape:label="data"> + inkscape:label="[2]" /> + inkscape:label="[0]" /> - - - - + inkscape:label="HMI:ScrollBar@.position@.range@.visibleAlarms" + transform="translate(9.7583007e-6)"> + id="path1266" + d="m -234.01097,332.35504 21.18736,28.36866 h -42.37471 z" + style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#ff6600;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.42391574px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" + inkscape:label="pageup" /> + + inkscape:label="range" /> + inkscape:label="cursor" /> + + Alarm Page 2 + + + + + + + + + + + + + + + + + + + + 8888 + + + + + + 8888 + + + + + + 8888 + + + + + range + position + notify + + + 8888 + + + + + + + + trigger + + + + + 8888 + + + ack + + + + disabled + + + + active + + + + alarm + + + Alarm Text + Status + + 8888 + + + filter + + + + + + Alarms2 + + + + + + + + Alarms + + + + + + + +