diff options
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala')
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala index 8ddba1a..dc8ee5e 100644 --- a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala +++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/components/SvgInstrument.scala @@ -3,12 +3,14 @@ package vfd.dashboard.ui.components import scala.scalajs.js.Any.fromFunction1 import org.scalajs.dom +import org.scalajs.dom.html import scalatags.JsDom.all.ExtendedString +import scalatags.JsDom.all.Int2CssNumber import scalatags.JsDom.all.`object` import scalatags.JsDom.all.stringAttr import scalatags.JsDom.all.stringFrag -import scalatags.JsDom.all.stringStyle +import scalatags.JsDom.all.stringPixelStyle import scalatags.JsDom.all.`type` import scalatags.JsDom.all.width import vfd.dashboard.Environment @@ -16,13 +18,13 @@ import vfd.dashboard.Environment trait SvgInstrument[A] { /** SVG object element that contains the rendered instrument */ - def element: dom.HTMLObjectElement + def element: html.Object /** Actual svg document */ - protected def content: dom.Document = element.contentDocument + protected def content = element.contentDocument /** Moveable parts of the instrument */ - protected def moveable: Seq[dom.HTMLElement] + protected def moveable: Seq[html.Element] /** Updates the instrument to show a new value */ def update(value: A): Unit @@ -38,17 +40,17 @@ trait SvgInstrument[A] { object SvgInstrument { - def svg(name: String)(implicit app: Environment): dom.HTMLObjectElement = { + def svg(name: String)(implicit app: Environment): html.Object = { val path = app.asset("images/instruments/" + name + ".svg") - `object`(`type` := "image/svg+xml", "data".attr := path, width := "100%")( + `object`(`type` := "image/svg+xml", "data".attr := path, width := 100.pct)( "Error loading instrument " + name).render } - def translate(elem: dom.HTMLElement, x: Int, y: Int): Unit = { + def translate(elem: html.Element, x: Int, y: Int): Unit = { elem.style.transform = "translate(" + x + "px, " + y + "px)"; } - def rotate(elem: dom.HTMLElement, deg: Int): Unit = { + def rotate(elem: html.Element, deg: Int): Unit = { elem.style.transform = "rotateZ(" + deg + "deg)"; } |