diff --git a/src/main/scala/ocelot/desktop/ui/widget/DiskEditWindow.scala b/src/main/scala/ocelot/desktop/ui/widget/DiskEditWindow.scala index 706e37b..983951c 100644 --- a/src/main/scala/ocelot/desktop/ui/widget/DiskEditWindow.scala +++ b/src/main/scala/ocelot/desktop/ui/widget/DiskEditWindow.scala @@ -91,25 +91,17 @@ class DiskEditWindow(item: DiskItem) extends PanelWindow { model = IconButton.ReadOnlyModel(isColorSelected), ) { - private val backgroundAnimation = new ColorAnimation(targetBackgroundColor, IconButton.AnimationSpeed) private val borderAnimation = new ColorAnimation(targetBorderColor, IconButton.AnimationSpeed) - private def targetBackgroundColor: Color = - if (isColorSelected) ColorScheme("FloppyIconButtonBackgroundSelected") - else ColorScheme("ButtonBackground") - private def targetBorderColor: Color = if (isColorSelected) ColorScheme("FloppyIconButtonBorderSelected") else ColorScheme("ButtonBorder") override protected def updateAnimationTargets(): Unit = { super.updateAnimationTargets() - backgroundAnimation.goto(targetBackgroundColor) borderAnimation.goto(targetBorderColor) } - override def backgroundColor: Color = backgroundAnimation.color - override def borderColor: Color = borderAnimation.color override def onPressed(): Unit = { @@ -120,7 +112,6 @@ class DiskEditWindow(item: DiskItem) extends PanelWindow { override def update(): Unit = { super.update() - backgroundAnimation.update() borderAnimation.update() } } diff --git a/src/main/scala/ocelot/desktop/ui/widget/IconButton.scala b/src/main/scala/ocelot/desktop/ui/widget/IconButton.scala index 8fd7ad1..83d075e 100644 --- a/src/main/scala/ocelot/desktop/ui/widget/IconButton.scala +++ b/src/main/scala/ocelot/desktop/ui/widget/IconButton.scala @@ -8,11 +8,12 @@ import ocelot.desktop.graphics.Graphics import ocelot.desktop.ui.event.handlers.{ClickHandler, HoverHandler} import ocelot.desktop.ui.event.{HoverEvent, MouseEvent} import ocelot.desktop.ui.widget.IconButton.{AnimationSpeed, Mode} +import ocelot.desktop.ui.widget.`trait`.HoverAnimation import ocelot.desktop.ui.widget.tooltip.LabelTooltip import ocelot.desktop.util.animation.{ColorAnimation, ValueAnimation} import ocelot.desktop.util.{DrawUtils, Spritesheet} -class IconButton( +class IconButton ( releasedIcon: String, pressedIcon: String, releasedColor: Color = Color.White, @@ -26,8 +27,9 @@ class IconButton( ) extends Widget with ClickHandler with HoverHandler - with ClickSoundSource { - + with HoverAnimation + with ClickSoundSource +{ override def receiveMouseEvents = true private var prevModelValue = model.pressed @@ -96,12 +98,11 @@ class IconButton( private val labelTooltip = tooltip.map(label => new LabelTooltip(label)) - def backgroundColor: Color = ColorScheme("ButtonBackground") def borderColor: Color = ColorScheme("ButtonBorder") override def draw(g: Graphics): Unit = { if (drawBackground) { - g.rect(bounds, backgroundColor) + g.rect(bounds, hoverAnimation.color) DrawUtils.ring(g, position.x, position.y, width, height, 2, borderColor) }