Add Main Stage

parent 82a9a009
......@@ -12,6 +12,7 @@ libraryDependencies += "com.lihaoyi" %% "requests" % "0.4.6"
fork := true
libraryDependencies += "org.scalafx" %% "scalafx" % "12.0.2-R18"
libraryDependencies += "com.panemu" % "tiwulfx" % "3.0"
// Determine OS version of JavaFX binaries
lazy val osName = System.getProperty("os.name") match {
......
import api.Client
import api.objects.collections.Sections
import api.objects.{AuthToken, Section}
import utils.config.UserConfig
object Sipam extends App {
import gui.MainStage
import scalafx.application.JFXApp
object Sipam extends JFXApp {
stage = MainStage
}
package gui
import scalafx.application.JFXApp.PrimaryStage
import scalafx.scene.image.Image
import utils.config.UserConfig
/**
* The main stage for the GUI. It initiate the whole GUI.
*
* It also saves the window size, if it is maximized, and display unhandled
* error in a nice notification window.
*/
object MainStage extends PrimaryStage {
val DEFAULT_HEIGHT = 550d
val DEFAULT_WIDTH = 800d
minHeight = DEFAULT_HEIGHT
minWidth = DEFAULT_WIDTH
title.value = "Sipam"
/* Load the state of the window from the user config file */
height = UserConfig.getHeight.getOrElse(DEFAULT_HEIGHT)
width = UserConfig.getWidth.getOrElse(DEFAULT_WIDTH)
maximized = UserConfig.getIsMaximized.getOrElse(true)
/* Window icon */
icons.add(new Image("/images/icon.png"))
/* Resize events */
width.onChange { (source, oldValue, newValue) =>
if (!maximized()) UserConfig.setWidth(newValue.doubleValue())
}
height.onChange { (source, oldValue, newValue) =>
if (!maximized()) UserConfig.setHeight(newValue.doubleValue())
}
maximized.onChange {(source, oldValue, newValue) =>
UserConfig.setMaximized(maximized())
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment