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

commonMain.io.nacular.doodle.deviceinput.ViewFinder.kt Maven / Gradle / Ivy

There is a newer version: 0.10.4
Show newest version
package io.nacular.doodle.deviceinput

import io.nacular.doodle.core.Display
import io.nacular.doodle.core.Internal
import io.nacular.doodle.core.View
import io.nacular.doodle.geometry.Point

/**
 * Created by Nicholas Eddy on 3/12/19.
 */
@Internal
public interface ViewFinder {
    public fun find(at: Point): View?
}

@Internal
public class ViewFinderImpl(private val display: Display): ViewFinder {
    override fun find(at: Point): View? {
        var newPoint = at
        var view     = display.child(at)?.takeIf { it.enabled }

        while(view != null) {
            newPoint = view.toLocal(newPoint, view.parent)
            view     = view.child_(at = newPoint)?.takeIf { it.enabled } ?: break
        }

        return view
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy