Unify Derivation and Prism 12/n
This commit is contained in:
parent
b2116e9a5d
commit
d9644f2370
8 changed files with 18 additions and 20 deletions
|
@ -118,7 +118,7 @@ export default class Sequence {
|
||||||
return this._lengthD.getValue()
|
return this._lengthD.getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
get positionDerivation() {
|
get positionPrism() {
|
||||||
return this._positionD
|
return this._positionD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ export default class SheetObject implements IdentityPrismProvider {
|
||||||
const interpolate =
|
const interpolate =
|
||||||
propConfig.interpolate! as Interpolator<$IntentionalAny>
|
propConfig.interpolate! as Interpolator<$IntentionalAny>
|
||||||
|
|
||||||
const updateSequenceValueFromItsDerivation = () => {
|
const updateSequenceValueFromItsPrism = () => {
|
||||||
const triple = pr.getValue()
|
const triple = pr.getValue()
|
||||||
|
|
||||||
if (!triple) return valsAtom.setIn(pathToProp, undefined)
|
if (!triple) return valsAtom.setIn(pathToProp, undefined)
|
||||||
|
@ -279,9 +279,9 @@ export default class SheetObject implements IdentityPrismProvider {
|
||||||
interpolate(left, right, triple.progression),
|
interpolate(left, right, triple.progression),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const untap = pr.onStale(updateSequenceValueFromItsDerivation)
|
const untap = pr.onStale(updateSequenceValueFromItsPrism)
|
||||||
|
|
||||||
updateSequenceValueFromItsDerivation()
|
updateSequenceValueFromItsPrism()
|
||||||
untaps.push(untap)
|
untaps.push(untap)
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -304,7 +304,7 @@ export default class SheetObject implements IdentityPrismProvider {
|
||||||
this.template.project.pointers.historic.sheetsById[this.address.sheetId]
|
this.template.project.pointers.historic.sheetsById[this.address.sheetId]
|
||||||
.sequence.tracksByObject[this.address.objectKey].trackData[trackId]
|
.sequence.tracksByObject[this.address.objectKey].trackData[trackId]
|
||||||
|
|
||||||
const timeD = this.sheet.getSequence().positionDerivation
|
const timeD = this.sheet.getSequence().positionPrism
|
||||||
|
|
||||||
return interpolationTripleAtPosition(this._internalUtilCtx, trackP, timeD)
|
return interpolationTripleAtPosition(this._internalUtilCtx, trackP, timeD)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ export default class SheetObjectTemplate {
|
||||||
* Returns values that are set statically (ie, not sequenced, and not defaults)
|
* Returns values that are set statically (ie, not sequenced, and not defaults)
|
||||||
*/
|
*/
|
||||||
getStaticValues(): Prism<SerializableMap> {
|
getStaticValues(): Prism<SerializableMap> {
|
||||||
return this._cache.get('getDerivationOfStatics', () =>
|
return this._cache.get('getStaticValues', () =>
|
||||||
prism(() => {
|
prism(() => {
|
||||||
const pointerToSheetState =
|
const pointerToSheetState =
|
||||||
this.sheetTemplate.project.pointers.historic.sheetsById[
|
this.sheetTemplate.project.pointers.historic.sheetsById[
|
||||||
|
|
|
@ -148,7 +148,7 @@ export default class TheatreSheetObject<
|
||||||
}
|
}
|
||||||
|
|
||||||
private _valuesPrism(): Prism<this['value']> {
|
private _valuesPrism(): Prism<this['value']> {
|
||||||
return this._cache.get('onValuesChangeDerivation', () => {
|
return this._cache.get('_valuesPrism', () => {
|
||||||
const sheetObject = privateAPI(this)
|
const sheetObject = privateAPI(this)
|
||||||
const d: Prism<PropsValue<Props>> = prism(() => {
|
const d: Prism<PropsValue<Props>> = prism(() => {
|
||||||
return val(sheetObject.getValues().getValue()) as $FixMe
|
return val(sheetObject.getValues().getValue()) as $FixMe
|
||||||
|
|
|
@ -410,8 +410,8 @@ export default class TheatreStudio implements IStudio {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getSelectionDerivation(): Prism<(ISheetObject | ISheet)[]> {
|
private _getSelectionPrism(): Prism<(ISheetObject | ISheet)[]> {
|
||||||
return this._cache.get('_getStateDerivation()', () =>
|
return this._cache.get('_getSelectionPrism()', () =>
|
||||||
prism((): (ISheetObject | ISheet)[] => {
|
prism((): (ISheetObject | ISheet)[] => {
|
||||||
return getOutlineSelection()
|
return getOutlineSelection()
|
||||||
.filter(
|
.filter(
|
||||||
|
@ -424,7 +424,7 @@ export default class TheatreStudio implements IStudio {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _getSelection(): (ISheetObject | ISheet)[] {
|
private _getSelection(): (ISheetObject | ISheet)[] {
|
||||||
return this._getSelectionDerivation().getValue()
|
return this._getSelectionPrism().getValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
setSelection(selection: Array<ISheetObject | ISheet>): void {
|
setSelection(selection: Array<ISheetObject | ISheet>): void {
|
||||||
|
@ -440,7 +440,7 @@ export default class TheatreStudio implements IStudio {
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectionChange(fn: (s: (ISheetObject | ISheet)[]) => void): VoidFn {
|
onSelectionChange(fn: (s: (ISheetObject | ISheet)[]) => void): VoidFn {
|
||||||
return this._getSelectionDerivation().onChange(studioTicker, fn, true)
|
return this._getSelectionPrism().onChange(studioTicker, fn, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
get selection(): Array<ISheetObject | ISheet> {
|
get selection(): Array<ISheetObject | ISheet> {
|
||||||
|
|
|
@ -265,7 +265,7 @@ const Playhead: React.FC<{layoutP: Pointer<SequenceEditorPanelLayout>}> = ({
|
||||||
getIsPlayheadAttachedToFocusRange(sequence),
|
getIsPlayheadAttachedToFocusRange(sequence),
|
||||||
)
|
)
|
||||||
|
|
||||||
const posInUnitSpace = sequence.positionDerivation.getValue()
|
const posInUnitSpace = sequence.positionPrism.getValue()
|
||||||
|
|
||||||
const posInClippedSpace = val(layoutP.clippedSpace.fromUnitSpace)(
|
const posInClippedSpace = val(layoutP.clippedSpace.fromUnitSpace)(
|
||||||
posInUnitSpace,
|
posInUnitSpace,
|
||||||
|
|
|
@ -235,7 +235,7 @@ function ControlIndicators({
|
||||||
return usePrism(() => {
|
return usePrism(() => {
|
||||||
const pathToProp = getPointerParts(pointerToProp).path
|
const pathToProp = getPointerParts(pointerToProp).path
|
||||||
|
|
||||||
const sequencePosition = val(obj.sheet.getSequence().positionDerivation)
|
const sequencePosition = val(obj.sheet.getSequence().positionPrism)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
2/10 perf concern:
|
2/10 perf concern:
|
||||||
|
|
|
@ -65,7 +65,7 @@ const cache = new WeakMap<{}, Prism<EditingTools<$IntentionalAny>>>()
|
||||||
* Note: we're able to get `obj` and `propConfig` from `pointerToProp`,
|
* Note: we're able to get `obj` and `propConfig` from `pointerToProp`,
|
||||||
* so the only reason they're still in the arguments list is that
|
* so the only reason they're still in the arguments list is that
|
||||||
*/
|
*/
|
||||||
function createDerivation<T extends SerializablePrimitive>(
|
function createPrism<T extends SerializablePrimitive>(
|
||||||
pointerToProp: Pointer<T>,
|
pointerToProp: Pointer<T>,
|
||||||
obj: SheetObject,
|
obj: SheetObject,
|
||||||
propConfig: PropTypeConfig_AllSimples,
|
propConfig: PropTypeConfig_AllSimples,
|
||||||
|
@ -181,9 +181,7 @@ function createDerivation<T extends SerializablePrimitive>(
|
||||||
sequenceTrackId
|
sequenceTrackId
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
const sequencePosition = val(
|
const sequencePosition = val(obj.sheet.getSequence().positionPrism)
|
||||||
obj.sheet.getSequence().positionDerivation,
|
|
||||||
)
|
|
||||||
return getNearbyKeyframesOfTrack(
|
return getNearbyKeyframesOfTrack(
|
||||||
obj,
|
obj,
|
||||||
track && {
|
track && {
|
||||||
|
@ -325,7 +323,7 @@ function createDerivation<T extends SerializablePrimitive>(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDerivation<T extends SerializablePrimitive>(
|
function getPrism<T extends SerializablePrimitive>(
|
||||||
pointerToProp: Pointer<T>,
|
pointerToProp: Pointer<T>,
|
||||||
obj: SheetObject,
|
obj: SheetObject,
|
||||||
propConfig: PropTypeConfig_AllSimples,
|
propConfig: PropTypeConfig_AllSimples,
|
||||||
|
@ -333,7 +331,7 @@ function getDerivation<T extends SerializablePrimitive>(
|
||||||
if (cache.has(pointerToProp)) {
|
if (cache.has(pointerToProp)) {
|
||||||
return cache.get(pointerToProp)!
|
return cache.get(pointerToProp)!
|
||||||
} else {
|
} else {
|
||||||
const d = createDerivation(pointerToProp, obj, propConfig)
|
const d = createPrism(pointerToProp, obj, propConfig)
|
||||||
cache.set(pointerToProp, d)
|
cache.set(pointerToProp, d)
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
@ -354,7 +352,7 @@ export function useEditingToolsForSimplePropInDetailsPanel<
|
||||||
obj: SheetObject,
|
obj: SheetObject,
|
||||||
propConfig: PropTypeConfig_AllSimples,
|
propConfig: PropTypeConfig_AllSimples,
|
||||||
): EditingTools<T> {
|
): EditingTools<T> {
|
||||||
const der = getDerivation(pointerToProp, obj, propConfig)
|
const der = getPrism(pointerToProp, obj, propConfig)
|
||||||
return usePrismInstance(der)
|
return usePrismInstance(der)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue