theme.ts 15.4 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 } 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';
10
import { Color, RGBA } from 'vs/base/common/color';
11

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

14
export const TABS_CONTAINER_BACKGROUND = registerColor('editorGroupHeader.tabsBackground', {
15 16
	dark: '#252526',
	light: '#F3F3F3',
B
Benjamin Pasero 已提交
17
	hc: null
18 19
}, nls.localize('tabsContainerBackground', "Background color of the tabs container. 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."));

20
export const TAB_ACTIVE_BACKGROUND = registerColor('tab.activeBackground', {
21 22 23
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
B
Benjamin Pasero 已提交
24
}, 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."));
25

26
export const TAB_INACTIVE_BACKGROUND = registerColor('tab.inactiveBackground', {
27 28
	dark: '#2D2D2D',
	light: '#ECECEC',
B
Benjamin Pasero 已提交
29
	hc: null
B
Benjamin Pasero 已提交
30
}, 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."));
31

32
export const TAB_BORDER = registerColor('tab.border', {
B
Benjamin Pasero 已提交
33 34
	dark: '#252526',
	light: '#F3F3F3',
35
	hc: contrastBorder
B
Benjamin Pasero 已提交
36 37
}, 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."));

38
export const TAB_ACTIVE_GROUP_ACTIVE_FOREGROUND = registerColor('tab.activeForeground', {
39 40 41
	dark: Color.white,
	light: Color.fromRGBA(new RGBA(51, 51, 51)),
	hc: Color.white
B
Benjamin Pasero 已提交
42
}, 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."));
43

44
export const TAB_ACTIVE_GROUP_INACTIVE_FOREGROUND = registerColor('tab.activeWithInactiveEditorGroupForeground', {
45 46 47
	dark: Color.white.transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.7),
	hc: Color.white
B
Benjamin Pasero 已提交
48
}, nls.localize('tabActiveEditorGroupInactiveForeground', "Active tab foreground color in an inactive 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."));
49

50
export const TAB_INACTIVE_GROUP_ACTIVE_FOREGROUND = registerColor('tab.inactiveForeground', {
51 52 53
	dark: Color.white.transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.5),
	hc: Color.white
B
Benjamin Pasero 已提交
54
}, 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."));
55

56
export const TAB_INACTIVE_GROUP_INACTIVE_FOREGROUND = registerColor('tab.inactiveWithInactiveEditorGroupForeground', {
57 58 59
	dark: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.5).transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.5).transparent(0.7),
	hc: Color.white
B
Benjamin Pasero 已提交
60
}, nls.localize('tabInactiveEditorGroupInactiveForeground', "Inactive tab foreground color in an inactive 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."));
61 62 63 64 65



// < --- Editors --- >

66
export const EDITOR_GROUP_BACKGROUND = registerColor('editorGroup.background', {
67 68 69 70 71
	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."));

72
export const EDITOR_GROUP_HEADER_BACKGROUND = registerColor('editorGroupHeader.noTabsBackground', {
B
Benjamin Pasero 已提交
73 74 75
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
76
}, 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 已提交
77

78
export const EDITOR_GROUP_BORDER_COLOR = registerColor('editorGroup.border', {
79 80
	dark: '#444444',
	light: '#E7E7E7',
81
	hc: contrastBorder
82 83
}, nls.localize('editorGroupBorder', "Color to separate multiple editor groups from each other. Editor groups are the containers of editors."));

84
export const EDITOR_DRAG_AND_DROP_BACKGROUND = registerColor('editorGroup.dropBackground', {
B
Benjamin Pasero 已提交
85 86 87 88
	dark: Color.fromRGBA(new RGBA(83, 89, 93)).transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 153, 255)).transparent(0.18),
	hc: null
}, nls.localize('editorDragAndDropBackground', "Background color when dragging editors around."));
89

90
export const EDITOR_MASTER_DETAILS_BORDER = registerColor('masterDetailsEditor.border', {
91 92 93
	dark: '#000000',
	light: '#DDDDDD',
	hc: null
B
Benjamin Pasero 已提交
94
}, nls.localize('editorMasterDetailsBorder', "Border color to separate the details from the master side for side by side editors. Examples include diff editors and the settings editor."));
95

96 97 98

// < --- Panels --- >

99
export const PANEL_BACKGROUND = registerColor('panel.background', {
100 101 102
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
103 104
}, nls.localize('panelBackground', "Panel background color. Panels are shown below the editor area and contain views like output and integrated terminal."));

105
export const PANEL_BORDER_COLOR = registerColor('panel.border', {
106 107
	dark: Color.fromRGBA(new RGBA(128, 128, 128)).transparent(0.35),
	light: Color.fromRGBA(new RGBA(128, 128, 128)).transparent(0.35),
108
	hc: contrastBorder
B
Benjamin Pasero 已提交
109
}, 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 已提交
110

111
export const PANEL_ACTIVE_TITLE_COLOR = registerColor('panelTitle.activeForeground', {
112 113 114
	dark: '#E7E7E7',
	light: '#424242',
	hc: Color.white
115
}, nls.localize('panelActiveTitleForeground', "Title color for the active panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
116

117
export const PANEL_INACTIVE_TITLE_COLOR = registerColor('panelTitle.inactiveForeground', {
118 119 120
	dark: Color.fromRGBA(new RGBA(231, 231, 231)).transparent(0.5),
	light: Color.fromRGBA(new RGBA(66, 66, 66)).transparent(0.75),
	hc: Color.white
121
}, nls.localize('panelInactiveTitleForeground', "Title color for the inactive panel. Panels are shown below the editor area and contain views like output and integrated terminal."));
122

123
export const PANEL_ACTIVE_TITLE_BORDER = registerColor('panelTitle.activeBorder', {
124 125
	dark: PANEL_BORDER_COLOR,
	light: PANEL_BORDER_COLOR,
126
	hc: contrastBorder
127 128
}, 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."));

129

130

131 132
// < --- Status --- >

133
export const STATUS_BAR_FOREGROUND = registerColor('statusBar.foreground', {
134 135 136
	dark: '#FFFFFF',
	light: '#FFFFFF',
	hc: '#FFFFFF'
137
}, nls.localize('statusBarForeground', "Status bar foreground color. The status bar is shown in the bottom of the window."));
138

139
export const STATUS_BAR_BACKGROUND = registerColor('statusBar.background', {
140 141
	dark: '#007ACC',
	light: '#007ACC',
B
Benjamin Pasero 已提交
142
	hc: null
143
}, nls.localize('statusBarBackground', "Standard status bar background color. The status bar is shown in the bottom of the window."));
144

145
export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBar.noFolderBackground', {
146 147
	dark: '#68217A',
	light: '#68217A',
B
Benjamin Pasero 已提交
148
	hc: null
149
}, 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 已提交
150

151
export const STATUS_BAR_ITEM_ACTIVE_BACKGROUND = registerColor('statusBarItem.activeBackground', {
B
Benjamin Pasero 已提交
152 153 154
	dark: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.18),
	light: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.18),
	hc: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.18)
155
}, nls.localize('statusBarItemActiveBackground', "Status bar item background color when clicking. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
156

157
export const STATUS_BAR_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.hoverBackground', {
B
Benjamin Pasero 已提交
158 159 160
	dark: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12),
	light: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12),
	hc: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12)
161
}, nls.localize('statusBarItemHoverBackground', "Status bar item background color when hovering. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
162

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

169
export const STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.prominentHoverBackground', {
B
Benjamin Pasero 已提交
170 171 172
	dark: '#369432',
	light: '#369432',
	hc: '#369432'
B
Benjamin Pasero 已提交
173
}, 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 已提交
174

