Class: BaseControls

PhotoEditorSDK.UI~DesktopUI~ BaseControls

Base class for all tool controls.

new BaseControls()

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 27

Members

canvasControlsComponentReact.Component

The canvas component for these controls

controlsComponentReact.Component

The controls component for these controls

defaultOptionsObject

The default options of these controls

identifierString

A unique identifier for these controls

requiredOperationsArray.<String>

The operations that are required for this control to function.

switchToDefaultControlsOnRemovalBoolean

If true, the editor will switch to the default controls when any of the updatableOperations is removed.

updatableOperationsArray.<String>

Operations which will trigger UI updates on this controls.

Methods

staticPhotoEditorSDK.UI.DesktopUI.BaseControls.clickAtPosition(clickPosition){Object}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 411

Checks if this control reacts to a click at the given (relative to canvas) position. If it does, it returns an object with a prepared shared state (e.g. selected sprite) that is passed to this control on creation

Name Type Description
clickPosition PhotoEditorSDK.Math.Vector2
Returns:
Type Description
Object

staticPhotoEditorSDK.UI.DesktopUI.BaseControls.getPreloadAssets(editor){Array.<String>}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 400

Returns the assets that should be preloaded for this control

Name Type Description
editor PhotoEditorSDK.UI.DesktopUI.Editor
Returns:
Type Description
Array.<String>

staticPhotoEditorSDK.UI.DesktopUI.BaseControls.isEnabled(){Boolean}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 419

Checks if this control is enabled

Returns:
Type Description
Boolean

staticPhotoEditorSDK.UI.DesktopUI.BaseControls.mapOperationsToSharedState(operations, initial){Object}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 164

Maps the operations state to a shared state object. Called whenever one of the updatableOperations is modified, created or removed.

Name Type Default Description
operations Object
initial Boolean false optional
Returns:
Type Description
Object
  • An object that will be passed to sharedState.set

_onOperationUpdated(operation)

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 138

Gets called whan any operation is updated

Name Type Description
operation PhotoEditorSDK.Operation

_t(key, interpolationOptions){String}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 101

Returns the translation for key

Name Type Description
key String
interpolationOptions Object optional
Returns:
Type Description
String

addGlobalHistorySnapshot(identifier, grouped)

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 358

Call this method before a change that should be added to the history is applied. The first argument identifies the history item. If grouped is set to true, we make sure to only create a history item if the previous item did not have the same identifier

Name Type Default Description
identifier String
grouped Boolean false

addLocalHistorySnapshot(identifier, grouped, operationIdentifier){HistoryItem}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 346

Call this method before a change that should be added to the history is applied. The first argument identifies the history item. If grouped is set to true, we make sure to only create a history item if the previous item did not have the same identifier

Name Type Default Description
identifier String
grouped Boolean false
operationIdentifier String
Returns:
Type Description
HistoryItem

getGlobalToolState(){Object}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 368

Returns the global editor state data for this tool.

Returns:
Type Description
Object

onBeforeLeave(){Promise.<Boolean>}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 325

Invoked before a control is left. Can control whether or not the control is left.

Returns:
Type Description
Promise.<Boolean>

onEnter()

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 180

Is called when a control is entered

onLeave(){Promise}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 272

Is called when a control is left

Returns:
Type Description
Promise

onOperationRemoved(operation)

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 131

Called when one of the updatableOperations is removed and if switchToDefaultControlsOnRemoval is false.

Name Type Description
operation PhotoEditorSDK.Operation

onOperationUpdated(operation)

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 171

Gets called when one of the operations in updatableOperations is updated

Name Type Description
operation PhotoEditorSDK.Operation

setGlobalToolState(){Object}

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 378

Sets the global editor state data for this tool.

Returns:
Type Description
Object

updateGlobalToolState(partialState)

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 388

Updates the global editor state data for this tool with the specified partial state changes

Name Type Description
partialState Object

updateSharedState()

ui/desktop-ui/core/components/screens/editor/controls/base-controls.js, line 149

Update the shared state for the current operation state.