mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds single-column gallery layout
This commit is contained in:
parent
876ae7f70f
commit
941d427302
@ -52,6 +52,7 @@ const HoverableImage = memo((props: HoverableImageProps) => {
|
||||
galleryImageMinimumWidth,
|
||||
mayDeleteImage,
|
||||
isLightBoxOpen,
|
||||
shouldUseSingleGalleryColumn,
|
||||
} = useAppSelector(hoverableImageSelector);
|
||||
const { image, isSelected } = props;
|
||||
const { url, thumbnail, uuid, metadata } = image;
|
||||
@ -171,7 +172,9 @@ const HoverableImage = memo((props: HoverableImageProps) => {
|
||||
>
|
||||
<Image
|
||||
className="hoverable-image-image"
|
||||
objectFit={galleryImageObjectFit}
|
||||
objectFit={
|
||||
shouldUseSingleGalleryColumn ? 'contain' : galleryImageObjectFit
|
||||
}
|
||||
rounded={'md'}
|
||||
src={thumbnail || url}
|
||||
loading={'lazy'}
|
||||
|
@ -25,6 +25,7 @@ import {
|
||||
setShouldAutoSwitchToNewImages,
|
||||
setShouldHoldGalleryOpen,
|
||||
setShouldPinGallery,
|
||||
setShouldUseSingleGalleryColumn,
|
||||
} from 'features/gallery/store/gallerySlice';
|
||||
import HoverableImage from './HoverableImage';
|
||||
import { setShouldShowGallery } from 'features/gallery/store/gallerySlice';
|
||||
@ -79,6 +80,7 @@ export default function ImageGallery() {
|
||||
isLightBoxOpen,
|
||||
isStaging,
|
||||
shouldEnableResize,
|
||||
shouldUseSingleGalleryColumn,
|
||||
} = useAppSelector(imageGallerySelector);
|
||||
|
||||
const { galleryMinWidth, galleryMaxWidth } = isLightBoxOpen
|
||||
@ -480,6 +482,17 @@ export default function ImageGallery() {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<IAICheckbox
|
||||
label="Single Column Layout"
|
||||
isChecked={shouldUseSingleGalleryColumn}
|
||||
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||
dispatch(
|
||||
setShouldUseSingleGalleryColumn(e.target.checked)
|
||||
)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</IAIPopover>
|
||||
|
||||
|
@ -42,6 +42,7 @@ export interface GalleryState {
|
||||
};
|
||||
currentCategory: GalleryCategory;
|
||||
galleryWidth: number;
|
||||
shouldUseSingleGalleryColumn: boolean;
|
||||
}
|
||||
|
||||
const initialState: GalleryState = {
|
||||
@ -69,6 +70,7 @@ const initialState: GalleryState = {
|
||||
},
|
||||
},
|
||||
galleryWidth: 300,
|
||||
shouldUseSingleGalleryColumn: false,
|
||||
};
|
||||
|
||||
export const gallerySlice = createSlice({
|
||||
@ -263,6 +265,12 @@ export const gallerySlice = createSlice({
|
||||
setGalleryWidth: (state, action: PayloadAction<number>) => {
|
||||
state.galleryWidth = action.payload;
|
||||
},
|
||||
setShouldUseSingleGalleryColumn: (
|
||||
state,
|
||||
action: PayloadAction<boolean>
|
||||
) => {
|
||||
state.shouldUseSingleGalleryColumn = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@ -284,6 +292,7 @@ export const {
|
||||
setShouldAutoSwitchToNewImages,
|
||||
setCurrentCategory,
|
||||
setGalleryWidth,
|
||||
setShouldUseSingleGalleryColumn,
|
||||
} = gallerySlice.actions;
|
||||
|
||||
export default gallerySlice.reducer;
|
||||
|
@ -27,6 +27,7 @@ export const imageGallerySelector = createSelector(
|
||||
shouldHoldGalleryOpen,
|
||||
shouldAutoSwitchToNewImages,
|
||||
galleryWidth,
|
||||
shouldUseSingleGalleryColumn,
|
||||
} = gallery;
|
||||
|
||||
const { isLightBoxOpen } = options;
|
||||
@ -38,7 +39,9 @@ export const imageGallerySelector = createSelector(
|
||||
galleryScrollPosition,
|
||||
galleryImageMinimumWidth,
|
||||
galleryImageObjectFit,
|
||||
galleryGridTemplateColumns: `repeat(auto-fill, minmax(${galleryImageMinimumWidth}px, auto))`,
|
||||
galleryGridTemplateColumns: shouldUseSingleGalleryColumn
|
||||
? 'auto'
|
||||
: `repeat(auto-fill, minmax(${galleryImageMinimumWidth}px, auto))`,
|
||||
activeTabName,
|
||||
shouldHoldGalleryOpen,
|
||||
shouldAutoSwitchToNewImages,
|
||||
@ -54,6 +57,7 @@ export const imageGallerySelector = createSelector(
|
||||
(activeTabName === 'unifiedCanvas' && shouldPinGallery)
|
||||
? false
|
||||
: true,
|
||||
shouldUseSingleGalleryColumn,
|
||||
};
|
||||
},
|
||||
{
|
||||
@ -80,6 +84,7 @@ export const hoverableImageSelector = createSelector(
|
||||
mayDeleteImage: system.isConnected && !system.isProcessing,
|
||||
galleryImageObjectFit: gallery.galleryImageObjectFit,
|
||||
galleryImageMinimumWidth: gallery.galleryImageMinimumWidth,
|
||||
shouldUseSingleGalleryColumn: gallery.shouldUseSingleGalleryColumn,
|
||||
activeTabName,
|
||||
isLightBoxOpen: options.isLightBoxOpen,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user