mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-04 17:23:45 -05:00
Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c (#8525)
* Merge from vscode a5cf1da01d5db3d2557132be8d30f89c38019f6c * remove files we don't want * fix hygiene * update distro * update distro * fix hygiene * fix strict nulls * distro * distro * fix tests * fix tests * add another edit * fix viewlet icon * fix azure dialog * fix some padding * fix more padding issues
This commit is contained in:
@@ -30,7 +30,7 @@ export interface IView {
|
||||
readonly onDidChange: Event<IViewSize | undefined>;
|
||||
readonly priority?: LayoutPriority;
|
||||
readonly snap?: boolean;
|
||||
layout(width: number, height: number, orientation: Orientation): void;
|
||||
layout(width: number, height: number, top: number, left: number): void;
|
||||
setVisible?(visible: boolean): void;
|
||||
}
|
||||
|
||||
@@ -69,10 +69,10 @@ export function orthogonal(orientation: Orientation): Orientation {
|
||||
}
|
||||
|
||||
export interface Box {
|
||||
top: number;
|
||||
left: number;
|
||||
width: number;
|
||||
height: number;
|
||||
readonly top: number;
|
||||
readonly left: number;
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
}
|
||||
|
||||
export interface GridLeafNode {
|
||||
@@ -117,11 +117,19 @@ export interface IGridViewOptions {
|
||||
readonly layoutController?: ILayoutController;
|
||||
}
|
||||
|
||||
class BranchNode implements ISplitView, IDisposable {
|
||||
interface ILayoutContext {
|
||||
readonly orthogonalSize: number;
|
||||
readonly absoluteOffset: number;
|
||||
readonly absoluteOrthogonalOffset: number;
|
||||
readonly absoluteSize: number;
|
||||
readonly absoluteOrthogonalSize: number;
|
||||
}
|
||||
|
||||
class BranchNode implements ISplitView<ILayoutContext>, IDisposable {
|
||||
|
||||
readonly element: HTMLElement;
|
||||
readonly children: Node[] = [];
|
||||
private splitview: SplitView;
|
||||
private splitview: SplitView<ILayoutContext>;
|
||||
|
||||
private _size: number;
|
||||
get size(): number { return this._size; }
|
||||
@@ -129,6 +137,9 @@ class BranchNode implements ISplitView, IDisposable {
|
||||
private _orthogonalSize: number;
|
||||
get orthogonalSize(): number { return this._orthogonalSize; }
|
||||
|
||||
private absoluteOffset: number = 0;
|
||||
private absoluteOrthogonalOffset: number = 0;
|
||||
|
||||
private _styles: IGridViewStyles;
|
||||
get styles(): IGridViewStyles { return this._styles; }
|
||||
|
||||
@@ -140,6 +151,14 @@ class BranchNode implements ISplitView, IDisposable {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.orthogonalSize : this.size;
|
||||
}
|
||||
|
||||
get top(): number {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOffset : this.absoluteOrthogonalOffset;
|
||||
}
|
||||
|
||||
get left(): number {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOrthogonalOffset : this.absoluteOffset;
|
||||
}
|
||||
|
||||
get minimumSize(): number {
|
||||
return this.children.length === 0 ? 0 : Math.max(...this.children.map(c => c.minimumOrthogonalSize));
|
||||
}
|
||||
@@ -221,7 +240,7 @@ class BranchNode implements ISplitView, IDisposable {
|
||||
if (!childDescriptors) {
|
||||
// Normal behavior, we have no children yet, just set up the splitview
|
||||
this.splitview = new SplitView(this.element, { orientation, styles, proportionalLayout });
|
||||
this.splitview.layout(size, orthogonalSize);
|
||||
this.splitview.layout(size, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
||||
} else {
|
||||
// Reconstruction behavior, we want to reconstruct a splitview
|
||||
const descriptor = {
|
||||
@@ -268,20 +287,32 @@ class BranchNode implements ISplitView, IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
layout(size: number, orthogonalSize: number | undefined): void {
|
||||
layout(size: number, offset: number, ctx: ILayoutContext | undefined): void {
|
||||
if (!this.layoutController.isLayoutEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof orthogonalSize !== 'number') {
|
||||
if (typeof ctx === 'undefined') {
|
||||
throw new Error('Invalid state');
|
||||
}
|
||||
|
||||
// branch nodes should flip the normal/orthogonal directions
|
||||
this._size = orthogonalSize;
|
||||
this._size = ctx.orthogonalSize;
|
||||
this._orthogonalSize = size;
|
||||
this.absoluteOffset = ctx.absoluteOffset + offset;
|
||||
this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
|
||||
|
||||
this.splitview.layout(orthogonalSize, size);
|
||||
this.splitview.layout(ctx.orthogonalSize, {
|
||||
orthogonalSize: size,
|
||||
absoluteOffset: this.absoluteOrthogonalOffset,
|
||||
absoluteOrthogonalOffset: this.absoluteOffset,
|
||||
absoluteSize: ctx.absoluteOrthogonalSize,
|
||||
absoluteOrthogonalSize: ctx.absoluteSize
|
||||
});
|
||||
|
||||
// Disable snapping on views which sit on the edges of the grid
|
||||
this.splitview.startSnappingEnabled = this.absoluteOrthogonalOffset > 0;
|
||||
this.splitview.endSnappingEnabled = this.absoluteOrthogonalOffset + ctx.orthogonalSize < ctx.absoluteOrthogonalSize;
|
||||
}
|
||||
|
||||
setVisible(visible: boolean): void {
|
||||
@@ -511,7 +542,7 @@ class BranchNode implements ISplitView, IDisposable {
|
||||
}
|
||||
}
|
||||
|
||||
class LeafNode implements ISplitView, IDisposable {
|
||||
class LeafNode implements ISplitView<ILayoutContext>, IDisposable {
|
||||
|
||||
private _size: number = 0;
|
||||
get size(): number { return this._size; }
|
||||
@@ -519,6 +550,9 @@ class LeafNode implements ISplitView, IDisposable {
|
||||
private _orthogonalSize: number;
|
||||
get orthogonalSize(): number { return this._orthogonalSize; }
|
||||
|
||||
private absoluteOffset: number = 0;
|
||||
private absoluteOrthogonalOffset: number = 0;
|
||||
|
||||
readonly onDidSashReset: Event<number[]> = Event.None;
|
||||
|
||||
private _onDidLinkedWidthNodeChange = new Relay<number | undefined>();
|
||||
@@ -565,6 +599,14 @@ class LeafNode implements ISplitView, IDisposable {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.size : this.orthogonalSize;
|
||||
}
|
||||
|
||||
get top(): number {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOffset : this.absoluteOrthogonalOffset;
|
||||
}
|
||||
|
||||
get left(): number {
|
||||
return this.orientation === Orientation.HORIZONTAL ? this.absoluteOrthogonalOffset : this.absoluteOffset;
|
||||
}
|
||||
|
||||
get element(): HTMLElement {
|
||||
return this.view.element;
|
||||
}
|
||||
@@ -617,18 +659,20 @@ class LeafNode implements ISplitView, IDisposable {
|
||||
// noop
|
||||
}
|
||||
|
||||
layout(size: number, orthogonalSize: number | undefined): void {
|
||||
layout(size: number, offset: number, ctx: ILayoutContext | undefined): void {
|
||||
if (!this.layoutController.isLayoutEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof orthogonalSize !== 'number') {
|
||||
if (typeof ctx === 'undefined') {
|
||||
throw new Error('Invalid state');
|
||||
}
|
||||
|
||||
this._size = size;
|
||||
this._orthogonalSize = orthogonalSize;
|
||||
this.view.layout(this.width, this.height, orthogonal(this.orientation));
|
||||
this._orthogonalSize = ctx.orthogonalSize;
|
||||
this.absoluteOffset = ctx.absoluteOffset + offset;
|
||||
this.absoluteOrthogonalOffset = ctx.absoluteOrthogonalOffset;
|
||||
this.view.layout(this.width, this.height, this.top, this.left);
|
||||
}
|
||||
|
||||
setVisible(visible: boolean): void {
|
||||
@@ -715,7 +759,7 @@ export class GridView implements IDisposable {
|
||||
|
||||
const { size, orthogonalSize } = this._root;
|
||||
this.root = flipNode(this._root, orthogonalSize, size);
|
||||
this.root.layout(size, orthogonalSize);
|
||||
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
||||
}
|
||||
|
||||
get width(): number { return this.root.width; }
|
||||
@@ -771,7 +815,7 @@ export class GridView implements IDisposable {
|
||||
this.firstLayoutController.isLayoutEnabled = true;
|
||||
|
||||
const [size, orthogonalSize] = this.root.orientation === Orientation.HORIZONTAL ? [height, width] : [width, height];
|
||||
this.root.layout(size, orthogonalSize);
|
||||
this.root.layout(size, 0, { orthogonalSize, absoluteOffset: 0, absoluteOrthogonalOffset: 0, absoluteSize: size, absoluteOrthogonalSize: orthogonalSize });
|
||||
}
|
||||
|
||||
addView(view: IView, size: number | Sizing, location: number[]): void {
|
||||
@@ -1032,7 +1076,7 @@ export class GridView implements IDisposable {
|
||||
getView(location?: number[]): GridNode;
|
||||
getView(location?: number[]): GridNode {
|
||||
const node = location ? this.getNode(location)[1] : this._root;
|
||||
return this._getViews(node, this.orientation, { top: 0, left: 0, width: this.width, height: this.height });
|
||||
return this._getViews(node, this.orientation);
|
||||
}
|
||||
|
||||
static deserialize<T extends ISerializableView>(json: ISerializedGridView, deserializer: IViewDeserializer<T>, options: IGridViewOptions = {}): GridView {
|
||||
@@ -1076,24 +1120,20 @@ export class GridView implements IDisposable {
|
||||
return result;
|
||||
}
|
||||
|
||||
private _getViews(node: Node, orientation: Orientation, box: Box, cachedVisibleSize?: number): GridNode {
|
||||
private _getViews(node: Node, orientation: Orientation, cachedVisibleSize?: number): GridNode {
|
||||
const box = { top: node.top, left: node.left, width: node.width, height: node.height };
|
||||
|
||||
if (node instanceof LeafNode) {
|
||||
return { view: node.view, box, cachedVisibleSize };
|
||||
}
|
||||
|
||||
const children: GridNode[] = [];
|
||||
let i = 0;
|
||||
let offset = 0;
|
||||
|
||||
for (const child of node.children) {
|
||||
const childOrientation = orthogonal(orientation);
|
||||
const childBox: Box = orientation === Orientation.HORIZONTAL
|
||||
? { top: box.top, left: box.left + offset, width: child.width, height: box.height }
|
||||
: { top: box.top + offset, left: box.left, width: box.width, height: child.height };
|
||||
const cachedVisibleSize = node.getChildCachedVisibleSize(i++);
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const child = node.children[i];
|
||||
const cachedVisibleSize = node.getChildCachedVisibleSize(i);
|
||||
|
||||
children.push(this._getViews(child, childOrientation, childBox, cachedVisibleSize));
|
||||
offset += orientation === Orientation.HORIZONTAL ? child.width : child.height;
|
||||
children.push(this._getViews(child, orthogonal(orientation), cachedVisibleSize));
|
||||
}
|
||||
|
||||
return { children, box };
|
||||
|
||||
Reference in New Issue
Block a user