mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds gallery auto-switch toggle; ref #1272
This commit is contained in:
parent
ac7ee9d0a5
commit
62898b0f8f
File diff suppressed because one or more lines are too long
2
frontend/dist/index.html
vendored
2
frontend/dist/index.html
vendored
@ -6,7 +6,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
<title>InvokeAI - A Stable Diffusion Toolkit</title>
|
||||||
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
|
<link rel="shortcut icon" type="icon" href="./assets/favicon.0d253ced.ico" />
|
||||||
<script type="module" crossorigin src="./assets/index.366cfb7e.js"></script>
|
<script type="module" crossorigin src="./assets/index.26f6b9c2.js"></script>
|
||||||
<link rel="stylesheet" href="./assets/index.25bb1c01.css">
|
<link rel="stylesheet" href="./assets/index.25bb1c01.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Button } from '@chakra-ui/button';
|
import { Button } from '@chakra-ui/button';
|
||||||
import { NumberSize, Resizable, Size } from 're-resizable';
|
import { NumberSize, Resizable, Size } from 're-resizable';
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||||
import { useHotkeys } from 'react-hotkeys-hook';
|
import { useHotkeys } from 'react-hotkeys-hook';
|
||||||
import { MdClear, MdPhotoLibrary } from 'react-icons/md';
|
import { MdClear, MdPhotoLibrary } from 'react-icons/md';
|
||||||
import { BsPinAngleFill } from 'react-icons/bs';
|
import { BsPinAngleFill } from 'react-icons/bs';
|
||||||
@ -14,6 +14,7 @@ import {
|
|||||||
setGalleryImageMinimumWidth,
|
setGalleryImageMinimumWidth,
|
||||||
setGalleryImageObjectFit,
|
setGalleryImageObjectFit,
|
||||||
setGalleryScrollPosition,
|
setGalleryScrollPosition,
|
||||||
|
setShouldAutoSwitchToNewImages,
|
||||||
setShouldHoldGalleryOpen,
|
setShouldHoldGalleryOpen,
|
||||||
setShouldPinGallery,
|
setShouldPinGallery,
|
||||||
} from './gallerySlice';
|
} from './gallerySlice';
|
||||||
@ -45,6 +46,7 @@ export default function ImageGallery() {
|
|||||||
activeTabName,
|
activeTabName,
|
||||||
galleryImageObjectFit,
|
galleryImageObjectFit,
|
||||||
shouldHoldGalleryOpen,
|
shouldHoldGalleryOpen,
|
||||||
|
shouldAutoSwitchToNewImages,
|
||||||
} = useAppSelector(imageGallerySelector);
|
} = useAppSelector(imageGallerySelector);
|
||||||
|
|
||||||
const [gallerySize, setGallerySize] = useState<Size>({
|
const [gallerySize, setGallerySize] = useState<Size>({
|
||||||
@ -370,6 +372,15 @@ export default function ImageGallery() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<IAICheckbox
|
||||||
|
label="Auto-Switch to New Images"
|
||||||
|
isChecked={shouldAutoSwitchToNewImages}
|
||||||
|
onChange={(e: ChangeEvent<HTMLInputElement>) =>
|
||||||
|
dispatch(setShouldAutoSwitchToNewImages(e.target.checked))
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</IAIPopover>
|
</IAIPopover>
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ export interface GalleryState {
|
|||||||
galleryImageMinimumWidth: number;
|
galleryImageMinimumWidth: number;
|
||||||
galleryImageObjectFit: GalleryImageObjectFitType;
|
galleryImageObjectFit: GalleryImageObjectFitType;
|
||||||
shouldHoldGalleryOpen: boolean;
|
shouldHoldGalleryOpen: boolean;
|
||||||
|
shouldAutoSwitchToNewImages: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: GalleryState = {
|
const initialState: GalleryState = {
|
||||||
@ -31,6 +32,7 @@ const initialState: GalleryState = {
|
|||||||
galleryImageMinimumWidth: 64,
|
galleryImageMinimumWidth: 64,
|
||||||
galleryImageObjectFit: 'contain',
|
galleryImageObjectFit: 'contain',
|
||||||
shouldHoldGalleryOpen: false,
|
shouldHoldGalleryOpen: false,
|
||||||
|
shouldAutoSwitchToNewImages: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const gallerySlice = createSlice({
|
export const gallerySlice = createSlice({
|
||||||
@ -94,9 +96,11 @@ export const gallerySlice = createSlice({
|
|||||||
}
|
}
|
||||||
|
|
||||||
state.images.unshift(newImage);
|
state.images.unshift(newImage);
|
||||||
|
if (state.shouldAutoSwitchToNewImages) {
|
||||||
state.currentImageUuid = uuid;
|
state.currentImageUuid = uuid;
|
||||||
state.intermediateImage = undefined;
|
|
||||||
state.currentImage = newImage;
|
state.currentImage = newImage;
|
||||||
|
}
|
||||||
|
state.intermediateImage = undefined;
|
||||||
state.latest_mtime = mtime;
|
state.latest_mtime = mtime;
|
||||||
},
|
},
|
||||||
setIntermediateImage: (state, action: PayloadAction<InvokeAI.Image>) => {
|
setIntermediateImage: (state, action: PayloadAction<InvokeAI.Image>) => {
|
||||||
@ -186,6 +190,9 @@ export const gallerySlice = createSlice({
|
|||||||
setShouldHoldGalleryOpen: (state, action: PayloadAction<boolean>) => {
|
setShouldHoldGalleryOpen: (state, action: PayloadAction<boolean>) => {
|
||||||
state.shouldHoldGalleryOpen = action.payload;
|
state.shouldHoldGalleryOpen = action.payload;
|
||||||
},
|
},
|
||||||
|
setShouldAutoSwitchToNewImages: (state, action: PayloadAction<boolean>) => {
|
||||||
|
state.shouldAutoSwitchToNewImages = action.payload;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -204,6 +211,7 @@ export const {
|
|||||||
setGalleryImageMinimumWidth,
|
setGalleryImageMinimumWidth,
|
||||||
setGalleryImageObjectFit,
|
setGalleryImageObjectFit,
|
||||||
setShouldHoldGalleryOpen,
|
setShouldHoldGalleryOpen,
|
||||||
|
setShouldAutoSwitchToNewImages,
|
||||||
} = gallerySlice.actions;
|
} = gallerySlice.actions;
|
||||||
|
|
||||||
export default gallerySlice.reducer;
|
export default gallerySlice.reducer;
|
||||||
|
@ -17,6 +17,7 @@ export const imageGallerySelector = createSelector(
|
|||||||
galleryImageMinimumWidth,
|
galleryImageMinimumWidth,
|
||||||
galleryImageObjectFit,
|
galleryImageObjectFit,
|
||||||
shouldHoldGalleryOpen,
|
shouldHoldGalleryOpen,
|
||||||
|
shouldAutoSwitchToNewImages
|
||||||
} = gallery;
|
} = gallery;
|
||||||
|
|
||||||
const { activeTab } = options;
|
const { activeTab } = options;
|
||||||
@ -33,6 +34,7 @@ export const imageGallerySelector = createSelector(
|
|||||||
galleryGridTemplateColumns: `repeat(auto-fill, minmax(${galleryImageMinimumWidth}px, auto))`,
|
galleryGridTemplateColumns: `repeat(auto-fill, minmax(${galleryImageMinimumWidth}px, auto))`,
|
||||||
activeTabName: tabMap[activeTab],
|
activeTabName: tabMap[activeTab],
|
||||||
shouldHoldGalleryOpen,
|
shouldHoldGalleryOpen,
|
||||||
|
shouldAutoSwitchToNewImages
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user