Scoop API

scoop:scoop.window:0.1.0

src/frame/values.scoop

Selected production source · src/frame/values.scoop

1package scoop.window
3public enum WindowContentMode {
4 Standard, Extended
5}
7/** Client suppresses host decoration without disabling native window operations. */
8public enum WindowFrame {
9 System(WindowContentMode), Client
12public enum WindowShadow {
13 System, None
16public enum WindowResizeEdge {
17 Left, Right, Top, Bottom, TopLeft, TopRight, BottomLeft, BottomRight
20public enum WindowSystemButton {
21 Close, Minimize, Maximize
24public struct WindowSystemButtonBounds(val button: WindowSystemButton, val bounds: LogicalRect)
26public struct WindowFrameMetrics(
27 val frame: WindowFrame,
28 val metrics: WindowMetrics,
29 val contentLayout: LogicalRect?,
30 val systemButtons: Array<WindowSystemButtonBounds>,
31 val visibleBorderThickness: Double?
34public 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: Boolean
49/** Immutable binary coverage in logical content coordinates. */
50public 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.height
75 )
76 return true
77 return false
78 }
81public enum WindowHitRole {
82 Client, Caption, Resize(WindowResizeEdge), SystemButton(WindowSystemButton)
85/** Published order resolves overlaps after reserved native buttons. */
86public struct WindowHitRegion(val region: WindowRegion, val role: WindowHitRole)
88internal fun frameCode(frame: WindowFrame): Int =
89 when (frame) {
90 case System(WindowContentMode.Standard) -> 0
91 case System(WindowContentMode.Extended) -> 1
92 case Client -> 2
93 }
95internal fun frameValue(code: Int): WindowFrame =
96 when (code) {
97 0 -> WindowFrame.System(WindowContentMode.Standard)
98 1 -> WindowFrame.System(WindowContentMode.Extended)
99 2 -> WindowFrame.Client
100 else -> throw WindowException("native frame mode", WindowErrorKind.NativeFailure)
101 }
103internal fun resizeEdgeCode(edge: WindowResizeEdge): Int =
104 when (edge) {
105 case Left -> 0;
106 case Right -> 1;
107 case Top -> 2;
108 case Bottom -> 3
109 case TopLeft -> 4;
110 case TopRight -> 5;
111 case BottomLeft -> 6;
112 case BottomRight -> 7
113 }
115internal fun systemButtonCode(button: WindowSystemButton): Int =
116 when (button) {
117 case Close -> 0;
118 case Minimize -> 1;
119 case Maximize -> 2
120 }
122internal fun systemButtonValue(code: Int): WindowSystemButton =
123 when (code) {
124 0 -> WindowSystemButton.Close;
125 1 -> WindowSystemButton.Minimize;
126 2 -> WindowSystemButton.Maximize
127 else -> throw WindowException("native frame button", WindowErrorKind.NativeFailure)
128 }
130internal fun hitRoleCode(role: WindowHitRole): Int =
131 when (role) {
132 case Client -> 0;
133 case Caption -> 1
134 case Resize(val edge) -> 2 + resizeEdgeCode(edge)
135 case SystemButton(val button) -> 10 + systemButtonCode(button)
136 }