InteractiveComponentDescriptor

We implement our editor by means of a relatively simple ComponentDescriptor subclass. This InteractiveComponentDescriptor allows us to open and close direct manipulation editing sessions and handles all the bookkeeping in the background.

Constructor

new InteractiveComponentDescriptor()

Methods

(async) edit() → {Promise.<Morph>}

Initiates a direct manipulation editing session of the component definition.

Returns:

The component morph.

Type: 
Promise.<Morph>

(async) ensureComponentDefBackup()

In order to reliably reset any unintended changes that happen due to direct manipulation this method allows to take a snapshot of the current component definition as code.

ensureComponentMorphUpToDate(copt)

Replace an existing component morph with a version that is ensured to by consistent with the policy wrapped by the descriptor.

Parameters:
NameTypeAttributesDescription
cMorph<optional>

The component morph.

ensureNoNameCollisionInDerived()

This method recursively checks if there are any name conflicts within the component scope or any of the scopes in any of the derived components. If there is a conflict, the default resolution is to adjust the addedMorph's name in such a way that it no longer causes a name collision. Note, that it does not matter wether or not the addedMorph is a entirely new morph or one that was reintroduced. At all times the renaming is applied to the addedMorph. This also means that derived adjustments will have to alter the name that they reference addedMorph by, if they are part of a reintroduction. This concerns cases in which we remove a morph 'bob' from a component, rename another morph in the component to 'bob' and then reintroduce the removed 'bob' once again.

getComponentMorph() → {Morph}

Returns (and initializes) a morph that represents the component definition and can be directly manipulated via Halo and other tools in order to adjust the component definition.

Returns:

The component morph.

Type: 
Morph

refreshDependants()

Traverses the world and manually applys each morph which is styled via a policy derived from this one.

(async) reset()

Revert the component definition back to when we started the edit session.

subscribeToParent()

Subscribe to any changes that happen to the parent policy if present.