Disallowed sequencing on non-numeric props

* This is temporary until we find a good UX for sequencing discrete values
This commit is contained in:
Aria Minaei 2021-09-06 11:42:09 +02:00
parent f6cf3711f4
commit b5e994f597
6 changed files with 143 additions and 113 deletions

View file

@ -15,7 +15,11 @@ const BooleanPropEditor: React.FC<{
pointerToProp: SheetObject['propsP']
obj: SheetObject
}> = ({propConfig, pointerToProp, obj}) => {
const stuff = useEditingToolsForPrimitiveProp<boolean>(pointerToProp, obj)
const stuff = useEditingToolsForPrimitiveProp<boolean>(
pointerToProp,
obj,
propConfig,
)
const onChange = useCallback(
(el: React.ChangeEvent<HTMLInputElement>) => {

View file

@ -10,7 +10,11 @@ const NumberPropEditor: React.FC<{
pointerToProp: SheetObject['propsP']
obj: SheetObject
}> = ({propConfig, pointerToProp, obj}) => {
const stuff = useEditingToolsForPrimitiveProp<number>(pointerToProp, obj)
const stuff = useEditingToolsForPrimitiveProp<number>(
pointerToProp,
obj,
propConfig,
)
const nudge = useCallback(
(params: {deltaX: number; deltaFraction: number; magnitude: number}) => {

View file

@ -12,7 +12,11 @@ const StringLiteralPropEditor: React.FC<{
pointerToProp: SheetObject['propsP']
obj: SheetObject
}> = ({propConfig, pointerToProp, obj}) => {
const stuff = useEditingToolsForPrimitiveProp<string>(pointerToProp, obj)
const stuff = useEditingToolsForPrimitiveProp<string>(
pointerToProp,
obj,
propConfig,
)
const onChange = useCallback(
(val: string) => {

View file

@ -12,6 +12,7 @@ import last from 'lodash-es/last'
import React from 'react'
import DefaultOrStaticValueIndicator from './DefaultValueIndicator'
import NextPrevKeyframeCursors from './NextPrevKeyframeCursors'
import type {PropTypeConfig} from '@theatre/core/propTypes'
interface CommonStuff<T> {
value: T
@ -44,7 +45,11 @@ type Stuff<T> = Default<T> | Static<T> | Sequenced<T>
export function useEditingToolsForPrimitiveProp<
T extends SerializablePrimitive,
>(pointerToProp: SheetObject['propsP'], obj: SheetObject): Stuff<T> {
>(
pointerToProp: SheetObject['propsP'],
obj: SheetObject,
propConfig: PropTypeConfig,
): Stuff<T> {
return usePrism(() => {
const pathToProp = getPointerParts(pointerToProp).path
@ -114,6 +119,9 @@ export function useEditingToolsForPrimitiveProp<
controlIndicators: <></>,
}
const isSequencable = isPropConfSequencable(propConfig)
if (isSequencable) {
const validSequencedTracks = val(
obj.template.getMapOfValidSequenceTracks_forStudio(),
)
@ -223,6 +231,7 @@ export function useEditingToolsForPrimitiveProp<
return ret
}
}
contextMenuItems.push({
label: 'Reset to default',
@ -233,6 +242,7 @@ export function useEditingToolsForPrimitiveProp<
},
})
if (isSequencable) {
contextMenuItems.push({
label: 'Sequence',
callback: () => {
@ -244,6 +254,7 @@ export function useEditingToolsForPrimitiveProp<
})
},
})
}
const statics = val(obj.template.getStaticValues())
@ -296,3 +307,7 @@ type Shade =
| 'Sequenced_OnKeyframe_BeingScrubbed'
| 'Sequenced_BeingInterpolated'
| 'Sequened_NotBeingInterpolated'
function isPropConfSequencable(conf: PropTypeConfig): boolean {
return conf.type === 'number'
}

View file

@ -90,6 +90,7 @@ const PrimitivePropRow: React.FC<{
const {controlIndicators} = useEditingToolsForPrimitiveProp(
pointerToProp,
obj,
leaf.propConf,
)
const possibleColor = usePrism(() => {

View file

@ -54,6 +54,7 @@ export type SequenceEditorTree_PrimitiveProp =
sheetObject: SheetObject
pathToProp: PathToProp
trackId: SequenceTrackId
propConf: PropTypeConfig_AllPrimitives
}
export type SequenceEditorTree_AllRowTypes =
@ -250,7 +251,7 @@ export const calculateSequenceEditorTree = (
sheetObject: SheetObject,
trackId: SequenceTrackId,
pathToProp: PathToProp,
conf: PropTypeConfig_AllPrimitives,
propConf: PropTypeConfig_AllPrimitives,
arrayOfChildren: Array<
SequenceEditorTree_PrimitiveProp | SequenceEditorTree_PropWithChildren
>,
@ -258,6 +259,7 @@ export const calculateSequenceEditorTree = (
) {
const row: SequenceEditorTree_PrimitiveProp = {
type: 'primitiveProp',
propConf: propConf,
depth: level,
sheetObject: sheetObject,
pathToProp,