package net.shadowfacts.phycon.client.screen import net.minecraft.client.util.math.MatrixStack import net.minecraft.util.Identifier import net.shadowfacts.cacao.geometry.Point import net.shadowfacts.cacao.geometry.Size import net.shadowfacts.cacao.util.texture.Texture import net.shadowfacts.cacao.view.TextureView import net.shadowfacts.cacao.view.button.AbstractButton import net.shadowfacts.phycon.PhysicalConnectivity /** * @author shadowfacts */ class ClipboardButton( handler: (ClipboardButton) -> Unit, ): AbstractButton( TextureView(DEFAULT) ) { companion object { private val DEFAULT = Texture(Identifier(PhysicalConnectivity.MODID, "textures/gui/icons.png"), 16, 0) private val HOVER = Texture(Identifier(PhysicalConnectivity.MODID, "textures/gui/icons.png"), 0, 0) } private val textureView: TextureView get() = content as TextureView init { intrinsicContentSize = Size(9.0, 7.0) content.intrinsicContentSize = Size(9.0, 7.0) this.handler = handler this.background = null this.hoveredBackground = null this.disabledBackground = null } override fun draw(matrixStack: MatrixStack, mouse: Point, delta: Float) { textureView.texture = if (mouse in bounds) HOVER else DEFAULT super.draw(matrixStack, mouse, delta) } }