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

final float

The aspect ratio of the entity during resizing.

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

The current size of the entity, in meters.

Public methods

addResizeListener

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

getFixedAspectRatio

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

getMaximumSize

Added in 1.0.0-alpha01
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-alpha01
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-alpha01
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

Added in 1.0.0-alpha01
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

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

setFixedAspectRatio

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

setMaximumSize

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