Skip to content

Commit

Permalink
feat(ui): add setting for always show image size badge
Browse files Browse the repository at this point in the history
  • Loading branch information
psychedelicious committed Mar 12, 2024
1 parent cc03fcb commit 43948e0
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions invokeai/frontend/web/public/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@
},
"gallery": {
"allImagesLoaded": "All Images Loaded",
"alwaysShowImageSizeBadge": "Always Show Image Size Badge",
"assets": "Assets",
"autoAssignBoardOnClick": "Auto-Assign Board on Click",
"autoSwitchNewImages": "Auto-Switch to New Images",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import {
alwaysShowImageSizeBadgeChanged,
autoAssignBoardOnClickChanged,
setGalleryImageMinimumWidth,
shouldAutoSwitchChanged,
Expand All @@ -36,6 +37,7 @@ const GallerySettingsPopover = () => {
const galleryImageMinimumWidth = useAppSelector((s) => s.gallery.galleryImageMinimumWidth);
const shouldAutoSwitch = useAppSelector((s) => s.gallery.shouldAutoSwitch);
const autoAssignBoardOnClick = useAppSelector((s) => s.gallery.autoAssignBoardOnClick);
const alwaysShowImageSizeBadge = useAppSelector((s) => s.gallery.alwaysShowImageSizeBadge);

const handleChangeGalleryImageMinimumWidth = useCallback(
(v: number) => {
Expand All @@ -56,6 +58,11 @@ const GallerySettingsPopover = () => {
[dispatch]
);

const handleChangeAlwaysShowImageSizeBadgeChanged = useCallback(
(e: ChangeEvent<HTMLInputElement>) => dispatch(alwaysShowImageSizeBadgeChanged(e.target.checked)),
[dispatch]
);

return (
<Popover isLazy>
<PopoverTrigger>
Expand Down Expand Up @@ -88,6 +95,10 @@ const GallerySettingsPopover = () => {
<FormLabel>{t('gallery.autoAssignBoardOnClick')}</FormLabel>
<Checkbox isChecked={autoAssignBoardOnClick} onChange={handleChangeAutoAssignBoardOnClick} />
</FormControl>
<FormControl>
<FormLabel>{t('gallery.alwaysShowImageSizeBadge')}</FormLabel>
<Checkbox isChecked={alwaysShowImageSizeBadge} onChange={handleChangeAlwaysShowImageSizeBadgeChanged} />
</FormControl>
</FormControlGroup>
<BoardAutoAddSelect />
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const GalleryImage = (props: HoverableImageProps) => {
const shift = useShiftModifier();
const { t } = useTranslation();
const selectedBoardId = useAppSelector((s) => s.gallery.selectedBoardId);
const alwaysShowImageSizeBadge = useAppSelector((s) => s.gallery.alwaysShowImageSizeBadge);
const { handleClick, isSelected, areMultiplesSelected } = useMultiselect(imageDTO);

const customStarUi = useStore($customStarUI);
Expand Down Expand Up @@ -155,7 +156,7 @@ const GalleryImage = (props: HoverableImageProps) => {
onMouseOut={handleMouseOut}
>
<>
{isHovered && (
{(isHovered || alwaysShowImageSizeBadge) && (
<Text
position="absolute"
background="base.900"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const initialGalleryState: GalleryState = {
autoAssignBoardOnClick: true,
autoAddBoardId: 'none',
galleryImageMinimumWidth: 90,
alwaysShowImageSizeBadge: false,
selectedBoardId: 'none',
galleryView: 'images',
boardSearchText: '',
Expand Down Expand Up @@ -71,6 +72,9 @@ export const gallerySlice = createSlice({
state.limit += IMAGE_LIMIT;
}
},
alwaysShowImageSizeBadgeChanged: (state, action: PayloadAction<boolean>) => {
state.alwaysShowImageSizeBadge = action.payload;
},
},
extraReducers: (builder) => {
builder.addMatcher(isAnyBoardDeleted, (state, action) => {
Expand Down Expand Up @@ -107,6 +111,7 @@ export const {
selectionChanged,
boardSearchTextChanged,
moreImagesLoaded,
alwaysShowImageSizeBadgeChanged,
} = gallerySlice.actions;

const isAnyBoardDeleted = isAnyOf(
Expand Down
1 change: 1 addition & 0 deletions invokeai/frontend/web/src/features/gallery/store/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export type GalleryState = {
boardSearchText: string;
offset: number;
limit: number;
alwaysShowImageSizeBadge: boolean;
};

0 comments on commit 43948e0

Please sign in to comment.