please, click on diamond to enable sequenced

This commit is contained in:
jrkb 2023-06-09 16:53:26 +02:00
parent 8d7a3007e2
commit 938568037a
3 changed files with 65 additions and 45 deletions

View file

@ -46,11 +46,15 @@ const FilledIcon = styled.div`
border: 1px solid grey; border: 1px solid grey;
` `
const DefaultOrStaticValueIndicator: React.FC<{hasStaticOverride: boolean}> = ( const DefaultOrStaticValueIndicator: React.FC<{
props, hasStaticOverride: boolean
) => { callbackPlease: () => void
}> = (props) => {
const whoopsy = (lol: any) => {
props.callbackPlease()
}
return ( return (
<Container hasStaticOverride={props.hasStaticOverride}> <Container hasStaticOverride={props.hasStaticOverride} onClick={whoopsy}>
{props.hasStaticOverride ? ( {props.hasStaticOverride ? (
<FilledIcon title="The default value is overridden" /> <FilledIcon title="The default value is overridden" />
) : ( ) : (

View file

@ -65,7 +65,12 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
beingScrubbed: false, beingScrubbed: false,
contextMenuItems: [], contextMenuItems: [],
controlIndicators: ( controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={false} /> <DefaultOrStaticValueIndicator
hasStaticOverride={false}
callbackPlease={() => {
console.log('nothing to do')
}}
/>
), ),
} }
} }
@ -171,28 +176,26 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
}) })
} }
const makeThisPropSequencedPlease = () => {
getStudio()!.transaction(({stateEditors}) => {
for (const {path, conf} of iteratePropType(propConfig, pathToProp)) {
if (isPropConfigComposite(conf)) continue
const propAddress = {...obj.address, pathToProp: path}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
}
})
}
if ( if (
!hasOneOrMoreSequencedTracks || !hasOneOrMoreSequencedTracks ||
(hasOneOrMoreSequencedTracks && hasStatics) (hasOneOrMoreSequencedTracks && hasStatics)
) { ) {
contextMenuItems.push({ contextMenuItems.push({
label: 'Sequence all', label: 'Sequence all',
callback: () => { callback: makeThisPropSequencedPlease,
getStudio()!.transaction(({stateEditors}) => {
for (const {path, conf} of iteratePropType(
propConfig,
pathToProp,
)) {
if (isPropConfigComposite(conf)) continue
const propAddress = {...obj.address, pathToProp: path}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
}
})
},
}) })
} }
@ -224,7 +227,10 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
...common, ...common,
type: 'AllStatic', type: 'AllStatic',
controlIndicators: ( controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={hasStatics} /> <DefaultOrStaticValueIndicator
hasStaticOverride={hasStatics}
callbackPlease={makeThisPropSequencedPlease}
/>
), ),
} }
} }

View file

@ -155,20 +155,22 @@ function createPrism<T extends SerializablePrimitive>(
const isSequenced = typeof possibleSequenceTrackId === 'string' const isSequenced = typeof possibleSequenceTrackId === 'string'
const makeThisPropStaticPlease = () => {
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic(
{
...propAddress,
value: obj.getValueByPointer(pointerToProp) as T,
},
)
})
}
if (isSequenced) { if (isSequenced) {
contextMenuItems.push({ contextMenuItems.push({
label: 'Make static', label: 'Make static',
callback: () => { callback: makeThisPropStaticPlease,
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic(
{
...propAddress,
value: obj.getValueByPointer(pointerToProp) as T,
},
)
})
},
}) })
const sequenceTrackId = possibleSequenceTrackId as SequenceTrackId const sequenceTrackId = possibleSequenceTrackId as SequenceTrackId
@ -287,19 +289,21 @@ function createPrism<T extends SerializablePrimitive>(
}) })
} }
const makeThisPropSequencedPlease = () => {
getStudio()!.transaction(({stateEditors, set}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
})
}
if (isSequencable) { if (isSequencable) {
contextMenuItems.push({ contextMenuItems.push({
label: 'Sequence', label: 'Sequence',
callback: () => { callback: makeThisPropSequencedPlease,
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
})
},
}) })
} }
@ -309,7 +313,10 @@ function createPrism<T extends SerializablePrimitive>(
type: 'Static', type: 'Static',
shade: common.beingScrubbed ? 'Static_BeingScrubbed' : 'Static', shade: common.beingScrubbed ? 'Static_BeingScrubbed' : 'Static',
controlIndicators: ( controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={true} /> <DefaultOrStaticValueIndicator
hasStaticOverride={true}
callbackPlease={makeThisPropSequencedPlease}
/>
), ),
} }
return ret return ret
@ -320,7 +327,10 @@ function createPrism<T extends SerializablePrimitive>(
type: 'Default', type: 'Default',
shade: 'Default', shade: 'Default',
controlIndicators: ( controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={false} /> <DefaultOrStaticValueIndicator
hasStaticOverride={false}
callbackPlease={makeThisPropSequencedPlease}
/>
), ),
} }