# HG changeset patch # User Edouard Tisserant # Date 1657791322 -7200 # Node ID a8b6d5e1fda31c16f3324510eb9a7f51399daa88 # Parent 611fd1f44ce9836ef4656a99448f0e647ffdba0b SVGHMI: add support for user JS script added in inkscape's document properties / scripting / embedded scripts. diff -r 611fd1f44ce9 -r a8b6d5e1fda3 svghmi/gen_index_xhtml.ysl2 --- a/svghmi/gen_index_xhtml.ysl2 Wed Jul 13 14:40:42 2022 +0200 +++ b/svghmi/gen_index_xhtml.ysl2 Thu Jul 14 11:35:22 2022 +0200 @@ -102,6 +102,12 @@ include text svghmi.js + | \n//\n//\n// Declarations from SVG scripts (inkscape document properties) \n//\n// + foreach "/svg:svg/svg:script" { + | + | /* «@id» */ + | «text()» + } } } } diff -r 611fd1f44ce9 -r a8b6d5e1fda3 tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg --- a/tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg Wed Jul 13 14:40:42 2022 +0200 +++ b/tests/projects/svghmi/svghmi_0@svghmi/svghmi.svg Thu Jul 14 11:35:22 2022 +0200 @@ -18,6 +18,14 @@ viewBox="0 0 1280 720" height="720" width="1280"> + <script + id="script1244"> +hmi_widgets["g443-3"].off_action = function(){ + console.log("Hello from Inkscape"); + PushButtonWidget.prototype.off_action.call(this); + fading_page_switch(); + console.log("Bye from Inkscape"); +}</script> <metadata id="metadata4542"> <rdf:RDF> @@ -125,12 +133,12 @@ inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:document-units="px" - inkscape:current-layer="g5053" + inkscape:current-layer="hmi0" showgrid="false" units="px" - inkscape:zoom="0.80184804" - inkscape:cx="784.66046" - inkscape:cy="-449.34319" + inkscape:zoom="0.14174805" + inkscape:cx="-1530.0784" + inkscape:cy="-1404.9832" inkscape:window-width="1600" inkscape:window-height="836" inkscape:window-x="0" @@ -8399,4 +8407,47 @@ sodipodi:role="line">Freq4</tspan></text> </g> </g> + <g + transform="matrix(0.57180538,0,0,0.57180538,-77.992226,121.53383)" + id="g443-3" + inkscape:label="HMI:PushButton@/SELECTION" + style="stroke-width:1"> + <rect + 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:#e6e6e6;fill-opacity:1;fill-rule:nonzero;stroke:#ff6600;stroke-width:5;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" + id="rect5492-6" + width="245.44583" + height="95.723877" + x="971.96545" + y="594.82263" + ry="23.930969" + inkscape:label="inactive" + rx="23.930969" /> + <rect + rx="23.930969" + inkscape:label="active" + ry="23.930969" + y="594.82263" + x="971.96545" + height="95.723877" + width="245.44583" + id="rect433-7" + 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:#fdfdfd;fill-opacity:1;fill-rule:nonzero;stroke:#ffd0b2;stroke-width:28.60938263;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" /> + <g + style="stroke-width:1" + inkscape:label="text" + id="g952-5"> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:40px;line-height:125%;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;text-anchor:middle;display:inline;fill:#ff6600;fill-opacity:1;stroke:none;stroke-width:0.99999994px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="1090.7626" + y="656.98151" + id="text950-3" + inkscape:label="setting_jmp"><tspan + sodipodi:role="line" + id="tspan948-5" + x="1090.7626" + y="656.98151" + style="text-align:center;text-anchor:middle;fill:#ff6600;stroke-width:0.99999994px">up</tspan></text> + </g> + </g> </svg>