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