mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
set node width dependent on gridsize
(up to 50 - then use half sizes or quarters etc)
This commit is contained in:
parent
3e0f080ea7
commit
260ac94dc7
@ -46,6 +46,7 @@ RED.view = (function() {
|
|||||||
var workspaceScrollPositions = {};
|
var workspaceScrollPositions = {};
|
||||||
|
|
||||||
var gridSize = 20;
|
var gridSize = 20;
|
||||||
|
var widthSize = 20;
|
||||||
var snapGrid = false;
|
var snapGrid = false;
|
||||||
|
|
||||||
var activeSpliceLink;
|
var activeSpliceLink;
|
||||||
@ -4025,7 +4026,7 @@ RED.view = (function() {
|
|||||||
if (hideLabel) {
|
if (hideLabel) {
|
||||||
d.w = node_height;
|
d.w = node_height;
|
||||||
} else {
|
} else {
|
||||||
d.w = Math.max(node_width,20*(Math.ceil((labelParts.width+50+(d._def.inputs>0?7:0))/20)) );
|
d.w = Math.max(node_width,widthSize*(Math.ceil((labelParts.width+50+(d._def.inputs>0?7:0))/widthSize)) );
|
||||||
}
|
}
|
||||||
if (ow !== undefined) {
|
if (ow !== undefined) {
|
||||||
d.x += (d.w-ow)/2;
|
d.x += (d.w-ow)/2;
|
||||||
@ -4572,9 +4573,9 @@ RED.view = (function() {
|
|||||||
d.nodes.forEach(function(n) {
|
d.nodes.forEach(function(n) {
|
||||||
groupOpCount++
|
groupOpCount++
|
||||||
if (n.type !== "group") {
|
if (n.type !== "group") {
|
||||||
minX = Math.min(minX,n.x-n.w/2-margin-((n._def.button && n._def.align!=="right")?20:0));
|
minX = Math.min(minX,n.x-n.w/2-margin-((n._def.button && n._def.align!=="right")?widthSize:0));
|
||||||
minY = Math.min(minY,n.y-n.h/2-margin);
|
minY = Math.min(minY,n.y-n.h/2-margin);
|
||||||
maxX = Math.max(maxX,n.x+n.w/2+margin+((n._def.button && n._def.align=="right")?20:0));
|
maxX = Math.max(maxX,n.x+n.w/2+margin+((n._def.button && n._def.align=="right")?widthSize:0));
|
||||||
maxY = Math.max(maxY,n.y+n.h/2+margin);
|
maxY = Math.max(maxY,n.y+n.h/2+margin);
|
||||||
} else {
|
} else {
|
||||||
minX = Math.min(minX,n.x-margin)
|
minX = Math.min(minX,n.x-margin)
|
||||||
@ -5096,7 +5097,7 @@ RED.view = (function() {
|
|||||||
if (hideLabel) {
|
if (hideLabel) {
|
||||||
result[0] = node_height;
|
result[0] = node_height;
|
||||||
} else {
|
} else {
|
||||||
result[0] = Math.max(node_width,20*(Math.ceil((labelParts.width+50+(node._def.inputs>0?7:0))/20)) );
|
result[0] = Math.max(node_width,widthSize*(Math.ceil((labelParts.width+50+(node._def.inputs>0?7:0))/widthSize)) );
|
||||||
}
|
}
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log("Error",node);
|
console.log("Error",node);
|
||||||
@ -5241,6 +5242,8 @@ RED.view = (function() {
|
|||||||
return gridSize;
|
return gridSize;
|
||||||
} else {
|
} else {
|
||||||
gridSize = Math.max(5,v);
|
gridSize = Math.max(5,v);
|
||||||
|
widthSize = gridSize;
|
||||||
|
while (widthSize > 50) { widthSize = Math.round(widthSize/2); }
|
||||||
updateGrid();
|
updateGrid();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user