Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3

This commit is contained in:
ADS Merger
2020-03-11 04:19:23 +00:00
parent 16fab722d5
commit 4c3e48773d
880 changed files with 20441 additions and 11232 deletions

View File

@@ -15,12 +15,15 @@ import { Color, RGBA } from 'vs/base/common/color';
import { SplitView, IView } from './splitview';
import { isFirefox } from 'vs/base/browser/browser';
import { DataTransfers } from 'vs/base/browser/dnd';
import { Orientation } from 'vs/base/browser/ui/sash/sash';
import { localize } from 'vs/nls';
export interface IPaneOptions {
ariaHeaderLabel?: string;
minimumBodySize?: number;
maximumBodySize?: number;
expanded?: boolean;
orientation?: Orientation;
title: string;
}
export interface IPaneStyles {
@@ -48,6 +51,8 @@ export abstract class Pane extends Disposable implements IView {
private body!: HTMLElement;
protected _expanded: boolean;
protected _orientation: Orientation;
protected _preventCollapse?: boolean;
private expandedSize: number | undefined = undefined;
private _headerVisible = true;
@@ -114,12 +119,13 @@ export abstract class Pane extends Disposable implements IView {
return headerSize + maximumBodySize;
}
width: number = 0;
orthogonalSize: number = 0;
constructor(options: IPaneOptions = {}) {
constructor(options: IPaneOptions) {
super();
this._expanded = typeof options.expanded === 'undefined' ? true : !!options.expanded;
this.ariaHeaderLabel = options.ariaHeaderLabel || '';
this._orientation = typeof options.orientation === 'undefined' ? Orientation.VERTICAL : Orientation.HORIZONTAL;
this.ariaHeaderLabel = localize('viewSection', "{0} Section", options.title);
this._minimumBodySize = typeof options.minimumBodySize === 'number' ? options.minimumBodySize : 120;
this._maximumBodySize = typeof options.maximumBodySize === 'number' ? options.maximumBodySize : Number.POSITIVE_INFINITY;
@@ -183,31 +189,37 @@ export abstract class Pane extends Disposable implements IView {
this.updateHeader();
const onHeaderKeyDown = Event.chain(domEvent(this.header, 'keydown'))
.map(e => new StandardKeyboardEvent(e));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.Enter || e.keyCode === KeyCode.Space)
.event(() => this.setExpanded(!this.isExpanded()), null));
if (!this._preventCollapse) {
const onHeaderKeyDown = Event.chain(domEvent(this.header, 'keydown'))
.map(e => new StandardKeyboardEvent(e));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.LeftArrow)
.event(() => this.setExpanded(false), null));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.Enter || e.keyCode === KeyCode.Space)
.event(() => this.setExpanded(!this.isExpanded()), null));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.RightArrow)
.event(() => this.setExpanded(true), null));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.LeftArrow)
.event(() => this.setExpanded(false), null));
this._register(domEvent(this.header, 'click')
(() => this.setExpanded(!this.isExpanded()), null));
this._register(onHeaderKeyDown.filter(e => e.keyCode === KeyCode.RightArrow)
.event(() => this.setExpanded(true), null));
this._register(domEvent(this.header, 'click')
(() => this.setExpanded(!this.isExpanded()), null));
}
this.body = append(this.element, $('.pane-body'));
this.renderBody(this.body);
}
layout(height: number): void {
layout(size: number): void {
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()) {
this.layoutBody(height - headerSize, this.width);
this.expandedSize = height;
this.layoutBody(height, width);
this.expandedSize = size;
}
}
@@ -371,6 +383,7 @@ export class DefaultPaneDndController implements IPaneDndController {
export interface IPaneViewOptions {
dnd?: IPaneDndController;
orientation?: Orientation;
}
interface IPaneItem {
@@ -384,8 +397,9 @@ export class PaneView extends Disposable {
private dndContext: IDndContext = { draggable: null };
private el: HTMLElement;
private paneItems: IPaneItem[] = [];
private width: number = 0;
private orthogonalSize: number = 0;
private splitview: SplitView;
private orientation: Orientation;
private animationTimer: number | undefined = undefined;
private _onDidDrop = this._register(new Emitter<{ from: Pane, to: Pane }>());
@@ -397,8 +411,9 @@ export class PaneView extends Disposable {
super();
this.dnd = options.dnd;
this.orientation = options.orientation ?? Orientation.VERTICAL;
this.el = append(container, $('.monaco-pane-view'));
this.splitview = this._register(new SplitView(this.el));
this.splitview = this._register(new SplitView(this.el, { orientation: this.orientation }));
this.onDidSashChange = this.splitview.onDidSashChange;
}
@@ -408,7 +423,7 @@ export class PaneView extends Disposable {
const paneItem = { pane: pane, disposable: disposables };
this.paneItems.splice(index, 0, paneItem);
pane.width = this.width;
pane.orthogonalSize = this.orthogonalSize;
this.splitview.addView(pane, size, index);
if (this.dnd) {
@@ -465,13 +480,13 @@ export class PaneView extends Disposable {
}
layout(height: number, width: number): void {
this.width = width;
this.orthogonalSize = this.orientation === Orientation.VERTICAL ? width : height;
for (const paneItem of this.paneItems) {
paneItem.pane.width = width;
paneItem.pane.orthogonalSize = this.orthogonalSize;
}
this.splitview.layout(height);
this.splitview.layout(this.orientation === Orientation.HORIZONTAL ? width : height);
}
private setupAnimation(): void {