diff --git a/README.md b/README.md index 94517cb..25521ba 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,7 @@ or `No - selecting unselects previous` (click an image to select it and unselect - `Show a small popup instead of covering the screen` - instead of taking over the whole screen immediately, display a tiny version of the image in the top left. Click that image to go into the full screen mode. You can move the tiny image window around to where you want it by dragging the title bar. - `Enter the Image Filter node with an image zoomed` - instead of showing the grid of images, zoom in on one. Options are `first` or `last` - `Play sound when activating` - play a 'ding' sound when any of the filter nodes becomes active. You can change the sound by replacing the file `ding.mp3` in the `js` subfolder. +- `Reminder sound every x seconds` - the 'ding' is repeated after x seconds if you are not interacting with the window. - `Video Frames per Second` - when previewing video(s), try to play them at this speed --- diff --git a/js/image_filter.js b/js/image_filter.js index 73368c8..31569b3 100644 --- a/js/image_filter.js +++ b/js/image_filter.js @@ -33,6 +33,14 @@ app.registerExtension({ type: "boolean", defaultValue: true }, + { + id: "Image Filter.UI.Sound Timeout", + name: "Reminder sound every x seconds", + type: "int", + defaultValue: 30, + onChange: popup.setup_sound_throttle.bind(popup) + }, + { id: "Image Filter.UI.Enlarge Small Images", name: "Enlarge small images in grid", diff --git a/js/popup.js b/js/popup.js index 4ff273b..8217269 100644 --- a/js/popup.js +++ b/js/popup.js @@ -3,7 +3,7 @@ import { api } from "../../scripts/api.js" import { mask_editor_listen_for_cancel, mask_editor_showing, hide_mask_editor, press_maskeditor_cancel, press_maskeditor_save, new_editor, open_maskeditor } from "./mask_utils.js"; import { Log } from "./log.js"; -import { create } from "./utils.js"; +import { create, CallbackThrottle } from "./utils.js"; import { FloatingWindow } from "./floating_window.js"; import { graph_id_to_tab } from "./graph_map.js"; @@ -98,11 +98,20 @@ class Popup extends HTMLElement { document.addEventListener("keydown", this.on_key_down.bind(this)) document.addEventListener("keypress", this.on_key_press.bind(this)) + document.addEventListener("click", ()=>this.sound_maker.reset()) + this.text_edit.addEventListener('input', ()=>this.sound_maker.reset()) + document.body.appendChild(this) this.last_response_sent = 0 this.state = State.INACTIVE this.hidden_by_toggle = false this.render() + this.setup_sound_throttle() + } + + setup_sound_throttle() { + const t = app.ui.settings.getSettingValue("Image Filter.UI.Sound Timeout") + this.sound_maker = new CallbackThrottle( this.maybe_play_sound.bind(this), t ) } unique_id() { return `${app.graph.id}:${this.node?.id}` } @@ -186,6 +195,8 @@ class Popup extends HTMLElement { *graph_id (string) (*) are added */ + this.sound_maker.unreset() + if (Date.now()-this.last_response_sent < 1000) { Log.message_out(msg, "(throttled)") return @@ -362,7 +373,7 @@ class Popup extends HTMLElement { this.state = State.TINY this.saved_message = message this.tiny_image.src = get_full_url(message.detail.urls[message.detail.urls.length-1]) - this.maybe_play_sound() + this.sound_maker.request() return `Deferring message and showing small window` } @@ -372,7 +383,7 @@ class Popup extends HTMLElement { this.extras_row.innerHTML = '' for (let i=0; i this.millisecs) { + console.log(`Callback`) + this.callback() + this.reset() + } + } } \ No newline at end of file