This class manages the pane expansion state for pane scaffolds. By providing and modifying an instance of this class, you can specify the expanded panes' expansion width or proportion when pane scaffold is displaying a dual-pane layout.

This class also serves as the DraggableState of pane expansion handle. When a handle implementation is provided to the associated pane scaffold, the scaffold will use PaneExpansionState to store and manage dragging and anchoring of the handle, and thus the pane expansion state.

Summary

Constants

const Int

The constant value used to denote the pane expansion is not specified.

Cmn

Public functions

Unit

Clears any previously set firstPaneWidth or firstPaneProportion, as well as the user dragging result.

Cmn
open Unit

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

Cmn
open suspend Unit
drag(dragPriority: MutatePriority, block: suspend DragScope.() -> Unit)

Call this function to take control of drag logic.

Cmn
Boolean

Returns true if none of firstPaneWidth or firstPaneProportion has been set.

Cmn
Unit
setFirstPaneProportion(
    firstPaneProportion: @FloatRange(from = 0.0, to = 1.0) Float
)

Set the proportion of the first expanded pane in the layout.

Cmn
Unit
setFirstPaneWidth(firstPaneWidth: Int)

Set the width of the first expanded pane in the layout.

Cmn

Constants

Unspecified

const val UnspecifiedInt

The constant value used to denote the pane expansion is not specified.

Public functions

clear

fun clear(): Unit

Clears any previously set firstPaneWidth or firstPaneProportion, as well as the user dragging result.

dispatchRawDelta

open fun dispatchRawDelta(delta: Float): Unit

Dispatch drag delta in pixels avoiding all drag related priority mechanisms.

NOTE: unlike drag, dispatching any delta with this method will bypass scrolling of any priority. This method will also ignore reverseDirection and other parameters set in draggable.

This method is used internally for low level operations, allowing implementers of DraggableState influence the consumption as suits them, e.g. introduce nested scrolling. Manually dispatching delta via this method will likely result in a bad user experience, you must prefer drag method over this one.

Parameters
delta: Float

amount of scroll dispatched in the nested drag process

drag

open suspend fun drag(dragPriority: MutatePriority, block: suspend DragScope.() -> Unit): Unit

Call this function to take control of drag logic.

All actions that change the logical drag position must be performed within a drag block (even if they don't call any other methods on this object) in order to guarantee that mutual exclusion is enforced.

If drag is called from elsewhere with the dragPriority higher or equal to ongoing drag, ongoing drag will be canceled.

Parameters
dragPriority: MutatePriority

of the drag operation

block: suspend DragScope.() -> Unit

to perform drag in

isUnspecified

fun isUnspecified(): Boolean

Returns true if none of firstPaneWidth or firstPaneProportion has been set.

setFirstPaneProportion

fun setFirstPaneProportion(
    firstPaneProportion: @FloatRange(from = 0.0, to = 1.0) Float
): Unit

Set the proportion of the first expanded pane in the layout. The set value needs to be within the range of [0f, 1f], otherwise the setter throws.

Note that setting this value will reset the first pane width previously set via setFirstPaneWidth or the current dragging result if there's any. Also if user drags the pane after setting the first pane proportion, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.

setFirstPaneWidth

fun setFirstPaneWidth(firstPaneWidth: Int): Unit

Set the width of the first expanded pane in the layout. When the set value gets applied, it will be coerced within the range of [0, the full displayable width of the layout].

Note that setting this value will reset the first pane proportion previously set via setFirstPaneProportion or the current dragging result if there's any. Also if user drags the pane after setting the first pane width, the user dragging result will take the priority over this set value when rendering panes, but the set value will be saved.