ResizableComponent


class ResizableComponent : Component


A Component which when attached to a PanelEntity provides a user-resize affordance.

Note: This Component is currently unsupported on GltfModelEntity.

Summary

Public companion functions

ResizableComponent
create(session: Session, minimumSize: Dimensions, maximumSize: Dimensions)

Public factory function for creating a ResizableComponent.

Public functions

Unit

Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end.

Unit
addResizeListener(executor: Executor, resizeListener: ResizeListener)

Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end.

open Boolean
onAttach(entity: Entity)

Attaches this component to the given entity.

open Unit
onDetach(entity: Entity)

Detaches this component from the entity it is attached to.

Unit

Removes a listener from the set listening to resize events.

Public properties

Boolean

Whether the content of the entity (and all child entities) should be automatically hidden while it is being resized.

Boolean

Whether the size of the ResizableComponent should be automatically updated to match during an ongoing resize (to match the proposed size as resize events are received).

Float

The aspect ratio of the entity during resizing.

Boolean

Whether the resize overlay should be shown even if the entity is not being resized.

Dimensions

An upper bound for the User's resize actions, in meters.

Dimensions

A lower bound for the User's resize actions, in meters.

Dimensions

The current size of the entity, in meters.

Public companion functions

create

Added in 1.0.0-alpha02
fun create(
    session: Session,
    minimumSize: Dimensions = ResizableComponent.kMinimumSize,
    maximumSize: Dimensions = ResizableComponent.kMaximumSize
): ResizableComponent

Public factory function for creating a ResizableComponent. This component can be attached to a single instance of any non-Anchor Entity.

When attached, this Component will enable the user to resize the Entity by dragging along the boundaries of the interaction highlight.

Parameters
session: Session

The Session to create the ResizableComponent in.

minimumSize: Dimensions = ResizableComponent.kMinimumSize

A lower bound for the User's resize actions, in meters. This value is used to set constraints on how small the user can resize the bounding box of the entity down to. The size of the content inside that bounding box is fully controlled by the application. The default value for this param is 0 meters.

maximumSize: Dimensions = ResizableComponent.kMaximumSize

An upper bound for the User's resize actions, in meters. This value is used to set constraints on how large the user can resize the bounding box of the entity up to. The size of the content inside that bounding box is fully controlled by the application. The default value for this param is 10 meters.

Public functions

addResizeListener

Added in 1.0.0-alpha02
fun addResizeListener(resizeListener: ResizeListener): Unit

Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end.

The listener is invoked on the main thread.

Parameters
resizeListener: ResizeListener

The listener to be invoked when a resize event occurs.

addResizeListener

Added in 1.0.0-alpha02
fun addResizeListener(executor: Executor, resizeListener: ResizeListener): Unit

Adds the listener to the set of listeners that are invoked through the resize operation, such as start, ongoing and end.

The listener is invoked on the provided executor. If the app intends to modify the UI elements/views during the callback, the app should provide the thread executor that is appropriate for the UI operations. For example, if the app is using the main thread to render the UI, the app should provide the main thread (Looper.getMainLooper()) executor. If the app is using a separate thread to render the UI, the app should provide the executor for that thread.

Parameters
executor: Executor

The executor to use for the listener callback.

resizeListener: ResizeListener

The listener to be invoked when a resize event occurs.

onAttach

open fun onAttach(entity: Entity): Boolean

Attaches this component to the given entity.

Parameters
entity: Entity

The entity to attach this component to.

Returns
Boolean

true if the component was successfully attached, false otherwise.

onDetach

open fun onDetach(entity: Entity): Unit

Detaches this component from the entity it is attached to.

Parameters
entity: Entity

The entity to detach this component from.

removeResizeListener

Added in 1.0.0-alpha02
fun removeResizeListener(resizeListener: ResizeListener): Unit

Removes a listener from the set listening to resize events.

Parameters
resizeListener: ResizeListener

The listener to be removed.

Public properties

autoHideContent

Added in 1.0.0-alpha02
var autoHideContentBoolean

Whether the content of the entity (and all child entities) should be automatically hidden while it is being resized.

autoUpdateSize

Added in 1.0.0-alpha02
var autoUpdateSizeBoolean

Whether the size of the ResizableComponent should be automatically updated to match during an ongoing resize (to match the proposed size as resize events are received).

fixedAspectRatio

Added in 1.0.0-alpha02
var fixedAspectRatioFloat

The aspect ratio of the entity during resizing. The aspect ratio is determined by taking the entity's width over its height. A value of 0.0f (or negative) means there are no preferences.

This method does not immediately resize the entity. The new aspect ratio will be applied the next time the user resizes the entity through the reform UI. During this resize operation, the entity's current area will be preserved.

If a different resizing behavior is desired, such as fixing the width and adjusting the height, the client can manually resize the entity to the preferred dimensions before calling this method. No automatic resizing will occur when using the reform UI then.

forceShowResizeOverlay

Added in 1.0.0-alpha02
var forceShowResizeOverlayBoolean

Whether the resize overlay should be shown even if the entity is not being resized.

This is useful for resizing multiple panels at once.

maximumSize

Added in 1.0.0-alpha02
var maximumSizeDimensions

An upper bound for the User's resize actions, in meters. This value constrains large the user can resize the bounding box of the entity. The size of the content inside that bounding box is fully controlled by the application.

minimumSize

Added in 1.0.0-alpha02
var minimumSizeDimensions

A lower bound for the User's resize actions, in meters. This value constrains how small the user can resize the bounding box of the entity. The size of the content inside that bounding box is fully controlled by the application.

size

Added in 1.0.0-alpha02
var sizeDimensions

The current size of the entity, in meters. This property is automatically updated after resize events to match the resize affordance to the newly suggested size of the content. The apps can still override it. The default value is set to 1 meter, updated to the size of the entity when attached.