Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
DOCKVIEW_TAB_CANVAS_VIEWER_ID,
DOCKVIEW_TAB_CANVAS_WORKSPACE_ID,
DOCKVIEW_TAB_LAUNCHPAD_ID,
enforceMainPanelMinWidth,
GALLERY_PANEL_DEFAULT_HEIGHT_PX,
GALLERY_PANEL_ID,
GALLERY_PANEL_MIN_HEIGHT_PX,
Expand All @@ -43,6 +44,7 @@ import {
LEFT_PANEL_ID,
LEFT_PANEL_MIN_SIZE_PX,
MAIN_PANEL_ID,
MAIN_PANEL_MIN_SIZE_PX,
RIGHT_PANEL_ID,
RIGHT_PANEL_MIN_SIZE_PX,
SETTINGS_PANEL_ID,
Expand Down Expand Up @@ -261,6 +263,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
const main = api.addPanel({
id: MAIN_PANEL_ID,
component: MAIN_PANEL_ID,
minimumWidth: MAIN_PANEL_MIN_SIZE_PX,
priority: LayoutPriority.High,
});

Expand Down Expand Up @@ -289,6 +292,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
left.api.setSize({ width: LEFT_PANEL_MIN_SIZE_PX });
right.api.setSize({ width: RIGHT_PANEL_MIN_SIZE_PX });
});
enforceMainPanelMinWidth(api);
};

export const CanvasTabAutoLayout = memo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ import {
DOCKVIEW_TAB_ID,
DOCKVIEW_TAB_LAUNCHPAD_ID,
DOCKVIEW_TAB_PROGRESS_ID,
enforceMainPanelMinWidth,
GALLERY_PANEL_DEFAULT_HEIGHT_PX,
GALLERY_PANEL_ID,
GALLERY_PANEL_MIN_HEIGHT_PX,
LAUNCHPAD_PANEL_ID,
LEFT_PANEL_ID,
LEFT_PANEL_MIN_SIZE_PX,
MAIN_PANEL_ID,
MAIN_PANEL_MIN_SIZE_PX,
RIGHT_PANEL_ID,
RIGHT_PANEL_MIN_SIZE_PX,
SETTINGS_PANEL_ID,
Expand Down Expand Up @@ -224,6 +226,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
const main = api.addPanel<GridviewPanelParameters>({
id: MAIN_PANEL_ID,
component: MAIN_PANEL_ID,
minimumWidth: MAIN_PANEL_MIN_SIZE_PX,
priority: LayoutPriority.High,
});

Expand All @@ -250,6 +253,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
left.api.setSize({ width: LEFT_PANEL_MIN_SIZE_PX });
right.api.setSize({ width: RIGHT_PANEL_MIN_SIZE_PX });
});
enforceMainPanelMinWidth(api);
};

