|
|
@ -11,6 +11,7 @@ import androidx.compose.ui.unit.Dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
import androidx.compose.ui.unit.dp |
|
|
|
|
|
|
|
|
|
|
|
/** Receiver scope which is used by [HorizontalSplitPane] and [VerticalSplitPane] */ |
|
|
|
/** Receiver scope which is used by [HorizontalSplitPane] and [VerticalSplitPane] */ |
|
|
|
|
|
|
|
@ExperimentalSplitPaneApi |
|
|
|
interface SplitPaneScope { |
|
|
|
interface SplitPaneScope { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -44,12 +45,14 @@ interface SplitPaneScope { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Receiver scope which is used by [SplitterScope] */ |
|
|
|
/** Receiver scope which is used by [SplitterScope] */ |
|
|
|
|
|
|
|
@ExperimentalSplitPaneApi |
|
|
|
interface HandleScope { |
|
|
|
interface HandleScope { |
|
|
|
/** allow mark composable as movable handle */ |
|
|
|
/** allow mark composable as movable handle */ |
|
|
|
fun Modifier.markAsHandle(): Modifier |
|
|
|
fun Modifier.markAsHandle(): Modifier |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Receiver scope which is used by [SplitPaneScope] */ |
|
|
|
/** Receiver scope which is used by [SplitPaneScope] */ |
|
|
|
|
|
|
|
@ExperimentalSplitPaneApi |
|
|
|
interface SplitterScope { |
|
|
|
interface SplitterScope { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set up visible part of splitter. This part will be measured and placed between split pane |
|
|
|
* Set up visible part of splitter. This part will be measured and placed between split pane |
|
|
@ -65,7 +68,7 @@ interface SplitterScope { |
|
|
|
* |
|
|
|
* |
|
|
|
* @param alignment alignment of handle according to [visiblePart] could be: |
|
|
|
* @param alignment alignment of handle according to [visiblePart] could be: |
|
|
|
* * [SplitterHandleAlign.BEFORE] if you place handle before [visiblePart], |
|
|
|
* * [SplitterHandleAlign.BEFORE] if you place handle before [visiblePart], |
|
|
|
* * [SplitterHandleAlign.ABOVE] if you place handle above [visiblePart] (will be centred) |
|
|
|
* * [SplitterHandleAlign.ABOVE] if you place handle above [visiblePart] (will be centered) |
|
|
|
* * and [SplitterHandleAlign.AFTER] if you place handle after [visiblePart]. |
|
|
|
* * and [SplitterHandleAlign.AFTER] if you place handle after [visiblePart]. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param content composable item content provider. Uses [HandleScope] to allow mark any provided composable part |
|
|
|
* @param content composable item content provider. Uses [HandleScope] to allow mark any provided composable part |
|
|
@ -74,10 +77,11 @@ interface SplitterScope { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun handle( |
|
|
|
fun handle( |
|
|
|
alignment: SplitterHandleAlign = SplitterHandleAlign.ABOVE, |
|
|
|
alignment: SplitterHandleAlign = SplitterHandleAlign.ABOVE, |
|
|
|
content: HandleScope.() -> @Composable () -> Unit |
|
|
|
content: @Composable HandleScope.() -> Unit |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalSplitPaneApi::class) |
|
|
|
internal class HandleScopeImpl( |
|
|
|
internal class HandleScopeImpl( |
|
|
|
private val containerScope: SplitPaneScopeImpl |
|
|
|
private val containerScope: SplitPaneScopeImpl |
|
|
|
) : HandleScope { |
|
|
|
) : HandleScope { |
|
|
@ -91,6 +95,7 @@ internal class HandleScopeImpl( |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalSplitPaneApi::class) |
|
|
|
internal class SplitterScopeImpl( |
|
|
|
internal class SplitterScopeImpl( |
|
|
|
private val containerScope: SplitPaneScopeImpl |
|
|
|
private val containerScope: SplitPaneScopeImpl |
|
|
|
) : SplitterScope { |
|
|
|
) : SplitterScope { |
|
|
@ -101,15 +106,16 @@ internal class SplitterScopeImpl( |
|
|
|
|
|
|
|
|
|
|
|
override fun handle( |
|
|
|
override fun handle( |
|
|
|
alignment: SplitterHandleAlign, |
|
|
|
alignment: SplitterHandleAlign, |
|
|
|
content: HandleScope.() -> @Composable () -> Unit |
|
|
|
content: @Composable HandleScope.() -> Unit |
|
|
|
) { |
|
|
|
) { |
|
|
|
containerScope.handle = HandleScopeImpl(containerScope).content() |
|
|
|
containerScope.handle = { HandleScopeImpl(containerScope).content() } |
|
|
|
containerScope.alignment = alignment |
|
|
|
containerScope.alignment = alignment |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private typealias ComposableSlot = @Composable () -> Unit |
|
|
|
private typealias ComposableSlot = @Composable () -> Unit |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@OptIn(ExperimentalSplitPaneApi::class) |
|
|
|
internal class SplitPaneScopeImpl( |
|
|
|
internal class SplitPaneScopeImpl( |
|
|
|
internal val isHorizontal: Boolean, |
|
|
|
internal val isHorizontal: Boolean, |
|
|
|
internal val splitPaneState: SplitPaneState |
|
|
|
internal val splitPaneState: SplitPaneState |
|
|
@ -168,6 +174,7 @@ internal class SplitPaneScopeImpl( |
|
|
|
* @param moveEnabled the initial value for [SplitPaneState.moveEnabled] |
|
|
|
* @param moveEnabled the initial value for [SplitPaneState.moveEnabled] |
|
|
|
* @param interactionState the initial value for [SplitPaneState.interactionState] |
|
|
|
* @param interactionState the initial value for [SplitPaneState.interactionState] |
|
|
|
* */ |
|
|
|
* */ |
|
|
|
|
|
|
|
@ExperimentalSplitPaneApi |
|
|
|
@Composable |
|
|
|
@Composable |
|
|
|
fun rememberSplitPaneState( |
|
|
|
fun rememberSplitPaneState( |
|
|
|
initialPositionPercentage: Float = 0f, |
|
|
|
initialPositionPercentage: Float = 0f, |
|
|
|