mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): improved panel interactions
This commit is contained in:
parent
4ce9f9dc36
commit
8a6f03cd46
@ -192,6 +192,7 @@ const InvokeTabs = () => {
|
||||
expand: expandOptionsPanel,
|
||||
collapse: collapseOptionsPanel,
|
||||
toggle: toggleOptionsPanel,
|
||||
onDoubleClickHandle: onDoubleClickOptionsPanelHandle,
|
||||
} = usePanel(optionsPanelUsePanelOptions);
|
||||
|
||||
const {
|
||||
@ -204,10 +205,19 @@ const InvokeTabs = () => {
|
||||
expand: expandGalleryPanel,
|
||||
collapse: collapseGalleryPanel,
|
||||
toggle: toggleGalleryPanel,
|
||||
onDoubleClickHandle: onDoubleClickGalleryPanelHandle,
|
||||
} = usePanel(galleryPanelUsePanelOptions);
|
||||
|
||||
useHotkeys('g', toggleGalleryPanel, []);
|
||||
useHotkeys(['t', 'o'], toggleOptionsPanel, []);
|
||||
useHotkeys('g', toggleGalleryPanel, [toggleGalleryPanel]);
|
||||
useHotkeys(['t', 'o'], toggleOptionsPanel, [toggleOptionsPanel]);
|
||||
useHotkeys(
|
||||
'shift+r',
|
||||
() => {
|
||||
resetOptionsPanel();
|
||||
resetGalleryPanel();
|
||||
},
|
||||
[resetOptionsPanel, resetGalleryPanel]
|
||||
);
|
||||
useHotkeys(
|
||||
'f',
|
||||
() => {
|
||||
@ -219,7 +229,14 @@ const InvokeTabs = () => {
|
||||
collapseGalleryPanel();
|
||||
}
|
||||
},
|
||||
[isOptionsPanelCollapsed, isGalleryPanelCollapsed]
|
||||
[
|
||||
isOptionsPanelCollapsed,
|
||||
isGalleryPanelCollapsed,
|
||||
expandOptionsPanel,
|
||||
expandGalleryPanel,
|
||||
collapseOptionsPanel,
|
||||
collapseGalleryPanel,
|
||||
]
|
||||
);
|
||||
|
||||
return (
|
||||
@ -265,7 +282,7 @@ const InvokeTabs = () => {
|
||||
</Panel>
|
||||
<ResizeHandle
|
||||
id="options-main-handle"
|
||||
onDoubleClick={resetOptionsPanel}
|
||||
onDoubleClick={onDoubleClickOptionsPanelHandle}
|
||||
orientation="vertical"
|
||||
/>
|
||||
</>
|
||||
@ -279,8 +296,8 @@ const InvokeTabs = () => {
|
||||
<>
|
||||
<ResizeHandle
|
||||
id="main-gallery-handle"
|
||||
onDoubleClick={resetGalleryPanel}
|
||||
orientation="vertical"
|
||||
onDoubleClick={onDoubleClickGalleryPanelHandle}
|
||||
/>
|
||||
<Panel
|
||||
id="gallery-panel"
|
||||
|
@ -64,18 +64,18 @@ export const resizeHandleTheme = defineStyleConfig({
|
||||
},
|
||||
'.resize-handle-drag-handle': {
|
||||
pos: 'absolute',
|
||||
borderRadius: '2px',
|
||||
borderRadius: '1px',
|
||||
transitionProperty: 'inherit',
|
||||
transitionDuration: 'inherit',
|
||||
'&[data-orientation="horizontal"]': {
|
||||
w: '20px',
|
||||
w: '30px',
|
||||
h: '6px',
|
||||
insetInlineStart: '50%',
|
||||
transform: 'translate(-50%, 0)',
|
||||
},
|
||||
'&[data-orientation="vertical"]': {
|
||||
w: '6px',
|
||||
h: '20px',
|
||||
h: '30px',
|
||||
insetBlockStart: '50%',
|
||||
transform: 'translate(0, -50%)',
|
||||
},
|
||||
|
@ -68,10 +68,14 @@ export type UsePanelReturn = {
|
||||
*/
|
||||
onExpand: PanelOnExpand;
|
||||
/**
|
||||
* Reset the panel to the minSize. If the panel is already at the minSize, collapse it.
|
||||
* This can be provided to the `onDoubleClick` prop of the panel's nearest resize handle.
|
||||
* Reset the panel to the minSize.
|
||||
*/
|
||||
reset: () => void;
|
||||
/**
|
||||
* Reset the panel to the minSize. If the panel is already at the minSize, collapse it.
|
||||
* This should be passed to the `onDoubleClick` prop of the panel's nearest resize handle.
|
||||
*/
|
||||
onDoubleClickHandle: () => void;
|
||||
/**
|
||||
* Toggle the panel between collapsed and expanded.
|
||||
*/
|
||||
@ -183,6 +187,10 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
|
||||
);
|
||||
|
||||
const reset = useCallback(() => {
|
||||
panelHandleRef.current?.resize(_minSize);
|
||||
}, [_minSize]);
|
||||
|
||||
const onDoubleClickHandle = useCallback(() => {
|
||||
// If the panel is really super close to the min size, collapse it
|
||||
if (Math.abs((panelHandleRef.current?.getSize() ?? 0) - _minSize) < 0.01) {
|
||||
collapse();
|
||||
@ -204,6 +212,7 @@ export const usePanel = (arg: UsePanelOptions): UsePanelReturn => {
|
||||
expand,
|
||||
collapse,
|
||||
resize,
|
||||
onDoubleClickHandle,
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user