mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-15 16:02:32 +08:00
resize any corner
This commit is contained in:
parent
5d6dfce548
commit
fb6aea2c9e
@ -3663,13 +3663,31 @@
|
|||||||
LGraphNode.prototype.inResizeCorner = function(canvasX, canvasY) {
|
LGraphNode.prototype.inResizeCorner = function(canvasX, canvasY) {
|
||||||
var rows = this.outputs ? this.outputs.length : 1;
|
var rows = this.outputs ? this.outputs.length : 1;
|
||||||
var outputs_offset = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
var outputs_offset = (this.constructor.slot_start_y || 0) + rows * LiteGraph.NODE_SLOT_HEIGHT;
|
||||||
return isInsideRectangle(canvasX,
|
|
||||||
canvasY,
|
var inrc = false;
|
||||||
this.pos[0] + this.size[0] - 15,
|
var c = 0;
|
||||||
this.pos[1] + Math.max(this.size[1] - 15, outputs_offset),
|
var m = [
|
||||||
20,
|
// bottom right
|
||||||
20
|
[this.pos[0] + this.size[0] - 15, this.pos[1] + Math.max(this.size[1] - 15, outputs_offset)],
|
||||||
);
|
// bottom left
|
||||||
|
[this.pos[0] - 5, this.pos[1] + Math.max(this.size[1] - 15, outputs_offset)],
|
||||||
|
// top left
|
||||||
|
[this.pos[0] - 5, this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT - 5],
|
||||||
|
// top right
|
||||||
|
[this.pos[0] + this.size[0] - 15, this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT - 5]
|
||||||
|
];
|
||||||
|
|
||||||
|
while (c < m.length && true != inrc) {
|
||||||
|
inrc = inrc || isInsideRectangle(canvasX, canvasY, m[c][0], m[c][1], 20, 20);
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return inrc;
|
||||||
|
}
|
||||||
|
|
||||||
|
LGraphNode.prototype.setResizeHandle = function(canvasX, canvasY) {
|
||||||
|
this.resize_handle_x = (this.size[0] / 2.0 > canvasX - this.pos[0]) ? 'left' : 'right';
|
||||||
|
this.resize_handle_y = (this.size[1] / 2.0 > canvasY - this.pos[1]) ? 'top' : 'bottom';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5933,6 +5951,7 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
) {
|
) {
|
||||||
this.graph.beforeChange();
|
this.graph.beforeChange();
|
||||||
this.resizing_node = node;
|
this.resizing_node = node;
|
||||||
|
this.resizing_node.setResizeHandle(e.canvasX, e.canvasY);
|
||||||
this.canvas.style.cursor = "se-resize";
|
this.canvas.style.cursor = "se-resize";
|
||||||
skip_action = true;
|
skip_action = true;
|
||||||
} else {
|
} else {
|
||||||
@ -6538,10 +6557,35 @@ LGraphNode.prototype.executeAction = function(action)
|
|||||||
|
|
||||||
if (this.resizing_node && !this.live_mode) {
|
if (this.resizing_node && !this.live_mode) {
|
||||||
//convert mouse to node space
|
//convert mouse to node space
|
||||||
var desired_size = [ e.canvasX - this.resizing_node.pos[0], e.canvasY - this.resizing_node.pos[1] ];
|
var desired_size = [ 0, 0 ];
|
||||||
var min_size = this.resizing_node.computeSize();
|
var min_size = this.resizing_node.computeSize();
|
||||||
desired_size[0] = Math.max( min_size[0], desired_size[0] );
|
var move_node = true;
|
||||||
desired_size[1] = Math.max( min_size[1], desired_size[1] );
|
|
||||||
|
desired_size[0] = Math.max(
|
||||||
|
min_size[0],
|
||||||
|
this.resizing_node.resize_handle_x == 'left' ?
|
||||||
|
- e.canvasX + this.resizing_node.pos[0] + this.resizing_node.size[0]:
|
||||||
|
e.canvasX - this.resizing_node.pos[0]
|
||||||
|
);
|
||||||
|
desired_size[1] = Math.max(
|
||||||
|
min_size[1],
|
||||||
|
this.resizing_node.resize_handle_y == 'top' ?
|
||||||
|
- e.canvasY + this.resizing_node.pos[1] + this.resizing_node.size[1] - LiteGraph.NODE_TITLE_HEIGHT:
|
||||||
|
e.canvasY - this.resizing_node.pos[1]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.resizing_node.resize_handle_x == 'left' && desired_size[0] != this.resizing_node.size[0]) {
|
||||||
|
this.resizing_node.pos[0] = e.canvasX;
|
||||||
|
move_node = true;
|
||||||
|
}
|
||||||
|
if (this.resizing_node.resize_handle_y == 'top' && desired_size[1] != this.resizing_node.size[1]) {
|
||||||
|
this.resizing_node.pos[1] = e.canvasY + LiteGraph.NODE_TITLE_HEIGHT;
|
||||||
|
move_node = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (move_node) {
|
||||||
|
this.processNodeSelected(this.resizing_node, e);
|
||||||
|
}
|
||||||
this.resizing_node.setSize( desired_size );
|
this.resizing_node.setSize( desired_size );
|
||||||
|
|
||||||
this.canvas.style.cursor = "se-resize";
|
this.canvas.style.cursor = "se-resize";
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user