Skip to content

Commit

Permalink
Toggle Maximized Panel
Browse files Browse the repository at this point in the history
fixes #7314
  • Loading branch information
isidorn committed Oct 14, 2016
1 parent a8351fa commit 2a322c0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/vs/test/utils/servicesTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ export class TestPartService implements IPartService {

public setPanelHidden(hidden: boolean): void { }

public toggleMaximizedPanel(): void { }

public getSideBarPosition() {
return 0;
}
Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
};
}

public layout(forceStyleReCompute?: boolean): void {
public layout(forceStyleReCompute?: boolean, toggleMaximizedPanel?: boolean): void {
if (forceStyleReCompute) {
this.computeStyle();
this.editor.getLayout().computeStyle();
Expand Down Expand Up @@ -338,13 +338,17 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal

// Panel part
let panelHeight: number;
const maxPanelHeight = sidebarSize.height - DEFAULT_MIN_EDITOR_PART_HEIGHT;
if (isPanelHidden) {
panelHeight = 0;
} else if (this.panelHeight > 0) {
panelHeight = Math.min(sidebarSize.height - DEFAULT_MIN_EDITOR_PART_HEIGHT, Math.max(this.computedStyles.panel.minHeight, this.panelHeight));
panelHeight = Math.min(maxPanelHeight, Math.max(this.computedStyles.panel.minHeight, this.panelHeight));
} else {
panelHeight = sidebarSize.height * 0.4;
}
if (toggleMaximizedPanel) {
panelHeight = panelHeight === maxPanelHeight ? sidebarSize.height * 0.4 : maxPanelHeight;
}
const panelDimension = new Dimension(this.workbenchSize.width - sidebarSize.width - activityBarSize.width, panelHeight);
this.panelWidth = panelDimension.width;

Expand Down
23 changes: 23 additions & 0 deletions src/vs/workbench/browser/parts/panel/panelPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,29 @@ class FocusPanelAction extends Action {
}
}

class ToggleMaximizedPanelAction extends Action {

public static ID = 'workbench.action.toggleMaximizedPanel';
public static LABEL = nls.localize('toggleMaximizedPanel', "Toggle Maximized Panel");

constructor(
id: string,
label: string,
@IPartService private partService: IPartService
) {
super(id, label);
}

public run(): TPromise<boolean> {
// Show panel
this.partService.setPanelHidden(false);
this.partService.toggleMaximizedPanel();

return TPromise.as(true);
}
}

let actionRegistry = <IWorkbenchActionRegistry>Registry.as(WorkbenchExtensions.WorkbenchActions);
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(TogglePanelAction, TogglePanelAction.ID, TogglePanelAction.LABEL, { primary: KeyMod.CtrlCmd | KeyCode.KEY_J }), 'View: Toggle Panel Visibility', nls.localize('view', "View"));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(FocusPanelAction, FocusPanelAction.ID, FocusPanelAction.LABEL), 'View: Focus into Panel', nls.localize('view', "View"));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMaximizedPanelAction, ToggleMaximizedPanelAction.ID, ToggleMaximizedPanelAction.LABEL), 'View: Toggle Maximized Panel', nls.localize('view', "View"));
4 changes: 4 additions & 0 deletions src/vs/workbench/electron-browser/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ export class Workbench implements IPartService {
this.storageService.store(Workbench.panelHiddenSettingKey, hidden ? 'true' : 'false', StorageScope.WORKSPACE);
}

public toggleMaximizedPanel(): void {
this.workbenchLayout.layout(true, true);
}

public getSideBarPosition(): Position {
return this.sideBarPosition;
}
Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/services/part/common/partService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ export interface IPartService {
*/
setPanelHidden(hidden: boolean): void;

/**
* Maximizes the panel height if the panel is not already maximized.
* Shrinks the panel to the default starting size if the panel is maximized.
*/
toggleMaximizedPanel(): void;

/**
* Gets the current side bar position. Note that the sidebar can be hidden too.
*/
Expand Down

0 comments on commit 2a322c0

Please sign in to comment.