diff --git a/src/app/components/slider-with-value/slider-with-value.component.html b/src/app/components/slider-with-value/slider-with-value.component.html new file mode 100644 index 0000000..c64cde9 --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.html @@ -0,0 +1,4 @@ +
+ + +
diff --git a/src/app/components/slider-with-value/slider-with-value.component.scss b/src/app/components/slider-with-value/slider-with-value.component.scss new file mode 100644 index 0000000..7eb920f --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.scss @@ -0,0 +1,9 @@ +div > input { + &:first-child { + flex: 85% 1 1; + margin-right: 1vw; + } + &:last-child { + flex: 15% 1 1; + } +} diff --git a/src/app/components/slider-with-value/slider-with-value.component.ts b/src/app/components/slider-with-value/slider-with-value.component.ts new file mode 100644 index 0000000..bbc9a6b --- /dev/null +++ b/src/app/components/slider-with-value/slider-with-value.component.ts @@ -0,0 +1,64 @@ +import {Component, effect, input, signal, WritableSignal} from '@angular/core'; +import {ControlValueAccessor, NG_VALUE_ACCESSOR, ReactiveFormsModule} from "@angular/forms"; +import {OnChange, OnTouched} from "../../types/value-accessor"; + +@Component({ + selector: 'app-slider-with-value', + standalone: true, + imports: [ + ReactiveFormsModule + ], + templateUrl: './slider-with-value.component.html', + styleUrl: './slider-with-value.component.scss', + providers: [ + { + provide: NG_VALUE_ACCESSOR, + multi: true, + useExisting: SliderWithValueComponent, + }, + ] +}) +export class SliderWithValueComponent implements ControlValueAccessor { + protected readonly Number = Number; + + private onChange: WritableSignal | null> = signal(null); + private onTouched: WritableSignal = signal(null); + + public inputId = input(); + public required = input(false); + public min = input(null); + public max = input(null); + public step = input(null); + + public disabled = signal(false); + + public value = signal(0); + + constructor() { + effect(() => { + if (this.onChange() === null) { + return; + } + (this.onChange()!)(this.value()); + if (this.onTouched() !== null) { + (this.onTouched()!)(); + } + }); + } + + public registerOnChange(fn: OnChange): void { + this.onChange.set(fn); + } + + public registerOnTouched(fn: OnTouched): void { + this.onTouched.set(fn); + } + + public setDisabledState(isDisabled: boolean): void { + this.disabled.set(isDisabled); + } + + public writeValue(obj: number): void { + this.value.set(obj); + } +} diff --git a/src/app/pages/generate-image/generate-image.component.html b/src/app/pages/generate-image/generate-image.component.html index 3cb7461..36d8c35 100644 --- a/src/app/pages/generate-image/generate-image.component.html +++ b/src/app/pages/generate-image/generate-image.component.html @@ -153,9 +153,9 @@ @if (form.value.faceFixers?.length) {
- - + + +
}
@@ -194,14 +194,16 @@
- - + + +
- - + + +
diff --git a/src/app/pages/generate-image/generate-image.component.ts b/src/app/pages/generate-image/generate-image.component.ts index 42b3df3..41d9891 100644 --- a/src/app/pages/generate-image/generate-image.component.ts +++ b/src/app/pages/generate-image/generate-image.component.ts @@ -62,6 +62,7 @@ import {getFaceFixers, getGenericPostProcessors, getUpscalers} from "../../helpe import _ from 'lodash'; import {BaselineModel} from "../../types/sd-repo/baseline-model"; import {AutoGrowDirective} from "../../directives/auto-grow.directive"; +import {SliderWithValueComponent} from "../../components/slider-with-value/slider-with-value.component"; interface Result { width: number; @@ -103,7 +104,8 @@ interface Result { LoraTextRowComponent, IsFaceFixerPipe, IsUpscalerPipe, - AutoGrowDirective + AutoGrowDirective, + SliderWithValueComponent ], templateUrl: './generate-image.component.html', styleUrl: './generate-image.component.scss' diff --git a/src/app/types/db/generation-options.ts b/src/app/types/db/generation-options.ts index 130e28b..bd31cee 100644 --- a/src/app/types/db/generation-options.ts +++ b/src/app/types/db/generation-options.ts @@ -41,7 +41,7 @@ export const DefaultGenerationOptions: GenerationOptions = { cfgScale: 5, denoisingStrength: 0.75, height: 512, - width: 52, + width: 512, steps: 25, model: 'AlbedoBase XL (SDXL)', karras: true,