scoop:scoop.ui:0.1.0
src/scroll/input_geometry.scoop
Selected production source · src/scroll/input_geometry.scoop
1
package scoop.ui3
import scoop.graphics.Point4
import scoop.graphics.Rect5
import scoop.surface.InputScope7
internal fun inputWindowPoint(scope: InputScope, point: Point): Point? =8
when (scope.area) {9
case Some(val area) -> when (area.toWindow(Rect(point.x, point.y, 0.0, 0.0))) {10
case Some(val bounds) -> Some(Point(bounds.x, bounds.y))11
case None -> None12
}13
case None -> Some(point)14
}16
internal fun inputLocalPoint(scope: InputScope, point: Point): Point? =17
when (scope.area) {18
case Some(val area) -> area.toLocal(point)19
case None -> Some(point)20
}22
internal fun inputLocalVector(scope: InputScope, origin: Point, amount: Point): Point? {23
val first = inputLocalPoint(scope, origin) ?: return None24
val last =25
inputLocalPoint(scope, Point(origin.x + amount.x, origin.y + amount.y)) ?: return None26
return Some(Point(last.x - first.x, last.y - first.y))27
}29
internal fun inputWindowVector(scope: InputScope, origin: Point, amount: Point): Point? {30
val local = inputLocalPoint(scope, origin) ?: return None31
val first = inputWindowPoint(scope, local) ?: return None32
val last = inputWindowPoint(scope, Point(local.x + amount.x, local.y + amount.y)) ?: return None33
return Some(Point(last.x - first.x, last.y - first.y))34
}