Skip to content
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 12 commits into from
Jun 19, 2018
Merged

Centered editor layout #52064

merged 12 commits into from
Jun 19, 2018

Conversation

isidorn
Copy link
Contributor

@isidorn isidorn commented Jun 15, 2018

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:

  • double check layout of the grid - seems to overflow to the right
  • add separator style (due to overflow right separtor is hidden)
  • background color of left and right empty areas should have the color of the editor

@isidorn isidorn added this to the June 2018 milestone Jun 15, 2018
@bpasero
Copy link
Member

bpasero commented Jun 15, 2018

@isidorn cool, I guess something is off with the background color?

image

There is also a bit weirdness when running this when no editor is opened:

before

@bpasero
Copy link
Member

bpasero commented Jun 15, 2018

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.

@joaomoreno
Copy link
Member

joaomoreno commented Jun 18, 2018

@isidorn I would merge master into this, since there was an ugly issue which I just fixed this morning.

@isidorn
Copy link
Contributor Author

isidorn commented Jun 18, 2018

I have merged master.
I am now also centering the layout by pushing empty views, not reparenting html elements - so it is more elegent.

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) {
Copy link
Member

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),
Copy link
Member

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;
Copy link
Member

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);
Copy link
Member

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: $('.'),
Copy link
Member

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);
Copy link
Member

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);
}
Copy link
Member

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().

@isidorn
Copy link
Contributor Author

isidorn commented Jun 18, 2018

@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 editorPart goes directly to the gridWidget and for some it goes to the centeredLayout instead which forwards to the gridWidget.

element: this.view.element,
maximumSize: this.view.maximumWidth,
minimumSize: this.view.minimumWidth,
onDidChange: Event.None,
Copy link
Member

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);
Copy link
Member

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) {
Copy link
Member

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.

@isidorn
Copy link
Contributor Author

isidorn commented Jun 18, 2018

@joaomoreno thanks - great feedback, I have addressed that feedback in the latest commit.
There are still some issues with the watermark that I want to address before merging in

@isidorn isidorn merged commit 6a1ca40 into master Jun 19, 2018
@isidorn isidorn deleted the isidorn/centeredLayout branch June 19, 2018 08:53
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Grid: Implement "Centered Editor Layout"
3 participants