export const GenerateTabAutoLayout = memo(() => {
Expand Down
24 changes: 24 additions & 0 deletions invokeai/frontend/web/src/features/ui/layouts/shared.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { GridviewApi } from 'dockview';

export const LEFT_PANEL_ID = 'left';
export const MAIN_PANEL_ID = 'main';
export const RIGHT_PANEL_ID = 'right';
Expand All @@ -24,6 +26,9 @@ export const DOCKVIEW_TAB_CANVAS_WORKSPACE_ID = 'tab-canvas-workspace';

export const LEFT_PANEL_MIN_SIZE_PX = 420;
export const RIGHT_PANEL_MIN_SIZE_PX = 420;
// Keeps the main panel wide enough to fit the floating left/right toggle button
// groups on small screens, so the user can always grab them to expand the side panels.
export const MAIN_PANEL_MIN_SIZE_PX = 128;

export const BOARD_PANEL_MIN_HEIGHT_PX = 36;
export const BOARD_PANEL_MIN_EXPANDED_HEIGHT_PX = 128;
Expand All @@ -38,3 +43,22 @@ export const LAYERS_PANEL_MIN_HEIGHT_PX = 36;
export const CANVAS_BOARD_PANEL_DEFAULT_HEIGHT_PX = 36; // Collapsed by default on Canvas

export const SWITCH_TABS_FAKE_DELAY_MS = 300;

/**
* Enforce the main panel's minimum width on the root gridview after the
* container has been (re)constructed. The panel's `minimumWidth` set at
* `addPanel` time only applies on a fresh layout — when `registerContainer`
* restores from persisted JSON, the constraints come from that JSON, which
* may pre-date `MAIN_PANEL_MIN_SIZE_PX`. Re-apply it here, and grow the panel
* if its restored size violates the new minimum.
*/
export const enforceMainPanelMinWidth = (api: GridviewApi): void => {
const main = api.getPanel(MAIN_PANEL_ID);
if (!main) {
return;
}
main.api.setConstraints({ maximumWidth: Number.MAX_SAFE_INTEGER, minimumWidth: MAIN_PANEL_MIN_SIZE_PX });
if (main.api.width < MAIN_PANEL_MIN_SIZE_PX) {
main.api.setSize({ width: MAIN_PANEL_MIN_SIZE_PX });
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ import {
DOCKVIEW_TAB_ID,
DOCKVIEW_TAB_LAUNCHPAD_ID,
DOCKVIEW_TAB_PROGRESS_ID,
enforceMainPanelMinWidth,
GALLERY_PANEL_DEFAULT_HEIGHT_PX,
GALLERY_PANEL_ID,
GALLERY_PANEL_MIN_HEIGHT_PX,
LAUNCHPAD_PANEL_ID,
LEFT_PANEL_ID,
LEFT_PANEL_MIN_SIZE_PX,
MAIN_PANEL_ID,
MAIN_PANEL_MIN_SIZE_PX,
RIGHT_PANEL_ID,
RIGHT_PANEL_MIN_SIZE_PX,
SETTINGS_PANEL_ID,
Expand Down Expand Up @@ -223,6 +225,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
const main = api.addPanel({
id: MAIN_PANEL_ID,
component: MAIN_PANEL_ID,
minimumWidth: MAIN_PANEL_MIN_SIZE_PX,
priority: LayoutPriority.High,
});

Expand All @@ -249,6 +252,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
left.api.setSize({ width: LEFT_PANEL_MIN_SIZE_PX });
right.api.setSize({ width: RIGHT_PANEL_MIN_SIZE_PX });
});
enforceMainPanelMinWidth(api);
};

export const UpscalingTabAutoLayout = memo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ import {
DOCKVIEW_TAB_ID,
DOCKVIEW_TAB_LAUNCHPAD_ID,
DOCKVIEW_TAB_PROGRESS_ID,
enforceMainPanelMinWidth,
GALLERY_PANEL_DEFAULT_HEIGHT_PX,
GALLERY_PANEL_ID,
GALLERY_PANEL_MIN_HEIGHT_PX,
LAUNCHPAD_PANEL_ID,
LEFT_PANEL_ID,
LEFT_PANEL_MIN_SIZE_PX,
MAIN_PANEL_ID,
MAIN_PANEL_MIN_SIZE_PX,
RIGHT_PANEL_ID,
RIGHT_PANEL_MIN_SIZE_PX,
SETTINGS_PANEL_ID,
Expand Down Expand Up @@ -243,6 +245,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
const main = api.addPanel({
id: MAIN_PANEL_ID,
component: MAIN_PANEL_ID,
minimumWidth: MAIN_PANEL_MIN_SIZE_PX,
priority: LayoutPriority.High,
});

Expand All @@ -269,6 +272,7 @@ const initializeRootPanelLayout = (tab: TabName, api: GridviewApi) => {
left.api.setSize({ width: LEFT_PANEL_MIN_SIZE_PX });
right.api.setSize({ width: RIGHT_PANEL_MIN_SIZE_PX });
});
enforceMainPanelMinWidth(api);
};

export const WorkflowsTabAutoLayout = memo(() => {
Expand Down
Loading