Commit 04234152 authored by pythongosssss's avatar pythongosssss
Browse files

Add support for multiselect

parent 26dc8e30
...@@ -28,7 +28,10 @@ app.registerExtension({ ...@@ -28,7 +28,10 @@ app.registerExtension({
const r = onNodeMoved?.apply(this, arguments); const r = onNodeMoved?.apply(this, arguments);
if (app.shiftDown) { if (app.shiftDown) {
node.alignToGrid(); // Ensure all selected nodes are realigned
for (const id in this.selected_nodes) {
this.selected_nodes[id].alignToGrid();
}
} }
return r; return r;
...@@ -39,7 +42,7 @@ app.registerExtension({ ...@@ -39,7 +42,7 @@ app.registerExtension({
app.graph.onNodeAdded = function (node) { app.graph.onNodeAdded = function (node) {
const onResize = node.onResize; const onResize = node.onResize;
node.onResize = function () { node.onResize = function () {
if(app.shiftDown) { if (app.shiftDown) {
const w = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.size[0] / LiteGraph.CANVAS_GRID_SIZE); const w = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.size[0] / LiteGraph.CANVAS_GRID_SIZE);
const h = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.size[1] / LiteGraph.CANVAS_GRID_SIZE); const h = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.size[1] / LiteGraph.CANVAS_GRID_SIZE);
node.size[0] = w; node.size[0] = w;
...@@ -50,10 +53,10 @@ app.registerExtension({ ...@@ -50,10 +53,10 @@ app.registerExtension({
return onNodeAdded?.apply(this, arguments); return onNodeAdded?.apply(this, arguments);
}; };
// Draw a preview of where the node will go if holding shift // Draw a preview of where the node will go if holding shift and the node is selected
const origDrawNode = LGraphCanvas.prototype.drawNode; const origDrawNode = LGraphCanvas.prototype.drawNode;
LGraphCanvas.prototype.drawNode = function (node, ctx) { LGraphCanvas.prototype.drawNode = function (node, ctx) {
if (app.shiftDown && node === this.node_dragged) { if (app.shiftDown && this.node_dragged && node.id in this.selected_nodes) {
const x = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[0] / LiteGraph.CANVAS_GRID_SIZE); const x = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[0] / LiteGraph.CANVAS_GRID_SIZE);
const y = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[1] / LiteGraph.CANVAS_GRID_SIZE); const y = LiteGraph.CANVAS_GRID_SIZE * Math.round(node.pos[1] / LiteGraph.CANVAS_GRID_SIZE);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment