diff --git a/image_filter.py b/image_filter.py index 52b43fe..7b73098 100644 --- a/image_filter.py +++ b/image_filter.py @@ -68,8 +68,10 @@ class ImageFilter(PreviewImage): return float("NaN") def func(self, images, timeout, ontimeout, uid, latents=None, masks=None, **kwargs): + B = images.shape[0] + all_the_same = ( B and all( (images[i]==images[0]).all() for i in range(1,B) )) urls:list[str] = self.save_images(images=images, **kwargs)['ui']['images'] - PromptServer.instance.send_sync("cg-image-filter-images", {"uid": uid, "urls":urls}) + PromptServer.instance.send_sync("cg-image-filter-images", {"uid": uid, "urls":urls, "allsame":all_the_same}) response = wait(timeout) if not response: diff --git a/js/filter.css b/js/filter.css index ba3e6d4..7c60eb6 100644 --- a/js/filter.css +++ b/js/filter.css @@ -38,11 +38,11 @@ .cg_popup .buttons { position: absolute; - width:15%; - left:85%; + width:14%; + left:86%; height:90%; top:5%; - padding: 20px; + font-size: small; } .cg_popup .control_text:after { diff --git a/js/popup.js b/js/popup.js index c10f3a5..fdb48c3 100644 --- a/js/popup.js +++ b/js/popup.js @@ -19,8 +19,8 @@ class Popup extends HTMLSpanElement { this.click_sends = create('input', 'control', this.checkboxes, {type:"checkbox", id:"click_sends"}) this.click_sends_label = create('label', 'control_text', this.checkboxes, {for:"click_sends", innerText:"click to send"}) this.auto_send = create('input', 'control', this.checkboxes, {type:"checkbox", id:"auto_send"}) - this.auto_sends_label = create('label', 'control_text', this.checkboxes, {for:"auto_send", innerText:"auto send if identical"}) - this.play_sound = create('input', 'control', this.checkboxes, {type:"checkbox", id:"play_sound"}) + this.auto_sends_label = create('label', 'control_text', this.checkboxes, {for:"auto_send", innerText:"autosend one if identical"}) + this.play_sound = create('input', 'control', this.checkboxes, {type:"checkbox", id:"play_sound", checked:true}) this.play_sound_label = create('label', 'control_text', this.checkboxes, {for:"play_sound", innerText:"play sound"}) this.send_button = create('button', 'control', this.buttons, {innerText:"Send (S)"} ) this.cancel_button = create('button', 'control', this.buttons, {innerText:"Cancel (X)"} ) @@ -63,6 +63,7 @@ class Popup extends HTMLSpanElement { handle_message(message) { const detail = message.detail + this.allsame = detail.allsame || false if (detail.timeout) this.handle_timeout(detail) else if (detail.tick) this.handle_tick(detail) else if (detail.maskedit) this.handle_maskedit(detail) @@ -104,6 +105,12 @@ class Popup extends HTMLSpanElement { const extra = create('input', 'extra', this.extras, {value:detail.extras[i]}) } + // do this after the extras are set up so that we send the right extras + if (this.auto_send.checked && this.allsame) { + this._send_response("0") + return + } + this.doing_text = (detail.text != null) this.n_images = detail.urls?.length @@ -156,9 +163,6 @@ class Popup extends HTMLSpanElement { } layout() { - if (this.auto_send.checked) { - // check for all the same - } if (this.laidOut) return const im_w = this.grid.firstChild.naturalWidth @@ -198,8 +202,15 @@ class Popup extends HTMLSpanElement { else c.classList.remove('selected') }) this.send_button.disabled = (!this.doing_text && (this.click_sends.checked || this.picked.size==0)) + this.cancel_button.style.visibility = (this.doing_text) ? 'hidden' : 'visible' - this.checkboxes.style.visibility = (this.doing_text) ? 'hidden' : 'visible' + + this.auto_send.style.visibility = (this.n_images>1) ? 'visible' : 'hidden' + this.auto_send_label.style.visibility = (this.n_images>1) ? 'visible' : 'hidden' + + this.click_sends.style.visibility = (this.doing_text) ? 'hidden' : 'visible' + this.click_sends_label.style.visibility = (this.doing_text) ? 'hidden' : 'visible' + this.send_button.innerText = (this.doing_text) ? 'Send' : 'Send (S)' }