175 176 177 178


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

179
export const ACTIVITY_BAR_BACKGROUND = registerColor('activityBar.background', {
180
	dark: '#333333',
181
	light: '#2C2C2C',
182 183
	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."));
184

185
export const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
186 187 188
	dark: Color.white,
	light: Color.white,
	hc: Color.white
189
}, 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."));
190

191
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBar.dropBackground', {
192 193 194
	dark: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12),
	light: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12),
	hc: Color.fromRGBA(new RGBA(255, 255, 255)).transparent(0.12),
195 196
}, nls.localize('activityBarDragAndDropBackground', "Drag and drop feedback color for the activity bar items. The activity bar is showing on the far left or right and allows to switch between views of the side bar."));

197
export const ACTIVITY_BAR_BADGE_BACKGROUND = registerColor('activityBarBadge.background', {
B
Benjamin Pasero 已提交
198 199 200
	dark: '#007ACC',
	light: '#007ACC',
	hc: '#000000'
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', {
B
Benjamin Pasero 已提交
204 205 206
	dark: Color.white,
	light: Color.white,
	hc: Color.white
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
export const SIDE_BAR_TITLE_FOREGROUND = registerColor('sideBarTitle.foreground', {
220 221 222 223 224
	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."));

225
export const SIDE_BAR_SECTION_HEADER_BACKGROUND = registerColor('sideBarSectionHeader.background', {
226 227 228 229 230
	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 已提交
231 232 233 234


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

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

241
export const TITLE_BAR_INACTIVE_FOREGROUND = registerColor('titleBar.inactiveForeground', {
B
Benjamin Pasero 已提交
242 243 244
	dark: Color.fromRGBA(new RGBA(204, 204, 204)).transparent(0.6),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.6),
	hc: null
N
Nicolas Ramz 已提交
245
}, nls.localize('titleBarInactiveForeground', "Title bar foreground when the window is inactive. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
246

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

253
export const TITLE_BAR_INACTIVE_BACKGROUND = registerColor('titleBar.inactiveBackground', {
B
Benjamin Pasero 已提交
254 255 256
	dark: Color.fromRGBA(new RGBA(60, 60, 60)).transparent(0.6),
	light: Color.fromRGBA(new RGBA(221, 221, 221)).transparent(0.6),
	hc: null
N
Nicolas Ramz 已提交
257
}, nls.localize('titleBarInactiveBackground', "Title bar background when the window is inactive. Note that this color is currently only supported on macOS."));
B
Benjamin Pasero 已提交
258

259 260
// < --- Notifications --- >

261
export const NOTIFICATIONS_FOREGROUND = registerColor('notification.foreground', {
262 263 264 265 266
	dark: '#EEEEEE',
	light: '#EEEEEE',
	hc: '#FFFFFF'
}, nls.localize('notificationsForeground', "Notifications foreground color. Notifications slide in from the top of the window."));

267
export const NOTIFICATIONS_BACKGROUND = registerColor('notification.background', {
268 269 270 271 272
	dark: '#333333',
	light: '#2C2C2C',
	hc: '#000000'
}, nls.localize('notificationsBackground', "Notifications background color. Notifications slide in from the top of the window."));

B
Benjamin Pasero 已提交
273 274 275 276 277
/**
 * Base class for all themable workbench components.
 */
export class Themable extends Disposable {
	private _toUnbind: IDisposable[];
B
Benjamin Pasero 已提交
278
	private theme: ITheme;
B
Benjamin Pasero 已提交
279 280 281 282 283 284 285

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

		this._toUnbind = [];
B
Benjamin Pasero 已提交
286
		this.theme = themeService.getTheme();
B
Benjamin Pasero 已提交
287 288

		// Hook up to theme changes
289
		this._toUnbind.push(this.themeService.onThemeChange(theme => this.onThemeChange(theme)));
B
Benjamin Pasero 已提交
290 291 292 293 294 295
	}

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

296
	protected onThemeChange(theme: ITheme): void {
B
Benjamin Pasero 已提交
297
		this.theme = theme;
B
Benjamin Pasero 已提交
298

299
		this.updateStyles();
B
Benjamin Pasero 已提交
300 301
	}

302
	protected updateStyles(): void {
B
Benjamin Pasero 已提交
303 304 305 306
		// Subclasses to override
	}

	protected getColor(id: string): string {
B
Benjamin Pasero 已提交
307
		const color = this.theme.getColor(id);
308 309

		return color ? color.toString() : null;
B
Benjamin Pasero 已提交
310 311 312 313 314 315 316
	}

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

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