Skip to content

Commit b65135a

Browse files
committed
changing the latent type setting to the manual method
1 parent c3bbf65 commit b65135a

1 file changed

Lines changed: 68 additions & 27 deletions

File tree

js/ResolutionMaster.js

Lines changed: 68 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@ import { CustomPresetsManager } from "./utils/CustomPresetsManager.js";
99
import { PresetManagerDialog } from "./utils/PresetManagerDialog.js";
1010
const log = createModuleLogger('ResolutionMaster');
1111

12-
class ResolutionMasterCanvas {
13-
static CATEGORY_MAPPING = {
14-
'Flux': 'latent_4x8',
15-
'Flux.2': 'latent_128x16',
16-
'Standard': 'latent_4x8',
17-
'SDXL': 'latent_4x8',
18-
'Social Media': 'latent_4x8',
19-
'Print': 'latent_4x8',
20-
'Cinema': 'latent_4x8',
21-
'Display Resolutions': 'latent_4x8',
22-
'WAN': 'latent_4x8',
23-
'HiDream Dev': 'latent_4x8',
24-
'Qwen-Image': 'latent_4x8'
25-
};
26-
12+
class ResolutionMasterCanvas {
2713
constructor(node) {
2814
this.node = node;
2915
this.node.properties = this.node.properties || {};
@@ -203,10 +189,7 @@ class ResolutionMasterCanvas {
203189
this.rescaleModeWidget = rescaleModeWidget;
204190
this.rescaleValueWidget = rescaleValueWidget;
205191
this.batchSizeWidget = batchSizeWidget;
206-
if (latentTypeWidget) {
207-
const backendLatentType = ResolutionMasterCanvas.CATEGORY_MAPPING[node.properties.selectedCategory] || 'latent_4x8';
208-
latentTypeWidget.value = backendLatentType;
209-
}
192+
// Latent type is now manually controlled via LAT selector - no automatic initialization based on category
210193
node.onDrawForeground = function(ctx) {
211194
if (this.flags.collapsed) return;
212195
self.ensureMinimumSize();
@@ -451,10 +434,34 @@ class ResolutionMasterCanvas {
451434
ctx.fillText(this.batchSizeWidget.value.toString(), node.size[0] - 20, y_offset_4);
452435
const y_offset_5 = 5 + (LiteGraph.NODE_SLOT_HEIGHT * 4.5);
453436

454-
ctx.fillStyle = "#F8B";
437+
// Create clickable area for LAT selector
438+
const latAreaWidth = 50;
439+
const latAreaHeight = 28;
440+
const latAreaX = node.size[0] - latAreaWidth - 5;
441+
442+
this.controls.latValueArea = {
443+
x: latAreaX,
444+
y: y_offset_5 - 10,
445+
w: latAreaWidth,
446+
h: latAreaHeight
447+
};
448+
449+
this.drawValueAreaHoverBackground(ctx, 'latValueArea', latAreaX, y_offset_5 - 10, latAreaWidth, latAreaHeight, [248, 136, 187]);
450+
451+
ctx.fillStyle = this.hoverElement === 'latValueArea' ? "#FAB" : "#F8B";
455452
ctx.font = "bold 12px Arial";
456453
ctx.textAlign = "right";
457454
ctx.fillText("LAT", node.size[0] - 20, y_offset_5);
455+
456+
// Draw latent type info in smaller gray font below LAT
457+
if (this.latentTypeWidget) {
458+
const latentType = this.latentTypeWidget.value || 'latent_4x8';
459+
const shortType = latentType.replace('latent_', '');
460+
ctx.fillStyle = this.hoverElement === 'latValueArea' ? "#999" : "#777";
461+
ctx.font = "9px Arial";
462+
ctx.textAlign = "right";
463+
ctx.fillText(shortType, node.size[0] - 20, y_offset_5 + 12);
464+
}
458465
}
459466
}
460467

@@ -1197,7 +1204,11 @@ class ResolutionMasterCanvas {
11971204
}
11981205
if (key.endsWith('ValueArea')) {
11991206
log.debug(`Detected ValueArea click: ${key}`);
1200-
this.dialogManager.showCustomValueDialog(key, e);
1207+
if (key === 'latValueArea') {
1208+
this.showLatentTypeSelector(e);
1209+
} else {
1210+
this.dialogManager.showCustomValueDialog(key, e);
1211+
}
12011212
return true;
12021213
}
12031214
if (key.endsWith('Header')) {
@@ -1670,6 +1681,41 @@ class ResolutionMasterCanvas {
16701681
}
16711682
}
16721683

1684+
showLatentTypeSelector(e) {
1685+
if (!this.latentTypeWidget) {
1686+
log.debug("Latent type selector: latent_type widget not found");
1687+
return;
1688+
}
1689+
1690+
const currentValue = this.latentTypeWidget.value || 'latent_4x8';
1691+
1692+
// Available latent types with descriptive names
1693+
const latentTypes = [
1694+
{ text: '4x8 (Standard SD/SDXL/Flux)', value: 'latent_4x8' },
1695+
{ text: '128x16 (Flux.2)', value: 'latent_128x16' }
1696+
];
1697+
1698+
const items = latentTypes.map(type => ({
1699+
text: type.text,
1700+
value: type.value,
1701+
isCustom: type.value === currentValue // Highlight current selection
1702+
}));
1703+
1704+
this.searchableDropdown.show(items, {
1705+
event: e,
1706+
title: 'Select Latent Type',
1707+
callback: (selectedText) => {
1708+
// Find the selected type by its display text
1709+
const selectedType = latentTypes.find(t => t.text === selectedText);
1710+
if (selectedType && this.latentTypeWidget) {
1711+
this.latentTypeWidget.value = selectedType.value;
1712+
log.debug(`Latent type manually changed to: ${selectedType.value}`);
1713+
app.graph.setDirtyCanvas(true);
1714+
}
1715+
}
1716+
});
1717+
}
1718+
16731719
showDropdownMenu(dropdownName, e) {
16741720
const props = this.node.properties;
16751721
let items, callback, title, propertyKey;
@@ -1696,12 +1742,7 @@ class ResolutionMasterCanvas {
16961742
callback = (value) => {
16971743
props.selectedCategory = value;
16981744
props.selectedPreset = null;
1699-
if (this.latentTypeWidget) {
1700-
const backendLatentType = ResolutionMasterCanvas.CATEGORY_MAPPING[value] || 'latent_4x8';
1701-
this.latentTypeWidget.value = backendLatentType;
1702-
log.debug(`Updated backend latent type widget to: ${backendLatentType} for UI category: ${value}`);
1703-
}
1704-
1745+
// Latent type is now manually controlled via LAT selector - no automatic change
17051746
app.graph.setDirtyCanvas(true);
17061747
};
17071748
} else if (dropdownName === 'presetDropdown' && props.selectedCategory) {

0 commit comments

Comments
 (0)