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;
`
const DefaultOrStaticValueIndicator: React.FC<{hasStaticOverride: boolean}> = (
props,
) => {
const DefaultOrStaticValueIndicator: React.FC<{
hasStaticOverride: boolean
callbackPlease: () => void
}> = (props) => {
const whoopsy = (lol: any) => {
props.callbackPlease()
}
return (
<Container hasStaticOverride={props.hasStaticOverride}>
<Container hasStaticOverride={props.hasStaticOverride} onClick={whoopsy}>
{props.hasStaticOverride ? (
<FilledIcon title="The default value is overridden" />
) : (

View file

@ -65,7 +65,12 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
beingScrubbed: false,
contextMenuItems: [],
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 (
!hasOneOrMoreSequencedTracks ||
(hasOneOrMoreSequencedTracks && hasStatics)
) {
contextMenuItems.push({
label: 'Sequence all',
callback: () => {
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,
)
}
})
},
callback: makeThisPropSequencedPlease,
})
}
@ -224,7 +227,10 @@ export function useEditingToolsForCompoundProp<T extends SerializablePrimitive>(
...common,
type: 'AllStatic',
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 makeThisPropStaticPlease = () => {
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic(
{
...propAddress,
value: obj.getValueByPointer(pointerToProp) as T,
},
)
})
}
if (isSequenced) {
contextMenuItems.push({
label: 'Make static',
callback: () => {
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsStatic(
{
...propAddress,
value: obj.getValueByPointer(pointerToProp) as T,
},
)
})
},
callback: makeThisPropStaticPlease,
})
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) {
contextMenuItems.push({
label: 'Sequence',
callback: () => {
getStudio()!.transaction(({stateEditors}) => {
const propAddress = {...obj.address, pathToProp}
stateEditors.coreByProject.historic.sheetsById.sequence.setPrimitivePropAsSequenced(
propAddress,
propConfig,
)
})
},
callback: makeThisPropSequencedPlease,
})
}
@ -309,7 +313,10 @@ function createPrism<T extends SerializablePrimitive>(
type: 'Static',
shade: common.beingScrubbed ? 'Static_BeingScrubbed' : 'Static',
controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={true} />
<DefaultOrStaticValueIndicator
hasStaticOverride={true}
callbackPlease={makeThisPropSequencedPlease}
/>
),
}
return ret
@ -320,7 +327,10 @@ function createPrism<T extends SerializablePrimitive>(
type: 'Default',
shade: 'Default',
controlIndicators: (
<DefaultOrStaticValueIndicator hasStaticOverride={false} />
<DefaultOrStaticValueIndicator
hasStaticOverride={false}
callbackPlease={makeThisPropSequencedPlease}
/>
),
}