Skip to content

Commit 1281eab

Browse files
author
Benjamin Pasero
committed
theming: Expose status bar debugging and no-folder foreground colors
1 parent eaf18ad commit 1281eab

6 files changed

Lines changed: 64 additions & 21 deletions

File tree

src/vs/workbench/browser/parts/statusbar/statusbarPart.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { getCodeEditor } from 'vs/editor/common/services/codeEditorService';
2727
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2828
import { Action } from 'vs/base/common/actions';
2929
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
30-
import { STATUS_BAR_BACKGROUND, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_ITEM_HOVER_BACKGROUND, STATUS_BAR_ITEM_ACTIVE_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND, STATUS_BAR_BORDER } from 'vs/workbench/common/theme';
30+
import { STATUS_BAR_BACKGROUND, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_ITEM_HOVER_BACKGROUND, STATUS_BAR_ITEM_ACTIVE_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_BACKGROUND, STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND, STATUS_BAR_BORDER, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme';
3131
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
3232
import { contrastBorder } from 'vs/platform/theme/common/colorRegistry';
3333

@@ -136,7 +136,7 @@ export class StatusbarPart extends Part implements IStatusbarService {
136136

137137
const container = this.getContainer();
138138

139-
container.style('color', this.getColor(STATUS_BAR_FOREGROUND));
139+
container.style('color', this.getColor(this.contextService.hasWorkspace() ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND));
140140
container.style('background-color', this.getColor(this.contextService.hasWorkspace() ? STATUS_BAR_BACKGROUND : STATUS_BAR_NO_FOLDER_BACKGROUND));
141141

142142
const borderColor = this.getColor(STATUS_BAR_BORDER) || this.getColor(contrastBorder);

src/vs/workbench/common/theme.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBar.noFolder
142142
hc: null
143143
}, nls.localize('statusBarNoFolderBackground', "Status bar background color when no folder is opened. The status bar is shown in the bottom of the window."));
144144

