mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-25 16:59:45 +00:00
@@ -1,3 +1,5 @@
|
||||
import { BadgePosition } from "./LGraphBadge";
|
||||
|
||||
const globalExport = {};
|
||||
|
||||
(function (globalThis) {
|
||||
@@ -2375,6 +2377,8 @@ const globalExport = {};
|
||||
this.inputs = [];
|
||||
this.outputs = [];
|
||||
this.connections = [];
|
||||
this.badges = [];
|
||||
this.badgePosition = BadgePosition.TopLeft;
|
||||
|
||||
//local data
|
||||
this.properties = {}; //for the values
|
||||
@@ -4814,6 +4818,27 @@ const globalExport = {};
|
||||
(y + this.pos[1]) * graphcanvas.scale + graphcanvas.offset[1]
|
||||
];
|
||||
}
|
||||
|
||||
get width() {
|
||||
return this.size[0];
|
||||
}
|
||||
|
||||
get height() {
|
||||
return this.size[1];
|
||||
}
|
||||
|
||||
drawBadges(ctx, {gap = 2} = {}) {
|
||||
const badgeInstances = this.badges.map(badge => badge instanceof LGraphBadge ? badge : badge());
|
||||
const isLeftAligned = this.badgePosition === BadgePosition.TopLeft;
|
||||
|
||||
let currentX = isLeftAligned ? 0 : this.width - badgeInstances.reduce((acc, badge) => acc + badge.getWidth(ctx) + gap, 0);
|
||||
const y = - (LiteGraph.NODE_TITLE_HEIGHT + gap);
|
||||
|
||||
for (const badge of badgeInstances) {
|
||||
badge.draw(ctx, currentX, y - badge.height);
|
||||
currentX += badge.getWidth(ctx) + gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.LGraphNode = LiteGraph.LGraphNode = LGraphNode;
|
||||
@@ -9466,6 +9491,8 @@ const globalExport = {};
|
||||
node.is_selected,
|
||||
node.mouseOver
|
||||
);
|
||||
node.drawBadges(ctx);
|
||||
|
||||
ctx.shadowColor = "transparent";
|
||||
|
||||
//draw foreground
|
||||
@@ -14379,3 +14406,4 @@ export const LGraphGroup = globalExport.LGraphGroup;
|
||||
export const DragAndScale = globalExport.DragAndScale;
|
||||
export const LGraphCanvas = globalExport.LGraphCanvas;
|
||||
export const ContextMenu = globalExport.ContextMenu;
|
||||
export { LGraphBadge, BadgePosition } from "./LGraphBadge";
|
||||
|
||||
Reference in New Issue
Block a user