scoop:scoop.ui.component:0.1.0
platform/desktop/native/chrome/values.scoop
Selected production source · platform/desktop/native/chrome/values.scoop
1
package scoop.ui.component3
import scoop.graphics.Path4
import scoop.ui.*5
import scoop.window.*7
public enum WindowChromeShape {8
Bounds, Rounded(Double), Ellipse, Path(Path)9
}11
public 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? = None22
) {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
}34
}36
public class WindowChromeBuilder internal constructor() {37
public var frame: WindowFrame = WindowFrame.Client38
public var fallbackFrame: WindowFrame? = None39
public var titleBar: View? = None40
public var titleBarHeight: Double = 32.041
public var transparent: Boolean? = None42
public var shadow: WindowShadow? = None43
public var clip: WindowChromeShape? = None44
public var windowShape: WindowChromeShape? = None45
public var inputShape: WindowChromeShape? = None46
public var key: ViewKey = ViewKey.Position47
}49
public 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.inputShape64
),65
{ current, mount -> WindowChrome(current, scope = mount) },66
builder.key67
)68
}70
internal fun requireChromeRequest(status: RequestStatus, operation: String) {71
if (status == RequestStatus.Unsupported)72
throw WindowException(operation, WindowErrorKind.Unsupported)73
}