2019-09-21 13:38:49 +03:00

42 lines
795 B
Scala

package ocelot.desktop.ui.window
import ocelot.desktop.ui.event.CloseWindowEvent
import ocelot.desktop.util.animation.ValueAnimation
trait BasicWindow extends Window {
private val state = new ValueAnimation()
override def show(): Unit = {
super.show()
state.goto(1)
}
override def hide(): Unit = {
super.hide()
state.goto(0)
}
override def focus(): Unit = {
super.focus()
state.goto(1)
}
override def unfocus(): Unit = {
super.focus()
state.goto(0.2f)
}
protected def backgroundAlpha: Float = state.value
protected def shadowAlpha: Float = state.value * 0.5f
override def update(): Unit = {
super.update()
state.update()
if (state.value == 0) {
parent.foreach(_.handleEvent(CloseWindowEvent(this)))
}
}
}