提交 b329bf4c 编写于 作者: B Benjamin Pasero

debt - allow parts to register with the workbench and adopt for title bar

上级 a6e596d7
......@@ -14,13 +14,8 @@ import { isMacintosh } from 'vs/base/common/platform';
import { memoize } from 'vs/base/common/decorators';
import { Dimension, getClientArea, size, position, hide, show } from 'vs/base/browser/dom';
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { TitlebarPart } from 'vs/workbench/browser/parts/titlebar/titlebarPart';
import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activitybarPart';
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart';
import { StatusbarPart } from 'vs/workbench/browser/parts/statusbar/statusbarPart';
import { getZoomFactor } from 'vs/base/browser/browser';
import { Part } from 'vs/workbench/browser/part';
const TITLE_BAR_HEIGHT = isMacintosh ? 22 : 30;
const STATUS_BAR_HEIGHT = 22;
......@@ -67,12 +62,12 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
private parent: HTMLElement,
private workbenchContainer: HTMLElement,
private parts: {
titlebar: TitlebarPart,
activitybar: ActivitybarPart,
editor: EditorPart,
sidebar: SidebarPart,
panel: PanelPart,
statusbar: StatusbarPart
titlebar: Part,
activitybar: Part,
editor: Part,
sidebar: Part,
panel: Part,
statusbar: Part
},
@IStorageService private readonly storageService: IStorageService,
@IContextViewService private readonly contextViewService: IContextViewService,
......@@ -106,7 +101,7 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
private registerListeners(): void {
this._register(this.themeService.onThemeChange(_ => this.layout()));
this._register(this.parts.editor.onDidSizeConstraintsChange(() => this.onDidEditorSizeConstraintsChange()));
this._register((this.parts.editor as any).onDidSizeConstraintsChange(() => this.onDidEditorSizeConstraintsChange()));
this.registerSashListeners();
}
......@@ -631,11 +626,11 @@ export class WorkbenchLegacyLayout extends Disposable implements IVerticalSashLa
}
// Propagate to Part Layouts
this.parts.titlebar.layout(this.workbenchSize.width, this.titlebarHeight);
this.parts.editor.layout(editorSize.width, editorSize.height);
this.parts.sidebar.layout(sidebarSize.width, sidebarSize.height);
this.parts.panel.layout(panelDimension.width, panelDimension.height);
this.parts.activitybar.layout(activityBarSize.width, activityBarSize.height);
this.parts.titlebar.layout(this.workbenchSize.width, this.titlebarHeight, -1);
this.parts.editor.layout(editorSize.width, editorSize.height, -1);
this.parts.sidebar.layout(sidebarSize.width, sidebarSize.height, -1);
this.parts.panel.layout(panelDimension.width, panelDimension.height, -1);
this.parts.activitybar.layout(activityBarSize.width, activityBarSize.height, -1);
// Propagate to Context View
this.contextViewService.layout();
......
......@@ -10,7 +10,7 @@ import { Dimension, size } from 'vs/base/browser/dom';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IDimension } from 'vs/platform/layout/browser/layoutService';
import { ISerializableView, Orientation } from 'vs/base/browser/ui/grid/grid';
import { Event } from 'vs/base/common/event';
import { Event, Emitter } from 'vs/base/common/event';
export interface IPartOptions {
hasTitle?: boolean;
......@@ -109,9 +109,11 @@ export abstract class Part extends Component implements ISerializableView {
//#region ISerializableView
abstract onDidChange: Event<IDimension>;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
element: HTMLElement;
abstract element: HTMLElement;
abstract minimumWidth: number;
abstract maximumWidth: number;
abstract minimumHeight: number;
......
......@@ -6,7 +6,6 @@
import 'vs/css!./media/activitybarpart';
import * as nls from 'vs/nls';
import { illegalArgument } from 'vs/base/common/errors';
import { Event, Emitter } from 'vs/base/common/event';
import { ActionsOrientation, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { GlobalActivityExtensions, IGlobalActivityRegistry } from 'vs/workbench/common/activity';
import { Registry } from 'vs/platform/registry/common/platform';
......@@ -49,15 +48,14 @@ export class ActivitybarPart extends Part {
private static readonly ACTION_HEIGHT = 50;
private static readonly PINNED_VIEWLETS = 'workbench.activity.pinnedViewlets';
element: HTMLElement;
//#region IView
readonly minimumWidth: number = 50;
readonly maximumWidth: number = 50;
readonly minimumHeight: number = 0;
readonly maximumHeight: number = Number.POSITIVE_INFINITY;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
//#endregion
private globalActionBar: ActionBar;
private globalActivityIdToActions: { [globalActivityId: string]: GlobalActivityAction; } = Object.create(null);
......@@ -67,7 +65,6 @@ export class ActivitybarPart extends Part {
private compositeActions: { [compositeId: string]: { activityAction: ViewletActivityAction, pinnedAction: ToggleCompositePinnedAction } } = Object.create(null);
constructor(
id: string,
@IViewletService private readonly viewletService: IViewletService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IWorkbenchLayoutService private readonly layoutService: IWorkbenchLayoutService,
......@@ -77,7 +74,7 @@ export class ActivitybarPart extends Part {
@IViewsService private readonly viewsService: IViewsService,
@IContextKeyService private readonly contextKeyService: IContextKeyService
) {
super(id, { hasTitle: false }, themeService, storageService);
super(Parts.ACTIVITYBAR_PART, { hasTitle: false }, themeService, storageService);
this.cachedViewlets = this.getCachedViewlets();
for (const cachedViewlet of this.cachedViewlets) {
......
......@@ -86,13 +86,6 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
private static readonly EDITOR_PART_UI_STATE_STORAGE_KEY = 'editorpart.state';
private static readonly EDITOR_PART_CENTERED_VIEW_STORAGE_KEY = 'editorpart.centeredview';
element: HTMLElement;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
readonly priority: LayoutPriority = LayoutPriority.High;
//#region Events
private readonly _onDidLayout: Emitter<Dimension> = this._register(new Emitter<Dimension>());
......@@ -143,14 +136,13 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
private whenRestoredResolve: () => void;
constructor(
id: string,
private restorePreviousState: boolean,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IStorageService storageService: IStorageService
) {
super(id, { hasTitle: false }, themeService, storageService);
super(Parts.EDITOR_PART, { hasTitle: false }, themeService, storageService);
this.gridWidgetView = new GridWidgetView<IEditorGroupView>();
......@@ -753,6 +745,8 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor
//#region Part
readonly priority: LayoutPriority = LayoutPriority.High;
get minimumWidth(): number { return this.centeredLayoutWidget.minimumWidth; }
get maximumWidth(): number { return this.centeredLayoutWidget.maximumWidth; }
get minimumHeight(): number { return this.centeredLayoutWidget.minimumHeight; }
......
......@@ -5,7 +5,7 @@
import 'vs/css!./media/panelpart';
import { IAction } from 'vs/base/common/actions';
import { Event, Emitter } from 'vs/base/common/event';
import { Event } from 'vs/base/common/event';
import { Registry } from 'vs/platform/registry/common/platform';
import { ActionsOrientation } from 'vs/base/browser/ui/actionbar/actionbar';
import { IPanel, ActivePanelContext, PanelFocusContext } from 'vs/workbench/common/panel';
......@@ -50,17 +50,17 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
_serviceBrand: ServiceIdentifier<any>;
element: HTMLElement;
//#region IView
readonly minimumWidth: number = 300;
readonly maximumWidth: number = Number.POSITIVE_INFINITY;
readonly minimumHeight: number = 77;
readonly maximumHeight: number = Number.POSITIVE_INFINITY;
readonly snapSize: number = 50;
readonly priority: LayoutPriority = LayoutPriority.Low;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
//#endregion
get onDidPanelOpen(): Event<{ panel: IPanel, focus: boolean }> { return Event.map(this.onDidCompositeOpen.event, compositeOpen => ({ panel: compositeOpen.composite, focus: compositeOpen.focus })); }
get onDidPanelClose(): Event<IPanel> { return this.onDidCompositeClose.event; }
......@@ -75,7 +75,6 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
private dimension: Dimension;
constructor(
id: string,
@INotificationService notificationService: INotificationService,
@IStorageService storageService: IStorageService,
@ITelemetryService telemetryService: ITelemetryService,
......@@ -102,7 +101,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
'panel',
'panel',
undefined,
id,
Parts.PANEL_PART,
{ hasTitle: true }
);
......
......@@ -38,17 +38,17 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
static readonly activeViewletSettingsKey = 'workbench.sidebar.activeviewletid';
element: HTMLElement;
//#region IView
readonly minimumWidth: number = 170;
readonly maximumWidth: number = Number.POSITIVE_INFINITY;
readonly minimumHeight: number = 0;
readonly maximumHeight: number = Number.POSITIVE_INFINITY;
readonly snapSize: number = 50;
readonly priority: LayoutPriority = LayoutPriority.Low;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
//#endregion
get onDidViewletRegister(): Event<ViewletDescriptor> { return <Event<ViewletDescriptor>>this.viewletRegistry.onDidRegister; }
......@@ -64,7 +64,6 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
private blockOpeningViewlet: boolean;
constructor(
id: string,
@INotificationService notificationService: INotificationService,
@IStorageService storageService: IStorageService,
@ITelemetryService telemetryService: ITelemetryService,
......@@ -91,7 +90,7 @@ export class SidebarPart extends CompositePart<Viewlet> implements IViewletServi
'sideBar',
'viewlet',
SIDE_BAR_TITLE_FOREGROUND,
id,
Parts.SIDEBAR_PART,
{ hasTitle: true, borderWidth: () => (this.getColor(SIDE_BAR_BORDER) || this.getColor(contrastBorder)) ? 1 : 0 }
);
......
......@@ -27,7 +27,6 @@ import { Color } from 'vs/base/common/color';
import { addClass, EventHelper, createStyleSheet, addDisposableListener } from 'vs/base/browser/dom';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Event, Emitter } from 'vs/base/common/event';
import { Parts } from 'vs/workbench/services/layout/browser/layoutService';
export class StatusbarPart extends Part implements IStatusbarService {
......@@ -37,27 +36,25 @@ export class StatusbarPart extends Part implements IStatusbarService {
private static readonly PRIORITY_PROP = 'statusbar-entry-priority';
private static readonly ALIGNMENT_PROP = 'statusbar-entry-alignment';
element: HTMLElement;
//#region IView
readonly minimumWidth: number = 0;
readonly maximumWidth: number = Number.POSITIVE_INFINITY;
readonly minimumHeight: number = 22;
readonly maximumHeight: number = 22;
private _onDidChange = this._register(new Emitter<{ width: number; height: number; }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
//#endregion
private statusMsgDispose: IDisposable;
private styleElement: HTMLStyleElement;
constructor(
id: string,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IStorageService storageService: IStorageService
) {
super(id, { hasTitle: false }, themeService, storageService);
super(Parts.STATUSBAR_PART, { hasTitle: false }, themeService, storageService);
this.registerListeners();
}
......
......@@ -33,8 +33,9 @@ import { template, getBaseLabel } from 'vs/base/common/labels';
import { ILabelService } from 'vs/platform/label/common/label';
import { Event, Emitter } from 'vs/base/common/event';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { Parts } from 'vs/workbench/services/layout/browser/layoutService';
import { Parts, IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { RunOnceScheduler } from 'vs/base/common/async';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
export class TitlebarPart extends Part implements ITitleService {
......@@ -44,16 +45,13 @@ export class TitlebarPart extends Part implements ITitleService {
private static readonly TITLE_DIRTY = '\u25cf ';
private static readonly TITLE_SEPARATOR = isMacintosh ? '' : ' - '; // macOS uses special - separator
element: HTMLElement;
//#region IView
readonly minimumWidth: number = 0;
readonly maximumWidth: number = Number.POSITIVE_INFINITY;
get minimumHeight(): number { return isMacintosh ? 22 / getZoomFactor() : (30 / (this.configurationService.getValue<MenuBarVisibility>('window.menuBarVisibility') === 'hidden' ? getZoomFactor() : 1)); }
get maximumHeight(): number { return isMacintosh ? 22 / getZoomFactor() : (30 / (this.configurationService.getValue<MenuBarVisibility>('window.menuBarVisibility') === 'hidden' ? getZoomFactor() : 1)); }
private _onDidChange = this._register(new Emitter<{ width: number, height: number }>());
get onDidChange(): Event<{ width: number, height: number }> { return this._onDidChange.event; }
//#endregion
private _onMenubarVisibilityChange = this._register(new Emitter<boolean>());
get onMenubarVisibilityChange(): Event<boolean> { return this._onMenubarVisibilityChange.event; }
......@@ -80,7 +78,6 @@ export class TitlebarPart extends Part implements ITitleService {
private titleUpdater: RunOnceScheduler = this._register(new RunOnceScheduler(() => this.doUpdateTitle(), 0));
constructor(
id: string,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IWindowService private readonly windowService: IWindowService,
@IConfigurationService private readonly configurationService: IConfigurationService,
......@@ -91,13 +88,16 @@ export class TitlebarPart extends Part implements ITitleService {
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IThemeService themeService: IThemeService,
@ILabelService private readonly labelService: ILabelService,
@IStorageService storageService: IStorageService
@IStorageService storageService: IStorageService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService
) {
super(id, { hasTitle: false }, themeService, storageService);
super(Parts.TITLEBAR_PART, { hasTitle: false }, themeService, storageService);
this.properties = { isPure: true, isAdmin: false };
this.activeEditorListeners = [];
layoutService.registerPart(this);
this.registerListeners();
}
......@@ -630,3 +630,5 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
`);
}
});
registerSingleton(ITitleService, TitlebarPart);
\ No newline at end of file
......@@ -24,7 +24,6 @@ import { ActivitybarPart } from 'vs/workbench/browser/parts/activitybar/activity
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart';
import { StatusbarPart } from 'vs/workbench/browser/parts/statusbar/statusbarPart';
import { TitlebarPart } from 'vs/workbench/browser/parts/titlebar/titlebarPart';
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart';
import { IActionBarRegistry, Extensions as ActionBarExtensions } from 'vs/workbench/browser/actions';
import { PanelRegistry, Extensions as PanelExtensions } from 'vs/workbench/browser/panel';
......@@ -43,7 +42,7 @@ import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IFileService } from 'vs/platform/files/common/files';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { ITitleService } from 'vs/workbench/services/title/common/titleService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IInstantiationService, ServicesAccessor, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { LifecyclePhase, StartupKind, ILifecycleService, WillShutdownEvent } from 'vs/platform/lifecycle/common/lifecycle';
......@@ -97,6 +96,7 @@ import { IProductService } from 'vs/platform/product/common/product';
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys';
import { IDimension } from 'vs/platform/layout/browser/layoutService';
import { Part } from 'vs/workbench/browser/part';
// import@node
import { getDelayedChannel } from 'vs/base/parts/ipc/node/ipc';
......@@ -128,15 +128,6 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/electron-browse
import { ExtensionService } from 'vs/workbench/services/extensions/electron-browser/extensionService';
import { RequestService } from 'vs/platform/request/electron-browser/requestService';
enum Identifiers {
TITLEBAR_PART = 'workbench.parts.titlebar',
ACTIVITYBAR_PART = 'workbench.parts.activitybar',
SIDEBAR_PART = 'workbench.parts.sidebar',
PANEL_PART = 'workbench.parts.panel',
EDITOR_PART = 'workbench.parts.editor',
STATUSBAR_PART = 'workbench.parts.statusbar'
}
enum Settings {
MENUBAR_VISIBLE = 'window.menuBarVisibility',
ACTIVITYBAR_VISIBLE = 'workbench.activityBar.visible',
......@@ -163,7 +154,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
//#region workbench
_serviceBrand: any;
_serviceBrand: ServiceIdentifier<any>;
private readonly _onShutdown = this._register(new Emitter<void>());
get onShutdown(): Event<void> { return this._onShutdown.event; }
......@@ -190,7 +181,8 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
private logService: ILogService;
private windowsService: IWindowsService;
private titlebarPart: TitlebarPart;
private parts: Map<string, Part> = new Map<string, Part>();
private activitybarPart: ActivitybarPart;
private sidebarPart: SidebarPart;
private panelPart: PanelPart;
......@@ -439,7 +431,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
serviceCollection.set(ILocalizationsService, new SyncDescriptor(LocalizationsChannelClient, [localizationsChannel]));
// Status bar
this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART);
this.statusbarPart = this.instantiationService.createInstance(StatusbarPart);
serviceCollection.set(IStatusbarService, this.statusbarPart); // TODO@Ben use SyncDescriptor
// Context Keys
......@@ -459,25 +451,25 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
// Viewlet service (sidebar part)
this.sidebarPart = this.instantiationService.createInstance(SidebarPart, Identifiers.SIDEBAR_PART);
this.sidebarPart = this.instantiationService.createInstance(SidebarPart);
serviceCollection.set(IViewletService, this.sidebarPart); // TODO@Ben use SyncDescriptor
// Panel service (panel part)
this.panelPart = this.instantiationService.createInstance(PanelPart, Identifiers.PANEL_PART);
this.panelPart = this.instantiationService.createInstance(PanelPart);
serviceCollection.set(IPanelService, this.panelPart); // TODO@Ben use SyncDescriptor
// Views service
serviceCollection.set(IViewsService, new SyncDescriptor(ViewsService));
// Activity service (activitybar part)
this.activitybarPart = this.instantiationService.createInstance(ActivitybarPart, Identifiers.ACTIVITYBAR_PART);
this.activitybarPart = this.instantiationService.createInstance(ActivitybarPart);
serviceCollection.set(IActivityService, new SyncDescriptor(ActivityService, [this.activitybarPart, this.panelPart], true));
// File Service
serviceCollection.set(IFileService, new SyncDescriptor(RemoteFileService));
// Editor and Group services
this.editorPart = this.instantiationService.createInstance(EditorPart, Identifiers.EDITOR_PART, !this.hasInitialFilesToOpen());
this.editorPart = this.instantiationService.createInstance(EditorPart, !this.hasInitialFilesToOpen());
this.editorGroupService = this.editorPart;
serviceCollection.set(IEditorGroupsService, this.editorPart); // TODO@Ben use SyncDescriptor
this.editorService = this.instantiationService.createInstance(EditorService);
......@@ -486,10 +478,6 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
// Accessibility
serviceCollection.set(IAccessibilityService, new SyncDescriptor(AccessibilityService, undefined, true));
// Title bar
this.titlebarPart = this.instantiationService.createInstance(TitlebarPart, Identifiers.TITLEBAR_PART);
serviceCollection.set(ITitleService, this.titlebarPart); // TODO@Ben use SyncDescriptor
// Contributed services
const contributedServices = getServices();
for (let contributedService of contributedServices) {
......@@ -616,37 +604,37 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
private createTitlebarPart(): void {
const titlebarContainer = this.createPart(Identifiers.TITLEBAR_PART, 'contentinfo', 'titlebar');
const titlebarContainer = this.createPart(Parts.TITLEBAR_PART, 'contentinfo', 'titlebar');
this.titlebarPart.create(titlebarContainer);
this.parts.get(Parts.TITLEBAR_PART).create(titlebarContainer);
}
private createActivityBarPart(): void {
const activitybarPartContainer = this.createPart(Identifiers.ACTIVITYBAR_PART, 'navigation', 'activitybar', this.state.sideBar.position === Position.LEFT ? 'left' : 'right');
const activitybarPartContainer = this.createPart(Parts.ACTIVITYBAR_PART, 'navigation', 'activitybar', this.state.sideBar.position === Position.LEFT ? 'left' : 'right');
this.activitybarPart.create(activitybarPartContainer);
}
private createSidebarPart(): void {
const sidebarPartContainer = this.createPart(Identifiers.SIDEBAR_PART, 'complementary', 'sidebar', this.state.sideBar.position === Position.LEFT ? 'left' : 'right');
const sidebarPartContainer = this.createPart(Parts.SIDEBAR_PART, 'complementary', 'sidebar', this.state.sideBar.position === Position.LEFT ? 'left' : 'right');
this.sidebarPart.create(sidebarPartContainer);
}
private createPanelPart(): void {
const panelPartContainer = this.createPart(Identifiers.PANEL_PART, 'complementary', 'panel', this.state.panel.position === Position.BOTTOM ? 'bottom' : 'right');
const panelPartContainer = this.createPart(Parts.PANEL_PART, 'complementary', 'panel', this.state.panel.position === Position.BOTTOM ? 'bottom' : 'right');
this.panelPart.create(panelPartContainer);
}
private createEditorPart(): void {
const editorContainer = this.createPart(Identifiers.EDITOR_PART, 'main', 'editor');
const editorContainer = this.createPart(Parts.EDITOR_PART, 'main', 'editor');
this.editorPart.create(editorContainer);
}
private createStatusbarPart(): void {
const statusbarContainer = this.createPart(Identifiers.STATUSBAR_PART, 'contentinfo', 'statusbar');
const statusbarContainer = this.createPart(Parts.STATUSBAR_PART, 'contentinfo', 'statusbar');
this.statusbarPart.create(statusbarContainer);
}
......@@ -793,7 +781,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
//#endregion
//#region IPartService
//#region ILayoutService
private readonly _onTitleBarVisibilityChange: Emitter<void> = this._register(new Emitter<void>());
get onTitleBarVisibilityChange(): Event<void> { return this._onTitleBarVisibilityChange.event; }
......@@ -867,6 +855,10 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
};
registerPart(part: Part): void {
this.parts.set(part.getId(), part);
}
private registerLayoutListeners(accessor: ServicesAccessor): void {
const storageService = accessor.get(IStorageService);
const editorService = accessor.get(IEditorService);
......@@ -1180,7 +1172,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
getContainer(part: Parts): HTMLElement | null {
switch (part) {
case Parts.TITLEBAR_PART:
return this.titlebarPart.getContainer();
return this.parts.get(Parts.TITLEBAR_PART).getContainer();
case Parts.ACTIVITYBAR_PART:
return this.activitybarPart.getContainer();
case Parts.SIDEBAR_PART:
......@@ -1231,7 +1223,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
let offset = 0;
if (this.isVisible(Parts.TITLEBAR_PART)) {
if (this.workbenchGrid instanceof Grid) {
offset = this.titlebarPart.maximumHeight;
offset = this.parts.get(Parts.TITLEBAR_PART).maximumHeight;
} else {
offset = this.workbenchGrid.partLayoutInfo.titlebar.height;
......@@ -1358,10 +1350,12 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
}
private createWorkbenchLayout(): void {
const titlePart = this.parts.get(Parts.TITLEBAR_PART);
if (this.configurationService.getValue('workbench.useExperimentalGridLayout')) {
// Create view wrappers for all parts
this.titleBarPartView = new View(this.titlebarPart);
this.titleBarPartView = new View(titlePart);
this.sideBarPartView = new View(this.sidebarPart);
this.activityBarPartView = new View(this.activitybarPart);
this.editorPartView = new View(this.editorPart);
......@@ -1377,7 +1371,7 @@ export class Workbench extends Disposable implements IWorkbenchLayoutService {
this.container,
this.workbench,
{
titlebar: this.titlebarPart,
titlebar: titlePart,
activitybar: this.activitybarPart,
editor: this.editorPart,
sidebar: this.sidebarPart,
......
......@@ -87,7 +87,7 @@ suite('Editor groups service', () => {
function createPart(): EditorPart {
const instantiationService = workbenchInstantiationService();
const part = instantiationService.createInstance(EditorPart, 'id', false);
const part = instantiationService.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......
......@@ -76,7 +76,7 @@ suite('Editor service', () => {
test('basics', function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......@@ -149,7 +149,7 @@ suite('Editor service', () => {
test('openEditors() / replaceEditors()', function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......@@ -290,7 +290,7 @@ suite('Editor service', () => {
test('close editor does not dispose when editor opened in other group', function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......@@ -329,7 +329,7 @@ suite('Editor service', () => {
test('open to the side', function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......@@ -363,7 +363,7 @@ suite('Editor service', () => {
test('active editor change / visible editor change events', async function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......@@ -573,7 +573,7 @@ suite('Editor service', () => {
test('openEditor returns NULL when opening fails or is inactive', async function () {
const partInstantiator = workbenchInstantiationService();
const part = partInstantiator.createInstance(EditorPart, 'id', false);
const part = partInstantiator.createInstance(EditorPart, false);
part.create(document.createElement('div'));
part.layout(400, 300);
......
......@@ -7,16 +7,17 @@ import { ServiceIdentifier, createDecorator } from 'vs/platform/instantiation/co
import { Event } from 'vs/base/common/event';
import { MenuBarVisibility } from 'vs/platform/windows/common/windows';
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { Part } from 'vs/workbench/browser/part';
export const IWorkbenchLayoutService = createDecorator<IWorkbenchLayoutService>('layoutService');
export const enum Parts {
ACTIVITYBAR_PART,
SIDEBAR_PART,
PANEL_PART,
EDITOR_PART,
STATUSBAR_PART,
TITLEBAR_PART
TITLEBAR_PART = 'workbench.parts.titlebar',
ACTIVITYBAR_PART = 'workbench.parts.activitybar',
SIDEBAR_PART = 'workbench.parts.sidebar',
PANEL_PART = 'workbench.parts.panel',
EDITOR_PART = 'workbench.parts.editor',
STATUSBAR_PART = 'workbench.parts.statusbar'
}
export const enum Position {
......@@ -145,4 +146,9 @@ export interface IWorkbenchLayoutService extends ILayoutService {
* Resizes currently focused part on main access
*/
resizePart(part: Parts, sizeChange: number): void;
/**
* Register a part to participate in the layout.
*/
registerPart(part: Part): void;
}
......@@ -78,6 +78,7 @@ import { IStorageService, InMemoryStorageService } from 'vs/platform/storage/com
import { isLinux, isMacintosh } from 'vs/base/common/platform';
import { LabelService } from 'vs/workbench/services/label/common/labelService';
import { IDimension } from 'vs/platform/layout/browser/layoutService';
import { Part } from 'vs/workbench/browser/part';
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
return instantiationService.createInstance(FileEditorInput, resource, undefined);
......@@ -542,6 +543,8 @@ export class TestLayoutService implements IWorkbenchLayoutService {
public resizePart(_part: Parts, _sizeChange: number): void { }
public registerPart(part: Part): void { }
}
export class TestStorageService extends InMemoryStorageService { }
......
......@@ -78,6 +78,7 @@ import 'vs/workbench/services/backup/node/backupFileService';
import 'vs/workbench/services/history/browser/history';
import 'vs/workbench/browser/parts/quickinput/quickInput';
import 'vs/workbench/browser/parts/quickopen/quickOpenController';
import 'vs/workbench/browser/parts/titlebar/titlebarPart';
registerSingleton(IMenuService, MenuService, true);
registerSingleton(IListService, ListService, true);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册