checkpoint widget group/ungroup

This commit is contained in:
Stewart Allen 2021-03-01 00:22:07 -05:00
commit 3f5ccf5158
4 changed files with 72 additions and 13 deletions

View file

@ -80,7 +80,10 @@
scale: scaleSelection,
rotate: rotateSelection,
meshes: function() { return selectedMeshes.slice() },
widgets: function() { return selectedMeshes.slice().map(m => m.widget) },
widgets: function(orall) {
let sel = selectedMeshes.slice().map(m => m.widget);
return sel.length ? sel : orall ? WIDGETS.slice() : []
},
for_groups: forSelectedGroups,
for_meshes: forSelectedMeshes,
for_widgets: forSelectedWidgets,
@ -290,6 +293,10 @@
clear: KIRI.client.clear,
parse: loadCode
},
group: {
merge: groupMerge,
split: groupSplit,
},
hide: {
alert: function(rec) { alert2cancel(rec) },
import: function() { },
@ -831,13 +838,10 @@
}
function forSelectedGroups(f) {
let m = selectedMeshes;
if (m.length === 0 && WIDGETS.length === 1) m = [ WIDGETS[0].mesh ];
let v = [];
m.slice().forEach(function (mesh) {
if (v.indexOf(mesh.widget.group) < 0) f(mesh.widget);
v.push(mesh.widget.group);
});
let groups = API.selection.widgets(true).map(w => w.group).uniq();
for (let group of groups) {
f(group[0]);
}
}
function forSelectedWidgets(f,noauto) {
@ -1334,6 +1338,14 @@
* Selection Functions
******************************************************************* */
function groupMerge() {
Widget.Groups.merge(API.selection.widgets(true));
}
function groupSplit() {
Widget.Groups.split(API.selection.widgets(false));
}
function updateSelectedInfo() {
let bounds = new THREE.Box3(), track;
forSelectedMeshes(mesh => {
@ -1657,10 +1669,17 @@
return settings.bounds = bounds;
}
function platformSelect(widget, shift) {
function platformSelect(widget, shift, recurse = true) {
if (viewMode !== VIEWS.ARRANGE) {
return;
}
// apply deselect to entire group
if (recurse && widget && widget.group.length > 1) {
for (let w of widget.group) {
platformSelect(w, true, false);
}
return;
}
let mesh = widget.mesh,
sel = (selectedMeshes.indexOf(mesh) >= 0);
if (sel) {
@ -1735,12 +1754,19 @@
}
}
function platformDeselect(widget) {
function platformDeselect(widget, recurse = true) {
if (viewMode !== VIEWS.ARRANGE) {
// don't de-select and re-color widgets in,
// for example, sliced or preview modes
return;
}
// apply deselect to entire group
if (recurse && widget && widget.group.length > 1) {
for (let w of widget.group) {
platformDeselect(w, false);
}
return;
}
if (!widget) {
forAllWidgets(function(widget) {
platform.deselect(widget);