titlebarPart.ts 18.3 KB
Newer Older
B
Benjamin Pasero 已提交
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

import 'vs/css!./media/titlebarpart';
B
Benjamin Pasero 已提交
9
import { TPromise } from 'vs/base/common/winjs.base';
10
import { Builder, $ } from 'vs/base/browser/builder';
B
Benjamin Pasero 已提交
11
import * as paths from 'vs/base/common/paths';
B
Benjamin Pasero 已提交
12
import { Part } from 'vs/workbench/browser/part';
13
import { ITitleService, ITitleProperties } from 'vs/workbench/services/title/common/titleService';
B
Benjamin Pasero 已提交
14
import { getZoomFactor } from 'vs/base/browser/browser';
15
import { IWindowService, IWindowsService, MenuBarVisibility } from 'vs/platform/windows/common/windows';
B
Benjamin Pasero 已提交
16 17 18 19
import * as errors from 'vs/base/common/errors';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { IAction, Action } from 'vs/base/common/actions';
20
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
B
Benjamin Pasero 已提交
21
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
22
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
23
import * as nls from 'vs/nls';
24
import * as labels from 'vs/base/common/labels';
B
Benjamin Pasero 已提交
25
import { EditorInput, toResource, Verbosity } from 'vs/workbench/common/editor';
26
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
27
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
B
Benjamin Pasero 已提交
28
import { IThemeService } from 'vs/platform/theme/common/themeService';
29
import { TITLE_BAR_ACTIVE_BACKGROUND, TITLE_BAR_ACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_FOREGROUND, TITLE_BAR_INACTIVE_BACKGROUND, TITLE_BAR_BORDER } from 'vs/workbench/common/theme';
B
Benjamin Pasero 已提交
30
import { isMacintosh, isWindows, isLinux } from 'vs/base/common/platform';
B
Benjamin Pasero 已提交
31
import URI from 'vs/base/common/uri';
R
Ryan Adolf 已提交
32
import { Color } from 'vs/base/common/color';
B
Benjamin Pasero 已提交
33
import { trim } from 'vs/base/common/strings';
S
SteVen Batten 已提交
34
import { addDisposableListener, EventType, EventHelper, Dimension } from 'vs/base/browser/dom';
35
import { IPartService } from 'vs/workbench/services/part/common/partService';
B
Benjamin Pasero 已提交
36 37 38

export class TitlebarPart extends Part implements ITitleService {

B
Benjamin Pasero 已提交
39
	_serviceBrand: any;
B
Benjamin Pasero 已提交
40

41
	private static readonly NLS_UNSUPPORTED = nls.localize('patchedWindowTitle', "[Unsupported]");
42
	private static readonly NLS_USER_IS_ADMIN = isWindows ? nls.localize('userIsAdmin', "[Administrator]") : nls.localize('userIsSudo', "[Superuser]");
43 44 45
	private static readonly NLS_EXTENSION_HOST = nls.localize('devExtensionWindowTitlePrefix', "[Extension Development Host]");
	private static readonly TITLE_DIRTY = '\u25cf ';
	private static readonly TITLE_SEPARATOR = isMacintosh ? '' : ' - '; // macOS uses special - separator
46

B
Benjamin Pasero 已提交
47 48
	private titleContainer: Builder;
	private title: Builder;
49
	private windowControls: Builder;
S
SteVen Batten 已提交
50
	private maxRestoreControl: Builder;
51
	private appIcon: Builder;
B
Benjamin Pasero 已提交
52

B
Benjamin Pasero 已提交
53
	private pendingTitle: string;
B
Benjamin Pasero 已提交
54
	private representedFileName: string;
55 56 57 58 59 60
	private menubarWidth: number;

