-
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
Centered editor layout #52064
Conversation
@isidorn cool, I guess something is off with the background color? There is also a bit weirdness when running this when no editor is opened: |
Also I would not mind if the centered widget was always used and when centered is off it would just fill the whole space and not allow to drag the sashes and when enabled it toggles. That way we do not need to perform any reparenting when switching modes. |
@isidorn I would merge |
I have merged master. Still needs some polish from my first comment, once I address that I plan to merge this in if nobody objects |
@@ -967,7 +985,11 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor | |||
|
|||
// Layout Grid | |||
try { | |||
this.gridWidget.layout(this.dimension.width, this.dimension.height); | |||
if (this.centeredViewLayout) { |
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.
Isn't there always a centeredViewLayout
? This will always be true, it seems.
this.doCreateGridControl(); | ||
this.centeredViewLayout = new CenteredViewLayout(this.container, { | ||
element: this.gridWidget.element, | ||
layout: size => this.gridWidget.layout(size, this.dimension ? this.dimension.height : this.gridWidget.maximumHeight), |
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.
This looks super weird. There must always be a this.dimension
. It's impossible for this view to be asked for layout before doLayout
has run.
Also, if you want to remove the weirdness, don't simply use IView
from splitview. Use IView
from gridview. This one talks about width
and height
. Simultaneously, CenteredViewLayout.layout
would take in both width
and height
.
} | ||
|
||
activate(active: boolean): void { | ||
this.active = active; |
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.
You probably also need if (this.active === active) { return; }
before this.
}; | ||
|
||
this.splitView.addView(emptyView, Sizing.Distribute, 0); | ||
this.splitView.addView(emptyView, Sizing.Distribute); |
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.
You need to add two different views... How can that DOM element be put twice in the DOM?
this.active = active; | ||
if (this.active) { | ||
const emptyView = { | ||
element: $('.'), |
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.
$('.')
doesn't mean anything. If you wan a div, use $('div')
. Though you probably should use something descriptive like $('.centered-layout-margin')
.
this.splitView.addView(emptyView, Sizing.Distribute); | ||
} else { | ||
this.splitView.removeView(0); | ||
this.splitView.removeView(1); |
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.
Why not disposing the splitview altogether and just put the provided view directly as a child of the container?
@@ -1009,6 +1031,9 @@ export class EditorPart extends Part implements EditorGroupsServiceImpl, IEditor | |||
if (this.gridWidget) { | |||
this.gridWidget.dispose(); | |||
} | |||
if (this.centeredViewLayout) { | |||
this.centeredViewLayout = dispose(this.centeredViewLayout); | |||
} |
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.
All you need is this.centeredViewLayout.dispose()
.
@joaomoreno thanks for the review, I have addressed your feedback. There are still some nit-bits to take care of which I am looking into now. What I find a bit ugly is that for some methods the |
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 comment
The reason will be displayed to describe this comment to others. Learn more.
You should expose this.view.onDidChange
here.
this.view = view; | ||
if (this.splitView) { | ||
this.splitView.removeView(1); | ||
this.splitView.addView(this.getView(), Sizing.Distribute, 1); |
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()
.
if (this.active) { | ||
const emptyView = { | ||
element: $('.'), | ||
if (active) { |
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.
You should still make a if (active === !!this.splitview) { return; }
, so you don't get any NPEs.
@joaomoreno thanks - great feedback, I have addressed that feedback in the latest commit. |
Fixes #50936
Brings back centered editor layout support to VSCode.
This is work in progress, creating PR now to potentially get early feedback.
Still needs to be done: