Merge pull request #36 from mathuo/35-dockview-fromjson-fix

feat: adjust fromJSON logic
This commit is contained in:
mathuo 2022-03-14 21:56:28 +00:00 committed by GitHub
commit 39eb6a3e25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 1043 additions and 11 deletions

File diff suppressed because it is too large Load Diff

View File

@ -154,8 +154,7 @@ export abstract class BaseGrid<T extends IGridPanelView>
this.element.appendChild(this.gridview.element);
// TODO for some reason this is required before anything will layout correctly
this.layout(0, 0, true);
this.layout(0, 0, true); // set some elements height/widths
this.addDisposables(
this.gridview.onDidChange(() => {

View File

@ -289,7 +289,8 @@ export class Gridview implements IDisposable {
public deserialize(json: any, deserializer: IViewDeserializer) {
const orientation = json.orientation;
const height = json.height;
const height =
orientation === Orientation.VERTICAL ? json.height : json.width;
this._deserialize(
json.root as ISerializedBranchNode,
orientation,
@ -308,7 +309,8 @@ export class Gridview implements IDisposable {
root,
orientation,
deserializer,
orthogonalSize
orthogonalSize,
true
) as BranchNode;
}
@ -316,7 +318,8 @@ export class Gridview implements IDisposable {
node: ISerializedNode,
orientation: Orientation,
deserializer: IViewDeserializer,
orthogonalSize: number
orthogonalSize: number,
isRoot = false
): Node {
let result: Node;
if (node.type === 'branch') {
@ -333,12 +336,14 @@ export class Gridview implements IDisposable {
} as INodeDescriptor;
});
// HORIZONTAL => height=orthogonalsize width=size
// VERTICAL => height=size width=orthogonalsize
result = new BranchNode(
orientation,
this.proportionalLayout,
this.styles,
node.size,
orthogonalSize,
isRoot ? orthogonalSize : node.size,
isRoot ? node.size : orthogonalSize,
children
);
} else {