Scoop API

scoop:scoop.ui.component:0.1.0

src/scroll/decoration.scoop

Selected production source · src/scroll/decoration.scoop

1package scoop.ui.component
3import scoop.graphics.*
4import scoop.ui.*
5import scoop.ui.style.*
7/** Bars share resolved bounds, including the fixed corner of a gutter layout. */
8internal class ScrollBarsLayout(
9 size: Size,
10 snapshot: ScrollSnapshot,
11 axes: ScrollAxes,
12 visibility: ScrollbarVisibility,
13 thickness: Double,
14 direction: LayoutDirection,
15 placement: ScrollbarPlacement = ScrollbarPlacement.Overlay
16) {
17 private val width = upperBound(thickness, size.width)
18 private val height = upperBound(thickness, size.height)
19 private val hasX =
20 axes.horizontal &&
21 showScrollbar(visibility, snapshot.bodySize.width - snapshot.viewport.width) &&
22 height >
23 0.0 &&
24 size.width >
25 0.0
26 private val hasY =
27 axes.vertical &&
28 showScrollbar(visibility, snapshot.bodySize.height - snapshot.viewport.height) &&
29 width >
30 0.0 &&
31 size.height >
32 0.0
33 private val cornerX =
34 if (
35 hasY ||
36 (
37 placement ==
38 ScrollbarPlacement.Gutter &&
39 axes.vertical &&
40 visibility !=
41 ScrollbarVisibility.Hidden
42 )
43 )
44 width
45 else
46 0.0
47 private val cornerY =
48 if (
49 hasX ||
50 (
51 placement ==
52 ScrollbarPlacement.Gutter &&
53 axes.horizontal &&
54 visibility !=
55 ScrollbarVisibility.Hidden
56 )
57 )
58 height
59 else
60 0.0
61 val horizontal: Rect? =
62 if (hasX && size.width > cornerX)
63 Some(
64 Rect(
65 if (direction == LayoutDirection.Rtl)
66 cornerX
67 else
68 0.0,
69 size.height - height,
70 size.width - cornerX,
71 height
72 )
73 )
74 else
75 None
76 val vertical: Rect? =
77 if (hasY && size.height > cornerY)
78 Some(
79 Rect(
80 if (direction == LayoutDirection.Rtl)
81 0.0
82 else
83 size.width - width,
84 0.0,
85 width,
86 size.height - cornerY
87 )
88 )
89 else
90 None
93internal fun scrollSurfaceOptions(local: StyleOverride, outline: OutlineStyle?): SurfaceOptions {
94 val decoration =
95 styleOverride {
96 this.background(None)
97 this.border(None)
98 this.corners(Corners.all(0.0))
99 this.boxShadows([])
100 }.then(local).then(styleOverride { this.clipContent(true) })
101 return surfaceOptions {
102 this.minimumSize = Some(Size(0.0, 0.0))
103 this.suggestedSize = Some(Size(0.0, 0.0))
104 this.padding = Some(Insets(0.0, 0.0, 0.0, 0.0))
105 this.style = decoration
106 this.focus = outline
107 }