提交 2b029679 编写于 作者: S SteVen Batten

fix #92387

上级 8c596fbf
...@@ -22,6 +22,7 @@ export interface IPaneOptions { ...@@ -22,6 +22,7 @@ export interface IPaneOptions {
minimumBodySize?: number; minimumBodySize?: number;
maximumBodySize?: number; maximumBodySize?: number;
expanded?: boolean; expanded?: boolean;
orientation?: Orientation;
title: string; title: string;
} }
...@@ -50,6 +51,7 @@ export abstract class Pane extends Disposable implements IView { ...@@ -50,6 +51,7 @@ export abstract class Pane extends Disposable implements IView {
private body!: HTMLElement; private body!: HTMLElement;
protected _expanded: boolean; protected _expanded: boolean;
protected _orientation: Orientation;
protected _preventCollapse?: boolean; protected _preventCollapse?: boolean;
private expandedSize: number | undefined = undefined; private expandedSize: number | undefined = undefined;
...@@ -117,11 +119,12 @@ export abstract class Pane extends Disposable implements IView { ...@@ -117,11 +119,12 @@ export abstract class Pane extends Disposable implements IView {
return headerSize + maximumBodySize; return headerSize + maximumBodySize;
} }
width: number = 0; orthogonalSize: number = 0;
constructor(options: IPaneOptions) { constructor(options: IPaneOptions) {
super(); super();
this._expanded = typeof options.expanded === 'undefined' ? true : !!options.expanded; this._expanded = typeof options.expanded === 'undefined' ? true : !!options.expanded;
this._orientation = typeof options.orientation === 'undefined' ? Orientation.VERTICAL : Orientation.HORIZONTAL;
this.ariaHeaderLabel = localize('viewSection', "{0} Section", options.title); this.ariaHeaderLabel = localize('viewSection', "{0} Section", options.title);
this._minimumBodySize = typeof options.minimumBodySize === 'number' ? options.minimumBodySize : 120; this._minimumBodySize = typeof options.minimumBodySize === 'number' ? options.minimumBodySize : 120;
this._maximumBodySize = typeof options.maximumBodySize === 'number' ? options.maximumBodySize : Number.POSITIVE_INFINITY; this._maximumBodySize = typeof options.maximumBodySize === 'number' ? options.maximumBodySize : Number.POSITIVE_INFINITY;
...@@ -208,12 +211,15 @@ export abstract class Pane extends Disposable implements IView { ...@@ -208,12 +211,15 @@ export abstract class Pane extends Disposable implements IView {
this.renderBody(this.body); this.renderBody(this.body);
} }
layout(height: number): void { layout(size: number): void {
const headerSize = this.headerVisible ? Pane.HEADER_SIZE : 0; const headerSize = this.headerVisible ? Pane.HEADER_SIZE : 0;
const width = this._orientation === Orientation.VERTICAL ? this.orthogonalSize : size;
const height = this._orientation === Orientation.VERTICAL ? size - headerSize : this.orthogonalSize - headerSize;
if (this.isExpanded()) { if (this.isExpanded()) {
this.layoutBody(height - headerSize, this.width); this.layoutBody(height, width);
this.expandedSize = height; this.expandedSize = size;
} }
} }
...@@ -391,7 +397,7 @@ export class PaneView extends Disposable { ...@@ -391,7 +397,7 @@ export class PaneView extends Disposable {
private dndContext: IDndContext = { draggable: null }; private dndContext: IDndContext = { draggable: null };
private el: HTMLElement; private el: HTMLElement;
private paneItems: IPaneItem[] = []; private paneItems: IPaneItem[] = [];
private width: number = 0; private orthogonalSize: number = 0;
private splitview: SplitView; private splitview: SplitView;
private orientation: Orientation; private orientation: Orientation;
private animationTimer: number | undefined = undefined; private animationTimer: number | undefined = undefined;
...@@ -417,7 +423,7 @@ export class PaneView extends Disposable { ...@@ -417,7 +423,7 @@ export class PaneView extends Disposable {
const paneItem = { pane: pane, disposable: disposables }; const paneItem = { pane: pane, disposable: disposables };
this.paneItems.splice(index, 0, paneItem); this.paneItems.splice(index, 0, paneItem);
pane.width = this.width; pane.orthogonalSize = this.orthogonalSize;
this.splitview.addView(pane, size, index); this.splitview.addView(pane, size, index);
if (this.dnd) { if (this.dnd) {
...@@ -474,10 +480,10 @@ export class PaneView extends Disposable { ...@@ -474,10 +480,10 @@ export class PaneView extends Disposable {
} }
layout(height: number, width: number): void { layout(height: number, width: number): void {
this.width = width; this.orthogonalSize = this.orientation === Orientation.VERTICAL ? width : height;
for (const paneItem of this.paneItems) { for (const paneItem of this.paneItems) {
paneItem.pane.width = width; paneItem.pane.orthogonalSize = this.orthogonalSize;
} }
this.splitview.layout(this.orientation === Orientation.HORIZONTAL ? width : height); this.splitview.layout(this.orientation === Orientation.HORIZONTAL ? width : height);
......
...@@ -210,7 +210,7 @@ export abstract class ViewPane extends Pane implements IView { ...@@ -210,7 +210,7 @@ export abstract class ViewPane extends Pane implements IView {
@IThemeService protected themeService: IThemeService, @IThemeService protected themeService: IThemeService,
@ITelemetryService protected telemetryService: ITelemetryService, @ITelemetryService protected telemetryService: ITelemetryService,
) { ) {
super(options); super({ ...options, ...{ orientation: viewDescriptorService.getViewLocation(options.id) === ViewContainerLocation.Panel ? Orientation.HORIZONTAL : Orientation.VERTICAL } });
this.id = options.id; this.id = options.id;
this.title = options.title; this.title = options.title;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册