aboutsummaryrefslogtreecommitdiff
path: root/vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2015-03-27 12:48:24 +0100
committerJakob Odersky <jodersky@gmail.com>2015-03-27 12:48:24 +0100
commitbd174539d8bb2921bef94cccd994a61e334a3dd7 (patch)
treefa89d47f97779c16d3a54b62518b8c83fc907d3c /vfd-dashboard/src/main/scala/vfd/dashboard/ui/instruments/Instrument.scala
parentf7f157cea1afd3386e46938a110c5a2ed72933fb (diff)
parentc2b0a3de4dca16cb9143acffdcc7a9ad1a730b50 (diff)
downloadmavigator-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.scala28
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