145+
export const STATUS_BAR_NO_FOLDER_FOREGROUND = registerColor('statusBar.noFolderForeground', {
146+
dark: STATUS_BAR_FOREGROUND,
147+
light: STATUS_BAR_FOREGROUND,
148+
hc: STATUS_BAR_FOREGROUND
149+
}, nls.localize('statusBarNoFolderForeground', "Status bar foreground color when no folder is opened. The status bar is shown in the bottom of the window."));
150+
145151
export const STATUS_BAR_ITEM_ACTIVE_BACKGROUND = registerColor('statusBarItem.activeBackground', {
146152
dark: Color.white.transparent(0.18),
147153
light: Color.white.transparent(0.18),

src/vs/workbench/parts/debug/electron-browser/statusbarColorProvider.ts

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { IThemeService } from 'vs/platform/theme/common/themeService';
6+
import { IThemeService, registerThemingParticipant, ITheme, ICssStyleCollector } from 'vs/platform/theme/common/themeService';
77
import { localize } from 'vs/nls';
88
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
99
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
1010
import { IPartService, Parts } from 'vs/workbench/services/part/common/partService';
1111
import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug';
1212
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
13-
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_BACKGROUND, Themable } from 'vs/workbench/common/theme';
13+
import { STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_BACKGROUND, Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme';
14+
import { addClass, removeClass } from "vs/base/browser/dom";
1415

1516
// colors for theming
1617

@@ -20,6 +21,12 @@ export const STATUS_BAR_DEBUGGING_BACKGROUND = registerColor('statusBar.debuggin
2021
hc: '#CC6633'
2122
}, localize('statusBarDebuggingBackground', "Status bar background color when a program is being debugged. The status bar is shown in the bottom of the window"));
2223

24+
export const STATUS_BAR_DEBUGGING_FOREGROUND = registerColor('statusBar.debuggingForeground', {
25+
dark: STATUS_BAR_FOREGROUND,
26+
light: STATUS_BAR_FOREGROUND,
27+
hc: STATUS_BAR_FOREGROUND
28+
}, localize('statusBarDebuggingForeground', "Status bar foreground color when a program is being debugged. The status bar is shown in the bottom of the window"));
29+
2330
export class StatusBarColorProvider extends Themable implements IWorkbenchContribution {
2431
private static ID = 'debug.statusbarColorProvider';
2532

@@ -45,25 +52,42 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
4552
protected updateStyles(): void {
4653
super.updateStyles();
4754

48-
if (this.partService.isVisible(Parts.STATUSBAR_PART)) {
49-
const container = this.partService.getContainer(Parts.STATUSBAR_PART);
50-
container.style.backgroundColor = this.getColor(this.getBackgroundColorKey());
55+
const container = this.partService.getContainer(Parts.STATUSBAR_PART);
56+
if (this.isDebugging()) {
57+
addClass(container, 'debugging');
58+
} else {
59+
removeClass(container, 'debugging');
5160
}
61+
62+
container.style.backgroundColor = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_BACKGROUND, STATUS_BAR_DEBUGGING_BACKGROUND, STATUS_BAR_BACKGROUND));
63+
container.style.color = this.getColor(this.getColorKey(STATUS_BAR_NO_FOLDER_FOREGROUND, STATUS_BAR_DEBUGGING_FOREGROUND, STATUS_BAR_FOREGROUND));
5264
}
5365

54-
private getBackgroundColorKey(): string {
66+
private getColorKey(noFolderColor: string, debuggingColor: string, normalColor: string): string {
5567

56-
// no debugging
57-
if (this.debugService.state === State.Inactive || this.isRunningWithoutDebug()) {
68+
// Not debugging
69+
if (!this.isDebugging()) {
5870
if (this.contextService.hasWorkspace()) {
59-
return STATUS_BAR_BACKGROUND;
71+
return normalColor;
6072
}
6173

62-
return STATUS_BAR_NO_FOLDER_BACKGROUND;
74+
return noFolderColor;
75+
}
76+
77+
// Debugging
78+
return debuggingColor;
79+
}
80+
81+
private isDebugging(): boolean {
82+
if (this.debugService.state === State.Inactive) {
83+
return false;
84+
}
85+
86+
if (this.isRunningWithoutDebug()) {
87+
return false;
6388
}
6489

65-
// debugging
66-
return STATUS_BAR_DEBUGGING_BACKGROUND;
90+
return true;
6791
}
6892

6993
private isRunningWithoutDebug(): boolean {
@@ -75,4 +99,11 @@ export class StatusBarColorProvider extends Themable implements IWorkbenchContri
7599
public getId(): string {
76100
return StatusBarColorProvider.ID;
77101
}
78-
}
102+
}
103+
104+
registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
105+
const statusBarItemDebuggingForeground = theme.getColor(STATUS_BAR_DEBUGGING_FOREGROUND);
106+
if (statusBarItemDebuggingForeground) {
107+
collector.addRule(`.monaco-workbench > .part.statusbar.debugging > .statusbar-item .mask-icon { background-color: ${statusBarItemDebuggingForeground} !important; }`);
108+
}
109+
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class FeedbackDropdown extends Dropdown {
7676
super(container, {
7777
contextViewProvider: options.contextViewProvider,
7878
labelRenderer: (container: HTMLElement): IDisposable => {
79-
$(container).addClass('send-feedback');
79+
$(container).addClass('send-feedback', 'mask-icon');
8080

8181
return null;
8282
}

src/vs/workbench/parts/feedback/electron-browser/feedbackStatusbarItem.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import { FeedbackDropdown, IFeedback, IFeedbackService } from './feedback';
1111
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
1212
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1313
import product from 'vs/platform/node/product';
14-
import { Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme';
14+
import { Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme';
1515
import { IThemeService } from 'vs/platform/theme/common/themeService';
16+
import { IWorkspaceContextService } from "vs/platform/workspace/common/workspace";
1617

1718
class TwitterFeedbackService implements IFeedbackService {
1819

@@ -53,6 +54,7 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem {
5354
constructor(
5455
@IInstantiationService private instantiationService: IInstantiationService,
5556
@IContextViewService private contextViewService: IContextViewService,
57+
@IWorkspaceContextService private contextService: IWorkspaceContextService,
5658
@IThemeService themeService: IThemeService
5759
) {
5860
super(themeService);
@@ -62,7 +64,7 @@ export class FeedbackStatusbarItem extends Themable implements IStatusbarItem {
6264
super.updateStyles();
6365

6466
if (this.dropdown) {
65-
this.dropdown.label.style('background-color', this.getColor(STATUS_BAR_FOREGROUND));
67+
this.dropdown.label.style('background-color', this.getColor(this.contextService.hasWorkspace() ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND));
6668
}
6769
}
6870

src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import { ProcessRunnerDetector } from 'vs/workbench/parts/tasks/node/processRunn
8080

8181
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
8282

83-
import { Themable, STATUS_BAR_FOREGROUND } from 'vs/workbench/common/theme';
83+
import { Themable, STATUS_BAR_FOREGROUND, STATUS_BAR_NO_FOLDER_FOREGROUND } from 'vs/workbench/common/theme';
8484
import { IThemeService } from 'vs/platform/theme/common/themeService';
8585

8686
let $ = Builder.$;
@@ -269,7 +269,8 @@ class StatusBarItem extends Themable implements IStatusbarItem {
269269
@IOutputService private outputService: IOutputService,
270270
@ITaskService private taskService: ITaskService,
271271
@IPartService private partService: IPartService,
272-
@IThemeService themeService: IThemeService
272+
@IThemeService themeService: IThemeService,
273+
@IWorkspaceContextService private contextService: IWorkspaceContextService
273274
) {
274275
super(themeService);
275276

@@ -281,7 +282,7 @@ class StatusBarItem extends Themable implements IStatusbarItem {
281282
super.updateStyles();
282283

283284
this.icons.forEach(icon => {
284-
icon.style.backgroundColor = this.getColor(STATUS_BAR_FOREGROUND);
285+
icon.style.backgroundColor = this.getColor(this.contextService.hasWorkspace() ? STATUS_BAR_FOREGROUND : STATUS_BAR_NO_FOLDER_FOREGROUND);
285286
});
286287
}
287288

@@ -310,6 +311,7 @@ class StatusBarItem extends Themable implements IStatusbarItem {
310311
element.title = nls.localize('problems', "Problems");
311312

312313
Dom.addClass(errorIcon, 'task-statusbar-item-label-error');
314+
Dom.addClass(errorIcon, 'mask-icon');
313315
label.appendChild(errorIcon);
314316
this.icons.push(errorIcon);
315317

@@ -318,6 +320,7 @@ class StatusBarItem extends Themable implements IStatusbarItem {
318320
label.appendChild(error);
319321

320322
Dom.addClass(warningIcon, 'task-statusbar-item-label-warning');
323+
Dom.addClass(warningIcon, 'mask-icon');
321324
label.appendChild(warningIcon);
322325
this.icons.push(warningIcon);
323326

@@ -326,6 +329,7 @@ class StatusBarItem extends Themable implements IStatusbarItem {
326329
label.appendChild(warning);
327330

328331
Dom.addClass(infoIcon, 'task-statusbar-item-label-info');
332+
Dom.addClass(infoIcon, 'mask-icon');
329333
label.appendChild(infoIcon);
330334
this.icons.push(infoIcon);
331335
$(infoIcon).hide();

0 commit comments

Comments
 (0)