net.peanuuutz.fork.ui.scene.screen.ScreenContext.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 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()
}
}