When setting group to Stack layout allow for unspecified spacings

Allow changing group to Stack layout except remove spacings requirement.

Current code to change to Stack:

let selectedGroup = selection.items[0];
let layoutStack = { type: SceneNode.LAYOUT_STACK, stack: { orientation: SceneNode.STACK_HORIZONTAL, spacings: 20 } };
selectedGroup.layout = layoutStack;

Requested:

let selectedGroup = selection.items[0];
let layoutStack = { type: SceneNode.LAYOUT_STACK}
layoutStack.stack = { orientation: SceneNode.STACK_HORIZONTAL } ; // no spacings
selectedGroup.layout = layoutStack;

I spoke with the developer, and it turns out that this is already supported because the layout.stack property is optional. So to set the group’s layout to a horizontal stack without specifying spacings:

let layoutStack = { type: SceneNode.LAYOUT_STACK };  // Defaults to horizontal
selectedGroup.layout = layoutStack;

To set the group’s layout to a vertical stack without specifying spacings, modify the existing layout property twice:

let layoutProperties = selectedGroup.layout;
layoutProperties.type = SceneNode.LAYOUT_STACK;
selectedGroup.layout = layoutProperties;
layoutProperties = selectedGroup.layout;
layoutProperties.stack.orientation = SceneNode.STACK_VERTICAL;
selectedGroup.layout = layoutProperties;

I hope this resolves your issue.

1 Like