提交 4f724cbf 编写于 作者: B Benjamin Pasero

notifications - proper center rooting

上级 83dd7fcc
...@@ -294,12 +294,14 @@ export class ListView<T> implements ISpliceable<T>, IDisposable { ...@@ -294,12 +294,14 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
item.row.domNode.style.top = `${this.elementTop(index)}px`; item.row.domNode.style.top = `${this.elementTop(index)}px`;
item.row.domNode.style.height = `${item.size}px`; item.row.domNode.style.height = `${item.size}px`;
item.row.domNode.setAttribute('data-index', `${index}`); item.row.domNode.setAttribute('data-index', `${index}`);
item.row.domNode.setAttribute('data-last-element', index === this.length - 1 ? 'true' : 'false');
renderer.renderElement(item.element, index, item.row.templateData); renderer.renderElement(item.element, index, item.row.templateData);
} }
private updateItemInDOM(item: IItem<T>, index: number): void { private updateItemInDOM(item: IItem<T>, index: number): void {
item.row.domNode.style.top = `${this.elementTop(index)}px`; item.row.domNode.style.top = `${this.elementTop(index)}px`;
item.row.domNode.setAttribute('data-index', `${index}`); item.row.domNode.setAttribute('data-index', `${index}`);
item.row.domNode.setAttribute('data-last-element', index === this.length - 1 ? 'true' : 'false');
} }
private removeItemFromDOM(item: IItem<T>): void { private removeItemFromDOM(item: IItem<T>): void {
......
...@@ -51,6 +51,11 @@ export interface IStatusbarEntry { ...@@ -51,6 +51,11 @@ export interface IStatusbarEntry {
* An optional extension ID if this entry is provided from an extension. * An optional extension ID if this entry is provided from an extension.
*/ */
extensionId?: string; extensionId?: string;
/**
* Wether to show a beak above the status bar entry.
*/
showBeak?: boolean;
} }
export interface IStatusbarService { export interface IStatusbarService {
......
...@@ -7,14 +7,13 @@ ...@@ -7,14 +7,13 @@
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;
right: 8px; right: 8px;
bottom: 30px; /* above status bar */ bottom: 31px;
display: none; display: none;
overflow: hidden; overflow: hidden;
} }
.monaco-workbench.nostatusbar > .notifications-center { .monaco-workbench.nostatusbar > .notifications-center {
right: 12px; bottom: 8px;
bottom: 12px;
} }
.monaco-workbench > .notifications-center.visible { .monaco-workbench > .notifications-center.visible {
......
...@@ -7,14 +7,13 @@ ...@@ -7,14 +7,13 @@
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;
right: 3px; right: 3px;
bottom: 28px; /* above status bar */ bottom: 26px;
display: none; display: none;
overflow: hidden; overflow: hidden;
} }
.monaco-workbench.nostatusbar > .notifications-toasts { .monaco-workbench.nostatusbar > .notifications-toasts {
right: 12px; bottom: 3px;
bottom: 12px;
} }
.monaco-workbench > .notifications-toasts.visible { .monaco-workbench > .notifications-toasts.visible {
......
...@@ -23,7 +23,7 @@ import { localize } from 'vs/nls'; ...@@ -23,7 +23,7 @@ import { localize } from 'vs/nls';
export class NotificationsCenter extends Themable { export class NotificationsCenter extends Themable {
private static MAX_DIMENSIONS = new Dimension(600, 400); private static MAX_DIMENSIONS = new Dimension(450, 400);
private notificationsCenterContainer: HTMLElement; private notificationsCenterContainer: HTMLElement;
private notificationsList: NotificationsList; private notificationsList: NotificationsList;
...@@ -166,7 +166,7 @@ export class NotificationsCenter extends Themable { ...@@ -166,7 +166,7 @@ export class NotificationsCenter extends Themable {
protected updateStyles(): void { protected updateStyles(): void {
if (this.notificationsCenterContainer) { if (this.notificationsCenterContainer) {
const widgetShadowColor = this.getColor(widgetShadow); const widgetShadowColor = this.getColor(widgetShadow);
this.notificationsCenterContainer.style.boxShadow = widgetShadowColor ? `0 5px 8px ${widgetShadowColor}` : null; this.notificationsCenterContainer.style.boxShadow = widgetShadowColor ? `0 0px 8px ${widgetShadowColor}` : null;
} }
} }
...@@ -219,6 +219,6 @@ export class NotificationsCenter extends Themable { ...@@ -219,6 +219,6 @@ export class NotificationsCenter extends Themable {
registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => { registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
const notificationBorderColor = theme.getColor(NOTIFICATIONS_BORDER); const notificationBorderColor = theme.getColor(NOTIFICATIONS_BORDER);
if (notificationBorderColor) { if (notificationBorderColor) {
collector.addRule(`.monaco-workbench > .notifications-center .notifications-list-container .notification-list-item { border-bottom: 1px solid ${notificationBorderColor}; }`); collector.addRule(`.monaco-workbench > .notifications-center .notifications-list-container .monaco-list-row[data-last-element="false"] > .notification-list-item { border-bottom: 1px solid ${notificationBorderColor}; }`);
} }
}); });
\ No newline at end of file
...@@ -72,7 +72,8 @@ export class NotificationsStatus { ...@@ -72,7 +72,8 @@ export class NotificationsStatus {
this.statusItem = this.statusbarService.addEntry({ this.statusItem = this.statusbarService.addEntry({
text: this.counter === 0 ? '$(megaphone)' : `$(megaphone) ${this.counter}`, text: this.counter === 0 ? '$(megaphone)' : `$(megaphone) ${this.counter}`,
command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER_COMMAND_ID : this.model.notifications.length > 0 ? SHOW_NOTIFICATIONS_CENTER_COMMAND_ID : void 0, command: this.isNotificationsCenterVisible ? HIDE_NOTIFICATIONS_CENTER_COMMAND_ID : this.model.notifications.length > 0 ? SHOW_NOTIFICATIONS_CENTER_COMMAND_ID : void 0,
tooltip: this.getTooltip() tooltip: this.getTooltip(),
showBeak: this.isNotificationsCenterVisible
}, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */); }, StatusbarAlignment.RIGHT, -1000 /* towards the far end of the right hand side */);
} }
......
...@@ -299,7 +299,7 @@ export class NotificationsToasts extends Themable { ...@@ -299,7 +299,7 @@ export class NotificationsToasts extends Themable {
protected updateStyles(): void { protected updateStyles(): void {
this.mapNotificationToToast.forEach(toast => { this.mapNotificationToToast.forEach(toast => {
const widgetShadowColor = this.getColor(widgetShadow); const widgetShadowColor = this.getColor(widgetShadow);
toast.container.style.boxShadow = widgetShadowColor ? `0 2px 8px ${widgetShadowColor}` : null; toast.container.style.boxShadow = widgetShadowColor ? `0 0px 8px ${widgetShadowColor}` : null;
}); });
} }
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
height: 22px; height: 22px;
font-size: 12px; font-size: 12px;
padding: 0 10px; padding: 0 10px;
overflow: hidden;
} }
.monaco-workbench > .part.statusbar > .statusbar-item { .monaco-workbench > .part.statusbar > .statusbar-item {
...@@ -19,6 +18,21 @@ ...@@ -19,6 +18,21 @@
vertical-align: top; vertical-align: top;
} }
.monaco-workbench > .part.statusbar > .statusbar-item.has-beak {
position: relative;
}
.monaco-workbench > .part.statusbar > .statusbar-item.has-beak:before {
content: '';
position: absolute;
left: 11px;
top: -5px;
border-bottom-width: 5px;
border-bottom-style: solid;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
}
.monaco-workbench > .part.statusbar > .statusbar-item.left > :first-child { .monaco-workbench > .part.statusbar > .statusbar-item.left > :first-child {
margin-right: 5px; margin-right: 5px;
} }
......
...@@ -29,7 +29,7 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/ ...@@ -29,7 +29,7 @@ import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
import { isThemeColor } from 'vs/editor/common/editorCommon'; import { isThemeColor } from 'vs/editor/common/editorCommon';
import { Color } from 'vs/base/common/color'; import { Color } from 'vs/base/common/color';
import { addClass, EventHelper } from 'vs/base/browser/dom'; import { addClass, EventHelper, createStyleSheet } from 'vs/base/browser/dom';
import { INotificationService } from 'vs/platform/notification/common/notification'; import { INotificationService } from 'vs/platform/notification/common/notification';
export class StatusbarPart extends Part implements IStatusbarService { export class StatusbarPart extends Part implements IStatusbarService {
...@@ -42,6 +42,8 @@ export class StatusbarPart extends Part implements IStatusbarService { ...@@ -42,6 +42,8 @@ export class StatusbarPart extends Part implements IStatusbarService {
private statusItemsContainer: Builder; private statusItemsContainer: Builder;
private statusMsgDispose: IDisposable; private statusMsgDispose: IDisposable;
private styleElement: HTMLStyleElement;
constructor( constructor(
id: string, id: string,
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService private instantiationService: IInstantiationService,
...@@ -60,7 +62,7 @@ export class StatusbarPart extends Part implements IStatusbarService { ...@@ -60,7 +62,7 @@ export class StatusbarPart extends Part implements IStatusbarService {
public addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IDisposable { public addEntry(entry: IStatusbarEntry, alignment: StatusbarAlignment, priority: number = 0): IDisposable {
// Render entry in status bar // Render entry in status bar
const el = this.doCreateStatusItem(alignment, priority); const el = this.doCreateStatusItem(alignment, priority, entry.showBeak ? 'has-beak' : void 0);
const item = this.instantiationService.createInstance(StatusBarEntryItem, entry); const item = this.instantiationService.createInstance(StatusBarEntryItem, entry);
const toDispose = item.render(el); const toDispose = item.render(el);
...@@ -140,18 +142,31 @@ export class StatusbarPart extends Part implements IStatusbarService { ...@@ -140,18 +142,31 @@ export class StatusbarPart extends Part implements IStatusbarService {
const container = this.getContainer(); const container = this.getContainer();
// Background colors
const backgroundColor = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BACKGROUND : STATUS_BAR_NO_FOLDER_BACKGROUND);
container.style('background-color', backgroundColor);
container.style('color', this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND)); container.style('color', this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND));
container.style('background-color', this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BACKGROUND : STATUS_BAR_NO_FOLDER_BACKGROUND));
// Border color
const borderColor = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BORDER : STATUS_BAR_NO_FOLDER_BORDER) || this.getColor(contrastBorder); const borderColor = this.getColor(this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY ? STATUS_BAR_BORDER : STATUS_BAR_NO_FOLDER_BORDER) || this.getColor(contrastBorder);
container.style('border-top-width', borderColor ? '1px' : null); container.style('border-top-width', borderColor ? '1px' : null);
container.style('border-top-style', borderColor ? 'solid' : null); container.style('border-top-style', borderColor ? 'solid' : null);
container.style('border-top-color', borderColor); container.style('border-top-color', borderColor);
// Notification Beak
if (!this.styleElement) {
this.styleElement = createStyleSheet(container.getHTMLElement());
}
this.styleElement.innerHTML = `.monaco-workbench > .part.statusbar > .statusbar-item.has-beak:before { border-bottom-color: ${backgroundColor}; }`;
} }
private doCreateStatusItem(alignment: StatusbarAlignment, priority: number = 0): HTMLElement { private doCreateStatusItem(alignment: StatusbarAlignment, priority: number = 0, extraClass?: string): HTMLElement {
const el = document.createElement('div'); const el = document.createElement('div');
addClass(el, 'statusbar-item'); addClass(el, 'statusbar-item');
if (extraClass) {
addClass(el, extraClass);
}
if (alignment === StatusbarAlignment.RIGHT) { if (alignment === StatusbarAlignment.RIGHT) {
addClass(el, 'right'); addClass(el, 'right');
......
...@@ -11,7 +11,7 @@ import { IPartService, Parts } from 'vs/workbench/services/part/common/partServi ...@@ -11,7 +11,7 @@ import { IPartService, Parts } from 'vs/workbench/services/part/common/partServi
import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug'; import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug';
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_BACKGROUND, Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BORDER, STATUS_BAR_BORDER } from 'vs/workbench/common/theme'; import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_BACKGROUND, Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BORDER, STATUS_BAR_BORDER } from 'vs/workbench/common/theme';
import { addClass, removeClass } from 'vs/base/browser/dom'; import { addClass, removeClass, createStyleSheet } from 'vs/base/browser/dom';
// colors for theming // colors for theming
...@@ -34,6 +34,7 @@ export const STATUS_BAR_DEBUGGING_BORDER = registerColor('statusBar.debuggingBor ...@@ -34,6 +34,7 @@ export const STATUS_BAR_DEBUGGING_BORDER = registerColor('statusBar.debuggingBor
}, localize('statusBarDebuggingBorder', "Status bar border color separating to the sidebar and editor when a program is being debugged. The status bar is shown in the bottom of the window")); }, localize('statusBarDebuggingBorder', "Status bar border color separating to the sidebar and editor when a program is being debugged. The status bar is shown in the bottom of the window"));
export class StatusBarColorProvider extends Themable implements IWorkbenchContribution { export class StatusBarColorProvider extends Themable implements IWorkbenchContribution {
private styleElement: HTMLStyleElement;
constructor( constructor(
@IThemeService themeService: IThemeService, @IThemeService themeService: IThemeService,
...@@ -61,13 +62,23 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri ...@@ -61,13 +62,23 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
removeClass(container, 'debugging'); removeClass(container, 'debugging');
} }
container.style.backgroundColor = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_DEBUGGING_BACKGROUND, STATUS_BAR_BACKGROUND)); // Container Colors
const backgroundColor = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_DEBUGGING_BACKGROUND, STATUS_BAR_BACKGROUND));
container.style.backgroundColor = backgroundColor;
container.style.color = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_DEBUGGING_FOREGROUND, STATUS_BAR_FOREGROUND)); container.style.color = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_DEBUGGING_FOREGROUND, STATUS_BAR_FOREGROUND));
// Border Color
const borderColor = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_BORDER, STATUS_BAR_DEBUGGING_BORDER, STATUS_BAR_BORDER)) || this.getColor(contrastBorder); const borderColor = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_BORDER, STATUS_BAR_DEBUGGING_BORDER, STATUS_BAR_BORDER)) || this.getColor(contrastBorder);
container.style.borderTopWidth = borderColor ? '1px' : null; container.style.borderTopWidth = borderColor ? '1px' : null;
container.style.borderTopStyle = borderColor ? 'solid' : null; container.style.borderTopStyle = borderColor ? 'solid' : null;
container.style.borderTopColor = borderColor; container.style.borderTopColor = borderColor;
// Notification Beak
if (!this.styleElement) {
this.styleElement = createStyleSheet(container);
}
this.styleElement.innerHTML = `.monaco-workbench > .part.statusbar > .statusbar-item.has-beak:before { border-bottom-color: ${backgroundColor} !important; }`;
} }
private getColorKey(noFolderColor: string, debuggingColor: string, normalColor: string): string { private getColorKey(noFolderColor: string, debuggingColor: string, normalColor: string): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册