Merge pull request #1368 from JeLuF/modifdlg

Modifier settings dialog improvements
This commit is contained in:
cmdr2 2023-06-27 16:08:18 +05:30 committed by GitHub
commit dbf9482303
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 85 additions and 44 deletions

View File

@ -72,8 +72,8 @@
<textarea id="negative_prompt" name="negative_prompt" placeholder="list the things to remove from the image (e.g. fog, green)"></textarea> <textarea id="negative_prompt" name="negative_prompt" placeholder="list the things to remove from the image (e.g. fog, green)"></textarea>
</div> </div>
<div id="editor-modifiers"> <div id="editor-modifiers">
<div id="editor-modifiers-header"> <div id="editor-modifiers-header" class="dialog-header">
<div id="modifiers-header-left"> <div id="modifiers-header-left" class="dialog-header-left">
<h4>Image Modifiers</h4> <h4>Image Modifiers</h4>
<span>(drawing style, camera, etc.)</span> <span>(drawing style, camera, etc.)</span>
</div> </div>
@ -525,13 +525,23 @@
</div> </div>
</div> </div>
<div id="modifier-settings-config" class="popup" tabindex="0"> <dialog id="modifier-settings-config">
<div> <div id="modifier-settings-header" class="dialog-header">
<i class="close-button fa-solid fa-xmark"></i> <div id="modifier-settings-header-left" class="dialog-header-left">
<h1>Modifier Settings</h1> <h4>Modifier Settings</h4>
<p>Set your custom modifiers (one per line)</p> <span>Set your custom modifiers (one per line)</span>
</div>
<div id="modifier-settings-header-right">
<i id="modifier-settings-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<textarea id="custom-modifiers-input" placeholder="Enter your custom modifiers, one-per-line" spellcheck="false"></textarea> <textarea id="custom-modifiers-input" placeholder="Enter your custom modifiers, one-per-line" spellcheck="false"></textarea>
<p><small><b>Tip:</b> You can include special characters like {} () [] and |. You can also put multiple comma-separated phrases in a single line, to make a single modifier that combines all of those.</small></p> <div>
<small>
<b>Tip:</b> You can include special characters like {} () [] and |. You can also put multiple comma-separated
phrases in a single line, to make a single modifier that combines all of those.
</small>
</div>
<div id="editor-modifiers-entries-toolbar"> <div id="editor-modifiers-entries-toolbar">
<label for="preview-image">Image Style:</label> <label for="preview-image">Image Style:</label>
<select id="preview-image" name="preview-image" value="portrait"> <select id="preview-image" name="preview-image" value="portrait">
@ -542,8 +552,7 @@
<label for="modifier-card-size-slider">Thumbnail Size:</label> <label for="modifier-card-size-slider">Thumbnail Size:</label>
<input id="modifier-card-size-slider" name="modifier-card-size-slider" value="0" type="range" min="-2" max="3"> <input id="modifier-card-size-slider" name="modifier-card-size-slider" value="0" type="range" min="-2" max="3">
</div> </div>
</div> </dialog>
</div>
<div id="image-editor" class="popup image-editor-popup"> <div id="image-editor" class="popup image-editor-popup">
<div> <div>

View File

@ -184,7 +184,7 @@ code {
#editor label { #editor label {
font-weight: normal; font-weight: normal;
} }
#editor h4 { .dialog-header h4 {
margin: 0px; margin: 0px;
white-space: nowrap; white-space: nowrap;
} }
@ -326,7 +326,7 @@ button#resume {
max-height: 100%; max-height: 100%;
flex: 1; flex: 1;
} }
#editor-modifiers-header { .dialog-header {
background-color: var(--background-color4); background-color: var(--background-color4);
padding: 0.5em; padding: 0.5em;
border-bottom: 1px solid rgb(255 255 255 / 10%); border-bottom: 1px solid rgb(255 255 255 / 10%);
@ -369,7 +369,7 @@ button#resume {
flex-direction: column; flex-direction: column;
grid-gap: 0.1em; grid-gap: 0.1em;
} }
#modifiers-header-left span { .dialog-header-left span {
font-size: 0.8em; font-size: 0.8em;
color: rgb(127 127 127); color: rgb(127 127 127);
font-weight: 200; font-weight: 200;
@ -467,6 +467,24 @@ button#resume {
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
} }
dialog {
background: var(--background-color2);
color: var(--text-color);
border-radius: 6px;
border: 2px solid rgb(255 255 255 / 10%);
padding: 0px;
}
dialog::backdrop {
background: rgba(0, 0, 0, 0.5);
}
dialog > div {
padding: 0.5em;
}
img { img {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.15); box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.15), 0 6px 20px 0 rgba(0, 0, 0, 0.15);
} }

