-
Notifications
You must be signed in to change notification settings - Fork 500
Fixed Brush Settings Post Refactor and Added Numeric Control #7783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
88f9906
Updated brush settings and added numeric control
brucew4yn3rp 77839b0
Revert styles.css
brucew4yn3rp bf94fbd
Resolve BrushSettingsPanel.vue comments
brucew4yn3rp 734b084
consolidate BrushSettingsPanel layout and reduce handler boilerplate
brucew4yn3rp efa2de2
Added keyboard shortcut for color picker and adjusted thickness max
brucew4yn3rp e7badcf
Merge branch 'main' into maskeditor-brush-sizes
DrJKL 8c3485b
v-model binding, remove arbitrary classes, and added colorInput ref
brucew4yn3rp a6366d6
Fixed clamping for numeric inputs with v-model
brucew4yn3rp 7dec1a0
Merge branch 'main' into maskeditor-brush-sizes
brucew4yn3rp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,129 +1,218 @@ | ||
| <template> | ||
| <div class="flex flex-col gap-3 pb-3"> | ||
| <h3 | ||
| class="text-center text-[15px] font-sans text-[var(--descrip-text)] mt-2.5" | ||
| > | ||
| <h3 class="text-center text-[15px] font-sans text-descrip-text mt-2.5"> | ||
| {{ t('maskEditor.brushSettings') }} | ||
| </h3> | ||
|
|
||
| <button :class="textButtonClass" @click="resetToDefault"> | ||
| {{ t('maskEditor.resetToDefault') }} | ||
| </button> | ||
|
|
||
| <!-- Brush Shape --> | ||
| <div class="flex flex-col gap-3 pb-3"> | ||
| <span class="text-left text-xs font-sans text-[var(--descrip-text)]">{{ | ||
| t('maskEditor.brushShape') | ||
| }}</span> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.brushShape') }} | ||
| </span> | ||
|
|
||
| <div | ||
| class="flex flex-row gap-2.5 items-center min-h-6 relative h-[50px] w-full rounded-[10px] bg-secondary-background-hover" | ||
| class="flex flex-row gap-2.5 items-center h-[50px] w-full rounded-[10px] bg-secondary-background-hover" | ||
| > | ||
| <div | ||
| class="maskEditor_sidePanelBrushShapeCircle bg-transparent hover:bg-comfy-menu-bg" | ||
| :class="{ active: store.brushSettings.type === BrushShape.Arc }" | ||
| :style="{ | ||
| background: | ||
| class="maskEditor_sidePanelBrushShapeCircle hover:bg-comfy-menu-bg" | ||
| :class=" | ||
| cn( | ||
| store.brushSettings.type === BrushShape.Arc | ||
| ? 'var(--p-button-text-primary-color)' | ||
| : '' | ||
| }" | ||
| ? 'bg-[var(--p-button-text-primary-color)] active' | ||
| : 'bg-transparent' | ||
| ) | ||
| " | ||
| @click="setBrushShape(BrushShape.Arc)" | ||
| ></div> | ||
|
|
||
| <div | ||
| class="maskEditor_sidePanelBrushShapeSquare bg-transparent hover:bg-comfy-menu-bg" | ||
| :class="{ active: store.brushSettings.type === BrushShape.Rect }" | ||
| :style="{ | ||
| background: | ||
| class="maskEditor_sidePanelBrushShapeSquare hover:bg-comfy-menu-bg" | ||
| :class=" | ||
| cn( | ||
| store.brushSettings.type === BrushShape.Rect | ||
| ? 'var(--p-button-text-primary-color)' | ||
| : '' | ||
| }" | ||
| ? 'bg-[var(--p-button-text-primary-color)] active' | ||
| : 'bg-transparent' | ||
| ) | ||
| " | ||
| @click="setBrushShape(BrushShape.Rect)" | ||
| ></div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <!-- Color --> | ||
| <div class="flex flex-col gap-3 pb-3"> | ||
| <span class="text-left text-xs font-sans text-[var(--descrip-text)]">{{ | ||
| t('maskEditor.colorSelector') | ||
| }}</span> | ||
| <input type="color" :value="store.rgbColor" @input="onColorChange" /> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.colorSelector') }} | ||
| </span> | ||
| <input | ||
| ref="colorInputRef" | ||
| v-model="store.rgbColor" | ||
| type="color" | ||
| class="h-10 rounded-md cursor-pointer" | ||
| /> | ||
| </div> | ||
brucew4yn3rp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| <!-- Thickness --> | ||
| <div class="flex flex-col gap-2"> | ||
| <div class="flex items-center justify-between"> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.thickness') }} | ||
| </span> | ||
| <input | ||
| v-model.number="brushSize" | ||
| type="number" | ||
| class="w-16 px-2 py-1 text-sm text-center border rounded-md bg-comfy-menu-bg border-p-form-field-border-color text-input-text" | ||
| :min="1" | ||
| :max="250" | ||
| :step="1" | ||
| /> | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| <SliderControl | ||
| v-model="brushSize" | ||
| class="flex-1" | ||
| label="" | ||
| :min="1" | ||
| :max="250" | ||
| :step="1" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Opacity --> | ||
| <div class="flex flex-col gap-2"> | ||
| <div class="flex items-center justify-between"> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.opacity') }} | ||
| </span> | ||
| <input | ||
| v-model.number="brushOpacity" | ||
| type="number" | ||
| class="w-16 px-2 py-1 text-sm text-center border rounded-md bg-comfy-menu-bg border-p-form-field-border-color text-input-text" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| /> | ||
| </div> | ||
| <SliderControl | ||
| v-model="brushOpacity" | ||
| class="flex-1" | ||
| label="" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| /> | ||
| </div> | ||
|
|
||
| <!-- Hardness --> | ||
| <div class="flex flex-col gap-2"> | ||
| <div class="flex items-center justify-between"> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.hardness') }} | ||
| </span> | ||
| <input | ||
| v-model.number="brushHardness" | ||
| type="number" | ||
| class="w-16 px-2 py-1 text-sm text-center border rounded-md bg-comfy-menu-bg border-p-form-field-border-color text-input-text" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| /> | ||
| </div> | ||
| <SliderControl | ||
| v-model="brushHardness" | ||
| class="flex-1" | ||
| label="" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| /> | ||
| </div> | ||
|
|
||
| <SliderControl | ||
| :label="t('maskEditor.thickness')" | ||
| :min="1" | ||
| :max="500" | ||
| :step="1" | ||
| :model-value="store.brushSettings.size" | ||
| @update:model-value="onThicknessChange" | ||
| /> | ||
|
|
||
| <SliderControl | ||
| :label="t('maskEditor.opacity')" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| :model-value="store.brushSettings.opacity" | ||
| @update:model-value="onOpacityChange" | ||
| /> | ||
|
|
||
| <SliderControl | ||
| :label="t('maskEditor.hardness')" | ||
| :min="0" | ||
| :max="1" | ||
| :step="0.01" | ||
| :model-value="store.brushSettings.hardness" | ||
| @update:model-value="onHardnessChange" | ||
| /> | ||
|
|
||
| <SliderControl | ||
| :label="$t('maskEditor.stepSize')" | ||
| :min="1" | ||
| :max="100" | ||
| :step="1" | ||
| :model-value="store.brushSettings.stepSize" | ||
| @update:model-value="onStepSizeChange" | ||
| /> | ||
| <!-- Step Size --> | ||
| <div class="flex flex-col gap-2"> | ||
| <div class="flex items-center justify-between"> | ||
| <span class="text-left text-xs font-sans text-descrip-text"> | ||
| {{ t('maskEditor.stepSize') }} | ||
| </span> | ||
| <input | ||
| v-model.number="brushStepSize" | ||
| type="number" | ||
| class="w-16 px-2 py-1 text-sm text-center border rounded-md bg-comfy-menu-bg border-p-form-field-border-color text-input-text" | ||
| :min="1" | ||
| :max="100" | ||
| :step="1" | ||
| /> | ||
| </div> | ||
| <SliderControl | ||
| v-model="brushStepSize" | ||
| class="flex-1" | ||
| label="" | ||
| :min="1" | ||
| :max="100" | ||
| :step="1" | ||
| /> | ||
| </div> | ||
brucew4yn3rp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed, onBeforeUnmount, onMounted, ref } from 'vue' | ||
|
|
||
| import { BrushShape } from '@/extensions/core/maskeditor/types' | ||
| import { t } from '@/i18n' | ||
| import { useMaskEditorStore } from '@/stores/maskEditorStore' | ||
| import { cn } from '@/utils/tailwindUtil' | ||
|
|
||
| import SliderControl from './controls/SliderControl.vue' | ||
|
|
||
| const store = useMaskEditorStore() | ||
|
|
||
| const textButtonClass = | ||
| 'h-7.5 w-32 rounded-[10px] border border-[var(--p-form-field-border-color)] text-[var(--input-text)] font-sans pointer-events-auto transition-colors duration-100 bg-[var(--comfy-menu-bg)] hover:bg-secondary-background-hover' | ||
| const colorInputRef = ref<HTMLInputElement>() | ||
|
|
||
| const textButtonClass = | ||
| 'h-7.5 w-32 rounded-[10px] border border-p-form-field-border-color text-input-text font-sans transition-colors duration-100 bg-comfy-menu-bg hover:bg-secondary-background-hover' | ||
|
|
||
| /* Computed properties that use store setters for validation */ | ||
| const brushSize = computed({ | ||
| get: () => store.brushSettings.size, | ||
| set: (value: number) => store.setBrushSize(value) | ||
| }) | ||
|
|
||
| const brushOpacity = computed({ | ||
| get: () => store.brushSettings.opacity, | ||
| set: (value: number) => store.setBrushOpacity(value) | ||
| }) | ||
|
|
||
| const brushHardness = computed({ | ||
| get: () => store.brushSettings.hardness, | ||
| set: (value: number) => store.setBrushHardness(value) | ||
| }) | ||
|
|
||
| const brushStepSize = computed({ | ||
| get: () => store.brushSettings.stepSize, | ||
| set: (value: number) => store.setBrushStepSize(value) | ||
| }) | ||
|
|
||
| /* Brush shape */ | ||
| const setBrushShape = (shape: BrushShape) => { | ||
| store.brushSettings.type = shape | ||
| } | ||
|
|
||
| const onColorChange = (event: Event) => { | ||
| store.rgbColor = (event.target as HTMLInputElement).value | ||
| } | ||
|
|
||
| const onThicknessChange = (value: number) => { | ||
| store.setBrushSize(value) | ||
| } | ||
|
|
||
| const onOpacityChange = (value: number) => { | ||
| store.setBrushOpacity(value) | ||
| } | ||
|
|
||
| const onHardnessChange = (value: number) => { | ||
| store.setBrushHardness(value) | ||
| } | ||
|
|
||
| const onStepSizeChange = (value: number) => { | ||
| store.setBrushStepSize(value) | ||
| } | ||
|
|
||
| /* Reset */ | ||
| const resetToDefault = () => { | ||
| store.resetBrushToDefault() | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| if (colorInputRef.value) { | ||
| store.colorInput = colorInputRef.value | ||
| } | ||
| }) | ||
|
|
||
| onBeforeUnmount(() => { | ||
| store.colorInput = null | ||
| }) | ||
| </script> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.