ResizableComponent


public final class ResizableComponent implements Component


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

Note: This Component is currently unsupported on GltfModelEntity.

Summary

Public methods

final void

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

final void
addResizeListener(
    @NonNull Executor executor,
    @NonNull ResizeListener resizeListener
)

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 Dimensions minimumSize,
    @NonNull Dimensions maximumSize
)

Public factory function for creating a ResizableComponent.

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 ResizableComponent should be automatically updated to match during an ongoing resize (to match the proposed size as resize events are received).

final float

The aspect ratio of the entity during resizing.

final boolean

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

final @NonNull Dimensions

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

final @NonNull Dimensions

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

final @NonNull Dimensions

The current size of the entity, in meters.

boolean

Attaches this component to the given entity.

void

Detaches this component from the entity it is attached to.

final void

Removes a listener from the set listening to resize events.

final void
setAutoHideContent(boolean autoHideContent)

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

final void
setAutoUpdateSize(boolean autoUpdateSize)

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

final void
setFixedAspectRatio(float fixedAspectRatio)

The aspect ratio of the entity during resizing.

final void
setForceShowResizeOverlay(boolean forceShowResizeOverlay)

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

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

The current size of the entity, in meters.

Public methods

addResizeListener

Added in 1.0.0-alpha02
public final void addResizeListener(@NonNull ResizeListener resizeListener)

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
@NonNull ResizeListener resizeListener

The listener to be invoked when a resize event occurs.

addResizeListener

Added in 1.0.0-alpha02
public final void addResizeListener(
    @NonNull Executor executor,
    @NonNull ResizeListener resizeListener
)

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
@NonNull Executor executor

The executor to use for the listener callback.

@NonNull ResizeListener resizeListener

The listener to be invoked when a resize event occurs.

create

Added in 1.0.0-alpha02
public static final @NonNull ResizableComponent create(
    @NonNull Session session,
    @NonNull Dimensions minimumSize,
    @NonNull Dimensions maximumSize
)

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
@NonNull Session session

The Session to create the ResizableComponent in.

@NonNull Dimensions 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 for this param is 0 meters.

@NonNull Dimensions 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 for this param is 10 meters.

getAutoHideContent

Added in 1.0.0-alpha02
public final boolean getAutoHideContent()

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

getAutoUpdateSize

Added in 1.0.0-alpha02
public final boolean getAutoUpdateSize()

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

getFixedAspectRatio

Added in 1.0.0-alpha02
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 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.

getForceShowResizeOverlay

Added in 1.0.0-alpha02
public final boolean getForceShowResizeOverlay()

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

This is useful for resizing multiple panels at once.

getMaximumSize

Added in 1.0.0-alpha02
public final @NonNull Dimensions getMaximumSize()

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.

getMinimumSize

Added in 1.0.0-alpha02
public final @NonNull Dimensions getMinimumSize()

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.

getSize

Added in 1.0.0-alpha02
public final @NonNull Dimensions getSize()

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.

onAttach

public boolean onAttach(@NonNull Entity entity)

Attaches this component to the given entity.

Parameters
@NonNull Entity entity

The entity to attach this component to.

Returns
boolean

true if the component was successfully attached, false otherwise.

onDetach

public void onDetach(@NonNull Entity entity)

Detaches this component from the entity it is attached to.

Parameters
@NonNull Entity entity

The entity to detach this component from.

removeResizeListener

Added in 1.0.0-alpha02
public final void removeResizeListener(@NonNull ResizeListener resizeListener)

Removes a listener from the set listening to resize events.

Parameters
@NonNull ResizeListener resizeListener

The listener to be removed.

setAutoHideContent

Added in 1.0.0-alpha02
public final void setAutoHideContent(boolean autoHideContent)

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

setAutoUpdateSize

Added in 1.0.0-alpha02
public final void setAutoUpdateSize(boolean autoUpdateSize)

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

setFixedAspectRatio

Added in 1.0.0-alpha02
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 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.

setForceShowResizeOverlay

Added in 1.0.0-alpha02
public final void setForceShowResizeOverlay(boolean forceShowResizeOverlay)

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

This is useful for resizing multiple panels at once.

setMaximumSize

Added in 1.0.0-alpha02
public final void setMaximumSize(@NonNull Dimensions maximumSize)

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.

setMinimumSize

Added in 1.0.0-alpha02
public final void setMinimumSize(@NonNull Dimensions minimumSize)

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.

setSize

Added in 1.0.0-alpha02
public final void setSize(@NonNull Dimensions size)

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.