theme.ts 15.7 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
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."));

59 60 61 62 63 64
export const EDITOR_GROUP_HEADER_TABS_BORDER = registerColor('editorGroupHeader.tabsBorder', {
	dark: null,
	light: null,
	hc: contrastBorder
}, nls.localize('tabsContainerBorder', "Border color of the editor group title header when tabs are enabled. Editor groups are the containers of editors."));

B
Benjamin Pasero 已提交
65
export const EDITOR_GROUP_HEADER_NO_TABS_BACKGROUND = registerColor('editorGroupHeader.noTabsBackground', {
B
Benjamin Pasero 已提交
66 67 68
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
69
}, 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 已提交
70

71
export const EDITOR_GROUP_BORDER = registerColor('editorGroup.border', {
72 73
	dark: '#444444',
	light: '#E7E7E7',
74
	hc: contrastBorder
75 76
}, nls.localize('editorGroupBorder', "Color to separate multiple editor groups from each other. Editor groups are the containers of editors."));

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

83

84 85 86

// < --- Panels --- >

87
export const PANEL_BACKGROUND = registerColor('panel.background', {
88 89 90
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
91 92
}, nls.localize('panelBackground', "Panel background color. Panels are shown below the editor area and contain views like output and integrated terminal."));

93
export const PANEL_BORDER = registerColor('panel.border', {
B
Benjamin Pasero 已提交
94 95
	dark: Color.fromHex('#808080').transparent(0.35),
	light: Color.fromHex('#808080').transparent(0.35),
96
	hc: contrastBorder
B
Benjamin Pasero 已提交
97
}, 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 已提交
98

99
export const PANEL_ACTIVE_TITLE_FOREGROUND = registerColor('panelTitle.activeForeground', {
100 101 102
	dark: '#E7E7E7',
	light: '#424242',
	hc: Color.white
103
}, nls.localize('panelActiveTitleForeground', "Title color for the active panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
104

105 106 107
export const PANEL_INACTIVE_TITLE_FOREGROUND = registerColor('panelTitle.inactiveForeground', {
	dark: transparent(PANEL_ACTIVE_TITLE_FOREGROUND, 0.5),
	light: transparent(PANEL_ACTIVE_TITLE_FOREGROUND, 0.75),
108
	hc: Color.white
109
}, nls.localize('panelInactiveTitleForeground', "Title color for the inactive panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
110

111
export const PANEL_ACTIVE_TITLE_BORDER = registerColor('panelTitle.activeBorder', {
112 113
	dark: PANEL_BORDER,
	light: PANEL_BORDER,
114
	hc: contrastBorder
115 116
}, 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."));

117

118

119 120
// < --- Status --- >

121
export const STATUS_BAR_FOREGROUND = registerColor('statusBar.foreground', {
122 123 124
	dark: '#FFFFFF',
	light: '#FFFFFF',
	hc: '#FFFFFF'
125
}, nls.localize('statusBarForeground', "Status bar foreground color. The status bar is shown in the bottom of the window."));
126

127
export const STATUS_BAR_BACKGROUND = registerColor('statusBar.background', {
128 129
	dark: '#007ACC',
	light: '#007ACC',
B
Benjamin Pasero 已提交
130
	hc: null
131
}, nls.localize('statusBarBackground', "Standard status bar background color. The status bar is shown in the bottom of the window."));
132

133 134 135 136 137 138
export const STATUS_BAR_BORDER = registerColor('statusBar.border', {
	dark: null,
	light: null,
	hc: contrastBorder
}, nls.localize('statusBarBorder', "Status bar border color separating to the sidebar and editor. The status bar is shown in the bottom of the window."));

139
export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBar.noFolderBackground', {
140 141
	dark: '#68217A',
	light: '#68217A',
B
Benjamin Pasero 已提交
142
	hc: null
143
}, 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 已提交
144

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

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

157
export const STATUS_BAR_PROMINENT_ITEM_BACKGROUND = registerColor('statusBarItem.prominentBackground', {
158 159 160
	dark: '#388A34',
	light: '#388A34',
	hc: '#3883A4'
B
Benjamin Pasero 已提交
161
}, 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 已提交
162

163
export const STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.prominentHoverBackground', {
B
Benjamin Pasero 已提交
164 165 166
	dark: '#369432',
	light: '#369432',
	hc: '#369432'
B
Benjamin Pasero 已提交
167
}, 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 已提交
168

169 170 171 172


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

173
export const ACTIVITY_BAR_BACKGROUND = registerColor('activityBar.background', {
174
	dark: '#333333',
175
	light: '#2C2C2C',
176 177
	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."));
178

179
export const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
180 181 182
	dark: Color.white,
	light: Color.white,
	hc: Color.white
183
}, 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."));
184

185 186 187 188 189 190
export const ACTIVITY_BAR_BORDER = registerColor('activityBar.border', {
	dark: null,
	light: null,
	hc: contrastBorder
}, nls.localize('activityBarBorder', "Activity bar border color separating to the side bar. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));

191
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBar.dropBackground', {
B
Benjamin Pasero 已提交
192 193 194
	dark: Color.white.transparent(0.12),
	light: Color.white.transparent(0.12),
	hc: Color.white.transparent(0.12),
B
Benjamin Pasero 已提交
195
}, 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."));
196

197
export const ACTIVITY_BAR_BADGE_BACKGROUND = registerColor('activityBarBadge.background', {
198 199 200
	dark: badgeBackground,
	light: badgeBackground,
	hc: badgeBackground
B
Benjamin Pasero 已提交
201
}, 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 已提交
202

203
export const ACTIVITY_BAR_BADGE_FOREGROUND = registerColor('activityBarBadge.foreground', {
204 205 206
	dark: badgeForeground,
	light: badgeForeground,
	hc: badgeForeground
B
Benjamin Pasero 已提交
207
}, 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 已提交
208

209 210 211 212


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

213
export const SIDE_BAR_BACKGROUND = registerColor('sideBar.background', {
214 215 216 217 218
	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."));

219 220 221 222 223 224
export const SIDE_BAR_FOREGROUND = registerColor('sideBar.foreground', {
	dark: null,
	light: null,
	hc: null
}, nls.localize('sideBarForeground', "Side bar foreground color. The side bar is the container for views like explorer and search."));

225 226 227 228 229 230
export const SIDE_BAR_BORDER = registerColor('sideBar.border', {
	dark: null,
	light: null,
	hc: contrastBorder
}, nls.localize('sideBarBorder', "Side bar border color on the side separating to the editor. The side bar is the container for views like explorer and search."));

231
export const SIDE_BAR_TITLE_FOREGROUND = registerColor('sideBarTitle.foreground', {
B
Benjamin Pasero 已提交
232 233 234
	dark: SIDE_BAR_FOREGROUND,
	light: SIDE_BAR_FOREGROUND,
	hc: SIDE_BAR_FOREGROUND
235 236
}, nls.localize('sideBarTitleForeground', "Side bar title foreground color. The side bar is the container for views like explorer and search."));

237
export const SIDE_BAR_SECTION_HEADER_BACKGROUND = registerColor('sideBarSectionHeader.background', {
238 239 240 241 242
	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."));

243 244 245 246 247 248
export const SIDE_BAR_SECTION_HEADER_FOREGROUND = registerColor('sideBarSectionHeader.foreground', {
	dark: SIDE_BAR_FOREGROUND,
	light: SIDE_BAR_FOREGROUND,
	hc: SIDE_BAR_FOREGROUND
}, nls.localize('sideBarSectionHeaderForeground', "Side bar section header foreground color. The side bar is the container for views like explorer and search."));

B
Benjamin Pasero 已提交
249 250 251 252


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

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

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

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

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

277 278
// < --- Notifications --- >

279
export const NOTIFICATIONS_FOREGROUND = registerColor('notification.foreground', {
280 281 282 283 284
	dark: '#EEEEEE',
	light: '#EEEEEE',
	hc: '#FFFFFF'
}, nls.localize('notificationsForeground', "Notifications foreground color. Notifications slide in from the top of the window."));

285
export const NOTIFICATIONS_BACKGROUND = registerColor('notification.background', {
286 287 288 289 290
	dark: '#333333',
	light: '#2C2C2C',
	hc: '#000000'
}, nls.localize('notificationsBackground', "Notifications background color. Notifications slide in from the top of the window."));

B
Benjamin Pasero 已提交
291 292 293 294 295
/**
 * Base class for all themable workbench components.
 */
export class Themable extends Disposable {
	private _toUnbind: IDisposable[];
B
Benjamin Pasero 已提交
296
	private theme: ITheme;
B
Benjamin Pasero 已提交
297 298 299 300 301 302 303

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

		this._toUnbind = [];
B
Benjamin Pasero 已提交
304
		this.theme = themeService.getTheme();
B
Benjamin Pasero 已提交
305 306

		// Hook up to theme changes
307
		this._toUnbind.push(this.themeService.onThemeChange(theme => this.onThemeChange(theme)));
B
Benjamin Pasero 已提交
308 309 310 311 312 313
	}

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

314
	protected onThemeChange(theme: ITheme): void {
B
Benjamin Pasero 已提交
315
		this.theme = theme;
B
Benjamin Pasero 已提交
316

317
		this.updateStyles();
B
Benjamin Pasero 已提交
318 319
	}

320
	protected updateStyles(): void {
B
Benjamin Pasero 已提交
321 322 323
		// Subclasses to override
	}

324 325 326 327 328 329
	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);
		}
330 331

		return color ? color.toString() : null;
B
Benjamin Pasero 已提交
332 333 334 335 336 337 338
	}

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

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