All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.peanuuutz.fork.ui.scene.screen.DelegatedPointerService.kt Maven / Gradle / Ivy

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)"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy