CubePresenter

class CubePresenter<T>(orientation: Orientation = Horizontal, camera: (viewPort: Size) -> Camera = { Camera(Point(it.width / 2, it.height / 2), 1000.0) }, itemConstraints: ConstraintDslContext.(Bounds) -> Unit = fill) : ConstraintBasedPresenter<T> (source)

Shows contents of a Carousel as though they are the faces of a cubic shape that rotates as the frame changes.

Parameters

orientation

indicates which axis the cube rotates around

camera

determining how the cube's perspective should be rendered

itemConstraints

that determine the bounds of each item relative to the Carousel

Constructors

Link copied to clipboard
constructor(orientation: Orientation = Horizontal, camera: (viewPort: Size) -> Camera = { Camera(Point(it.width / 2, it.height / 2), 1000.0) }, itemConstraints: ConstraintDslContext.(Bounds) -> Unit = fill)

Functions

Link copied to clipboard

A Carousel will call this method when trying to do manual movement. This is a fundamentally different problem than it needs to solve when skipping through items (interpolate between indexes). This requires mapping pixel offsets to indexes. Only a Carousel's Presenter knows how items are laid out and can provide any information about "distance" between them. Hence, this API.

Link copied to clipboard

Called by Carousel to update the Presentation it should display.

Inherited functions

Link copied to clipboard
protected fun boundsFromConstraint(item: Carousel.PresentedItem, viewPort: Size, forceSetup: Boolean = false): Rectangle
Link copied to clipboard
protected fun setBounds(item: Carousel.PresentedItem, viewPort: Size, adjust: (Rectangle) -> Rectangle = { it })

Sets the bounds of item based on the result of using. This method tries to handle cases where the item being constrained adjusts its size after a bounds change. This would be the case for an item that maintains an aspect ratio for example. The calculation is run a second time in these cases to allow any constraint to adjust as needed.

Link copied to clipboard
fun Carousel<T, *>.update()

Indicate that the stage is outdated and suggest the Carousel invoke present.