scoop:scoop.ui.component:0.1.0
src/resizable/builder.scoop
Selected production source · src/resizable/builder.scoop
1
package scoop.ui.component3
import scoop.ui.*4
import scoop.ui.style.*6
public class ResizablePanelBuilder internal constructor() {7
public var minimum: Double = 0.08
public var maximum: Double? = None9
public var collapsible: Boolean = false10
public var collapsedSize: Double = 0.011
public var style: StyleOverride = styleOverride()12
public fun style(configure: StyleOverrideBuilder.() -> Unit) {13
style = style.copy(configure)14
}15
internal fun snapshot(key: ViewKey, content: View): ResizablePanelProps =16
ResizablePanelProps(key, content, minimum, maximum, collapsible, collapsedSize, style)17
}19
public class ResizableHandleBuilder internal constructor() {20
public var withHandle: Boolean? = None21
public var enabled: Boolean = true22
public var focus: FocusOptions = FocusOptions()23
public var style: StyleOverride = styleOverride()24
public var hitWidth: Double = 20.025
public var semantics: ComponentSemantics = ComponentSemantics()26
public fun style(configure: StyleOverrideBuilder.() -> Unit) {27
style = style.copy(configure)28
}29
public fun focus(configure: FocusOptionsBuilder.() -> Unit) {30
focus = focus.copy(configure)31
}32
internal fun snapshot(key: ViewKey): ResizableHandleOptions =33
ResizableHandleOptions(key, withHandle, enabled, focus, style, hitWidth, semantics)34
}36
public class ResizableBuilder internal constructor() {37
private val panels = ArrayList<ResizablePanelProps>()38
private val handles = ArrayList<ResizableHandleOptions>()39
public var orientation: Orientation = Orientation.Horizontal40
public var enabled: Boolean = true41
public var withHandle: Boolean = false42
public var length: Double? = None43
public var keyboardStep: Double = 10.044
public var dragThreshold: Double = 4.045
public var theme: ThemeSource? = None46
public var style: StyleOverride = styleOverride()47
public var clip: Boolean = false48
public var onSizesChange: (Array<ResizableSize>) -> Unit = {}49
public var onSizesCommit: (Array<ResizableSize>) -> Unit = {}50
public var onSizesCancel: (Array<ResizableSize>, DragCancelReason) -> Unit = { _, _ -> }51
public var key: ViewKey = ViewKey.Position52
public fun style(configure: StyleOverrideBuilder.() -> Unit) {53
style = style.copy(configure)54
}55
public fun panel(56
key: ViewKey,57
content: View,58
configure: ResizablePanelBuilder.() -> Unit = {}59
) {60
val builder = ResizablePanelBuilder()61
builder.configure()62
add(builder.snapshot(key, content))63
}64
public fun add(panel: ResizablePanelProps) {65
panels.add(panel)66
}67
public fun handle(afterKey: ViewKey, configure: ResizableHandleBuilder.() -> Unit = {}) {68
val builder = ResizableHandleBuilder()69
builder.configure()70
handles.add(builder.snapshot(afterKey))71
}72
internal fun snapshot(sizes: Binding<Array<ResizableSize>>): ResizableProps =73
ResizableProps(74
sizes,75
panels.toArray(),76
handles.toArray(),77
orientation,78
enabled,79
withHandle,80
length,81
keyboardStep,82
dragThreshold,83
theme,84
style,85
clip,86
onSizesChange,87
onSizesCommit,88
onSizesCancel89
)90
}92
public fun resizable(93
sizes: Binding<Array<ResizableSize>>,94
configure: ResizableBuilder.() -> Unit = {}95
): View {96
val builder = ResizableBuilder()97
builder.configure()98
return component(99
builder.snapshot(sizes),100
{ current, mount -> Resizable(current, scope = mount) },101
builder.key102
)103
}