diff options
author | Jakob Odersky <jodersky@gmail.com> | 2015-03-27 12:48:24 +0100 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2015-03-27 12:48:24 +0100 |
commit | bd174539d8bb2921bef94cccd994a61e334a3dd7 (patch) | |
tree | fa89d47f97779c16d3a54b62518b8c83fc907d3c /vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala | |
parent | f7f157cea1afd3386e46938a110c5a2ed72933fb (diff) | |
parent | c2b0a3de4dca16cb9143acffdcc7a9ad1a730b50 (diff) | |
download | mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.tar.gz mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.tar.bz2 mavigator-bd174539d8bb2921bef94cccd994a61e334a3dd7.zip |
Merge pull request #12 from jodersky/design/cleanupconcise-dialect
Clean up internal structure of dashboard ui
Diffstat (limited to 'vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala')
-rw-r--r-- | vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala new file mode 100644 index 0000000..5b0a13d --- /dev/null +++ b/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala @@ -0,0 +1,28 @@ +package vfd.dashboard.ui.instruments + +import rx._ +import org.scalajs.dom.html + +/** Common trait to all flight instruments. */ +trait Instrument[A] { + + /** Initial value. */ + val initial: A + + /** Current value that is displayed in the instrument. */ + val value: Var[A] = Var(initial) + + /** HTML element that contains the rendered instrument */ + val element: html.Element + + /** Performs the actual UI update of this instrument. */ + protected def update(newValue: A): Unit + + /** Call when instrument has finished setting up its UI. */ + protected def ready() = { + Obs(value, skipInitial = true) { + update(value()) + } + } + +}
\ No newline at end of file |