mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 21:39:43 +00:00
additional handling of the panel position with panel alignment
This commit is contained in:
parent
0fa6b06a1d
commit
7ca80515bd
|
@ -352,6 +352,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
const newPositionValue = (position === Position.LEFT) ? 'left' : 'right';
|
const newPositionValue = (position === Position.LEFT) ? 'left' : 'right';
|
||||||
const oldPositionValue = (position === Position.RIGHT) ? 'left' : 'right';
|
const oldPositionValue = (position === Position.RIGHT) ? 'left' : 'right';
|
||||||
const panelAlignment = this.getPanelAlignment();
|
const panelAlignment = this.getPanelAlignment();
|
||||||
|
const panelPosition = this.getPanelPosition();
|
||||||
|
|
||||||
this.stateModel.setRuntimeValue(LayoutStateKeys.SIDEBAR_POSITON, position);
|
this.stateModel.setRuntimeValue(LayoutStateKeys.SIDEBAR_POSITON, position);
|
||||||
|
|
||||||
|
@ -374,7 +375,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
auxiliaryBar.updateStyles();
|
auxiliaryBar.updateStyles();
|
||||||
|
|
||||||
// Move activity bar, side bar, and side panel
|
// Move activity bar, side bar, and side panel
|
||||||
this.adjustPartPositions(position, panelAlignment);
|
this.adjustPartPositions(position, panelAlignment, panelPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateWindowBorder(skipLayout: boolean = false) {
|
private updateWindowBorder(skipLayout: boolean = false) {
|
||||||
|
@ -1464,31 +1465,43 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
return viewContainerModel.activeViewDescriptors.length >= 1;
|
return viewContainerModel.activeViewDescriptors.length >= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private adjustPartPositions(sideBarPosition: Position, panelAlignment: PanelAlignment): void {
|
private adjustPartPositions(sideBarPosition: Position, panelAlignment: PanelAlignment, panelPosition: Position): void {
|
||||||
// Move activity bar, side bar, and side panel
|
// Move activity bar, side bar, and side panel
|
||||||
const sideBarNextToEditor = !(panelAlignment === 'center' || (sideBarPosition === Position.LEFT && panelAlignment === 'right') || (sideBarPosition === Position.RIGHT && panelAlignment === 'left'));
|
const sideBarSiblingToEditor = panelPosition !== Position.BOTTOM || !(panelAlignment === 'center' || (sideBarPosition === Position.LEFT && panelAlignment === 'right') || (sideBarPosition === Position.RIGHT && panelAlignment === 'left'));
|
||||||
const auxiliaryBarNextToEditor = !(panelAlignment === 'center' || (sideBarPosition === Position.RIGHT && panelAlignment === 'right') || (sideBarPosition === Position.LEFT && panelAlignment === 'left'));
|
const auxiliaryBarSiblingToEditor = panelPosition !== Position.BOTTOM || !(panelAlignment === 'center' || (sideBarPosition === Position.RIGHT && panelAlignment === 'right') || (sideBarPosition === Position.LEFT && panelAlignment === 'left'));
|
||||||
|
const preMovePanelWidth = !this.isVisible(Parts.PANEL_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.panelPartView) ?? this.panelPartView.minimumWidth) : this.workbenchGrid.getViewSize(this.panelPartView).width;
|
||||||
|
const preMovePanelHeight = !this.isVisible(Parts.PANEL_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.panelPartView) ?? this.panelPartView.minimumHeight) : this.workbenchGrid.getViewSize(this.panelPartView).height;
|
||||||
const preMoveSideBarSize = !this.isVisible(Parts.SIDEBAR_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.sideBarPartView) ?? this.sideBarPartView.minimumWidth) : this.workbenchGrid.getViewSize(this.sideBarPartView).width;
|
const preMoveSideBarSize = !this.isVisible(Parts.SIDEBAR_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.sideBarPartView) ?? this.sideBarPartView.minimumWidth) : this.workbenchGrid.getViewSize(this.sideBarPartView).width;
|
||||||
const preMoveAuxiliaryBarSize = !this.isVisible(Parts.AUXILIARYBAR_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.auxiliaryBarPartView) ?? this.auxiliaryBarPartView.minimumWidth) : this.workbenchGrid.getViewSize(this.auxiliaryBarPartView).width;
|
const preMoveAuxiliaryBarSize = !this.isVisible(Parts.AUXILIARYBAR_PART) ? Sizing.Invisible(this.workbenchGrid.getViewCachedVisibleSize(this.auxiliaryBarPartView) ?? this.auxiliaryBarPartView.minimumWidth) : this.workbenchGrid.getViewSize(this.auxiliaryBarPartView).width;
|
||||||
|
|
||||||
if (sideBarPosition === Position.LEFT) {
|
if (sideBarPosition === Position.LEFT) {
|
||||||
this.workbenchGrid.moveViewTo(this.activityBarPartView, [2, 0]);
|
this.workbenchGrid.moveViewTo(this.activityBarPartView, [2, 0]);
|
||||||
this.workbenchGrid.moveView(this.sideBarPartView, preMoveSideBarSize, sideBarNextToEditor ? this.editorPartView : this.activityBarPartView, sideBarNextToEditor ? Direction.Left : Direction.Right);
|
this.workbenchGrid.moveView(this.sideBarPartView, preMoveSideBarSize, sideBarSiblingToEditor ? this.editorPartView : this.activityBarPartView, sideBarSiblingToEditor ? Direction.Left : Direction.Right);
|
||||||
if (auxiliaryBarNextToEditor) {
|
if (auxiliaryBarSiblingToEditor) {
|
||||||
this.workbenchGrid.moveView(this.auxiliaryBarPartView, preMoveAuxiliaryBarSize, this.editorPartView, Direction.Right);
|
this.workbenchGrid.moveView(this.auxiliaryBarPartView, preMoveAuxiliaryBarSize, this.editorPartView, Direction.Right);
|
||||||
} else {
|
} else {
|
||||||
this.workbenchGrid.moveViewTo(this.auxiliaryBarPartView, [2, -1]);
|
this.workbenchGrid.moveViewTo(this.auxiliaryBarPartView, [2, -1]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.workbenchGrid.moveViewTo(this.activityBarPartView, [2, -1]);
|
this.workbenchGrid.moveViewTo(this.activityBarPartView, [2, -1]);
|
||||||
this.workbenchGrid.moveView(this.sideBarPartView, preMoveSideBarSize, sideBarNextToEditor ? this.editorPartView : this.activityBarPartView, sideBarNextToEditor ? Direction.Right : Direction.Left);
|
this.workbenchGrid.moveView(this.sideBarPartView, preMoveSideBarSize, sideBarSiblingToEditor ? this.editorPartView : this.activityBarPartView, sideBarSiblingToEditor ? Direction.Right : Direction.Left);
|
||||||
if (auxiliaryBarNextToEditor) {
|
if (auxiliaryBarSiblingToEditor) {
|
||||||
this.workbenchGrid.moveView(this.auxiliaryBarPartView, preMoveAuxiliaryBarSize, this.editorPartView, Direction.Left);
|
this.workbenchGrid.moveView(this.auxiliaryBarPartView, preMoveAuxiliaryBarSize, this.editorPartView, Direction.Left);
|
||||||
} else {
|
} else {
|
||||||
this.workbenchGrid.moveViewTo(this.auxiliaryBarPartView, [2, 0]);
|
this.workbenchGrid.moveViewTo(this.auxiliaryBarPartView, [2, 0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We moved all the side parts based on the editor and ignored the panel
|
||||||
|
// Now, we need to put the panel back in the right position when it is next to the editor
|
||||||
|
if (panelPosition !== Position.BOTTOM) {
|
||||||
|
this.workbenchGrid.moveView(this.panelPartView, preMovePanelWidth, this.editorPartView, panelPosition === Position.LEFT ? Direction.Left : Direction.Right);
|
||||||
|
this.workbenchGrid.resizeView(this.panelPartView, {
|
||||||
|
height: preMovePanelHeight as number,
|
||||||
|
width: preMovePanelWidth as number
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Moving views in the grid can cause them to re-distribute sizing unnecessarily
|
// Moving views in the grid can cause them to re-distribute sizing unnecessarily
|
||||||
// Resize visible parts to the width they were before the operation
|
// Resize visible parts to the width they were before the operation
|
||||||
if (this.isVisible(Parts.SIDEBAR_PART)) {
|
if (this.isVisible(Parts.SIDEBAR_PART)) {
|
||||||
|
@ -1519,7 +1532,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
|
|
||||||
this.stateModel.setRuntimeValue(LayoutStateKeys.PANEL_ALIGNMENT, alignment);
|
this.stateModel.setRuntimeValue(LayoutStateKeys.PANEL_ALIGNMENT, alignment);
|
||||||
|
|
||||||
this.adjustPartPositions(this.getSideBarPosition(), alignment);
|
this.adjustPartPositions(this.getSideBarPosition(), alignment, this.getPanelPosition());
|
||||||
|
|
||||||
this._onDidChangePanelAlignment.fire(alignment);
|
this._onDidChangePanelAlignment.fire(alignment);
|
||||||
}
|
}
|
||||||
|
@ -1627,7 +1640,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
*/
|
*/
|
||||||
private panelOpensMaximized(): boolean {
|
private panelOpensMaximized(): boolean {
|
||||||
// the workbench grid currently prevents us from supporting panel maximization with non-center panel alignment
|
// the workbench grid currently prevents us from supporting panel maximization with non-center panel alignment
|
||||||
if (this.getPanelAlignment() !== 'center') {
|
if (this.getPanelAlignment() !== 'center' && this.getPanelPosition() === Position.BOTTOM) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1760,8 +1773,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
const oldPositionValue = positionToString(this.getPanelPosition());
|
const oldPositionValue = positionToString(this.getPanelPosition());
|
||||||
const newPositionValue = positionToString(position);
|
const newPositionValue = positionToString(position);
|
||||||
|
|
||||||
this.stateModel.setRuntimeValue(LayoutStateKeys.PANEL_POSITION, position);
|
|
||||||
|
|
||||||
// Adjust CSS
|
// Adjust CSS
|
||||||
const panelContainer = assertIsDefined(panelPart.getContainer());
|
const panelContainer = assertIsDefined(panelPart.getContainer());
|
||||||
panelContainer.classList.remove(oldPositionValue);
|
panelContainer.classList.remove(oldPositionValue);
|
||||||
|
@ -1775,7 +1786,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
const sideBarSize = this.workbenchGrid.getViewSize(this.sideBarPartView);
|
const sideBarSize = this.workbenchGrid.getViewSize(this.sideBarPartView);
|
||||||
const auxiliaryBarSize = this.workbenchGrid.getViewSize(this.auxiliaryBarPartView);
|
const auxiliaryBarSize = this.workbenchGrid.getViewSize(this.auxiliaryBarPartView);
|
||||||
|
|
||||||
const editorHidden = !this.isVisible(Parts.EDITOR_PART);
|
let editorHidden = !this.isVisible(Parts.EDITOR_PART);
|
||||||
|
|
||||||
// Save last non-maximized size for panel before move
|
// Save last non-maximized size for panel before move
|
||||||
if (newPositionValue !== oldPositionValue && !editorHidden) {
|
if (newPositionValue !== oldPositionValue && !editorHidden) {
|
||||||
|
@ -1790,6 +1801,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position === Position.BOTTOM && this.getPanelAlignment() !== 'center' && editorHidden) {
|
||||||
|
this.toggleMaximizedPanel();
|
||||||
|
editorHidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.stateModel.setRuntimeValue(LayoutStateKeys.PANEL_POSITION, position);
|
||||||
|
|
||||||
const sideBarVisible = this.isVisible(Parts.SIDEBAR_PART);
|
const sideBarVisible = this.isVisible(Parts.SIDEBAR_PART);
|
||||||
const auxiliaryBarVisible = this.isVisible(Parts.AUXILIARYBAR_PART);
|
const auxiliaryBarVisible = this.isVisible(Parts.AUXILIARYBAR_PART);
|
||||||
|
|
||||||
|
@ -1812,6 +1830,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
|
||||||
this.setAuxiliaryBarHidden(true);
|
this.setAuxiliaryBarHidden(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (position === Position.BOTTOM) {
|
||||||
|
this.adjustPartPositions(this.getSideBarPosition(), this.getPanelAlignment(), position);
|
||||||
|
}
|
||||||
|
|
||||||
this._onDidChangePanelPosition.fire(newPositionValue);
|
this._onDidChangePanelPosition.fire(newPositionValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ import { IAction, Separator, toAction } from 'vs/base/common/actions';
|
||||||
import { ToggleAuxiliaryBarAction } from 'vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions';
|
import { ToggleAuxiliaryBarAction } from 'vs/workbench/browser/parts/auxiliarybar/auxiliaryBarActions';
|
||||||
import { assertIsDefined } from 'vs/base/common/types';
|
import { assertIsDefined } from 'vs/base/common/types';
|
||||||
import { MoveSidePanelToPanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
|
import { MoveSidePanelToPanelAction } from 'vs/workbench/browser/parts/panel/panelActions';
|
||||||
|
import { LayoutPriority } from 'vs/base/browser/ui/splitview/splitview';
|
||||||
|
|
||||||
export class AuxiliaryBarPart extends BasePanelPart {
|
export class AuxiliaryBarPart extends BasePanelPart {
|
||||||
static readonly activePanelSettingsKey = 'workbench.auxiliarybar.activepanelid';
|
static readonly activePanelSettingsKey = 'workbench.auxiliarybar.activepanelid';
|
||||||
|
@ -39,6 +40,8 @@ export class AuxiliaryBarPart extends BasePanelPart {
|
||||||
override readonly minimumHeight: number = 0;
|
override readonly minimumHeight: number = 0;
|
||||||
override readonly maximumHeight: number = Number.POSITIVE_INFINITY;
|
override readonly maximumHeight: number = Number.POSITIVE_INFINITY;
|
||||||
|
|
||||||
|
readonly priority: LayoutPriority = LayoutPriority.Low;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@INotificationService notificationService: INotificationService,
|
@INotificationService notificationService: INotificationService,
|
||||||
@IStorageService storageService: IStorageService,
|
@IStorageService storageService: IStorageService,
|
||||||
|
|
Loading…
Reference in a new issue