From 967b49842fc62a195794b1126e18d0cc57162137 Mon Sep 17 00:00:00 2001 From: Victor Seiji Hariki Date: Tue, 3 Jan 2023 12:50:38 -0300 Subject: [PATCH] fix dream cursor shows on img2img Signed-off-by: Victor Seiji Hariki --- index.html | 4 ++-- js/lib/toolbar.js | 8 ++++---- js/ui/tool/dream.js | 8 +++++--- pages/embed.test.html | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index f1c7e36..d2f6b96 100644 --- a/index.html +++ b/index.html @@ -328,7 +328,7 @@ - + - + diff --git a/js/lib/toolbar.js b/js/lib/toolbar.js index 10e48f8..4a82f0f 100644 --- a/js/lib/toolbar.js +++ b/js/lib/toolbar.js @@ -106,24 +106,24 @@ const toolbar = { while (contextMenuEl.lastChild) { contextMenuEl.removeChild(contextMenuEl.lastChild); } - options.populateContextMenu(contextMenuEl, tool.state); + options.populateContextMenu(contextMenuEl, tool.state, tool); tool._element && tool._element.classList.add("using"); tool.enabled = true; this._current_tool = tool; - enable(tool.state, opt); + enable(tool.state, opt, tool); }, disable: (opt = null) => { tool._element && tool._element.classList.remove("using"); this._current_tool = null; tool.enabled = false; - disable(tool.state, opt); + disable(tool.state, opt, tool); }, }; // Initalize - options.init && options.init(tool.state); + options.init && options.init(tool.state, tool); this.tools.push(tool); diff --git a/js/ui/tool/dream.js b/js/ui/tool/dream.js index 8d04257..e8d9e54 100644 --- a/js/ui/tool/dream.js +++ b/js/ui/tool/dream.js @@ -1441,7 +1441,7 @@ const dreamTool = () => dream_erase_callback(bb, state); }; }, - populateContextMenu: (menu, state) => { + populateContextMenu: (menu, state, tool) => { if (!state.ctxmenu) { state.ctxmenu = {}; @@ -1463,7 +1463,7 @@ const dreamTool = () => resSlider.value = state.cursorSize; } - state.redraw(); + if (tool.enabled) state.redraw(); }, } ); @@ -1972,7 +1972,7 @@ const img2imgTool = () => dream_erase_callback(bb, state); }; }, - populateContextMenu: (menu, state) => { + populateContextMenu: (menu, state, tool) => { if (!state.ctxmenu) { state.ctxmenu = {}; @@ -1990,6 +1990,8 @@ const img2imgTool = () => if (global.syncCursorSize) { resSlider.value = state.cursorSize; } + + if (tool.enabled) state.redraw(); }, } ); diff --git a/pages/embed.test.html b/pages/embed.test.html index 1376eb6..94fce93 100644 --- a/pages/embed.test.html +++ b/pages/embed.test.html @@ -8,8 +8,8 @@