net.peanuuutz.fork.ui.scene.screen.DelegatedPointerService.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fork-ui Show documentation
Show all versions of fork-ui Show documentation
Comprehensive API designed for Minecraft modders
The newest version!
package net.peanuuutz.fork.ui.scene.screen
import androidx.compose.runtime.Stable
import net.peanuuutz.fork.ui.ui.context.pointer.PointerService
import net.peanuuutz.fork.ui.ui.context.window.CoordinateConvertor
import net.peanuuutz.fork.ui.ui.unit.FloatOffset
@Stable
class DelegatedPointerService(
private val coordinateConvertor: CoordinateConvertor
) : PointerService by ScreenPointerService {
override var position: FloatOffset
get() = coordinateConvertor.windowToRoot(ScreenPointerService.position)
set(value) {
ScreenPointerService.position = coordinateConvertor.rootToWindow(value)
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is DelegatedPointerService) return false
if (coordinateConvertor != other.coordinateConvertor) return false
return true
}
override fun hashCode(): Int {
return coordinateConvertor.hashCode()
}
override fun toString(): String {
return "DelegatedPointerService(coordinateConvertor=$coordinateConvertor)"
}
}