theme.ts 20.6 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');
B
Benjamin Pasero 已提交
7
import { registerColor, editorBackground, contrastBorder, transparent, lighten, darken } 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
36
}, nls.localize('tabActiveForeground', "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
42 43 44 45 46 47 48 49 50 51 52 53 54
}, nls.localize('tabInactiveForeground', "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."));

export const TAB_UNFOCUSED_ACTIVE_FOREGROUND = registerColor('tab.unfocusedActiveForeground', {
	dark: transparent(TAB_ACTIVE_FOREGROUND, 0.5),
	light: transparent(TAB_ACTIVE_FOREGROUND, 0.7),
	hc: Color.white
}, nls.localize('tabUnfocusedActiveForeground', "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."));

export const TAB_UNFOCUSED_INACTIVE_FOREGROUND = registerColor('tab.unfocusedInactiveForeground', {
	dark: transparent(TAB_INACTIVE_FOREGROUND, 0.5),
	light: transparent(TAB_INACTIVE_FOREGROUND, 0.5),
	hc: Color.white
}, nls.localize('tabUnfocusedInactiveForeground', "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."));
55

56 57 58

// < --- Editors --- >

59
export const EDITOR_GROUP_BACKGROUND = registerColor('editorGroup.background', {
60 61 62 63 64
	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 已提交
65 66 67 68 69 70
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."));

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

83
export const EDITOR_GROUP_BORDER = registerColor('editorGroup.border', {
84 85
	dark: '#444444',
	light: '#E7E7E7',
86
	hc: contrastBorder
87 88
}, nls.localize('editorGroupBorder', "Color to separate multiple editor groups from each other. Editor groups are the containers of editors."));

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

95

96 97 98

// < --- Panels --- >

99 100 101 102 103 104
export const PANEL_BACKGROUND = registerColor('panel.background', {
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
}, 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 = registerColor('panel.border', {
B
Benjamin Pasero 已提交
106 107
	dark: Color.fromHex('#808080').transparent(0.35),
	light: Color.fromHex('#808080').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_FOREGROUND = 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 118 119
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),
120
	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,
	light: PANEL_BORDER,
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 140 141 142 143 144
export const STATUS_BAR_NO_FOLDER_FOREGROUND = registerColor('statusBar.noFolderForeground', {
	dark: STATUS_BAR_FOREGROUND,
	light: STATUS_BAR_FOREGROUND,
	hc: STATUS_BAR_FOREGROUND
}, nls.localize('statusBarNoFolderForeground', "Status bar foreground color when no folder is opened. The status bar is shown in the bottom of the window."));

145
export const STATUS_BAR_BACKGROUND = registerColor('statusBar.background', {
146 147
	dark: '#007ACC',
	light: '#007ACC',
B
Benjamin Pasero 已提交
148
	hc: null
149
}, nls.localize('statusBarBackground', "Standard status bar background color. The status bar is shown in the bottom of the window."));
150

151
export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBar.noFolderBackground', {
152 153
	dark: '#68217A',
	light: '#68217A',
B
Benjamin Pasero 已提交
154
	hc: null
155
}, 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 已提交
156

157 158 159 160 161
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."));
162

163 164 165 166 167
export const STATUS_BAR_NO_FOLDER_BORDER = registerColor('statusBar.noFolderBorder', {
	dark: STATUS_BAR_BORDER,
	light: STATUS_BAR_BORDER,
	hc: STATUS_BAR_BORDER
}, nls.localize('statusBarNoFolderBorder', "Status bar border color separating to the sidebar and editor when no folder is opened. The status bar is shown in the bottom of the window."));
168

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

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

181
export const STATUS_BAR_PROMINENT_ITEM_BACKGROUND = registerColor('statusBarItem.prominentBackground', {
182 183 184
	dark: '#388A34',
	light: '#388A34',
	hc: '#3883A4'
B
Benjamin Pasero 已提交
185
}, 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 已提交
186

187
export const STATUS_BAR_PROMINENT_ITEM_HOVER_BACKGROUND = registerColor('statusBarItem.prominentHoverBackground', {
B
Benjamin Pasero 已提交
188 189 190
	dark: '#369432',
	light: '#369432',
	hc: '#369432'
B
Benjamin Pasero 已提交
191
}, 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 已提交
192

193 194 195 196


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

197
export const ACTIVITY_BAR_BACKGROUND = registerColor('activityBar.background', {
198
	dark: '#333333',
199
	light: '#2C2C2C',
200 201
	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."));
202

203
export const ACTIVITY_BAR_FOREGROUND = registerColor('activityBar.foreground', {
204 205 206
	dark: Color.white,
	light: Color.white,
	hc: Color.white
207
}, 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."));
208

209 210 211 212 213 214
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."));

215
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBar.dropBackground', {
B
Benjamin Pasero 已提交
216 217 218
	dark: Color.white.transparent(0.12),
	light: Color.white.transparent(0.12),
	hc: Color.white.transparent(0.12),
B
Benjamin Pasero 已提交
219
}, 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."));
220

221
export const ACTIVITY_BAR_BADGE_BACKGROUND = registerColor('activityBarBadge.background', {
B
Benjamin Pasero 已提交
222 223 224
	dark: '#007ACC',
	light: '#007ACC',
	hc: '#000000'
B
Benjamin Pasero 已提交
225
}, 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 已提交
226

227
export const ACTIVITY_BAR_BADGE_FOREGROUND = registerColor('activityBarBadge.foreground', {
B
Benjamin Pasero 已提交
228 229 230
	dark: Color.white,
	light: Color.white,
	hc: Color.white
B
Benjamin Pasero 已提交
231
}, 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 已提交
232

233 234 235 236


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

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

243 244 245 246 247 248
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."));

249 250 251 252 253 254
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."));

255
export const SIDE_BAR_TITLE_FOREGROUND = registerColor('sideBarTitle.foreground', {
B
Benjamin Pasero 已提交
256 257 258
	dark: SIDE_BAR_FOREGROUND,
	light: SIDE_BAR_FOREGROUND,
	hc: SIDE_BAR_FOREGROUND
259 260
}, nls.localize('sideBarTitleForeground', "Side bar title foreground color. The side bar is the container for views like explorer and search."));

261 262 263 264 265 266
export const SIDE_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('sideBar.dropBackground', {
	dark: Color.white.transparent(0.12),
	light: Color.white.transparent(0.12),
	hc: Color.white.transparent(0.12),
}, nls.localize('sideBarDragAndDropBackground', "Drag and drop feedback color for the side bar sections. The color should have transparency so that the side bar sections can still shine through. The side bar is the container for views like explorer and search."));

267
export const SIDE_BAR_SECTION_HEADER_BACKGROUND = registerColor('sideBarSectionHeader.background', {
268 269 270 271 272
	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."));

273 274 275 276 277 278
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 已提交
279 280 281 282


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

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

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

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

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

307 308 309 310 311 312
export const TITLE_BAR_BORDER = registerColor('titleBar.border', {
	dark: null,
	light: null,
	hc: null
}, nls.localize('titleBarBorder', "Title bar border color. Note that this color is currently only supported on macOS."));

313 314
// < --- Notifications --- >

315
export const NOTIFICATIONS_FOREGROUND = registerColor('notification.foreground', {
316 317 318 319 320
	dark: '#EEEEEE',
	light: '#EEEEEE',
	hc: '#FFFFFF'
}, nls.localize('notificationsForeground', "Notifications foreground color. Notifications slide in from the top of the window."));

321
export const NOTIFICATIONS_BACKGROUND = registerColor('notification.background', {
322 323 324 325
	dark: '#333333',
	light: '#2C2C2C',
	hc: '#000000'
}, nls.localize('notificationsBackground', "Notifications background color. Notifications slide in from the top of the window."));
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379

export const NOTIFICATIONS_BUTTON_BACKGROUND = registerColor('notification.buttonBackground', {
	dark: '#0E639C',
	light: '#007ACC',
	hc: null
}, nls.localize('notificationsButtonBackground', "Notifications button background color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_BUTTON_HOVER_BACKGROUND = registerColor('notification.buttonHoverBackground', {
	dark: lighten(NOTIFICATIONS_BUTTON_BACKGROUND, 0.2),
	light: darken(NOTIFICATIONS_BUTTON_BACKGROUND, 0.2),
	hc: null
}, nls.localize('notificationsButtonHoverBackground', "Notifications button background color when hovering. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_BUTTON_FOREGROUND = registerColor('notification.buttonForeground', {
	dark: Color.white,
	light: Color.white,
	hc: Color.white
}, nls.localize('notificationsButtonForeground', "Notifications button foreground color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_INFO_BACKGROUND = registerColor('notification.infoBackground', {
	dark: '#007acc',
	light: '#007acc',
	hc: contrastBorder
}, nls.localize('notificationsInfoBackground', "Notifications info background color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_INFO_FOREGROUND = registerColor('notification.infoForeground', {
	dark: NOTIFICATIONS_FOREGROUND,
	light: NOTIFICATIONS_FOREGROUND,
	hc: null
}, nls.localize('notificationsInfoForeground', "Notifications info foreground color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_WARNING_BACKGROUND = registerColor('notification.warningBackground', {
	dark: '#B89500',
	light: '#B89500',
	hc: contrastBorder
}, nls.localize('notificationsWarningBackground', "Notifications warning background color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_WARNING_FOREGROUND = registerColor('notification.warningForeground', {
	dark: NOTIFICATIONS_FOREGROUND,
	light: NOTIFICATIONS_FOREGROUND,
	hc: null
}, nls.localize('notificationsWarningForeground', "Notifications warning foreground color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_ERROR_BACKGROUND = registerColor('notification.errorBackground', {
	dark: '#BE1100',
	light: '#BE1100',
	hc: contrastBorder
}, nls.localize('notificationsErrorBackground', "Notifications error background color. Notifications slide in from the top of the window."));

export const NOTIFICATIONS_ERROR_FOREGROUND = registerColor('notification.errorForeground', {
	dark: NOTIFICATIONS_FOREGROUND,
	light: NOTIFICATIONS_FOREGROUND,
	hc: null
}, nls.localize('notificationsErrorForeground', "Notifications error foreground color. Notifications slide in from the top of the window."));
380

B
Benjamin Pasero 已提交
381 382 383 384 385
/**
 * Base class for all themable workbench components.
 */
export class Themable extends Disposable {
	private _toUnbind: IDisposable[];
B
Benjamin Pasero 已提交
386
	private theme: ITheme;
B
Benjamin Pasero 已提交
387 388 389 390 391 392 393

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

		this._toUnbind = [];
B
Benjamin Pasero 已提交
394
		this.theme = themeService.getTheme();
B
Benjamin Pasero 已提交
395 396

		// Hook up to theme changes
397
		this._toUnbind.push(this.themeService.onThemeChange(theme => this.onThemeChange(theme)));
B
Benjamin Pasero 已提交
398 399 400 401 402 403
	}

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

404
	protected onThemeChange(theme: ITheme): void {
B
Benjamin Pasero 已提交
405
		this.theme = theme;
B
Benjamin Pasero 已提交
406

407
		this.updateStyles();
B
Benjamin Pasero 已提交
408 409
	}

410
	protected updateStyles(): void {
B
Benjamin Pasero 已提交
411 412 413
		// Subclasses to override
	}

414 415 416 417 418 419
	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);
		}
420 421

		return color ? color.toString() : null;
B
Benjamin Pasero 已提交
422 423 424 425 426 427 428
	}

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

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