scoop:scoop.ui.component:0.1.0
src/scroll/decoration.scoop
Selected production source · src/scroll/decoration.scoop
1
package scoop.ui.component3
import scoop.graphics.*4
import scoop.ui.*5
import scoop.ui.style.*7
/** Bars share resolved bounds, including the fixed corner of a gutter layout. */8
internal class ScrollBarsLayout(9
size: Size,10
snapshot: ScrollSnapshot,11
axes: ScrollAxes,12
visibility: ScrollbarVisibility,13
thickness: Double,14
direction: LayoutDirection,15
placement: ScrollbarPlacement = ScrollbarPlacement.Overlay16
) {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.026
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.033
private val cornerX =34
if (35
hasY ||36
(37
placement ==38
ScrollbarPlacement.Gutter &&39
axes.vertical &&40
visibility !=41
ScrollbarVisibility.Hidden42
)43
)44
width45
else46
0.047
private val cornerY =48
if (49
hasX ||50
(51
placement ==52
ScrollbarPlacement.Gutter &&53
axes.horizontal &&54
visibility !=55
ScrollbarVisibility.Hidden56
)57
)58
height59
else60
0.061
val horizontal: Rect? =62
if (hasX && size.width > cornerX)63
Some(64
Rect(65
if (direction == LayoutDirection.Rtl)66
cornerX67
else68
0.0,69
size.height - height,70
size.width - cornerX,71
height72
)73
)74
else75
None76
val vertical: Rect? =77
if (hasY && size.height > cornerY)78
Some(79
Rect(80
if (direction == LayoutDirection.Rtl)81
0.082
else83
size.width - width,84
0.0,85
width,86
size.height - cornerY87
)88
)89
else90
None91
}93
internal 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 = decoration106
this.focus = outline107
}108
}