mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-01-11 16:58:31 +01:00
Slider for preview image size (#767)
* Slider for preview image size Add a slider to the system settings so that users can configure the max size of thumbnails * Remove debug output * Fix var definition * Move slider to 'display settings' menu * thumbnail slider CSS
This commit is contained in:
parent
4bc7bca60d
commit
1023f5f7cc
@ -288,6 +288,20 @@
|
|||||||
<div id="preview-tools">
|
<div id="preview-tools">
|
||||||
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can"></i> Clear All</button>
|
<button id="clear-all-previews" class="secondaryButton"><i class="fa-solid fa-trash-can"></i> Clear All</button>
|
||||||
<button id="save-all-images" class="primaryButton"><i class="fa-solid fa-download"></i> Download All Images</button>
|
<button id="save-all-images" class="primaryButton"><i class="fa-solid fa-download"></i> Download All Images</button>
|
||||||
|
<div class="dropdown display-settings">
|
||||||
|
<button class="dropbtn primaryButton">Display settings</button>
|
||||||
|
<div class="dropdown-content">
|
||||||
|
<div class="auto-scroll dropdown-item">
|
||||||
|
<div class="input-toggle"><input id="auto_scroll" name="auto_scroll" type="checkbox"><label for="auto_scroll"></label></div>
|
||||||
|
<label for="auto_scroll">Scroll to generated image</label>
|
||||||
|
</div>
|
||||||
|
<div class="dropdown-item">
|
||||||
|
Preview image size limit:<br/>
|
||||||
|
<input id="thumbnail_size" name="thumbnail_size" class="editor-slider" type="range" value="70" min="5" max="200" oninput="sliderUpdate(event)">
|
||||||
|
<input id="thumbnail_size-input" name="thumbnail_size-input" size="3" value="70" pattern="^[0-9.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)"> %
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -403,9 +403,6 @@ div.img-preview img {
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
|
|
||||||
background: var(--background-color4);
|
|
||||||
border: 2px solid var(--background-color2);
|
|
||||||
border-radius: 7px;
|
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
box-shadow: 0 20px 28px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.15);
|
box-shadow: 0 20px 28px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.15);
|
||||||
@ -414,6 +411,28 @@ div.img-preview img {
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.display-settings {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.display-settings .dropdown-content {
|
||||||
|
right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item {
|
||||||
|
padding: 4px;
|
||||||
|
background: var(--background-color4);
|
||||||
|
border: 2px solid var(--background-color2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item:first-child {
|
||||||
|
border-radius: 7px 7px 0px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item:last-child {
|
||||||
|
border-radius: 0px 0px 7px 7px;
|
||||||
|
}
|
||||||
|
|
||||||
.imageTaskContainer {
|
.imageTaskContainer {
|
||||||
border: 1px solid var(--background-color2);
|
border: 1px solid var(--background-color2);
|
||||||
margin-bottom: 10pt;
|
margin-bottom: 10pt;
|
||||||
|
@ -44,7 +44,8 @@ const SETTINGS_IDS_LIST = [
|
|||||||
"metadata_output_format",
|
"metadata_output_format",
|
||||||
"auto_save_settings",
|
"auto_save_settings",
|
||||||
"apply_color_correction",
|
"apply_color_correction",
|
||||||
"process_order_toggle"
|
"process_order_toggle",
|
||||||
|
"thumbnail_size"
|
||||||
]
|
]
|
||||||
|
|
||||||
const IGNORE_BY_DEFAULT = [
|
const IGNORE_BY_DEFAULT = [
|
||||||
|
@ -47,6 +47,7 @@ let blockNSFWField = document.querySelector('#block_nsfw')
|
|||||||
let showOnlyFilteredImageField = document.querySelector("#show_only_filtered_image")
|
let showOnlyFilteredImageField = document.querySelector("#show_only_filtered_image")
|
||||||
let updateBranchLabel = document.querySelector("#updateBranchLabel")
|
let updateBranchLabel = document.querySelector("#updateBranchLabel")
|
||||||
let streamImageProgressField = document.querySelector("#stream_image_progress")
|
let streamImageProgressField = document.querySelector("#stream_image_progress")
|
||||||
|
let thumbnailSizeField = document.querySelector("#thumbnail_size")
|
||||||
|
|
||||||
let makeImageBtn = document.querySelector('#makeImage')
|
let makeImageBtn = document.querySelector('#makeImage')
|
||||||
let stopImageBtn = document.querySelector('#stopImage')
|
let stopImageBtn = document.querySelector('#stopImage')
|
||||||
@ -1330,6 +1331,24 @@ outputFormatField.addEventListener('change', e => {
|
|||||||
outputQualityRow.style.display='table-row'
|
outputQualityRow.style.display='table-row'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
/********************* Zoom Slider **********************/
|
||||||
|
thumbnailSizeField.addEventListener('input', () => {
|
||||||
|
(function (s) {
|
||||||
|
for (var j =0; j < document.styleSheets.length; j++) {
|
||||||
|
let cssSheet = document.styleSheets[j]
|
||||||
|
for (var i = 0; i < cssSheet.cssRules.length; i++) {
|
||||||
|
var rule = cssSheet.cssRules[i];
|
||||||
|
if (rule.selectorText == "div.img-preview img") {
|
||||||
|
rule.style['max-height'] = s+'vh';
|
||||||
|
rule.style['max-width'] = s+'vw';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})(thumbnailSizeField.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function checkRandomSeed() {
|
function checkRandomSeed() {
|
||||||
if (randomSeedField.checked) {
|
if (randomSeedField.checked) {
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
checkbox: "checkbox",
|
checkbox: "checkbox",
|
||||||
select: "select",
|
select: "select",
|
||||||
select_multiple: "select_multiple",
|
select_multiple: "select_multiple",
|
||||||
|
slider: "slider",
|
||||||
custom: "custom",
|
custom: "custom",
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -155,6 +156,17 @@ var PARAMETERS = [
|
|||||||
icon: "fa-gear",
|
icon: "fa-gear",
|
||||||
default: true,
|
default: true,
|
||||||
},
|
},
|
||||||
|
/* {
|
||||||
|
id: "thumbnail_size",
|
||||||
|
type: ParameterType.slider,
|
||||||
|
label: "Maximum image display size",
|
||||||
|
note: "Downscale large images to keep a better overview",
|
||||||
|
icon: "fa-compress",
|
||||||
|
slider_min: 1,
|
||||||
|
slider_max: 100,
|
||||||
|
slider_unit: "%",
|
||||||
|
default: 70
|
||||||
|
}, */
|
||||||
{
|
{
|
||||||
id: "confirm_dangerous_actions",
|
id: "confirm_dangerous_actions",
|
||||||
type: ParameterType.checkbox,
|
type: ParameterType.checkbox,
|
||||||
@ -199,6 +211,16 @@ function getParameterSettingsEntry(id) {
|
|||||||
return parameter[0].settingsEntry
|
return parameter[0].settingsEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sliderUpdate(event) {
|
||||||
|
if (event.srcElement.id.endsWith('-input')) {
|
||||||
|
console.log(event.srcElement.value)
|
||||||
|
document.getElementById(event.srcElement.id.slice(0,-6)).value = event.srcElement.value
|
||||||
|
} else {
|
||||||
|
console.log(event.srcElement.value)
|
||||||
|
document.getElementById(event.srcElement.id+'-input').value = event.srcElement.value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getParameterElement(parameter) {
|
function getParameterElement(parameter) {
|
||||||
switch (parameter.type) {
|
switch (parameter.type) {
|
||||||
case ParameterType.checkbox:
|
case ParameterType.checkbox:
|
||||||
@ -209,6 +231,8 @@ function getParameterElement(parameter) {
|
|||||||
var options = (parameter.options || []).map(option => `<option value="${option.value}">${option.label}</option>`).join("")
|
var options = (parameter.options || []).map(option => `<option value="${option.value}">${option.label}</option>`).join("")
|
||||||
var multiple = (parameter.type == ParameterType.select_multiple ? 'multiple' : '')
|
var multiple = (parameter.type == ParameterType.select_multiple ? 'multiple' : '')
|
||||||
return `<select id="${parameter.id}" name="${parameter.id}" ${multiple}>${options}</select>`
|
return `<select id="${parameter.id}" name="${parameter.id}" ${multiple}>${options}</select>`
|
||||||
|
case ParameterType.slider:
|
||||||
|
return `<input id="${parameter.id}" name="${parameter.id}" class="editor-slider" type="range" value="${parameter.default}" min="${parameter.slider_min}" max="${parameter.slider_max}" oninput="sliderUpdate(event)"> <input id="${parameter.id}-input" name="${parameter.id}-input" size="4" value="${parameter.default}" pattern="^[0-9\.]+$" onkeypress="preventNonNumericalInput(event)" oninput="sliderUpdate(event)"> ${parameter.slider_unit}`
|
||||||
case ParameterType.custom:
|
case ParameterType.custom:
|
||||||
return parameter.render(parameter)
|
return parameter.render(parameter)
|
||||||
default:
|
default:
|
||||||
@ -461,3 +485,4 @@ saveSettingsBtn.addEventListener('click', function() {
|
|||||||
saveSettingsBtn.classList.add('active')
|
saveSettingsBtn.classList.add('active')
|
||||||
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
asyncDelay(300).then(() => saveSettingsBtn.classList.remove('active'))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,20 +1,6 @@
|
|||||||
(function () {
|
(function () {
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
var styleSheet = document.createElement("style");
|
|
||||||
styleSheet.textContent = `
|
|
||||||
.auto-scroll {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
document.head.appendChild(styleSheet);
|
|
||||||
|
|
||||||
const autoScrollControl = document.createElement('div');
|
|
||||||
autoScrollControl.innerHTML = `<input id="auto_scroll" name="auto_scroll" type="checkbox">
|
|
||||||
<label for="auto_scroll">Scroll to generated image</label>`
|
|
||||||
autoScrollControl.className = "auto-scroll"
|
|
||||||
clearAllPreviewsBtn.parentNode.insertBefore(autoScrollControl, clearAllPreviewsBtn.nextSibling)
|
|
||||||
prettifyInputs(document);
|
|
||||||
let autoScroll = document.querySelector("#auto_scroll")
|
let autoScroll = document.querySelector("#auto_scroll")
|
||||||
|
|
||||||
// save/restore the toggle state
|
// save/restore the toggle state
|
||||||
|
Loading…
Reference in New Issue
Block a user