Skip to content

Commit

Permalink
Add back the overlay to show current down keys for #376
Browse files Browse the repository at this point in the history
  • Loading branch information
rgthree committed Nov 24, 2024
1 parent 8df5e33 commit 6d22bbf
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
3 changes: 3 additions & 0 deletions py/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ def refresh_config():
if "unreleased" in USER_CONFIG and "unreleased" not in RGTHREE_CONFIG:
RGTHREE_CONFIG["unreleased"] = USER_CONFIG["unreleased"]

if "debug" in USER_CONFIG and "debug" not in RGTHREE_CONFIG:
RGTHREE_CONFIG["debug"] = USER_CONFIG["debug"]


def get_config():
"""Returns the congfig."""
Expand Down
3 changes: 2 additions & 1 deletion src_web/comfyui/rgthree.scss
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,11 @@ body:not([style*=grid]):not([class*=grid]) {
.rgthree-debug-keydowns {
display: block;
position: fixed;
z-index: 999;
z-index: 1050;
top: 3px;
right: 8px;
font-size: 10px;
color: #fff;
font-family: sans-serif;
pointer-events: none;
}
14 changes: 12 additions & 2 deletions src_web/comfyui/rgthree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {ComfyApiFormat, ComfyApiPrompt, ComfyApp} from "typings/comfy.js";
import {app} from "scripts/app.js";
import {api} from "scripts/api.js";
import {SERVICE as CONFIG_SERVICE} from "./services/config_service.js";
import {SERVICE as KEY_EVENT_SERVICE} from "./services/key_events_services.js";
import {fixBadLinks} from "rgthree/common/link_fixer.js";
import {injectCss, wait} from "rgthree/common/shared_utils.js";
import {replaceNode, waitForCanvas, waitForGraph} from "./utils.js";
Expand Down Expand Up @@ -242,8 +243,6 @@ class Rgthree extends EventTarget {
canvasCurrentlyCopyingToClipboardWithMultipleNodes = false;
initialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff: any = null;

private elDebugKeydowns: HTMLDivElement | null = null;

private readonly isMac: boolean = !!(
navigator.platform?.toLocaleUpperCase().startsWith("MAC") ||
(navigator as any).userAgentData?.platform?.toLocaleUpperCase().startsWith("MAC")
Expand All @@ -269,6 +268,17 @@ class Rgthree extends EventTarget {
this.initializeProgressBar();
}
}) as EventListener);

if (CONFIG_SERVICE.getConfigValue("debug.keys_down.enabled")) {
const elDebugKeydowns = createElement<HTMLDivElement>("div.rgthree-debug-keydowns", {
parent: document.body,
});
const updateDebugKeyDown = () => {
elDebugKeydowns.innerText = Object.keys(KEY_EVENT_SERVICE.downKeys).join(" ");
}
KEY_EVENT_SERVICE.addEventListener("keydown", updateDebugKeyDown);
KEY_EVENT_SERVICE.addEventListener("keyup", updateDebugKeyDown);
}
}

/**
Expand Down
3 changes: 2 additions & 1 deletion web/comfyui/rgthree.css
Original file line number Diff line number Diff line change
Expand Up @@ -627,10 +627,11 @@ body:not([style*=grid]):not([class*=grid]) rgthree-progress-bar.rgthree-pos-bott
.rgthree-debug-keydowns {
display: block;
position: fixed;
z-index: 999;
z-index: 1050;
top: 3px;
right: 8px;
font-size: 10px;
color: #fff;
font-family: sans-serif;
pointer-events: none;
}
14 changes: 12 additions & 2 deletions web/comfyui/rgthree.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js";
import { SERVICE as CONFIG_SERVICE } from "./services/config_service.js";
import { SERVICE as KEY_EVENT_SERVICE } from "./services/key_events_services.js";
import { fixBadLinks } from "../../rgthree/common/link_fixer.js";
import { injectCss, wait } from "../../rgthree/common/shared_utils.js";
import { replaceNode, waitForCanvas, waitForGraph } from "./utils.js";
import { NodeTypesString, addRgthree, getNodeTypeStrings } from "./constants.js";
import { RgthreeProgressBar } from "../../rgthree/common/progress_bar.js";
import { RgthreeConfigDialog } from "./config.js";
import { iconGear, iconNode, iconReplace, iconStarFilled, logoRgthree, } from "../../rgthree/common/media/svgs.js";
import { query, queryOne } from "../../rgthree/common/utils_dom.js";
import { createElement, query, queryOne } from "../../rgthree/common/utils_dom.js";
export var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["IMPORTANT"] = 1] = "IMPORTANT";
Expand Down Expand Up @@ -138,7 +139,6 @@ class Rgthree extends EventTarget {
this.canvasCurrentlyCopyingToClipboard = false;
this.canvasCurrentlyCopyingToClipboardWithMultipleNodes = false;
this.initialGraphToPromptSerializedWorkflowBecauseComfyUIBrokeStuff = null;
this.elDebugKeydowns = null;
this.isMac = !!(((_a = navigator.platform) === null || _a === void 0 ? void 0 : _a.toLocaleUpperCase().startsWith("MAC")) ||
((_c = (_b = navigator.userAgentData) === null || _b === void 0 ? void 0 : _b.platform) === null || _c === void 0 ? void 0 : _c.toLocaleUpperCase().startsWith("MAC")));
const logLevel = (_d = LogLevelKeyToLogLevel[CONFIG_SERVICE.getConfigValue("log_level")]) !== null && _d !== void 0 ? _d : GLOBAL_LOG_LEVEL;
Expand All @@ -154,6 +154,16 @@ class Rgthree extends EventTarget {
this.initializeProgressBar();
}
}));
if (CONFIG_SERVICE.getConfigValue("debug.keys_down.enabled")) {
const elDebugKeydowns = createElement("div.rgthree-debug-keydowns", {
parent: document.body,
});
const updateDebugKeyDown = () => {
elDebugKeydowns.innerText = Object.keys(KEY_EVENT_SERVICE.downKeys).join(" ");
};
KEY_EVENT_SERVICE.addEventListener("keydown", updateDebugKeyDown);
KEY_EVENT_SERVICE.addEventListener("keyup", updateDebugKeyDown);
}
}
async initializeProgressBar() {
var _a;
Expand Down

0 comments on commit 6d22bbf

Please sign in to comment.