Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/litegraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9958,6 +9958,30 @@ LGraphNode.prototype.executeAction = function(action)
if(values && values.constructor !== Array)
v = values[ w.value ];
}
const labelWidth = ctx.measureText(w.label || w.name).width + margin * 2;
const inputWidth = widget_width - margin * 4
const availableWidth = inputWidth - labelWidth
const textWidth = ctx.measureText(v).width;
if (textWidth > availableWidth) {
const ELLIPSIS = "\u2026";
const ellipsisWidth = ctx.measureText(ELLIPSIS).width;
const charWidthAvg = ctx.measureText("a").width;
if (availableWidth <= ellipsisWidth) {
v = "\u2024"; // One dot leader
} else {
const overflowWidth = (textWidth + ellipsisWidth) - availableWidth;
// Only first 3 characters need to be measured precisely
if ( overflowWidth + charWidthAvg * 3 > availableWidth) {
const preciseRange = availableWidth + charWidthAvg * 3;
const preTruncateCt = Math.floor((preciseRange - ellipsisWidth) / charWidthAvg);
v = v.substr(0, preTruncateCt)
}
while (ctx.measureText(v).width + ellipsisWidth > availableWidth) {
v = v.substr(0, v.length - 1);
}
v += ELLIPSIS;
}
}
ctx.fillText(
v,
widget_width - margin * 2 - 20,
Expand Down