提交 aeb4bd53 编写于 作者: C Christof Marti

Hide watermark based on editor part size (fixes #16130)

上级 4e745c2a
...@@ -104,6 +104,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -104,6 +104,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private pendingEditorInputsToClose: EditorIdentifier[]; private pendingEditorInputsToClose: EditorIdentifier[];
private pendingEditorInputCloseTimeout: number; private pendingEditorInputCloseTimeout: number;
private onLayoutEmitter = new Emitter<Dimension>();
public onLayout = this.onLayoutEmitter.event;
constructor( constructor(
id: string, id: string,
restoreFromStorage: boolean, restoreFromStorage: boolean,
...@@ -1191,6 +1194,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService ...@@ -1191,6 +1194,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this.dimension = sizes[1]; this.dimension = sizes[1];
this.editorGroupsControl.layout(this.dimension); this.editorGroupsControl.layout(this.dimension);
this.onLayoutEmitter.fire(dimension);
return sizes; return sizes;
} }
......
...@@ -9,7 +9,7 @@ import 'vs/css!./media/workbench'; ...@@ -9,7 +9,7 @@ import 'vs/css!./media/workbench';
import { TPromise, ValueCallback } from 'vs/base/common/winjs.base'; import { TPromise, ValueCallback } from 'vs/base/common/winjs.base';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter, chain } from 'vs/base/common/event';
import DOM = require('vs/base/browser/dom'); import DOM = require('vs/base/browser/dom');
import { Builder, $ } from 'vs/base/browser/builder'; import { Builder, $ } from 'vs/base/browser/builder';
import { Delayer } from 'vs/base/common/async'; import { Delayer } from 'vs/base/common/async';
...@@ -236,6 +236,12 @@ export class Workbench implements IPartService { ...@@ -236,6 +236,12 @@ export class Workbench implements IPartService {
return this._onTitleBarVisibilityChange.event; return this._onTitleBarVisibilityChange.event;
} }
public get onEditorLayout(): Event<void> {
return chain(this.editorPart.onLayout)
.map(() => void 0)
.event;
}
/** /**
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started * Starts the workbench and creates the HTML elements on the container. A workbench can only be started
* once. Use the shutdown function to free up resources created by the workbench on startup. * once. Use the shutdown function to free up resources created by the workbench on startup.
......
...@@ -27,19 +27,11 @@ ...@@ -27,19 +27,11 @@
border-spacing: 13px 17px; border-spacing: 13px 17px;
} }
@media (min-height: 501px) { .monaco-workbench > .part.editor.empty.max-height-478px > .content > .watermark {
.monaco-workbench > .part.editor.empty > .content > .watermark { display: none;
display: block; }
} .monaco-workbench .part.editor.empty.max-height-478px {
} background-position-y: 50%;
@media (max-height: 500px) {
.monaco-workbench > .part.editor.empty > .content > .watermark {
display: none;
}
.monaco-workbench .part.editor.empty {
background-position-y: 50%;
}
} }
.monaco-workbench > .part.editor.empty > .content > .watermark dl { .monaco-workbench > .part.editor.empty > .content > .watermark dl {
......
...@@ -175,9 +175,15 @@ export class WatermarkContribution implements IWorkbenchContribution { ...@@ -175,9 +175,15 @@ export class WatermarkContribution implements IWorkbenchContribution {
}); });
}); });
}; };
const layout = () => {
const { height } = container.getBoundingClientRect();
container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px');
};
update(); update();
watermark.build(container.firstChild as HTMLElement, 0); watermark.build(container.firstElementChild as HTMLElement, 0);
layout();
this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update)); this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update));
this.toDispose.push(this.partService.onEditorLayout(layout));
} }
public dispose(): void { public dispose(): void {
......
...@@ -36,6 +36,11 @@ export interface IPartService { ...@@ -36,6 +36,11 @@ export interface IPartService {
*/ */
onTitleBarVisibilityChange: Event<void>; onTitleBarVisibilityChange: Event<void>;
/**
* Emits when the editor part's layout changes.
*/
onEditorLayout: Event<void>;
/** /**
* Asks the part service to layout all parts. * Asks the part service to layout all parts.
*/ */
......
...@@ -240,11 +240,16 @@ export class TestPartService implements IPartService { ...@@ -240,11 +240,16 @@ export class TestPartService implements IPartService {
public _serviceBrand: any; public _serviceBrand: any;
private _onTitleBarVisibilityChange = new Emitter<void>(); private _onTitleBarVisibilityChange = new Emitter<void>();
private _onEditorLayout = new Emitter<void>();
public get onTitleBarVisibilityChange(): Event<void> { public get onTitleBarVisibilityChange(): Event<void> {
return this._onTitleBarVisibilityChange.event; return this._onTitleBarVisibilityChange.event;
} }
public get onEditorLayout(): Event<void> {
return this._onEditorLayout.event;
}
public layout(): void { } public layout(): void { }
public isCreated(): boolean { public isCreated(): boolean {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册