scoop:scoop.window:0.1.0
src/frame/values.scoop
Selected production source · src/frame/values.scoop
1
package scoop.window3
public enum WindowContentMode {4
Standard, Extended5
}7
/** Client suppresses host decoration without disabling native window operations. */8
public enum WindowFrame {9
System(WindowContentMode), Client10
}12
public enum WindowShadow {13
System, None14
}16
public enum WindowResizeEdge {17
Left, Right, Top, Bottom, TopLeft, TopRight, BottomLeft, BottomRight18
}20
public enum WindowSystemButton {21
Close, Minimize, Maximize22
}24
public struct WindowSystemButtonBounds(val button: WindowSystemButton, val bounds: LogicalRect)26
public struct WindowFrameMetrics(27
val frame: WindowFrame,28
val metrics: WindowMetrics,29
val contentLayout: LogicalRect?,30
val systemButtons: Array<WindowSystemButtonBounds>,31
val visibleBorderThickness: Double?32
)34
public struct WindowFrameCapabilities(35
val client: Boolean,36
val extendedContent: Boolean,37
val systemResizeEdges: Boolean,38
val beginMove: Boolean,39
val beginResize: Boolean,40
val windowMenu: Boolean,41
val windowRegion: Boolean,42
val inputRegion: Boolean,43
val ignoreMouse: Boolean,44
val shadow: Boolean,45
val resizeHitRegions: Boolean,46
val systemButtonHitRegions: Boolean47
)49
/** Immutable binary coverage in logical content coordinates. */50
public class WindowRegion public constructor(public val rectangles: Array<LogicalRect>) {51
init {52
for (rect in rectangles) {53
checkRect(rect)54
requireWindow(55
(rect.origin.x + rect.size.width).isFinite() &&56
(rect.origin.y + rect.size.height).isFinite(),57
"region endpoint overflow"58
)59
}60
}61
public fun contains(point: LogicalPosition): Boolean {62
checkPosition(point)63
for (rect in rectangles)64
if (65
point.x >=66
rect.origin.x &&67
point.y >=68
rect.origin.y &&69
point.x <70
rect.origin.x +71
rect.size.width &&72
point.y <73
rect.origin.y +74
rect.size.height75
)76
return true77
return false78
}79
}81
public enum WindowHitRole {82
Client, Caption, Resize(WindowResizeEdge), SystemButton(WindowSystemButton)83
}85
/** Published order resolves overlaps after reserved native buttons. */86
public struct WindowHitRegion(val region: WindowRegion, val role: WindowHitRole)88
internal fun frameCode(frame: WindowFrame): Int =89
when (frame) {90
case System(WindowContentMode.Standard) -> 091
case System(WindowContentMode.Extended) -> 192
case Client -> 293
}95
internal fun frameValue(code: Int): WindowFrame =96
when (code) {97
0 -> WindowFrame.System(WindowContentMode.Standard)98
1 -> WindowFrame.System(WindowContentMode.Extended)99
2 -> WindowFrame.Client100
else -> throw WindowException("native frame mode", WindowErrorKind.NativeFailure)101
}103
internal fun resizeEdgeCode(edge: WindowResizeEdge): Int =104
when (edge) {105
case Left -> 0;106
case Right -> 1;107
case Top -> 2;108
case Bottom -> 3109
case TopLeft -> 4;110
case TopRight -> 5;111
case BottomLeft -> 6;112
case BottomRight -> 7113
}115
internal fun systemButtonCode(button: WindowSystemButton): Int =116
when (button) {117
case Close -> 0;118
case Minimize -> 1;119
case Maximize -> 2120
}122
internal fun systemButtonValue(code: Int): WindowSystemButton =123
when (code) {124
0 -> WindowSystemButton.Close;125
1 -> WindowSystemButton.Minimize;126
2 -> WindowSystemButton.Maximize127
else -> throw WindowException("native frame button", WindowErrorKind.NativeFailure)128
}130
internal fun hitRoleCode(role: WindowHitRole): Int =131
when (role) {132
case Client -> 0;133
case Caption -> 1134
case Resize(val edge) -> 2 + resizeEdgeCode(edge)135
case SystemButton(val button) -> 10 + systemButtonCode(button)136
}