Skip to content

Commit 76b68f9

Browse files
committed
Cap output value area height by first-slot canvas inset
1 parent 8daf984 commit 76b68f9

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

js/drawing/resolution_master_draw_methods.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const log = createModuleLogger("resolution_master_draw_methods");
88
const OUTPUT_VALUE_VISUAL_RIGHT_INSET = 3;
99
const OUTPUT_VALUE_HIT_RIGHT_INSET = 12;
1010
const OUTPUT_VALUE_VERTICAL_GAP = 4;
11+
const OUTPUT_VALUE_CANVAS_TOP_INSET = 1;
1112
const SECTION_BACKGROUND_COLOR = "rgba(0,0,0,0.2)";
1213

1314
export const drawingMethods = {
@@ -225,7 +226,12 @@ export const drawingMethods = {
225226
: LiteGraph.NODE_SLOT_HEIGHT;
226227
const [y_offset_1, y_offset_2, y_offset_3, y_offset_4, y_offset_5] = slotCenters;
227228
const valueAreaWidth = 60;
228-
const valueAreaHeight = Math.max(14, slotSpacing - OUTPUT_VALUE_VERTICAL_GAP);
229+
const preferredValueAreaHeight = Math.max(14, slotSpacing - OUTPUT_VALUE_VERTICAL_GAP);
230+
const availableFirstSlotHeight = Math.max(
231+
8,
232+
2 * (y_offset_1 - OUTPUT_VALUE_CANVAS_TOP_INSET)
233+
);
234+
const valueAreaHeight = Math.min(preferredValueAreaHeight, availableFirstSlotHeight);
229235
const outputValueRight = node.size[0] - OUTPUT_VALUE_VISUAL_RIGHT_INSET;
230236
const valueAreaX = outputValueRight - valueAreaWidth;
231237
const outputValueCenterX = valueAreaX + valueAreaWidth / 2;

tests/js/output_value_drawing.test.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,16 @@ test("Nodes 2.0 output pills follow the measured DOM slot centers", () => {
149149
try {
150150
const controller = createController();
151151
controller.isVueNodesMode = () => true;
152-
controller._vueCompatOutputSlotCenters = [12, 35, 58, 81, 104];
152+
controller._vueCompatOutputSlotCenters = [8, 31, 54, 77, 100];
153153
const ctx = createCanvasContext();
154154
controller.drawOutputValues(ctx);
155155

156-
assert.equal(ctx.rectangles[0].y + ctx.rectangles[0].h / 2, 12);
157-
assert.equal(ctx.rectangles[1].y + ctx.rectangles[1].h / 2, 35);
158-
assert.equal(ctx.rectangles[2].y + ctx.rectangles[2].h / 2, 81);
159-
assert.equal(ctx.text.find(entry => entry.value === "LAT")?.y, 104);
156+
assert.equal(ctx.rectangles[0].y, 1);
157+
assert.equal(ctx.rectangles[0].h, 14);
158+
assert.equal(ctx.rectangles[0].y + ctx.rectangles[0].h / 2, 8);
159+
assert.equal(ctx.rectangles[1].y + ctx.rectangles[1].h / 2, 31);
160+
assert.equal(ctx.rectangles[2].y + ctx.rectangles[2].h / 2, 77);
161+
assert.equal(ctx.text.find(entry => entry.value === "LAT")?.y, 100);
160162
} finally {
161163
globalThis.LiteGraph = originalLiteGraph;
162164
}

0 commit comments

Comments
 (0)