Skip to content

Commit aeb4bd5

Browse files
committed
Hide watermark based on editor part size (fixes microsoft#16130)
1 parent 4e745c2 commit aeb4bd5

6 files changed

Lines changed: 34 additions & 15 deletions

File tree

src/vs/workbench/browser/parts/editor/editorPart.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
104104
private pendingEditorInputsToClose: EditorIdentifier[];
105105
private pendingEditorInputCloseTimeout: number;
106106

107+
private onLayoutEmitter = new Emitter<Dimension>();
108+
public onLayout = this.onLayoutEmitter.event;
109+
107110
constructor(
108111
id: string,
109112
restoreFromStorage: boolean,
@@ -1191,6 +1194,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
11911194
this.dimension = sizes[1];
11921195
this.editorGroupsControl.layout(this.dimension);
11931196

1197+
this.onLayoutEmitter.fire(dimension);
1198+
11941199
return sizes;
11951200
}
11961201

src/vs/workbench/electron-browser/workbench.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'vs/css!./media/workbench';
99

1010
import { TPromise, ValueCallback } from 'vs/base/common/winjs.base';
1111
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
12-
import Event, { Emitter } from 'vs/base/common/event';
12+
import Event, { Emitter, chain } from 'vs/base/common/event';
1313
import DOM = require('vs/base/browser/dom');
1414
import { Builder, $ } from 'vs/base/browser/builder';
1515
import { Delayer } from 'vs/base/common/async';
@@ -236,6 +236,12 @@ export class Workbench implements IPartService {
236236
return this._onTitleBarVisibilityChange.event;
237237
}
238238

239+
public get onEditorLayout(): Event<void> {
240+
return chain(this.editorPart.onLayout)
241+
.map(() => void 0)
242+
.event;
243+
}
244+
239245
/**
240246
* Starts the workbench and creates the HTML elements on the container. A workbench can only be started
241247
* once. Use the shutdown function to free up resources created by the workbench on startup.

src/vs/workbench/parts/watermark/electron-browser/watermark.css

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,11 @@
2727
border-spacing: 13px 17px;
2828
}
2929

30-
@media (min-height: 501px) {
31-
.monaco-workbench > .part.editor.empty > .content > .watermark {
32-
display: block;
33-
}
34-
}
35-
36-
@media (max-height: 500px) {
37-
.monaco-workbench > .part.editor.empty > .content > .watermark {
38-
display: none;
39-
}
40-
.monaco-workbench .part.editor.empty {
41-
background-position-y: 50%;
42-
}
30+
.monaco-workbench > .part.editor.empty.max-height-478px > .content > .watermark {
31+
display: none;
32+
}
33+
.monaco-workbench .part.editor.empty.max-height-478px {
34+
background-position-y: 50%;
4335
}
4436

4537
.monaco-workbench > .part.editor.empty > .content > .watermark dl {

src/vs/workbench/parts/watermark/electron-browser/watermark.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,15 @@ export class WatermarkContribution implements IWorkbenchContribution {
175175
});
176176
});
177177
};
178+
const layout = () => {
179+
const { height } = container.getBoundingClientRect();
180+
container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px');
181+
};
178182
update();
179-
watermark.build(container.firstChild as HTMLElement, 0);
183+
watermark.build(container.firstElementChild as HTMLElement, 0);
184+
layout();
180185
this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update));
186+
this.toDispose.push(this.partService.onEditorLayout(layout));
181187
}
182188

183189
public dispose(): void {

src/vs/workbench/services/part/common/partService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export interface IPartService {
3636
*/
3737
onTitleBarVisibilityChange: Event<void>;
3838

39+
/**
40+
* Emits when the editor part's layout changes.
41+
*/
42+
onEditorLayout: Event<void>;
43+
3944
/**
4045
* Asks the part service to layout all parts.
4146
*/

src/vs/workbench/test/workbenchTestServices.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,16 @@ export class TestPartService implements IPartService {
240240
public _serviceBrand: any;
241241

242242
private _onTitleBarVisibilityChange = new Emitter<void>();
243+
private _onEditorLayout = new Emitter<void>();
243244

244245
public get onTitleBarVisibilityChange(): Event<void> {
245246
return this._onTitleBarVisibilityChange.event;
246247
}
247248

249+
public get onEditorLayout(): Event<void> {
250+
return this._onEditorLayout.event;
251+
}
252+
248253
public layout(): void { }
249254

250255
public isCreated(): boolean {

0 commit comments

Comments
 (0)