Let a container sort its content with its parent (#243)
A container is not drawn, so it had no place in the draw order. The chain from its content to the parent of the container broke there, and a container under a character could not be drawn together with it. - A container gets the switch Sort with parent under Z. It defaults to off, also for new containers, so projects draw as they did. - With the switch on, the whole content is drawn in the slot of the container's parent. The content's own switch does not count there. - Containers in a row pass the content on as long as each has the switch on. On the top level or under a tilemap it has no effect. - drawSlots follows the new sortsWith field of a draw item. Scene view, game and picking all use drawSlots, so all three agree. Found on the way: a scene object hung directly under a container spells the container out, and its template content is dropped. That is the existing spelledOut rule, the tests now keep both cases apart. Tests: - ./check.sh: 178 files, 2573 tests, CHECK EXIT 0 - 7 new unit tests in sort-with-parent.test.ts: the switch, template content, override per container, a chain, top level and tilemap, game and picking - e2e 5b-iii: a real click on the switch in the inspector, with undo - 4 counter-probes over #242 and #243 bite (2 unit, 2 browser) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
074bda2247
commit
3abb6894a7
5 files changed
+188
-15
No files matched your search
@@ -274,13 +274,26 @@ export const SORT_PROPS: PropertySchema = [
|
||||
{ key: SORT_WITH_PARENT_KEY, label: 'Sort with parent', kind: 'boolean', default: false, initial: true },
|
||||
];
|
||||
|
||||
/**
|
||||
* A container is not drawn, but with the switch on it passes its content on to its own parent
|
||||
* (#243). It starts off, so content placed before draws as it did.
|
||||
*/
|
||||
const CONTAINER_SORT_PROPS: PropertySchema = [
|
||||
{ key: SORT_WITH_PARENT_KEY, label: 'Sort with parent', kind: 'boolean', default: false },
|
||||
];
|
||||
|
||||
/** A tilemap has no single place in the draw order, and the other types are not drawn at all. */
|
||||
const SORT_TYPES: ReadonlySet<AssetType> = new Set(['sprite', 'text', 'particles']);
|
||||
const SORT_TYPES: ReadonlySet<AssetType> = new Set(['sprite', 'text', 'particles', 'container']);
|
||||
|
||||
export function hasSortProps(type: AssetType): boolean {
|
||||
return SORT_TYPES.has(type);
|
||||
}
|
||||
|
||||
function sortPropsOf(type: AssetType): PropertySchema {
|
||||
if (!hasSortProps(type)) return [];
|
||||
return type === 'container' ? CONTAINER_SORT_PROPS : SORT_PROPS;
|
||||
}
|
||||
|
||||
export function isSortProp(key: string): boolean {
|
||||
return key === SORT_WITH_PARENT_KEY;
|
||||
}
|
||||
@@ -640,7 +653,7 @@ const FULL_SCHEMAS: Record<AssetType, PropertySchema> = Object.fromEntries(
|
||||
? [
|
||||
...COMMON_PROPS,
|
||||
...(hasTransformProps(type) ? TRANSFORM_PROPS : []),
|
||||
...(hasSortProps(type) ? SORT_PROPS : []),
|
||||
...sortPropsOf(type),
|
||||
...ASSET_SCHEMAS[type],
|
||||
]
|
||||
: ASSET_SCHEMAS[type],
|
||||
|
||||
Reference in new issue
Block a user