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,18 +176,9 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
}) })
} }
if ( const makeThisPropSequencedPlease = () => {
!hasOneOrMoreSequencedTracks ||
(hasOneOrMoreSequencedTracks && hasStatics)
) {
contextMenuItems.push({
label: 'Sequence all',
callback: () => {
getStudio()!.transaction(({stateEditors}) => { getStudio()!.transaction(({stateEditors}) => {
for (const {path, conf} of iteratePropType( for (const {path, conf} of iteratePropType(propConfig, pathToProp)) {
propConfig,
pathToProp,
)) {
if (isPropConfigComposite(conf)) continue if (isPropConfigComposite(conf)) continue
const propAddress = {...obj.address, pathToProp: path} const propAddress = {...obj.address, pathToProp: path}
@ -192,7 +188,14 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
) )
} }
}) })
}, }
if (
!hasOneOrMoreSequencedTracks ||
(hasOneOrMoreSequencedTracks && hasStatics)
) {
contextMenuItems.push({
label: 'Sequence all',
callback: makeThisPropSequencedPlease,
}) })
} }
@ -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,10 +155,7 @@ function createPrism<T extends SerializablePrimitive>(
const isSequenced = typeof possibleSequenceTrackId === 'string' const isSequenced = typeof possibleSequenceTrackId === 'string'
if (isSequenced) { const makeThisPropStaticPlease = () => {
contextMenuItems.push({
label: 'Make static',
callback: () => {
getStudio()!.transaction(({stateEditors}) => { getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp} const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic( stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic(
@ -168,7 +165,12 @@ function createPrism<T extends SerializablePrimitive>(
}, },
) )
}) })
}, }
if (isSequenced) {
contextMenuItems.push({
label: 'Make static',
callback: makeThisPropStaticPlease,
}) })
const sequenceTrackId = possibleSequenceTrackId as SequenceTrackId const sequenceTrackId = possibleSequenceTrackId as SequenceTrackId
@ -287,11 +289,8 @@ function createPrism<T extends SerializablePrimitive>(
}) })
} }
if (isSequencable) { const makeThisPropSequencedPlease = () => {
contextMenuItems.push({ getStudio()!.transaction(({stateEditors, set}) => {
label: 'Sequence',
callback: () => {
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp} const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced( stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
@ -299,7 +298,12 @@ function createPrism<T extends SerializablePrimitive>(
propConfig, propConfig,
) )
}) })
}, }
if (isSequencable) {
contextMenuItems.push({
label: 'Sequence',
callback: makeThisPropSequencedPlease,
}) })
} }
@ -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}
/>
), ),
} }