Skip to content

Commit

Permalink
feat(ui): move seed out of advanced, hide HRF settings
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Sep 6, 2024
1 parent b19419a commit c153dc8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
2 changes: 2 additions & 0 deletions invokeai/frontend/web/knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const config: KnipConfig = {
'src/features/nodes/types/v2/**',
// TODO(psyche): maybe we can clean up these utils after canvas v2 release
'src/features/controlLayers/konva/util.ts',
// TODO(psyche): restore HRF functionality?
'src/features/hrf/**',
],
ignoreBinaries: ['only-allow'],
paths: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { FormLabelProps } from '@invoke-ai/ui-library';
import { Expander, Flex, FormControlGroup, StandaloneAccordion } from '@invoke-ai/ui-library';
import { EMPTY_ARRAY } from 'app/store/constants';
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { useAppSelector } from 'app/store/storeHooks';
import { selectParamsSlice } from 'features/controlLayers/store/paramsSlice';
import { selectCanvasSlice } from 'features/controlLayers/store/selectors';
import { HrfSettings } from 'features/hrf/components/HrfSettings';
import { selectHrfSlice } from 'features/hrf/store/hrfSlice';
import BboxScaledHeight from 'features/parameters/components/Bbox/BboxScaledHeight';
import BboxScaledWidth from 'features/parameters/components/Bbox/BboxScaledWidth';
import BboxScaleMethod from 'features/parameters/components/Bbox/BboxScaleMethod';
Expand All @@ -18,42 +17,38 @@ import { useStandaloneAccordionToggle } from 'features/settingsAccordions/hooks/
import { memo } from 'react';
import { useTranslation } from 'react-i18next';

const selector = createMemoizedSelector(
[selectHrfSlice, selectCanvasSlice, selectParamsSlice],
(hrf, canvas, params) => {
const { shouldRandomizeSeed, model } = params;
const { hrfEnabled } = hrf;
const badges: string[] = [];
const isSDXL = model?.base === 'sdxl';
const selectBadges = createMemoizedSelector([selectCanvasSlice, selectParamsSlice], (canvas, params) => {
const { shouldRandomizeSeed } = params;
const badges: string[] = [];

const { aspectRatio } = canvas.bbox;
const { width, height } = canvas.bbox.rect;
const { aspectRatio } = canvas.bbox;
const { width, height } = canvas.bbox.rect;

badges.push(`${width}×${height}`);
badges.push(aspectRatio.id);
badges.push(`${width}×${height}`);
badges.push(aspectRatio.id);

if (aspectRatio.isLocked) {
badges.push('locked');
}
if (aspectRatio.isLocked) {
badges.push('locked');
}

if (!shouldRandomizeSeed) {
badges.push('Manual Seed');
}
if (!shouldRandomizeSeed) {
badges.push('Manual Seed');
}

if (hrfEnabled && !isSDXL) {
badges.push('HiRes Fix');
}
return { badges, isSDXL };
if (badges.length === 0) {
return EMPTY_ARRAY;
}
);

badges;
});

const scalingLabelProps: FormLabelProps = {
minW: '4.5rem',
};

export const ImageSettingsAccordion = memo(() => {
const { t } = useTranslation();
const { badges, isSDXL } = useAppSelector(selector);
const badges = useAppSelector(selectBadges);
const { isOpen: isOpenAccordion, onToggle: onToggleAccordion } = useStandaloneAccordionToggle({
id: 'image-settings',
defaultIsOpen: true,
Expand All @@ -72,14 +67,13 @@ export const ImageSettingsAccordion = memo(() => {
>
<Flex px={4} pt={4} w="full" h="full" flexDir="column" data-testid="image-settings-accordion">
<BboxSettings />
<Flex pt={4} gap={4} alignItems="center">
<ParamSeedNumberInput />
<ParamSeedShuffle />
<ParamSeedRandomize />
</Flex>
<Expander label={t('accordions.advanced.options')} isOpen={isOpenExpander} onToggle={onToggleExpander}>
<Flex gap={4} pb={4} flexDir="column">
<Flex gap={4} alignItems="center">
<ParamSeedNumberInput />
<ParamSeedShuffle />
<ParamSeedRandomize />
</Flex>
{!isSDXL && <HrfSettings />}
<BboxScaleMethod />
<FormControlGroup formLabelProps={scalingLabelProps}>
<BboxScaledWidth />
Expand Down

0 comments on commit c153dc8

Please sign in to comment.