Scoop API

scoop:scoop.ui.component:0.1.0

platform/desktop/native/chrome/values.scoop

Selected production source · platform/desktop/native/chrome/values.scoop

1package scoop.ui.component
3import scoop.graphics.Path
4import scoop.ui.*
5import scoop.window.*
7public enum WindowChromeShape {
8 Bounds, Rounded(Double), Ellipse, Path(Path)
9}
11public class WindowChromeProps public constructor(
12 public val content: View,
13 public val frame: WindowFrame = WindowFrame.Client,
14 public val fallbackFrame: WindowFrame? = None,
15 public val titleBar: View? = None,
16 public val titleBarHeight: Double = 32.0,
17 public val transparent: Boolean? = None,
18 public val shadow: WindowShadow? = None,
19 public val clip: WindowChromeShape? = None,
20 public val windowShape: WindowChromeShape? = None,
21 public val inputShape: WindowChromeShape? = None
22) {
23 init {
24 nonnegative(titleBarHeight, "invalid title bar height")
25 for (shape in [clip, windowShape, inputShape])
26 when (shape) {
27 case Some(WindowChromeShape.Rounded(val radius)) -> nonnegative(
28 radius,
29 "invalid window corner radius"
30 )
31 else -> {}
32 }
33 }
36public class WindowChromeBuilder internal constructor() {
37 public var frame: WindowFrame = WindowFrame.Client
38 public var fallbackFrame: WindowFrame? = None
39 public var titleBar: View? = None
40 public var titleBarHeight: Double = 32.0
41 public var transparent: Boolean? = None
42 public var shadow: WindowShadow? = None
43 public var clip: WindowChromeShape? = None
44 public var windowShape: WindowChromeShape? = None
45 public var inputShape: WindowChromeShape? = None
46 public var key: ViewKey = ViewKey.Position
49public fun windowChrome(content: View, configure: WindowChromeBuilder.() -> Unit = {}): View {
50 val builder = WindowChromeBuilder()
51 builder.configure()
52 return component(
53 WindowChromeProps(
54 content,
55 builder.frame,
56 builder.fallbackFrame,
57 builder.titleBar,
58 builder.titleBarHeight,
59 builder.transparent,
60 builder.shadow,
61 builder.clip,
62 builder.windowShape,
63 builder.inputShape
64 ),
65 { current, mount -> WindowChrome(current, scope = mount) },
66 builder.key
67 )
70internal fun requireChromeRequest(status: RequestStatus, operation: String) {
71 if (status == RequestStatus.Unsupported)
72 throw WindowException(operation, WindowErrorKind.Unsupported)