View File

@ -173,6 +173,8 @@
vertical-align: middle; vertical-align: middle;
} }
#modifier-settings-config textarea { #modifier-settings-config textarea {
margin-left: 5%;
margin-top: 2ex;
width: 90%; width: 90%;
height: 150px; height: 150px;
} }

View File

@ -16,9 +16,10 @@ let modifierSettingsBtn = document.querySelector("#modifier-settings-btn")
let modifiersContainerSizeBtn = document.querySelector("#modifiers-container-size-btn") let modifiersContainerSizeBtn = document.querySelector("#modifiers-container-size-btn")
let modifiersCloseBtn = document.querySelector("#modifiers-close-button") let modifiersCloseBtn = document.querySelector("#modifiers-close-button")
let modifiersCollapsiblesBtn = document.querySelector("#modifiers-action-collapsibles-btn") let modifiersCollapsiblesBtn = document.querySelector("#modifiers-action-collapsibles-btn")
let modifierSettingsOverlay = document.querySelector("#modifier-settings-config") let modifierSettingsDialog = document.querySelector("#modifier-settings-config")
let customModifiersTextBox = document.querySelector("#custom-modifiers-input") let customModifiersTextBox = document.querySelector("#custom-modifiers-input")
let customModifierEntriesToolbar = document.querySelector("#editor-modifiers-entries-toolbar") let customModifierEntriesToolbar = document.querySelector("#editor-modifiers-entries-toolbar")
let modifierSettingsCloseBtn = document.querySelector("#modifier-settings-close-button")
const modifierThumbnailPath = "media/modifier-thumbnails" const modifierThumbnailPath = "media/modifier-thumbnails"
const activeCardClass = "modifier-card-active" const activeCardClass = "modifier-card-active"
@ -415,7 +416,7 @@ function hideModifierContainer() {
function checkIfClickedOutsideDropdownElem(e) { function checkIfClickedOutsideDropdownElem(e) {
const clickedElement = e.target const clickedElement = e.target
const clickedInsideSpecificElems = [modifierDropdown, editorModifiersContainer, modifierSettingsOverlay].some((div) => const clickedInsideSpecificElems = [modifierDropdown, editorModifiersContainer, modifierSettingsDialog].some((div) =>
div && (div.contains(clickedElement) || div === clickedElement)) div && (div.contains(clickedElement) || div === clickedElement))
if (!clickedInsideSpecificElems && !modifierPanelFreezed) { if (!clickedInsideSpecificElems && !modifierPanelFreezed) {
@ -452,17 +453,17 @@ customModifiersTextBox.addEventListener("change", saveCustomModifiers)
modifierCardSizeSlider.onchange = () => resizeModifierCards(modifierCardSizeSlider.value) modifierCardSizeSlider.onchange = () => resizeModifierCards(modifierCardSizeSlider.value)
previewImageField.onchange = () => changePreviewImages(previewImageField.value) previewImageField.onchange = () => changePreviewImages(previewImageField.value)
modifierSettingsOverlay.addEventListener("keydown", function(e) { modifierSettingsDialog.addEventListener("keydown", function(e) {
switch (e.key) { switch (e.key) {
case "Escape": // Escape to cancel case "Escape": // Escape to cancel
customModifiersTextBox.value = customModifiersInitialContent // undo the changes customModifiersTextBox.value = customModifiersInitialContent // undo the changes
modifierSettingsOverlay.classList.remove("active") modifierSettingsDialog.close()
e.stopPropagation() e.stopPropagation()
break break
case "Enter": case "Enter":
if (e.ctrlKey) { if (e.ctrlKey) {
// Ctrl+Enter to confirm // Ctrl+Enter to confirm
modifierSettingsOverlay.classList.remove("active") modifierSettingsDialog.close()
e.stopPropagation() e.stopPropagation()
break break
} }
@ -538,7 +539,7 @@ modifiersContainerSizeBtn.addEventListener("click", (e) => {
}) })
modifierSettingsBtn.addEventListener("click", (e) => { modifierSettingsBtn.addEventListener("click", (e) => {
modifierSettingsOverlay.classList.add("active") modifierSettingsDialog.showModal()
customModifiersTextBox.setSelectionRange(0, 0) customModifiersTextBox.setSelectionRange(0, 0)
customModifiersTextBox.focus() customModifiersTextBox.focus()
customModifiersInitialContent = customModifiersTextBox.value // preserve the initial content customModifiersInitialContent = customModifiersTextBox.value // preserve the initial content
@ -551,11 +552,25 @@ modifiersCloseBtn.addEventListener("click", (e) => {
// prevents the modifier panel closing at the same time as the settings overlay // prevents the modifier panel closing at the same time as the settings overlay
new MutationObserver(() => { new MutationObserver(() => {
const isActive = modifierSettingsOverlay.classList.contains("active") const isActive = modifierSettingsDialog.open
if (!isActive) { if (!isActive) {
modifierPanelFreezed = true modifierPanelFreezed = true
setTimeout(() => modifierPanelFreezed = false, 25) setTimeout(() => modifierPanelFreezed = false, 25)
} }
}).observe(modifierSettingsOverlay, { attributes: true }) }).observe(modifierSettingsDialog, { attributes: true })
modifierSettingsCloseBtn.addEventListener("click", (e) => {
modifierSettingsDialog.close()
})
modifierSettingsDialog.addEventListener('click', function (event) {
var rect = modifierSettingsDialog.getBoundingClientRect();
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
&& rect.left <= event.clientX && event.clientX <= rect.left + rect.width);
if (!isInDialog) {
modifierSettingsDialog.close();
}
});

View File

@ -30,7 +30,15 @@
// ---- Add HTML // ---- Add HTML
document.getElementById('container').lastElementChild.insertAdjacentHTML("afterend", document.getElementById('container').lastElementChild.insertAdjacentHTML("afterend",
`<dialog id="download-tiled-image-dialog"> `<dialog id="download-tiled-image-dialog">
<h1>Download tiled image</h1> <div class="dialog-header">
<div class="dialog-header-left">
<h4>Download tiled image</h4>
<span>Generate a larger image from this tile</span>
</div>
<div id="modifier-settings-header-right">
<i id="downnload-tiled-close-button" class="fa-solid fa-xmark fa-lg"></i>
</div>
</div>
<div class="download-tiled-image dtim-container"> <div class="download-tiled-image dtim-container">
<div class="download-tiled-image-top"> <div class="download-tiled-image-top">
<div class="tab-container"> <div class="tab-container">
@ -130,6 +138,7 @@
// ---- Close popup // ---- Close popup
document.getElementById("dti-cancel").addEventListener("click", (e) => downloadTiledImageDialog.close()) document.getElementById("dti-cancel").addEventListener("click", (e) => downloadTiledImageDialog.close())
document.getElementById("downnload-tiled-close-button").addEventListener("click", (e) => downloadTiledImageDialog.close())
downloadTiledImageDialog.addEventListener('click', function (event) { downloadTiledImageDialog.addEventListener('click', function (event) {
var rect = downloadTiledImageDialog.getBoundingClientRect(); var rect = downloadTiledImageDialog.getBoundingClientRect();
var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height var isInDialog=(rect.top <= event.clientY && event.clientY <= rect.top + rect.height
@ -142,18 +151,6 @@
// ---- Stylesheet // ---- Stylesheet
const styleSheet = document.createElement("style") const styleSheet = document.createElement("style")
styleSheet.textContent = ` styleSheet.textContent = `
dialog {
background: var(--background-color2);
color: var(--text-color);
border-radius: 7px;
border: 1px solid var(--background-color3);
}
dialog::backdrop {
background: rgba(0, 0, 0, 0.5);
}
button[disabled] { button[disabled] {
opacity: 0.5; opacity: 0.5;
} }