From 825ec722c3a2b5c801541c45a321f4d1480640d4 Mon Sep 17 00:00:00 2001 From: brucew4yn3rp <135722417+brucew4yn3rp@users.noreply.github.com> Date: Sat, 3 Jan 2026 10:33:57 -0500 Subject: [PATCH] Fixed Brush Settings Post Refactor and Added Numeric Control (#7783) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Refactored BrushSettingsPanel layout to stack labels and number inputs above sliders, and fixed brush size keybinding limits to match the updated 1-250 range. ## Changes - **What**: - Reorganized BrushSettingsPanel UI to display labels and number inputs in a row above each slider (instead of side-by-side), creating a cleaner vertical layout with better visual hierarchy. - Updated brush size increase/decrease keybindings to clamp between 1-250 (previously 1-100) to match the refactored slider limits. - Added setting for color picker keybinding - **Breaking**: None ## Review Focus - Verify the stacked layout (label + number input above slider) works well across different panel widths - Confirm all slider controls properly sync with their corresponding number inputs - Test brush size keybindings (increase/decrease) respect the new 1-250 limits ## Screenshot image ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7783-Fixed-Brush-Settings-Port-Refactor-and-Added-Numeric-Control-2d76d73d365081bda7a8e12d3c649085) by [Unito](https://www.unito.io) --------- Co-authored-by: Alexander Brown --- .../maskeditor/BrushSettingsPanel.vue | 247 ++++++++++++------ .../maskeditor/MaskEditorContent.vue | 1 + src/extensions/core/maskeditor.ts | 33 ++- src/stores/maskEditorStore.ts | 6 +- 4 files changed, 196 insertions(+), 91 deletions(-) diff --git a/src/components/maskeditor/BrushSettingsPanel.vue b/src/components/maskeditor/BrushSettingsPanel.vue index 444dc8ceb..7054f1a15 100644 --- a/src/components/maskeditor/BrushSettingsPanel.vue +++ b/src/components/maskeditor/BrushSettingsPanel.vue @@ -1,8 +1,6 @@ diff --git a/src/components/maskeditor/MaskEditorContent.vue b/src/components/maskeditor/MaskEditorContent.vue index 999f81775..a524edfcb 100644 --- a/src/components/maskeditor/MaskEditorContent.vue +++ b/src/components/maskeditor/MaskEditorContent.vue @@ -202,6 +202,7 @@ onBeforeUnmount(() => { } store.canvasHistory.clearStates() + store.resetState() dataStore.reset() }) diff --git a/src/extensions/core/maskeditor.ts b/src/extensions/core/maskeditor.ts index d5bbe5e97..406fdcd7d 100644 --- a/src/extensions/core/maskeditor.ts +++ b/src/extensions/core/maskeditor.ts @@ -37,6 +37,15 @@ function isOpened(): boolean { return useDialogStore().isDialogOpen('global-mask-editor') } +const changeBrushSize = async (sizeChanger: (oldSize: number) => number) => { + if (!isOpened()) return + + const store = useMaskEditorStore() + const oldBrushSize = store.brushSettings.size + const newBrushSize = sizeChanger(oldBrushSize) + store.setBrushSize(newBrushSize) +} + app.registerExtension({ name: 'Comfy.MaskEditor', settings: [ @@ -82,13 +91,24 @@ app.registerExtension({ id: 'Comfy.MaskEditor.BrushSize.Increase', icon: 'pi pi-plus-circle', label: 'Increase Brush Size in MaskEditor', - function: () => changeBrushSize((old) => _.clamp(old + 4, 1, 100)) + function: () => changeBrushSize((old) => _.clamp(old + 2, 1, 250)) }, { id: 'Comfy.MaskEditor.BrushSize.Decrease', icon: 'pi pi-minus-circle', label: 'Decrease Brush Size in MaskEditor', - function: () => changeBrushSize((old) => _.clamp(old - 4, 1, 100)) + function: () => changeBrushSize((old) => _.clamp(old - 2, 1, 250)) + }, + { + id: 'Comfy.MaskEditor.ColorPicker', + icon: 'pi pi-palette', + label: 'Open Color Picker in MaskEditor', + function: () => { + if (!isOpened()) return + + const store = useMaskEditorStore() + store.colorInput?.click() + } } ], init() { @@ -101,12 +121,3 @@ app.registerExtension({ ) } }) - -const changeBrushSize = async (sizeChanger: (oldSize: number) => number) => { - if (!isOpened()) return - - const store = useMaskEditorStore() - const oldBrushSize = store.brushSettings.size - const newBrushSize = sizeChanger(oldBrushSize) - store.setBrushSize(newBrushSize) -} diff --git a/src/stores/maskEditorStore.ts b/src/stores/maskEditorStore.ts index b52edf7be..d2140e845 100644 --- a/src/stores/maskEditorStore.ts +++ b/src/stores/maskEditorStore.ts @@ -73,6 +73,8 @@ export const useMaskEditorStore = defineStore('maskEditor', () => { const tgpuRoot = ref(null) + const colorInput = ref(null) + watch(maskCanvas, (canvas) => { if (canvas) { maskCtx.value = canvas.getContext('2d', { willReadFrequently: true }) @@ -113,7 +115,7 @@ export const useMaskEditorStore = defineStore('maskEditor', () => { }) function setBrushSize(size: number): void { - brushSettings.value.size = _.clamp(size, 1, 500) + brushSettings.value.size = _.clamp(size, 1, 250) } function setBrushOpacity(opacity: number): void { @@ -252,6 +254,8 @@ export const useMaskEditorStore = defineStore('maskEditor', () => { tgpuRoot, + colorInput, + setBrushSize, setBrushOpacity, setBrushHardness,