0.13.1: new track-group lands above the active layer
addTrackGroup takes an optional anchorTrackId and inserts directly above it in trackOrder; anchors nested inside another group resolve to their parent's slot. The timeline's group-add button forwards selectedLayerId so the new group lands where the user is working instead of always jumping to the top. Covered by store + UI tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
86ec7aa835
commit
8aa91fc27b
5 files changed
+113
-5
No files matched your search
+27
-2
@@ -2660,14 +2660,39 @@ export const useSceneStore = defineStore('scene', {
|
||||
else inst.rotation = r
|
||||
}
|
||||
},
|
||||
addTrackGroup(name?: string): TrackGroup {
|
||||
/** Create an empty group. When `anchorTrackId` is given the group
|
||||
* lands directly above that track in trackOrder — resolving to
|
||||
* the parent group's position if the anchor sits inside one. Falls
|
||||
* back to the top of the stack when the anchor is missing or the
|
||||
* scene has no trackOrder yet. */
|
||||
addTrackGroup(name?: string, anchorTrackId?: string | null): TrackGroup {
|
||||
const group: TrackGroup = {
|
||||
id: uid(),
|
||||
name: name?.trim() || 'Group',
|
||||
childIds: [],
|
||||
}
|
||||
;(this.scene.groups ||= []).push(group)
|
||||
;(this.scene.trackOrder ||= []).unshift(group.id)
|
||||
const order = (this.scene.trackOrder ||= [])
|
||||
|
||||
let insertAt = 0
|
||||
if (anchorTrackId) {
|
||||
const direct = order.indexOf(anchorTrackId)
|
||||
if (direct >= 0) {
|
||||
insertAt = direct
|
||||
} else {
|
||||
// Anchor is inside a group — put the new group above the
|
||||
// group container instead of trying to wedge in between
|
||||
// group children (nested groups are not supported).
|
||||
const parent = this.scene.groups?.find((g) =>
|
||||
g.childIds.includes(anchorTrackId),
|
||||
)
|
||||
if (parent) {
|
||||
const pi = order.indexOf(parent.id)
|
||||
if (pi >= 0) insertAt = pi
|
||||
}
|
||||
}
|
||||
}
|
||||
order.splice(insertAt, 0, group.id)
|
||||
return group
|
||||
},
|
||||
/** Create a new group and move every currently-selected layer
|
||||
|
||||
Reference in new issue
Block a user