# HG changeset patch # User Edouard Tisserant # Date 1613276245 -3600 # Node ID 1d724e8d5592339c888c212a67dd7e22cf7cc4aa # Parent ac3ec66e9c6d478325ed53d7bb3c2d9a374ac9d5 SVGHMI: fix scrollbar not behaving when rotated. diff -r ac3ec66e9c6d -r 1d724e8d5592 svghmi/widget_scrollbar.ysl2 --- a/svghmi/widget_scrollbar.ysl2 Sun Feb 14 05:15:13 2021 +0100 +++ b/svghmi/widget_scrollbar.ysl2 Sun Feb 14 05:17:25 2021 +0100 @@ -65,6 +65,13 @@ } on_cursor_down(e){ + // get scrollbar -> root transform + let ctm = this.range_elt.getCTM(); + // relative motion -> discard translation + ctm.e = 0; + ctm.f = 0; + // root -> scrollbar transform + this.invctm = ctm.inverse(); svg_root.addEventListener("pointerup", this.bound_drop, true); svg_root.addEventListener("pointermove", this.bound_drag, true); } @@ -77,9 +84,8 @@ drag(e) { let [size, maxh, range, pixels, units] = this.get_ratios(); if(pixels == 0) return; - let matrix = this.range_elt.getCTM().inverse(); let point = new DOMPoint(e.movementX, e.movementY); - let movement = point.matrixTransform(matrix).y; + let movement = point.matrixTransform(this.invctm).y; this.apply_position(this.position + movement * units / pixels); } } diff -r ac3ec66e9c6d -r 1d724e8d5592 tests/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg --- a/tests/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg Sun Feb 14 05:15:13 2021 +0100 +++ b/tests/svghmi_scrollbar/svghmi_0@svghmi/svghmi.svg Sun Feb 14 05:17:25 2021 +0100 @@ -56,12 +56,12 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="g4507" + inkscape:current-layer="hmi0" showgrid="false" units="px" inkscape:zoom="0.64" - inkscape:cx="512.75649" - inkscape:cy="208.59799" + inkscape:cx="318.22524" + inkscape:cy="196.09799" inkscape:window-width="1939" inkscape:window-height="1243" inkscape:window-x="3325" @@ -380,7 +380,7 @@ + transform="translate(80,100)"> + transform="translate(80,-220)"> + inkscape:label="HMI:ScrollBar@.position@.range@.size" + transform="translate(-202)"> Position + y="276.54129">Position Range @@ -810,10 +811,81 @@ xml:space="preserve" style="font-style:normal;font-weight:normal;font-size:40px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none" x="277.58728" - y="496.54126" + y="596.54126" id="text949">Size + y="596.54126">Size + + + + + + + + + + + +