feat: add Custom resolution mode#2
Merged
Merged
Conversation
- Add "Custom" as a 4th resolution combo value (D-02) - Add custom_width/custom_height INT inputs (default 1024, min 512, max 4096, step 8), appended at the END of required for saved-workflow back-compat (D-03/D-04) - Add calculate_custom_dimensions() helper: clamp to [512, 4096] then round8(value / scale_factor) per axis, no orientation swap (D-01/D-05/D-06) - Add CUSTOM_DIMENSION_MIN/MAX module constants shared by INPUT_TYPES and the helper so widget bounds and clamp bounds cannot drift - generate() gains defaulted custom_width/custom_height params and dispatches to the custom helper when resolution == "Custom"; preset path unchanged - Update test_resolution_combo assertion for the new Custom value
Add tests/test_custom_resolution.py covering the locked D-01..D-06 decisions: - D-01: round8(custom / scale_factor) per axis (target -> scale-divided) - D-05: clamp to [512, 4096] then round up to 8; below-min/zero/above-max and non-8 inputs never raise; parametric divisible-by-8 spread - D-06: Custom generate() output identical under Landscape and Portrait (no swap) - Integration: 5-tuple outputs + LATENT tensor shape (1, 4, 64, 128) - D-02/D-03/D-04: preset back-compat without custom args + INPUT_TYPES widget config
- calculateCustomDimensions parity with nodes.py (clamp [512,4096], round8(value/scale), no swap) - getCustomTargetDimensions achievable-target math (output x scale, D-09) - getSizeBoxClickAction W/H box hit-test incl. central-gap null
- config.js: add "Custom" to RESOLUTIONS; CUSTOM_MIN/MAX; calculateCustomDimensions + getCustomTargetDimensions mirroring nodes.py exactly (clamp [512,4096], round8, no orientation swap) - draw.js: drawSize renders two 26px W/H boxes + central × and registers controls.sizeW/sizeH - layout.js: getSizeBoxClickAction hit-test; CUSTOM_CONTROLS_HEIGHT stays 294
- new js/size_input.js exports openSizeInput({ node, box, localPos, event, value, min, max, onCommit })
- positions a fixed <input> over the box via the VERIFIED transform
(rect + (node.pos + box + ds.offset) * ds.scale; no devicePixelRatio term)
- built with createElement + .value/.style only (ASVS V5; no innerHTML interpolation)
- deferred focus in setTimeout(0) to beat LiteGraph's canvas.focus()
- integer-only keydown filter + stopPropagation; Enter/blur/wheel commit idempotently
(done guard) with [min,max] clamp; Esc cancels
- find + hide custom_width/custom_height widgets; customWidthVal/customHeightVal state that persists across preset<->Custom switches (D-12) - recalculate() custom branch drives live Target panel + output-port labels (D-09) - onDrawForeground swaps the Aspect-Ratio row for a Size row (label + drawSize) at the identical y-cadence -> no vertical jump (CUST-02/CUST-03) - onMouseDown: Size-box hit-test opens openSizeInput; ratio hit-test guarded to preset mode; Portrait/Landscape swaps custom W/H (CUST-04/D-06) - syncToHidden serializes custom_width/custom_height; onConfigure restores them for workflow save/load (CUST-05)
Custom width/height are now the raw output (latent) size: the node emits exactly the entered dimensions (8-aligned) and scale is display-only (UI target = output x scale). Reverses the earlier target-then-divide semantics after Phase 5 UAT. Backend calculate_custom_dimensions drops the scale divide; the config.js client mirror and both test suites are updated.
Inset the transient inline input symmetrically (both sides) so it stays centred on the box: its centre matches the drawn value's centre, so the number no longer shifts when the editor opens, while the left strip keeps the faint W/H hint visible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add Custom resolution mode to QuickLatent so users can enter explicit output dimensions while keeping backend and frontend calculations aligned.
Changes
Verification
python -m pytest- 514 passednpm test- 21 passedImpact
Breaking changes: None
User-facing changes: Adds Custom resolution mode and editable custom Size controls
Migration required: None