think it makes more sense here

This commit is contained in:
tim h 2022-12-12 18:25:02 -06:00
parent 228bd3d9a0
commit 8e5d48f97b
3 changed files with 30 additions and 34 deletions

View file

@ -87,6 +87,13 @@
<br />
<input type="checkbox" id="cbxHRFix" onchange="changeHiResFix()" />
<label for="cbxHRFix">Auto txt2img HRfix</label>
<br />
<input
type="checkbox"
id="cbxSyncCursorSize"
onchange="changeSyncCursorSize()" />
<label for="cbxSyncCursorSize">Sync cursor size</label>
<br />
<div id="resolution"></div>
<div id="steps"></div>
<div id="cfgScale"></div>

View file

@ -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);

View file

@ -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);