	private initialSizing: {
		titleFontSize?: number;
		titlebarHeight?: number;
		controlsWidth?: number;
61
		appIconSize?: number;
62
		appIconWidth?: number;
B
Benjamin Pasero 已提交
63
	} = Object.create(null);
B
Benjamin Pasero 已提交
64

B
Benjamin Pasero 已提交
65 66
	private isInactive: boolean;

67
	private properties: ITitleProperties;
68 69
	private activeEditorListeners: IDisposable[];

70 71
	constructor(
		id: string,
B
Benjamin Pasero 已提交
72 73
		@IContextMenuService private contextMenuService: IContextMenuService,
		@IWindowService private windowService: IWindowService,
74 75
		@IConfigurationService private configurationService: IConfigurationService,
		@IWindowsService private windowsService: IWindowsService,
B
Benjamin Pasero 已提交
76
		@IEditorService private editorService: IEditorService,
77
		@IEnvironmentService private environmentService: IEnvironmentService,
B
Benjamin Pasero 已提交
78
		@IWorkspaceContextService private contextService: IWorkspaceContextService,
79
		@IPartService private partService: IPartService,
B
Benjamin Pasero 已提交
80
		@IThemeService themeService: IThemeService
81
	) {
B
Benjamin Pasero 已提交
82
		super(id, { hasTitle: false }, themeService);
83

84
		this.properties = { isPure: true, isAdmin: false };
85 86
		this.activeEditorListeners = [];

87 88 89 90
		this.registerListeners();
	}

	private registerListeners(): void {
B
Benjamin Pasero 已提交
91 92 93 94 95 96 97 98
		this._register(addDisposableListener(window, EventType.BLUR, () => this.onBlur()));
		this._register(addDisposableListener(window, EventType.FOCUS, () => this.onFocus()));
		this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationChanged(e)));
		this._register(this.editorService.onDidActiveEditorChange(() => this.onActiveEditorChange()));
		this._register(this.contextService.onDidChangeWorkspaceFolders(() => this.setTitle(this.getWindowTitle())));
		this._register(this.contextService.onDidChangeWorkbenchState(() => this.setTitle(this.getWindowTitle())));
		this._register(this.contextService.onDidChangeWorkspaceName(() => this.setTitle(this.getWindowTitle())));
		this._register(this.partService.onMenubarVisibilityChange(this.onMenubarVisibilityChanged, this));
99 100
	}

B
Benjamin Pasero 已提交
101 102 103 104 105 106 107 108 109 110
	private onBlur(): void {
		this.isInactive = true;
		this.updateStyles();
	}

	private onFocus(): void {
		this.isInactive = false;
		this.updateStyles();
	}

111 112
	private onConfigurationChanged(event: IConfigurationChangeEvent): void {
		if (event.affectsConfiguration('window.title')) {
113 114 115 116
			this.setTitle(this.getWindowTitle());
		}
	}

117 118 119 120 121 122
	private onMenubarVisibilityChanged(dimension: Dimension): void {
		this.menubarWidth = dimension.width;

		this.updateLayout();
	}

B
Benjamin Pasero 已提交
123
	private onActiveEditorChange(): void {
124 125 126 127 128 129 130 131 132

		// Dispose old listeners
		dispose(this.activeEditorListeners);
		this.activeEditorListeners = [];

		// Calculate New Window Title
		this.setTitle(this.getWindowTitle());

		// Apply listener for dirty and label changes
B
Benjamin Pasero 已提交
133 134 135
		const activeEditor = this.editorService.activeEditor;
		if (activeEditor instanceof EditorInput) {
			this.activeEditorListeners.push(activeEditor.onDidChangeDirty(() => {
136 137 138
				this.setTitle(this.getWindowTitle());
			}));

B
Benjamin Pasero 已提交
139
			this.activeEditorListeners.push(activeEditor.onDidChangeLabel(() => {
140 141 142
				this.setTitle(this.getWindowTitle());
			}));
		}
B
Benjamin Pasero 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155 156

		// Represented File Name
		this.updateRepresentedFilename();
	}

	private updateRepresentedFilename(): void {
		const file = toResource(this.editorService.activeEditor, { supportSideBySide: true, filter: 'file' });
		const path = file ? file.fsPath : '';

		// Apply to window
		this.windowService.setRepresentedFilename(path);

		// Keep for context menu
		this.representedFileName = path;
157 158 159 160
	}

	private getWindowTitle(): string {
		let title = this.doGetWindowTitle();
B
Benjamin Pasero 已提交
161
		if (!trim(title)) {
162 163 164
			title = this.environmentService.appNameLong;
		}

165 166 167 168 169
		if (this.properties.isAdmin) {
			title = `${title} ${TitlebarPart.NLS_USER_IS_ADMIN}`;
		}

		if (!this.properties.isPure) {
170 171 172 173 174 175 176 177 178 179 180
			title = `${title} ${TitlebarPart.NLS_UNSUPPORTED}`;
		}

		// Extension Development Host gets a special title to identify itself
		if (this.environmentService.isExtensionDevelopment) {
			title = `${TitlebarPart.NLS_EXTENSION_HOST} - ${title}`;
		}

		return title;
	}

B
Benjamin Pasero 已提交
181
	updateProperties(properties: ITitleProperties): void {
182 183 184 185 186 187 188 189 190 191 192
		const isAdmin = typeof properties.isAdmin === 'boolean' ? properties.isAdmin : this.properties.isAdmin;
		const isPure = typeof properties.isPure === 'boolean' ? properties.isPure : this.properties.isPure;

		if (isAdmin !== this.properties.isAdmin || isPure !== this.properties.isPure) {
			this.properties.isAdmin = isAdmin;
			this.properties.isPure = isPure;

			this.setTitle(this.getWindowTitle());
		}
	}

193 194 195
	/**
	 * Possible template values:
	 *
B
Benjamin Pasero 已提交
196 197 198
	 * {activeEditorLong}: e.g. /Users/Development/myProject/myFolder/myFile.txt
	 * {activeEditorMedium}: e.g. myFolder/myFile.txt
	 * {activeEditorShort}: e.g. myFile.txt
199
	 * {rootName}: e.g. myFolder1, myFolder2, myFolder3
200
	 * {rootPath}: e.g. /Users/Development/myProject
201 202
	 * {folderName}: e.g. myFolder
	 * {folderPath}: e.g. /Users/Development/myFolder
203 204 205 206 207
	 * {appName}: e.g. VS Code
	 * {dirty}: indiactor
	 * {separator}: conditional separator
	 */
	private doGetWindowTitle(): string {
B
Benjamin Pasero 已提交
208
		const editor = this.editorService.activeEditor;
B
Benjamin Pasero 已提交
209
		const workspace = this.contextService.getWorkspace();
210

211
		let root: URI;
212
		if (workspace.configuration) {
213
			root = workspace.configuration;
214 215
		} else if (workspace.folders.length) {
			root = workspace.folders[0].uri;
216 217 218 219
		}

		// Compute folder resource
		// Single Root Workspace: always the root single workspace in this case
220
		// Otherwise: root folder of the currently active file if any
B
Benjamin Pasero 已提交
221
		let folder = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? workspace.folders[0] : this.contextService.getWorkspaceFolder(toResource(editor, { supportSideBySide: true }));
222

223
		// Variables
B
Benjamin Pasero 已提交
224 225 226
		const activeEditorShort = editor ? editor.getTitle(Verbosity.SHORT) : '';
		const activeEditorMedium = editor ? editor.getTitle(Verbosity.MEDIUM) : activeEditorShort;
		const activeEditorLong = editor ? editor.getTitle(Verbosity.LONG) : activeEditorMedium;
227
		const rootName = workspace.name;
228
		const rootPath = root ? labels.getPathLabel(root, this.environmentService) : '';
B
Benjamin Pasero 已提交
229
		const folderName = folder ? folder.name : '';
230
		const folderPath = folder ? labels.getPathLabel(folder.uri, this.environmentService) : '';
B
Benjamin Pasero 已提交
231
		const dirty = editor && editor.isDirty() ? TitlebarPart.TITLE_DIRTY : '';
232 233
		const appName = this.environmentService.appNameLong;
		const separator = TitlebarPart.TITLE_SEPARATOR;
234
		const titleTemplate = this.configurationService.getValue<string>('window.title');
235

236
		return labels.template(titleTemplate, {
B
Benjamin Pasero 已提交
237 238 239
			activeEditorShort,
			activeEditorLong,
			activeEditorMedium,
240 241
			rootName,
			rootPath,
242 243
			folderName,
			folderPath,
244 245 246 247 248 249
			dirty,
			appName,
			separator: { label: separator }
		});
	}

B
Benjamin Pasero 已提交
250
	createContentArea(parent: HTMLElement): HTMLElement {
B
Benjamin Pasero 已提交
251 252
		this.titleContainer = $(parent);

B
Benjamin Pasero 已提交
253
		// App Icon (Windows/Linux)
R
Ryan Adolf 已提交
254
		if (!isMacintosh) {
S
SteVen Batten 已提交
255
			this.appIcon = $(this.titleContainer).div({ class: 'window-appicon' });
B
Benjamin Pasero 已提交
256

S
SteVen Batten 已提交
257 258 259 260 261 262 263
			if (isWindows) {
				this.appIcon.on(EventType.DBLCLICK, e => {
					EventHelper.stop(e, true);

					this.windowService.closeWindow().then(null, errors.onUnexpectedError);
				});
			}
264
		}
S
SteVen Batten 已提交
265

B
Benjamin Pasero 已提交
266 267 268 269
		// Title
		this.title = $(this.titleContainer).div({ class: 'window-title' });
		if (this.pendingTitle) {
			this.title.text(this.pendingTitle);
B
Benjamin Pasero 已提交
270 271
		} else {
			this.setTitle(this.getWindowTitle());
B
Benjamin Pasero 已提交
272 273
		}

274
		// Maximize/Restore on doubleclick
275 276
		this.titleContainer.on(EventType.DBLCLICK, (e) => {
			EventHelper.stop(e);
277 278 279 280

			this.onTitleDoubleclick();
		});

B
Benjamin Pasero 已提交
281
		// Context menu on title
282 283 284
		this.title.on([EventType.CONTEXT_MENU, EventType.MOUSE_DOWN], (e: MouseEvent) => {
			if (e.type === EventType.CONTEXT_MENU || e.metaKey) {
				EventHelper.stop(e);
B
Benjamin Pasero 已提交
285 286 287 288 289

				this.onContextMenu(e);
			}
		});

B
Benjamin Pasero 已提交
290
		// Window Controls (Windows/Linux)
R
Ryan Adolf 已提交
291
		if (!isMacintosh) {
292
			this.windowControls = $(this.titleContainer).div({ class: 'window-controls-container' });
S
SteVen Batten 已提交
293

B
Benjamin Pasero 已提交
294
			// Minimize
295
			$(this.windowControls).div({ class: 'window-icon window-minimize' }).on(EventType.CLICK, () => {
R
Ryan Adolf 已提交
296
				this.windowService.minimizeWindow().then(null, errors.onUnexpectedError);
297
			});
R
Ryan Adolf 已提交
298

B
Benjamin Pasero 已提交
299
			// Restore
S
SteVen Batten 已提交
300
			this.maxRestoreControl = $(this.windowControls).div({ class: 'window-icon window-max-restore' }).on(EventType.CLICK, () => {
S
SteVen Batten 已提交
301 302 303 304
				this.windowService.isMaximized().then((maximized) => {
					if (maximized) {
						return this.windowService.unmaximizeWindow();
					}
B
Benjamin Pasero 已提交
305 306

					return this.windowService.maximizeWindow();
S
SteVen Batten 已提交
307
				}).then(null, errors.onUnexpectedError);
308
			});
R
Ryan Adolf 已提交
309

B
Benjamin Pasero 已提交
310
			// Close
311
			$(this.windowControls).div({ class: 'window-icon window-close' }).on(EventType.CLICK, () => {
R
Ryan Adolf 已提交
312
				this.windowService.closeWindow().then(null, errors.onUnexpectedError);
313
			});
314

B
Benjamin Pasero 已提交
315
			const isMaximized = this.windowService.getConfiguration().maximized ? true : false;
316
			this.onDidChangeMaximized(isMaximized);
317
			this.windowService.onDidChangeMaximize(this.onDidChangeMaximized, this);
318 319 320

			// Resizer
			$(this.titleContainer).div({ class: 'resizer' });
321
		}
R
Ryan Adolf 已提交
322

323 324
		// Since the title area is used to drag the window, we do not want to steal focus from the
		// currently active element. So we restore focus after a timeout back to where it was.
325
		this.titleContainer.on([EventType.MOUSE_DOWN], () => {
326 327 328 329 330 331 332 333
			const active = document.activeElement;
			setTimeout(() => {
				if (active instanceof HTMLElement) {
					active.focus();
				}
			}, 0 /* need a timeout because we are in capture phase */);
		}, void 0, true /* use capture to know the currently active element properly */);

334
		return this.titleContainer.getHTMLElement();
B
Benjamin Pasero 已提交
335 336
	}

337
	private onDidChangeMaximized(maximized: boolean) {
S
SteVen Batten 已提交
338
		if (!this.maxRestoreControl) {
S
SteVen Batten 已提交
339 340
			return;
		}
S
SteVen Batten 已提交
341

S
SteVen Batten 已提交
342
		if (maximized) {
S
SteVen Batten 已提交
343 344
			this.maxRestoreControl.removeClass('window-maximize');
			this.maxRestoreControl.addClass('window-unmaximize');
S
SteVen Batten 已提交
345
		} else {
S
SteVen Batten 已提交
346 347
			this.maxRestoreControl.removeClass('window-unmaximize');
			this.maxRestoreControl.addClass('window-maximize');
S
SteVen Batten 已提交
348
		}
349 350
	}

B
Benjamin Pasero 已提交
351 352 353 354
	protected updateStyles(): void {
		super.updateStyles();

		// Part container
355
		if (this.titleContainer) {
B
Benjamin Pasero 已提交
356 357 358
			const titleBackground = this.getColor(this.isInactive ? TITLE_BAR_INACTIVE_BACKGROUND : TITLE_BAR_ACTIVE_BACKGROUND);
			this.titleContainer.style('background-color', titleBackground);
			if (Color.fromHex(titleBackground).isLighter()) {
S
SteVen Batten 已提交
359 360 361 362
				this.titleContainer.addClass('light');
			} else {
				this.titleContainer.removeClass('light');
			}
363

B
Benjamin Pasero 已提交
364 365 366
			const titleForeground = this.getColor(this.isInactive ? TITLE_BAR_INACTIVE_FOREGROUND : TITLE_BAR_ACTIVE_FOREGROUND);
			this.titleContainer.style('color', titleForeground);

367
			const titleBorder = this.getColor(TITLE_BAR_BORDER);
368
			this.titleContainer.style('border-bottom', titleBorder ? `1px solid ${titleBorder}` : null);
369
		}
B
Benjamin Pasero 已提交
370 371
	}

372
	private onTitleDoubleclick(): void {
373
		this.windowService.onWindowTitleDoubleClick().then(null, errors.onUnexpectedError);
374 375
	}

B
Benjamin Pasero 已提交
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
	private onContextMenu(e: MouseEvent): void {

		// Find target anchor
		const event = new StandardMouseEvent(e);
		const anchor = { x: event.posx, y: event.posy };

		// Show menu
		const actions = this.getContextMenuActions();
		if (actions.length) {
			this.contextMenuService.showContextMenu({
				getAnchor: () => anchor,
				getActions: () => TPromise.as(actions),
				onHide: () => actions.forEach(a => a.dispose())
			});
		}
	}

	private getContextMenuActions(): IAction[] {
		const actions: IAction[] = [];

		if (this.representedFileName) {
			const segments = this.representedFileName.split(paths.sep);
			for (let i = segments.length; i > 0; i--) {
399 400 401 402 403 404 405 406 407
				const isFile = (i === segments.length);

				let pathOffset = i;
				if (!isFile) {
					pathOffset++; // for segments which are not the file name we want to open the folder
				}

				const path = segments.slice(0, pathOffset).join(paths.sep);

B
Benjamin Pasero 已提交
408
				let label: string;
409
				if (!isFile) {
B
Benjamin Pasero 已提交
410 411 412
					label = labels.getBaseLabel(paths.dirname(path));
				} else {
					label = labels.getBaseLabel(path);
413 414 415
				}

				actions.push(new ShowItemInFolderAction(path, label || paths.sep, this.windowsService));
B
Benjamin Pasero 已提交
416 417 418 419 420 421
			}
		}

		return actions;
	}

B
Benjamin Pasero 已提交
422
	setTitle(title: string): void {
B
Benjamin Pasero 已提交
423 424 425 426 427 428 429 430 431 432 433 434

		// Always set the native window title to identify us properly to the OS
		window.document.title = title;

		// Apply if we can
		if (this.title) {
			this.title.text(title);
		} else {
			this.pendingTitle = title;
		}
	}

435
	private updateLayout() {
B
Benjamin Pasero 已提交
436

B
Benjamin Pasero 已提交
437
		// To prevent zooming we need to adjust the font size with the zoom factor
438 439 440 441 442 443
		if (typeof this.initialSizing.titleFontSize !== 'number') {
			this.initialSizing.titleFontSize = parseInt(this.titleContainer.getComputedStyle().fontSize, 10);
		}

		if (typeof this.initialSizing.titlebarHeight !== 'number') {
			this.initialSizing.titlebarHeight = parseInt(this.titleContainer.getComputedStyle().height, 10);
B
Benjamin Pasero 已提交
444
		}
445 446 447 448 449 450 451 452

		// Set font size and line height
		const newHeight = this.initialSizing.titlebarHeight / getZoomFactor();
		this.titleContainer.style({
			fontSize: `${this.initialSizing.titleFontSize / getZoomFactor()}px`,
			'line-height': `${newHeight}px`
		});

B
Benjamin Pasero 已提交
453 454
		// Windows/Linux specific layout
		if (isWindows || isLinux) {
455 456 457 458 459 460 461 462
			if (typeof this.initialSizing.controlsWidth !== 'number') {
				this.initialSizing.controlsWidth = parseInt(this.windowControls.getComputedStyle().width, 10);
			}

			if (typeof this.initialSizing.appIconWidth !== 'number') {
				this.initialSizing.appIconWidth = parseInt(this.appIcon.getComputedStyle().width, 10);
			}

463 464
			if (typeof this.initialSizing.appIconSize !== 'number') {
				this.initialSizing.appIconSize = parseInt(this.appIcon.getComputedStyle().backgroundSize, 10);
465 466 467 468 469
			}

			const currentAppIconHeight = parseInt(this.appIcon.getComputedStyle().height, 10);
			const newControlsWidth = this.initialSizing.controlsWidth / getZoomFactor();
			const newAppIconWidth = this.initialSizing.appIconWidth / getZoomFactor();
470
			const newAppIconSize = this.initialSizing.appIconSize / getZoomFactor();
471 472 473 474 475

			if (!this.menubarWidth) {
				this.menubarWidth = 0;
			}

476 477 478 479 480 481 482 483 484 485 486 487
			// If we can center the title in the titlebar, we should
			const fullWidth = parseInt(this.titleContainer.getComputedStyle().width, 10);
			const titleWidth = parseInt(this.title.getComputedStyle().width, 10);
			const freeSpace = fullWidth - newAppIconWidth - newControlsWidth - titleWidth;
			const leftSideTitle = newAppIconWidth + (freeSpace / 2);

			let bufferWidth = this.menubarWidth;
			if (newAppIconWidth + this.menubarWidth < leftSideTitle) {
				bufferWidth = 0;
			}

			// Adjust app icon mimic menubar
488
			this.appIcon.style({
489 490 491
				'width': `${newAppIconWidth}px`,
				'background-size': `${newAppIconSize}px`,
				'margin-right': `${newControlsWidth - newAppIconWidth + bufferWidth}px`,
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
				'padding-top': `${(newHeight - currentAppIconHeight) / 2.0}px`,
				'padding-bottom': `${(newHeight - currentAppIconHeight) / 2.0}px`
			});

			// Adjust windows controls
			this.windowControls.style({
				'width': `${newControlsWidth}px`
			});

			// Hide title when toggling menu bar
			let menubarToggled = this.configurationService.getValue<MenuBarVisibility>('window.menuBarVisibility') === 'toggle';
			if (menubarToggled && this.menubarWidth) {
				this.title.style('visibility', 'hidden');
			} else {
				this.title.style('visibility', null);
			}
		}
	}

B
Benjamin Pasero 已提交
511
	layout(dimension: Dimension): Dimension[] {
512
		this.updateLayout();
B
Benjamin Pasero 已提交
513 514 515

		return super.layout(dimension);
	}
B
Benjamin Pasero 已提交
516 517 518 519
}

class ShowItemInFolderAction extends Action {

520 521
	constructor(private path: string, label: string, private windowsService: IWindowsService) {
		super('showItemInFolder.action.id', label);
B
Benjamin Pasero 已提交
522 523
	}

B
Benjamin Pasero 已提交
524
	run(): TPromise<void> {
B
Benjamin Pasero 已提交
525 526
		return this.windowsService.showItemInFolder(this.path);
	}
R
Ryan Adolf 已提交
527
}