add reprocess plus major processing refactor

This commit is contained in:
Vladimir Mandic
2024-09-24 20:31:05 -04:00
parent 1395f5bf9e
commit 4136983f82
32 changed files with 377 additions and 222 deletions
+15 -10
View File
@@ -1,20 +1,22 @@
// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes
function attachGalleryListeners(tab_name) {
const gallery = gradioApp().querySelector(`#${tab_name}_gallery`);
function attachGalleryListeners(tabName) {
const gallery = gradioApp().querySelector(`#${tabName}_gallery`);
if (!gallery) return null;
gallery.addEventListener('click', () => setTimeout(() => {
log('galleryItemSelected:', tab_name);
gradioApp().getElementById(`${tab_name}_generation_info_button`)?.click();
}, 500));
gallery.addEventListener('click', () => {
// log('galleryItemSelected:', tabName);
const btn = gradioApp().getElementById(`${tabName}_generation_info_button`);
if (btn) btn.click();
});
gallery?.addEventListener('keydown', (e) => {
if (e.keyCode === 37 || e.keyCode === 39) gradioApp().getElementById(`${tab_name}_generation_info_button`).click(); // left or right arrow
if (e.keyCode === 37 || e.keyCode === 39) gradioApp().getElementById(`${tabName}_generation_info_button`).click(); // left or right arrow
});
return gallery;
}
let txt2img_gallery;
let img2img_gallery;
let control_gallery;
let modal;
async function initiGenerationParams() {
@@ -23,14 +25,17 @@ async function initiGenerationParams() {
const modalObserver = new MutationObserver((mutations) => {
mutations.forEach((mutationRecord) => {
let selectedTab = gradioApp().querySelector('#tabs div button.selected')?.innerText;
if (!selectedTab) selectedTab = gradioApp().querySelector('#tabs div button')?.innerText;
if (mutationRecord.target.style.display === 'none' && (selectedTab === 'txt2img' || selectedTab === 'img2img')) { gradioApp().getElementById(`${selectedTab}_generation_info_button`)?.click(); }
const tabName = getENActiveTab();
if (mutationRecord.target.style.display === 'none') {
const btn = gradioApp().getElementById(`${tabName}_generation_info_button`);
if (btn) btn.click();
}
});
});
if (!txt2img_gallery) txt2img_gallery = attachGalleryListeners('txt2img');
if (!img2img_gallery) img2img_gallery = attachGalleryListeners('img2img');
if (!control_gallery) control_gallery = attachGalleryListeners('control');
modalObserver.observe(modal, { attributes: true, attributeFilter: ['style'] });
log('initGenerationParams');
}