From 8e5d48f97ba6982bce533e3f838fd6de89ce8f9d Mon Sep 17 00:00:00 2001 From: tim h Date: Mon, 12 Dec 2022 18:25:02 -0600 Subject: [PATCH] think it makes more sense here --- index.html | 7 +++++++ js/index.js | 23 +++++++++++++++++++++-- js/ui/tool/dream.js | 34 ++-------------------------------- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/index.html b/index.html index 77f031d..17e49d5 100644 --- a/index.html +++ b/index.html @@ -87,6 +87,13 @@
+
+ + +
diff --git a/js/index.js b/js/index.js index 2aede1c..2821b27 100644 --- a/js/index.js +++ b/js/index.js @@ -115,6 +115,7 @@ function startup() { changeSmoothRendering(); changeSeed(); changeHiResFix(); + changeSyncCursorSize(); } /** @@ -543,6 +544,17 @@ function changeHiResFix() { ); localStorage.setItem("enable_hr", stableDiffusionData.enable_hr); } + +function changeSyncCursorSize() { + stableDiffusionData.sync_cursor_size = Boolean( + document.getElementById("cbxSyncCursorSize").checked + ); //is this horribly hacky, putting it in SD data instead of making a gross global var? + localStorage.setItem( + "sync_cursor_size", + stableDiffusionData.sync_cursor_size + ); +} + function changeSmoothRendering() { const layers = document.getElementById("layer-render"); if (document.getElementById("cbxSmooth").checked) { @@ -957,6 +969,11 @@ function loadSettings() { ? false : localStorage.getItem("enable_hr") ); + var _sync_cursor_size = Boolean( + localStorage.getItem("sync_cursor_size") == (null || "false") + ? false + : localStorage.getItem("sync_cursor_size") + ); // set the values into the UI document.getElementById("prompt").value = String(_prompt); @@ -966,6 +983,8 @@ function loadSettings() { document.getElementById("maskBlur").value = Number(_mask_blur); document.getElementById("seed").value = Number(_seed); document.getElementById("cbxHRFix").checked = Boolean(_enable_hr); + document.getElementById("cbxSyncCursorSize").checked = + Boolean(_sync_cursor_size); } imageCollection.element.addEventListener( @@ -992,7 +1011,7 @@ function resetToDefaults() { } function informSliders() { - if (toolbar._current_tool && toolbar._current_tool.state.matchResolution) { + if (stableDiffusionData.sync_cursor_size) { if (!toolbar._current_tool.state.ignorePrevious) { toolbar._current_tool.state.setCursorSize(stableDiffusionData.width); } @@ -1001,7 +1020,7 @@ function informSliders() { } const _resolution_onwheel = (evn) => { - if (toolbar._current_tool && toolbar._current_tool.state.matchResolution) { + if (stableDiffusionData.sync_cursor_size) { toolbar._current_tool.state.ignorePrevious = true; //so hacky resSlider.value = stableDiffusionData.width - (128 * evn.deltaY) / Math.abs(evn.deltaY); diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 3c939a5..fe5e0f5 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -916,7 +916,7 @@ const dreamTool = () => setMask(state.invertMask ? "hold" : "clear"); // update cursor size if matching is enabled - if (state.matchResolution) { + if (stableDiffusionData.sync_cursor_size) { state.setCursorSize(stableDiffusionData.width); } }, @@ -939,7 +939,6 @@ const dreamTool = () => }; state.cursorSize = 512; - state.matchResolution = true; state.snapToGrid = true; state.invertMask = false; state.overMaskPx = 0; @@ -997,18 +996,6 @@ const dreamTool = () => state.setCursorSize = cursorSizeSlider.setValue; state.ctxmenu.cursorSizeSlider = cursorSizeSlider.slider; - // Match Resolution Checkbox - state.ctxmenu.matchResolutionLabel = _toolbar_input.checkbox( - state, - "matchResolution", - "Match Resolution", - () => { - if (state.matchResolution) { - resSlider.value = state.cursorSize; - } - } - ).label; - // Snap to Grid Checkbox state.ctxmenu.snapToGridLabel = _toolbar_input.checkbox( state, @@ -1041,8 +1028,6 @@ const dreamTool = () => } menu.appendChild(state.ctxmenu.cursorSizeSlider); - menu.appendChild(state.ctxmenu.matchResolutionLabel); - menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.snapToGridLabel); menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.invertMaskLabel); @@ -1074,7 +1059,7 @@ const img2imgTool = () => setMask(state.invertMask ? "hold" : "clear"); // update cursor size if matching is enabled - if (state.matchResolution) { + if (stableDiffusionData.sync_cursor_size) { state.setCursorSize(stableDiffusionData.width); } }, @@ -1096,7 +1081,6 @@ const img2imgTool = () => }; state.cursorSize = 512; - state.matchResolution = true; state.snapToGrid = true; state.invertMask = true; state.fullResolution = false; @@ -1258,18 +1242,6 @@ const img2imgTool = () => state.setCursorSize = cursorSizeSlider.setValue; state.ctxmenu.cursorSizeSlider = cursorSizeSlider.slider; - // Match Resolution Checkbox - state.ctxmenu.matchResolutionLabel = _toolbar_input.checkbox( - state, - "matchResolution", - "Match Resolution", - () => { - if (state.matchResolution) { - resSlider.value = state.cursorSize; - } - } - ).label; - // Snap To Grid Checkbox state.ctxmenu.snapToGridLabel = _toolbar_input.checkbox( state, @@ -1329,8 +1301,6 @@ const img2imgTool = () => } menu.appendChild(state.ctxmenu.cursorSizeSlider); - menu.appendChild(state.ctxmenu.matchResolutionLabel); - menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.snapToGridLabel); menu.appendChild(document.createElement("br")); menu.appendChild(state.ctxmenu.invertMaskLabel);