Scoop API

scoop:scoop.ui.style:0.1.0

src/theme/parts.scoop

Selected production source · src/theme/parts.scoop

1package scoop.ui.style
3import scoop.graphics.*
5public struct SurfaceMetrics(
6 val suggestedSize: Size,
7 val minimumSize: Size,
8 val padding: Insets,
9 val borderInsets: Insets,
10 val corners: CornerRadii,
11 val focusOutset: Double
12) {
13 public val contentInsets: Insets
14 get() = Insets(
15 padding.left + borderInsets.left,
16 padding.top + borderInsets.top,
17 padding.right + borderInsets.right,
18 padding.bottom + borderInsets.bottom
19 )
22public class SurfaceOptions internal constructor(
23 public val suggestedSize: Size? = None,
24 public val minimumSize: Size? = None,
25 public val padding: Insets? = None,
26 public val style: StyleOverride = styleOverride(),
27 public val focus: OutlineStyle? = None,
28 public val validation: OutlineStyle? = None
29) {
30 public fun copy(configure: SurfaceOptionsBuilder.() -> Unit = {}): SurfaceOptions =
31 configureSurfaceOptions(this, configure)
34public class SurfaceGeometry public constructor(
35 public val bounds: Rect,
36 public val outline: RoundedOutline,
37 public val borderInner: RoundedOutline,
38 public val content: Rect,
39 public val ring: OutlineRing?,
40 public val style: Style,
41 public val opacity: Double = 1.0
42) {
43 public val contentStyle: Style
44 get() = Style(
45 corners = Corners.Physical(outline.radii),
46 contentEffects = style.contentEffects,
47 clipContent = style.clipContent
48 )
51public struct CheckboxMetrics(
52 val suggestedSize: Size,
53 val minimumSize: Size,
54 val borderInsets: Insets,
55 val corners: CornerRadii,
56 val markInset: Double,
57 val markWidth: Double,
58 val focusOutset: Double
61public class CheckboxOptions internal constructor(
62 public val size: Double? = None,
63 public val minimumSize: Double? = None,
64 public val markInset: Double? = None,
65 public val style: StyleOverride = styleOverride(),
66 public val markColor: Color? = None,
67 public val focus: OutlineStyle? = None,
68 public val validation: OutlineStyle? = None
69) {
70 public fun copy(configure: CheckboxOptionsBuilder.() -> Unit = {}): CheckboxOptions =
71 configureCheckboxOptions(this, configure)
74public class CheckboxGeometry public constructor(
75 public val bounds: Rect,
76 public val outline: RoundedOutline,
77 public val interior: RoundedOutline,
78 public val markBounds: Rect,
79 public val tick: StrokeSegment,
80 public val mixed: RoundedOutline,
81 public val ring: OutlineRing?,
82 public val style: Style,
83 public val markColor: Color,
84 public val selection: Double,
85 public val opacity: Double = 1.0,
86 public val stateLayer: MarkerStateLayerGeometry? = None
89public struct RadioMetrics(
90 val suggestedSize: Size,
91 val minimumSize: Size,
92 val ringWidth: Double,
93 val dotInset: Double,
94 val focusOutset: Double
97public class RadioOptions internal constructor(
98 public val size: Double? = None,
99 public val minimumSize: Double? = None,
100 public val dotInset: Double? = None,
101 public val background: StyleValue<Paint?> = StyleValue.Inherit,
102 public val border: StyleValue<BorderEdge?> = StyleValue.Inherit,
103 public val dotColor: Color? = None,
104 public val focus: OutlineStyle? = None,
105 public val validation: OutlineStyle? = None
106) {
107 public fun copy(configure: RadioOptionsBuilder.() -> Unit = {}): RadioOptions =
108 configureRadioOptions(this, configure)
111public class RadioGeometry public constructor(
112 public val bounds: Rect,
113 public val outer: Circle,
114 public val interior: Circle,
115 public val dot: Circle,
116 public val ring: OutlineRing?,
117 public val style: Style,
118 public val dotColor: Color,
119 public val selection: Double,
120 public val opacity: Double = 1.0,
121 public val stateLayer: MarkerStateLayerGeometry? = None
124public struct ScrollbarMetrics(
125 val thickness: Double,
126 val minimumThumbLength: Double,
127 val trackInset: Double,
128 val thumbInset: Double,
129 val cornerRadius: Double,
130 val buttonLength: Double?
133public class ScrollbarOptions internal constructor(
134 public val thickness: Double? = None,
135 public val minimumThumbLength: Double? = None,
136 public val trackInset: Double? = None,
137 public val thumbInset: Double? = None,
138 public val buttonLength: StyleValue<Double?> = StyleValue.Inherit
139) {
140 public fun copy(configure: ScrollbarOptionsBuilder.() -> Unit = {}): ScrollbarOptions =
141 configureScrollbarOptions(this, configure)
144public struct ScrollbarButtonGeometry(val outline: RoundedOutline, val arrow: StrokeSegment)
146public class ScrollbarGeometry public constructor(
147 public val bounds: Rect,
148 public val orientation: Orientation,
149 public val track: RoundedOutline,
150 public val thumb: RoundedOutline,
151 public val decrement: ScrollbarButtonGeometry?,
152 public val increment: ScrollbarButtonGeometry?,
153 public val travelStart: Point,
154 public val travel: Double,
155 public val thumbLength: Double,
156 public val position: Double,
157 public val visibleFraction: Double
160/** Concrete descriptions shared by the shape-based themes and custom presets. */
161public class SurfacePart internal constructor(
162 public val metrics: SurfaceMetrics,
163 public val fill: StateColors,
164 public val border: StateColors,
165 public val foreground: StateColors,
166 public val focus: OutlineStyle,
167 public val shadows: Array<BoxShadow> = [],
168 /** None inherits shadows; an empty array removes the hover elevation. */
169 public val hoverShadows: Array<BoxShadow>? = None
170) {
171 public fun copy(configure: SurfacePartBuilder.() -> Unit = {}): SurfacePart =
172 configureSurfacePart(this, configure)
175public class SurfaceParts internal constructor(
176 public val plain: SurfacePart,
177 public val action: SurfacePart,
178 public val outlinedAction: SurfacePart,
179 public val elevated: SurfacePart
180) {
181 public fun copy(configure: SurfacePartsBuilder.() -> Unit = {}): SurfaceParts =
182 configureSurfaceParts(this, configure)
184 public fun get(kind: SurfaceKind): SurfacePart = when (kind) {
185 case Plain -> plain;
186 case Action -> action;
187 case OutlinedAction -> outlinedAction;
188 case Elevated -> elevated
189 }
192/** A circular interaction layer behind a selection marker, independent of its hit target. */
193public struct MarkerStateLayer(val size: Double, val empty: StateColors, val selected: StateColors)
195/** Resolved drawing data; the painter does not recalculate interaction or selection. */
196public struct MarkerStateLayerGeometry(val circle: Circle, val color: Color)
198public class MarkerAppearance internal constructor(
199 public val empty: StateColors,
200 public val selected: StateColors,
201 public val border: StateColors,
202 public val selectedBorder: StateColors,
203 public val mark: StateColors,
204 public val focus: OutlineStyle,
205 public val shadows: Array<BoxShadow> = [],
206 public val stateLayer: MarkerStateLayer? = None
207) {
208 public fun copy(configure: MarkerAppearanceBuilder.() -> Unit = {}): MarkerAppearance =
209 configureMarkerAppearance(this, configure)
212public class CheckboxPart internal constructor(
213 public val metrics: CheckboxMetrics,
214 public val appearance: MarkerAppearance,
215 /** None keeps the same appearance for checked and mixed states. */
216 public val mixedAppearance: MarkerAppearance? = None,
217 public val mixedShape: MixedMarkShape = MixedMarkShape.Bar
218) {
219 public fun copy(configure: CheckboxPartBuilder.() -> Unit = {}): CheckboxPart =
220 configureCheckboxPart(this, configure)
223public class RadioPart internal constructor(
224 public val metrics: RadioMetrics,
225 public val appearance: MarkerAppearance
226) {
227 public fun copy(configure: RadioPartBuilder.() -> Unit = {}): RadioPart = configureRadioPart(
228 this,
229 configure
230 )
233public class ScrollbarPart internal constructor(
234 public val metrics: ScrollbarMetrics,
235 public val track: StateColors,
236 public val thumb: StateColors,
237 public val button: StateColors,
238 public val arrow: StateColors,
239 public val arrowWidth: Double = 1.5
240) {
241 public fun copy(configure: ScrollbarPartBuilder.() -> Unit = {}): ScrollbarPart =
242 configureScrollbarPart(this, configure)