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

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

The newest version!
package net.peanuuutz.fork.ui.scene.screen

import net.peanuuutz.fork.ui.scene.base.DefaultClipboardService
import net.peanuuutz.fork.ui.scene.base.DefaultTextInputDispatcher
import net.peanuuutz.fork.ui.ui.context.UIContext
import net.peanuuutz.fork.ui.ui.context.pointer.PointerService
import net.peanuuutz.fork.ui.ui.context.text.ClipboardService
import net.peanuuutz.fork.ui.ui.context.text.TextInputDispatcher
import net.peanuuutz.fork.ui.ui.context.window.CoordinateConvertor
import net.peanuuutz.fork.ui.ui.context.window.WindowInfo
import net.peanuuutz.fork.ui.ui.draw.canvas.Canvas
import net.peanuuutz.fork.ui.ui.unit.FloatOffset

class ScreenContext(
    override val canvas: Canvas = ScreenCanvas(),
    private val onExitRequest: (() -> Unit)? = null
) : UIContext,
    CoordinateConvertor // Small interfaces don't deserve an object
{
    override val clipboardService: ClipboardService
        get() = DefaultClipboardService

    override val coordinateConvertor: CoordinateConvertor
        get() = this

    override val pointerService: PointerService
        get() = ScreenPointerService

    override val textInputDispatcher: TextInputDispatcher = DefaultTextInputDispatcher()

    override val windowInfo: WindowInfo
        get() = ScreenWindowInfo

    override fun rootToWindow(relativeToRoot: FloatOffset): FloatOffset {
        return relativeToRoot
    }

    override fun windowToRoot(relativeToWindow: FloatOffset): FloatOffset {
        return relativeToWindow
    }

    override fun exit() {
        onExitRequest?.invoke()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy