titlebarPart.ts 18.4 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, addClass, removeClass } from 'vs/base/browser/dom';
35
import { IPartService } from 'vs/workbench/services/part/common/partService';
B
Benjamin Pasero 已提交
36 37 38 39 40

export class TitlebarPart extends Part implements ITitleService {

	public _serviceBrand: any;

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 50
	private windowControls: Builder;
	private appIcon: Builder;
B
Benjamin Pasero 已提交
51

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

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

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

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

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

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

86 87 88 89
		this.registerListeners();
	}

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

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

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

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

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

		this.updateLayout();
	}

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

		// 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 已提交
132 133 134
		const activeEditor = this.editorService.activeEditor;
		if (activeEditor instanceof EditorInput) {
			this.activeEditorListeners.push(activeEditor.onDidChangeDirty(() => {
135 136 137
				this.setTitle(this.getWindowTitle());
			}));

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

		// 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;
156 157 158 159
	}

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

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

		if (!this.properties.isPure) {
169 170 171 172 173 174 175 176 177 178 179
			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;
	}

180 181 182 183 184 185 186 187 188 189 190 191
	public updateProperties(properties: ITitleProperties): void {
		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());
		}
	}

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

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

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

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

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

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

B
Benjamin Pasero 已提交
252
		// App Icon (Windows/Linux)
R
Ryan Adolf 已提交
253
		if (!isMacintosh) {
254
			this.appIcon = $(this.titleContainer).img({
255
				class: 'window-appicon',
256
				src: paths.join(this.environmentService.appRoot, isWindows ? 'resources/win32/code.ico' : 'resources/linux/code.png')
B
Benjamin Pasero 已提交
257
			}).on(EventType.DBLCLICK, e => {
258
				EventHelper.stop(e, true);
B
Benjamin Pasero 已提交
259

260 261
				this.windowService.closeWindow().then(null, errors.onUnexpectedError);
			});
262 263 264

			// Resizer
			$(this.titleContainer).div({ class: 'resizer' });
265
		}
S
SteVen Batten 已提交
266

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

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

			this.onTitleDoubleclick();
		});

B
Benjamin Pasero 已提交
280
		// Context menu on title
281 282 283
		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 已提交
284 285 286 287 288

				this.onContextMenu(e);
			}
		});

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

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

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

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

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

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

319 320
		// 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.
321
		this.titleContainer.on([EventType.MOUSE_DOWN], () => {
322 323 324 325 326 327 328 329
			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 */);

330
		return this.titleContainer.getHTMLElement();
B
Benjamin Pasero 已提交
331 332
	}

333
	private onDidChangeMaximized(maximized: boolean) {
B
Benjamin Pasero 已提交
334
		const element = $(this.titleContainer).getHTMLElement().querySelector('.window-max-restore') as HTMLElement;
S
SteVen Batten 已提交
335 336 337
		if (!element) {
			return;
		}
S
SteVen Batten 已提交
338

S
SteVen Batten 已提交
339
		if (maximized) {
B
Benjamin Pasero 已提交
340 341
			removeClass(element, 'window-maximize');
			addClass(element, 'window-unmaximize');
S
SteVen Batten 已提交
342
		} else {
B
Benjamin Pasero 已提交
343 344
			removeClass(element, 'window-unmaximize');
			addClass(element, 'window-maximize');
S
SteVen Batten 已提交
345
		}
346 347
	}

B
Benjamin Pasero 已提交
348 349 350 351
	protected updateStyles(): void {
		super.updateStyles();

		// Part container
352
		if (this.titleContainer) {
B
Benjamin Pasero 已提交
353 354 355
			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 已提交
356 357 358 359
				this.titleContainer.addClass('light');
			} else {
				this.titleContainer.removeClass('light');
			}
360

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

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

369
	private onTitleDoubleclick(): void {
370
		this.windowService.onWindowTitleDoubleClick().then(null, errors.onUnexpectedError);
371 372
	}

B
Benjamin Pasero 已提交
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
	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--) {
396 397 398 399 400 401 402 403 404
				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 已提交
405
				let label: string;
406
				if (!isFile) {
B
Benjamin Pasero 已提交
407 408 409
					label = labels.getBaseLabel(paths.dirname(path));
				} else {
					label = labels.getBaseLabel(path);
410 411 412
				}

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

		return actions;
	}

419
	public setTitle(title: string): void {
B
Benjamin Pasero 已提交
420 421 422 423 424 425 426 427 428 429 430 431

		// 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;
		}
	}

432
	private updateLayout() {
B
Benjamin Pasero 已提交
433

B
Benjamin Pasero 已提交
434
		// To prevent zooming we need to adjust the font size with the zoom factor
435 436 437 438 439 440
		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 已提交
441
		}
442 443 444 445 446 447 448 449

		// 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 已提交
450 451
		// Windows/Linux specific layout
		if (isWindows || isLinux) {
452 453 454 455 456 457 458 459
			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);
			}

460 461
			if (typeof this.initialSizing.appIconLeftPadding !== 'number') {
				this.initialSizing.appIconLeftPadding = parseInt(this.appIcon.getComputedStyle().paddingLeft, 10);
462 463 464 465 466
			}

			const currentAppIconHeight = parseInt(this.appIcon.getComputedStyle().height, 10);
			const newControlsWidth = this.initialSizing.controlsWidth / getZoomFactor();
			const newAppIconWidth = this.initialSizing.appIconWidth / getZoomFactor();
467
			const newAppIconPaddingLeft = this.initialSizing.appIconLeftPadding / getZoomFactor();
468 469 470 471 472

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

473 474 475 476 477 478 479 480 481 482 483 484
			// 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
485
			this.appIcon.style({
486 487 488
				width: `${newAppIconWidth}px`,
				'padding-left': `${newAppIconPaddingLeft}px`,
				'margin-right': `${newControlsWidth - newAppIconWidth - newAppIconPaddingLeft + bufferWidth}px`,
489 490 491 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);
			}
		}
	}

	public layout(dimension: Dimension): Dimension[] {

		this.updateLayout();
B
Benjamin Pasero 已提交
511 512 513

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

class ShowItemInFolderAction extends Action {

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

	public run(): TPromise<void> {
		return this.windowsService.showItemInFolder(this.path);
	}
R
Ryan Adolf 已提交
525
}