mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
42 lines
795 B
Scala
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)))
|
|
}
|
|
}
|
|
}
|