From 68c4b55945a05098de5f6d0c957b6b2be65ea3eb Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Sat, 8 Oct 2022 07:55:24 -0400 Subject: [PATCH 1/3] Disable 'resizeInpaintingEditor' when 'maskSetting' is unchecked. --- ui/media/main.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ui/media/main.js b/ui/media/main.js index 7db632c8..ad79caf6 100644 --- a/ui/media/main.js +++ b/ui/media/main.js @@ -264,6 +264,9 @@ async function healthCheck() { } } function resizeInpaintingEditor() { + if (!maskSetting.checked) { + return + } let widthValue = parseInt(widthField.value) let heightValue = parseInt(heightField.value) if (widthValue === heightValue) { From 68dd9a29e871b4b21b2610bb29485213e67d2b82 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Sat, 8 Oct 2022 07:56:01 -0400 Subject: [PATCH 2/3] Run 'resizeInpaintingEditor' once when 'maskSetting' is changed. --- ui/media/main.js | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/media/main.js b/ui/media/main.js index ad79caf6..9e91cb8f 100644 --- a/ui/media/main.js +++ b/ui/media/main.js @@ -1140,6 +1140,7 @@ initImageClearBtn.addEventListener('click', function() { maskSetting.addEventListener('click', function() { inpaintingEditorContainer.style.display = (this.checked ? 'block' : 'none') + resizeInpaintingEditor() }) promptsFromFileBtn.addEventListener('click', function() { From 2c4a8619a8c452d474e76931eae830d9413b8ce8 Mon Sep 17 00:00:00 2001 From: Marc-Andre Ferland Date: Sat, 8 Oct 2022 08:42:25 -0400 Subject: [PATCH 3/3] Only 'resizeInpaintingEditor' if 'aspectRatio' has changed. --- ui/media/main.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ui/media/main.js b/ui/media/main.js index 9e91cb8f..c33429c2 100644 --- a/ui/media/main.js +++ b/ui/media/main.js @@ -279,6 +279,11 @@ function resizeInpaintingEditor() { widthValue = (widthValue / heightValue) * INPAINTING_EDITOR_SIZE heightValue = INPAINTING_EDITOR_SIZE } + if (inpaintingEditor.opts.aspectRatio === (widthValue / heightValue).toFixed(3)) { + // Same ratio, don't reset the canvas. + return + } + inpaintingEditor.opts.aspectRatio = (widthValue / heightValue).toFixed(3) inpaintingEditorContainer.style.width = widthValue + 'px' inpaintingEditorContainer.style.height = heightValue + 'px'