-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Centered editor layout #52064
Merged
Merged
Centered editor layout #52064
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a86d0e5
add centeredViewLayout
isidorn 98e0b5b
editorPart: plugin centeredViewLayout
isidorn e362c61
update the content class name depending on who is direct chald of edi…
isidorn afcd1fc
merge master
isidorn 151790c
center layout by adding empty views, do not reparent html elements
isidorn 01bafa1
centered layout: respect separator style
isidorn 899aef9
centerd view: address feedback
isidorn 2370f86
properly pass onDidChange and react to other feedback
isidorn 8f7a642
use helper functino to clarify toSplitViewView cast
isidorn 4d2c0dd
centeredViewLayout: height 100% to show watermark
isidorn 906007f
Merge branch 'master' into isidorn/centeredLayout
isidorn 8527801
centeredView: store ratios and restore them properly
isidorn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,60 +3,93 @@ | |
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { SplitView, Sizing, IView, Orientation, ISplitViewStyles } from 'vs/base/browser/ui/splitview/splitview'; | ||
import { SplitView, Sizing, Orientation, ISplitViewStyles, IView as ISplitViewView } from 'vs/base/browser/ui/splitview/splitview'; | ||
import { $ } from 'vs/base/browser/dom'; | ||
import { Event } from 'vs/base/common/event'; | ||
import { IView } from 'vs/base/browser/ui/grid/gridview'; | ||
|
||
export class CenteredViewLayout { | ||
|
||
private splitView: SplitView; | ||
readonly element: HTMLElement; | ||
private active: boolean; | ||
private element: HTMLElement; | ||
private height: number; | ||
private style: ISplitViewStyles; | ||
|
||
constructor(container: HTMLElement, view: IView) { | ||
this.element = $('.centered-view-layout'); | ||
container.appendChild(this.element); | ||
|
||
this.splitView = new SplitView(this.element, { | ||
inverseAltBehavior: true, | ||
orientation: Orientation.HORIZONTAL | ||
}); | ||
|
||
this.splitView.addView(view, Sizing.Distribute); | ||
constructor(private container: HTMLElement, private view: IView) { | ||
this.container.appendChild(this.view.element); | ||
} | ||
|
||
layout(size: number): void { | ||
this.splitView.layout(size); | ||
layout(width: number, height: number): void { | ||
this.height = height; | ||
if (this.splitView) { | ||
this.splitView.layout(width); | ||
} else { | ||
this.view.layout(width, height); | ||
} | ||
} | ||
|
||
isActive(): boolean { | ||
return this.active; | ||
return !!this.splitView; | ||
} | ||
|
||
styles(style: ISplitViewStyles): void { | ||
this.splitView.style(style); | ||
this.style = style; | ||
if (this.splitView) { | ||
this.splitView.style(this.style); | ||
} | ||
} | ||
|
||
resetView(view: IView): void { | ||
this.view = view; | ||
if (this.splitView) { | ||
this.splitView.removeView(1); | ||
this.splitView.addView(this.getView(), Sizing.Distribute, 1); | ||
} | ||
} | ||
|
||
private getView(): ISplitViewView { | ||
return { | ||
element: this.view.element, | ||
maximumSize: this.view.maximumWidth, | ||
minimumSize: this.view.minimumWidth, | ||
onDidChange: Event.None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should expose |
||
layout: size => this.view.layout(size, this.height) | ||
}; | ||
} | ||
|
||
activate(active: boolean): void { | ||
this.active = active; | ||
if (this.active) { | ||
const emptyView = { | ||
element: $('.'), | ||
if (active) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should still make a |
||
this.element = $('.centered-view-layout'); | ||
this.container.removeChild(this.view.element); | ||
this.container.appendChild(this.element); | ||
this.splitView = new SplitView(this.element, { | ||
inverseAltBehavior: true, | ||
orientation: Orientation.HORIZONTAL, | ||
styles: this.style | ||
}); | ||
|
||
const getEmptyView = () => ({ | ||
element: $('.centered-layout-margin'), | ||
layout: () => undefined, | ||
minimumSize: 20, | ||
maximumSize: Number.POSITIVE_INFINITY, | ||
onDidChange: Event.None | ||
}; | ||
}); | ||
|
||
this.splitView.addView(emptyView, Sizing.Distribute, 0); | ||
this.splitView.addView(emptyView, Sizing.Distribute); | ||
this.splitView.addView(getEmptyView(), Sizing.Distribute); | ||
this.splitView.addView(this.getView(), Sizing.Distribute); | ||
this.splitView.addView(getEmptyView(), Sizing.Distribute); | ||
} else { | ||
this.splitView.removeView(0); | ||
this.splitView.removeView(1); | ||
this.splitView.dispose(); | ||
this.splitView = undefined; | ||
this.container.removeChild(this.element); | ||
this.container.appendChild(this.view.element); | ||
} | ||
} | ||
|
||
dispose(): void { | ||
this.splitView.dispose(); | ||
if (this.splitView) { | ||
this.splitView.dispose(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is
splitview.distributeViewSizes()
.