theme.ts 14.0 KB
Newer Older
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import nls = require('vs/nls');
7
import { registerColor, editorBackground, contrastBorder, transparent, badgeForeground, badgeBackground } from 'vs/platform/theme/common/colorRegistry';
B
Benjamin Pasero 已提交
8
import { IDisposable, Disposable, dispose } from 'vs/base/common/lifecycle';
9
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
B
Benjamin Pasero 已提交
10
import { Color } from 'vs/base/common/color';
11

12 13
// < --- Tabs --- >

14
export const TAB_ACTIVE_BACKGROUND = registerColor('tab.activeBackground', {
15 16 17
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
B
Benjamin Pasero 已提交
18
}, nls.localize('tabActiveBackground', "Active tab background color. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
19

20
export const TAB_INACTIVE_BACKGROUND = registerColor('tab.inactiveBackground', {
21 22
	dark: '#2D2D2D',
	light: '#ECECEC',
B
Benjamin Pasero 已提交
23
	hc: null
B
Benjamin Pasero 已提交
24
}, nls.localize('tabInactiveBackground', "Inactive tab background color. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
25

26
export const TAB_BORDER = registerColor('tab.border', {
B
Benjamin Pasero 已提交
27 28
	dark: '#252526',
	light: '#F3F3F3',
29
	hc: contrastBorder
B
Benjamin Pasero 已提交
30 31
}, nls.localize('tabBorder', "Border to separate tabs from each other. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));

32
export const TAB_ACTIVE_FOREGROUND = registerColor('tab.activeForeground', {
33
	dark: Color.white,
B
Benjamin Pasero 已提交
34
	light: '#333333',
35
	hc: Color.white
B
Benjamin Pasero 已提交
36
}, nls.localize('tabActiveEditorGroupActiveForeground', "Active tab foreground color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
37

38
export const TAB_INACTIVE_FOREGROUND = registerColor('tab.inactiveForeground', {
B
Benjamin Pasero 已提交
39 40
	dark: transparent(TAB_ACTIVE_FOREGROUND, 0.5),
	light: transparent(TAB_ACTIVE_FOREGROUND, 0.5),
41
	hc: Color.white
B
Benjamin Pasero 已提交
42
}, nls.localize('tabInactiveEditorGroupActiveForeground', "Inactive tab foreground color in an active group. Tabs are the containers for editors in the editor area. Multiple tabs can be opened in one editor group. There can be multiple editor groups."));
43

44 45 46

// < --- Editors --- >

47
export const EDITOR_GROUP_BACKGROUND = registerColor('editorGroup.background', {
48 49 50 51 52
	dark: '#2D2D2D',
	light: '#ECECEC',
	hc: null
}, nls.localize('editorGroupBackground', "Background color of an editor group. Editor groups are the containers of editors. The background color shows up when dragging editor groups around."));

B
Benjamin Pasero 已提交
53 54 55 56 57 58 59
export const EDITOR_GROUP_HEADER_TABS_BACKGROUND = registerColor('editorGroupHeader.tabsBackground', {
	dark: '#252526',
	light: '#F3F3F3',
	hc: null
}, nls.localize('tabsContainerBackground', "Background color of the editor group title header when tabs are enabled. Editor groups are the containers of editors."));

export const EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND = registerColor('editorGroupHeader.noTabsBackground', {
B
Benjamin Pasero 已提交
60 61 62
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
63
}, nls.localize('editorGroupHeaderBackground', "Background color of the editor group title header when tabs are disabled. Editor groups are the containers of editors."));
B
Benjamin Pasero 已提交
64

65
export const EDITOR_GROUP_BORDER_COLOR = registerColor('editorGroup.border', {
66 67
	dark: '#444444',
	light: '#E7E7E7',
68
	hc: contrastBorder
69 70
}, nls.localize('editorGroupBorder', "Color to separate multiple editor groups from each other. Editor groups are the containers of editors."));

71
export const EDITOR_DRAG_AND_DROP_BACKGROUND = registerColor('editorGroup.dropBackground', {
B
Benjamin Pasero 已提交
72 73
	dark: Color.fromHex('#53595D').transparent(0.5),
	light: Color.fromHex('#3399FF').transparent(0.18),
B
Benjamin Pasero 已提交
74
	hc: null
B
Benjamin Pasero 已提交
75
}, nls.localize('editorDragAndDropBackground', "Background color when dragging editors around. The color should have transparency so that the editor contents can still shine through."));
76

77

78 79 80

// < --- Panels --- >

81
export const PANEL_BACKGROUND = registerColor('panel.background', {
82 83 84
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
85 86
}, nls.localize('panelBackground', "Panel background color. Panels are shown below the editor area and contain views like output and integrated terminal."));

87
export const PANEL_BORDER_COLOR = registerColor('panel.border', {
B
Benjamin Pasero 已提交
88 89
	dark: Color.fromHex('#808080').transparent(0.35),
	light: Color.fromHex('#808080').transparent(0.35),
90
	hc: contrastBorder
B
Benjamin Pasero 已提交
91
}, nls.localize('panelBorder', "Panel border color on the top separating to the editor. Panels are shown below the editor area and contain views like output and integrated terminal."));
B
Benjamin Pasero 已提交
92

93
export const PANEL_ACTIVE_TITLE_COLOR = registerColor('panelTitle.activeForeground', {
94 95 96
	dark: '#E7E7E7',
	light: '#424242',
	hc: Color.white
97
}, nls.localize('panelActiveTitleForeground', "Title color for the active panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
98

99
export const PANEL_INACTIVE_TITLE_COLOR = registerColor('panelTitle.inactiveForeground', {
B
Benjamin Pasero 已提交
100 101
	dark: transparent(PANEL_ACTIVE_TITLE_COLOR, 0.5),
	light: transparent(PANEL_ACTIVE_TITLE_COLOR, 0.75),
102
	hc: Color.white
103
}, nls.localize('panelInactiveTitleForeground', "Title color for the inactive panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
104

105
export const PANEL_ACTIVE_TITLE_BORDER = registerColor('panelTitle.activeBorder', {
106 107
	dark: PANEL_BORDER_COLOR,
	light: PANEL_BORDER_COLOR,
108
	hc: contrastBorder
109 110
}, nls.localize('panelActiveTitleBorder', "Border color for the active panel title. Panels are shown below the editor area and contain views like output and integrated terminal."));

111

112

113 114
// < --- Status --- >

115
export const STATUS_BAR_FOREGROUND = registerColor('statusBar.foreground', {
116 117 118
	dark: '#FFFFFF',
	light: '#FFFFFF',
	hc: '#FFFFFF'
119
}, nls.localize('statusBarForeground', "Status bar foreground color. The status bar is shown in the bottom of the window."));
120

121
export const STATUS_BAR_BACKGROUND = registerColor('statusBar.background', {
122 123
	dark: '#007ACC',
	light: '#007ACC',
B
Benjamin Pasero 已提交
124
	hc: null
125
}, nls.localize('statusBarBackground', "Standard status bar background color. The status bar is shown in the bottom of the window."));
126

127
export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBar.noFolderBackground', {
128 129
	dark: '#68217A',
	light: '#68217A',
B
Benjamin Pasero 已提交
130
	hc: null
131
}, nls.localize('statusBarNoFolderBackground', "Status bar background color when no folder is opened. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
132

133
export const STATUS_BAR_ITEM_ACTIVE_BACKGROUND = registerColor('statusBarItem.activeBackground', {
B
Benjamin Pasero 已提交
134 135 136
	dark: Color.white.transparent(0.18),
	light: Color.white.transparent(0.18),
	hc: Color.white.transparent(0.18)
137
}, nls.localize('statusBarItemActiveBackground', "Status bar item background color when clicking. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
138

139
export const STATUS_BAR_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.hoverBackground', {
B
Benjamin Pasero 已提交
140 141 142
	dark: Color.white.transparent(0.12),
	light: Color.white.transparent(0.12),
	hc: Color.white.transparent(0.12)
143
}, nls.localize('statusBarItemHoverBackground', "Status bar item background color when hovering. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
144

145
export const STATUS_BAR_PROMINENT_ITEM_BACKGROUND = registerColor('statusBarItem.prominentBackground', {
146 147 148
	dark: '#388A34',
	light: '#388A34',
	hc: '#3883A4'
B
Benjamin Pasero 已提交
149
}, nls.localize('statusBarProminentItemBackground', "Status bar prominent items background color. Prominent items stand out from other status bar entries to indicate importance. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
150

151
export const STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.prominentHoverBackground', {
B
Benjamin Pasero 已提交
152 153 154
	dark: '#369432',
	light: '#369432',
	hc: '#369432'
B
Benjamin Pasero 已提交
155
}, nls.localize('statusBarProminentItemHoverBackground', "Status bar prominent items background color when hovering. Prominent items stand out from other status bar entries to indicate importance. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
156

157 158 159 160


// < --- Activity Bar --- >

161
export const ACTIVITY_BAR_BACKGROUND = registerColor('activityBar.background', {
162
	dark: '#333333',
163
	light: '#2C2C2C',
164 165
	hc: '#000000'
}, nls.localize('activityBarBackground', "Activity bar background color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
166

167
export const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
168 169 170
	dark: Color.white,
	light: Color.white,
	hc: Color.white
171
}, nls.localize('activityBarForeground', "Activity bar foreground color (e.g. used for the icons). The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
172

173
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBar.dropBackground', {
B
Benjamin Pasero 已提交
174 175 176
	dark: Color.white.transparent(0.12),
	light: Color.white.transparent(0.12),
	hc: Color.white.transparent(0.12),
B
Benjamin Pasero 已提交
177
}, nls.localize('activityBarDragAndDropBackground', "Drag and drop feedback color for the activity bar items. The color should have transparency so that the activity bar entries can still shine through. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
178

179
export const ACTIVITY_BAR_BADGE_BACKGROUND = registerColor('activityBarBadge.background', {
180 181 182
	dark: badgeBackground,
	light: badgeBackground,
	hc: badgeBackground
B
Benjamin Pasero 已提交
183
}, nls.localize('activityBarBadgeBackground', "Activity notification badge background color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
B
Benjamin Pasero 已提交
184

185
export const ACTIVITY_BAR_BADGE_FOREGROUND = registerColor('activityBarBadge.foreground', {
186 187 188
	dark: badgeForeground,
	light: badgeForeground,
	hc: badgeForeground
B
Benjamin Pasero 已提交
189
}, nls.localize('activityBarBadgeForeground', "Activity notification badge foreground color. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));
B
Benjamin Pasero 已提交
190

191 192 193 194


// < --- Side Bar --- >

195
export const SIDE_BAR_BACKGROUND = registerColor('sideBar.background', {
196 197 198 199 200
	dark: '#252526',
	light: '#F3F3F3',
	hc: '#000000'
}, nls.localize('sideBarBackground', "Side bar background color. The side bar is the container for views like explorer and search."));

201
export const SIDE_BAR_TITLE_FOREGROUND = registerColor('sideBarTitle.foreground', {
202 203 204 205 206
	dark: '#BBBBBB',
	light: '#6f6f6f',
	hc: '#FFFFFF'
}, nls.localize('sideBarTitleForeground', "Side bar title foreground color. The side bar is the container for views like explorer and search."));

207
export const SIDE_BAR_SECTION_HEADER_BACKGROUND = registerColor('sideBarSectionHeader.background', {
208 209 210 211 212
	dark: Color.fromHex('#808080').transparent(0.2),
	light: Color.fromHex('#808080').transparent(0.2),
	hc: null
}, nls.localize('sideBarSectionHeaderBackground', "Side bar section header background color. The side bar is the container for views like explorer and search."));

B
Benjamin Pasero 已提交
213 214 215 216


// < --- Title Bar --- >

217
export const TITLE_BAR_ACTIVE_FOREGROUND = registerColor('titleBar.activeForeground', {
B
Benjamin Pasero 已提交
218 219 220
	dark: '#CCCCCC',
	light: '#333333',
	hc: '#FFFFFF'
N
Nicolas Ramz 已提交
221
}, nls.localize('titleBarActiveForeground', "Title bar foreground when the window is active. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
222

223
export const TITLE_BAR_INACTIVE_FOREGROUND = registerColor('titleBar.inactiveForeground', {
B
Benjamin Pasero 已提交
224 225
	dark: transparent(TITLE_BAR_ACTIVE_FOREGROUND, 0.6),
	light: transparent(TITLE_BAR_ACTIVE_FOREGROUND, 0.6),
B
Benjamin Pasero 已提交
226
	hc: null
N
Nicolas Ramz 已提交
227
}, nls.localize('titleBarInactiveForeground', "Title bar foreground when the window is inactive. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
228

229
export const TITLE_BAR_ACTIVE_BACKGROUND = registerColor('titleBar.activeBackground', {
B
Benjamin Pasero 已提交
230 231 232
	dark: '#3C3C3C',
	light: '#DDDDDD',
	hc: '#000000'
N
Nicolas Ramz 已提交
233
}, nls.localize('titleBarActiveBackground', "Title bar background when the window is active. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
234

235
export const TITLE_BAR_INACTIVE_BACKGROUND = registerColor('titleBar.inactiveBackground', {
B
Benjamin Pasero 已提交
236 237
	dark: transparent(TITLE_BAR_ACTIVE_BACKGROUND, 0.6),
	light: transparent(TITLE_BAR_ACTIVE_BACKGROUND, 0.6),
B
Benjamin Pasero 已提交
238
	hc: null
N
Nicolas Ramz 已提交
239
}, nls.localize('titleBarInactiveBackground', "Title bar background when the window is inactive. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
240

241 242
// < --- Notifications --- >

243
export const NOTIFICATIONS_FOREGROUND = registerColor('notification.foreground', {
244 245 246 247 248
	dark: '#EEEEEE',
	light: '#EEEEEE',
	hc: '#FFFFFF'
}, nls.localize('notificationsForeground', "Notifications foreground color. Notifications slide in from the top of the window."));

249
export const NOTIFICATIONS_BACKGROUND = registerColor('notification.background', {
250 251 252 253 254
	dark: '#333333',
	light: '#2C2C2C',
	hc: '#000000'
}, nls.localize('notificationsBackground', "Notifications background color. Notifications slide in from the top of the window."));

B
Benjamin Pasero 已提交
255 256 257 258 259
/**
 * Base class for all themable workbench components.
 */
export class Themable extends Disposable {
	private _toUnbind: IDisposable[];
B
Benjamin Pasero 已提交
260
	private theme: ITheme;
B
Benjamin Pasero 已提交
261 262 263 264 265 266 267

	constructor(
		protected themeService: IThemeService
	) {
		super();

		this._toUnbind = [];
B
Benjamin Pasero 已提交
268
		this.theme = themeService.getTheme();
B
Benjamin Pasero 已提交
269 270

		// Hook up to theme changes
271
		this._toUnbind.push(this.themeService.onThemeChange(theme => this.onThemeChange(theme)));
B
Benjamin Pasero 已提交
272 273 274 275 276 277
	}

	protected get toUnbind() {
		return this._toUnbind;
	}

278
	protected onThemeChange(theme: ITheme): void {
B
Benjamin Pasero 已提交
279
		this.theme = theme;
B
Benjamin Pasero 已提交
280

281
		this.updateStyles();
B
Benjamin Pasero 已提交
282 283
	}

284
	protected updateStyles(): void {
B
Benjamin Pasero 已提交
285 286 287
		// Subclasses to override
	}

288 289 290 291 292 293
	protected getColor(id: string, modify?: (color: Color, theme: ITheme) => Color): string {
		let color = this.theme.getColor(id);

		if (color && modify) {
			color = modify(color, this.theme);
		}
294 295

		return color ? color.toString() : null;
B
Benjamin Pasero 已提交
296 297 298 299 300 301 302
	}

	public dispose(): void {
		this._toUnbind = dispose(this._toUnbind);

		super.dispose();
	}
N
Nicolas Ramz 已提交
303
}