ResizableComponent


public final class ResizableComponent implements Component


This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to resize the Entity by selecting and dragging along the boundaries of a user-resize affordance. While resizing an overlay will appear indicating the proposed updated size.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

Note: This Component is currently unsupported on GltfModelEntity.

Summary

Public methods

final void
addResizeEventListener(
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)

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

static final @NonNull ResizableComponent
create(
    @NonNull Session session,
    @NonNull FloatSize3d minimumSize,
    @NonNull FloatSize3d maximumSize,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)

Public factory function for creating a ResizableComponent.

final @NonNull FloatSize3d

The current size of the affordance for the Entity, in meters.

final float

The aspect ratio of the entity during resizing.

final @NonNull FloatSize3d

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

final @NonNull FloatSize3d

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

boolean

Called by an Entity when it attempts to add this Component to itself.

void

Called by an Entity when it attempts to detach this Component from itself.

final void

Removes a listener from the set listening to resize events.

final void

The current size of the affordance for the Entity, in meters.

final void
setFixedAspectRatio(float fixedAspectRatio)

The aspect ratio of the entity during resizing.

final void

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

final void

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

final void
setShouldAlwaysShowOverlay(boolean shouldAlwaysShowOverlay)

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

final void
setShouldAutoHideContent(boolean shouldAutoHideContent)

Whether the content of the Entity, and all child Entities, should be automatically hidden while it is being resized.

final void
setShouldAutoUpdateOverlay(boolean shouldAutoUpdateOverlay)

Whether the size of the resize overlay should be automatically updated to match the proposed size as resize events are received.

final boolean

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

final boolean

Whether the content of the Entity, and all child Entities, should be automatically hidden while it is being resized.

final boolean

Whether the size of the resize overlay should be automatically updated to match the proposed size as resize events are received.

Public methods

addResizeEventListener

Added in 1.0.0-alpha05
public final void addResizeEventListener(
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)

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 provided.

Parameters
@NonNull Executor executor

The Executor to run the listener on. By default listener is invoked on the main thread.

@NonNull Consumer<@NonNull ResizeEvent> resizeEventListener

The listener to be invoked when a resize event occurs.

create

Added in 1.0.0-alpha05
public static final @NonNull ResizableComponent create(
    @NonNull Session session,
    @NonNull FloatSize3d minimumSize,
    @NonNull FloatSize3d maximumSize,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)

Public factory function for creating a ResizableComponent.

This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to resize the Entity by dragging along the boundaries of a user-resize affordance.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

Parameters
@NonNull Session session

The Session to create the ResizableComponent in.

@NonNull FloatSize3d minimumSize

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 is 0 meters.

@NonNull FloatSize3d maximumSize

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 is 10 meters.

@NonNull Executor executor

The Executor to run the listener on. By default listener is invoked on the main thread.

@NonNull Consumer<@NonNull ResizeEvent> resizeEventListener

A resize event listener for the event. The application should set the size of a PanelEntity using PanelEntity.size.

getAffordanceSize

Added in 1.0.0-alpha05
public final @NonNull FloatSize3d getAffordanceSize()

The current size of the affordance for 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. If attached to a PanelEntity, this is updated to the size of the Entity when attached.

getFixedAspectRatio

Added in 1.0.0-alpha05
public final float getFixedAspectRatio()

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 provided in the Consumer the next time the user resizes the Entity through the reform UI.

getMaximumEntitySize

Added in 1.0.0-alpha05
public final @NonNull FloatSize3d getMaximumEntitySize()

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.

getMinimumEntitySize

Added in 1.0.0-alpha05
public final @NonNull FloatSize3d getMinimumEntitySize()

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.

onAttach

Added in 1.0.0-alpha05
public boolean onAttach(@NonNull Entity entity)

Called by an Entity when it attempts to add this Component to itself.

This method is restricted because it is only called from Entity.addComponent.

Parameters
@NonNull Entity entity

Entity to which this Component was attached.

Returns
boolean

True if the Component was attached to the given Entity. False if the Entity did not support having this Component attached.

onDetach

Added in 1.0.0-alpha05
public void onDetach(@NonNull Entity entity)

Called by an Entity when it attempts to detach this Component from itself.

This method is restricted because it is only called from Entity.removeComponent.

Parameters
@NonNull Entity entity

Entity from which this Component was detached.

removeResizeEventListener

Added in 1.0.0-alpha05
public final void removeResizeEventListener(
    @NonNull Consumer<@NonNull ResizeEvent> resizeEventListener
)

Removes a listener from the set listening to resize events.

Parameters
@NonNull Consumer<@NonNull ResizeEvent> resizeEventListener

The listener to be removed.

setAffordanceSize

Added in 1.0.0-alpha05
public final void setAffordanceSize(@NonNull FloatSize3d affordanceSize)

The current size of the affordance for 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. If attached to a PanelEntity, this is updated to the size of the Entity when attached.

setFixedAspectRatio

Added in 1.0.0-alpha05
public final void setFixedAspectRatio(float fixedAspectRatio)

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 provided in the Consumer the next time the user resizes the Entity through the reform UI.

setMaximumEntitySize

Added in 1.0.0-alpha05
public final void setMaximumEntitySize(@NonNull FloatSize3d maximumEntitySize)

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.

setMinimumEntitySize

Added in 1.0.0-alpha05
public final void setMinimumEntitySize(@NonNull FloatSize3d minimumEntitySize)

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.

setShouldAlwaysShowOverlay

Added in 1.0.0-alpha05
public final void setShouldAlwaysShowOverlay(boolean shouldAlwaysShowOverlay)

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

This is useful for resizing multiple panels at once.

setShouldAutoHideContent

Added in 1.0.0-alpha05
public final void setShouldAutoHideContent(boolean shouldAutoHideContent)

Whether the content of the Entity, and all child Entities, should be automatically hidden while it is being resized.

setShouldAutoUpdateOverlay

Added in 1.0.0-alpha05
public final void setShouldAutoUpdateOverlay(boolean shouldAutoUpdateOverlay)

Whether the size of the resize overlay should be automatically updated to match the proposed size as resize events are received.

shouldAlwaysShowOverlay

Added in 1.0.0-alpha05
public final boolean shouldAlwaysShowOverlay()

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

This is useful for resizing multiple panels at once.

shouldAutoHideContent

Added in 1.0.0-alpha05
public final boolean shouldAutoHideContent()

Whether the content of the Entity, and all child Entities, should be automatically hidden while it is being resized.

shouldAutoUpdateOverlay

Added in 1.0.0-alpha05
public final boolean shouldAutoUpdateOverlay()

Whether the size of the resize overlay should be automatically updated to match the proposed size as resize events are received.