theme.ts 14.8 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, highContrastBorder } 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 15 16
export const TABS_CONTAINER_BACKGROUND = registerColor('tabsContainerBackground', {
	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 21 22 23
export const ACTIVE_TAB_BACKGROUND = registerColor('activeTabBackground', {
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
24
}, nls.localize('activeTabBackground', "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 27 28

export const INACTIVE_TAB_BACKGROUND = registerColor('inactiveTabBackground', {
	dark: '#2D2D2D',
	light: '#ECECEC',
B
Benjamin Pasero 已提交
29
	hc: null
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
}, nls.localize('inactiveTabBackground', "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."));

export const ACTIVE_TAB_ACTIVE_GROUP_FOREGROUND = registerColor('activeTabActiveGroupForeground', {
	dark: Color.white,
	light: Color.fromRGBA(new RGBA(51, 51, 51)),
	hc: Color.white
}, nls.localize('activeTabActiveGroupForeground', "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."));

export const ACTIVE_TAB_INACTIVE_GROUP_FOREGROUND = registerColor('activeTabInactiveGroupForeground', {
	dark: Color.white.transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.7),
	hc: Color.white
}, nls.localize('activeTabInactiveGroupForeground', "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 INACTIVE_TAB_ACTIVE_GROUP_FOREGROUND = registerColor('inactiveTabActiveGroupForeground', {
	dark: Color.white.transparent(0.5),
	light: Color.fromRGBA(new RGBA(51, 51, 51)).transparent(0.5),
	hc: Color.white
}, nls.localize('inactiveTabActiveGroupForeground', "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 INACTIVE_TAB_INACTIVE_GROUP_FOREGROUND = registerColor('inactiveTabInactiveGroupForeground', {
	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
}, nls.localize('inactiveTabInactiveGroupForeground', "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."));

56 57 58 59 60 61 62 63 64 65
export const TAB_BORDER = registerColor('tabBorder', {
	dark: '#252526',
	light: '#F3F3F3',
	hc: highContrastBorder
}, 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."));



// < --- Editors --- >

B
Benjamin Pasero 已提交
66 67 68 69
export const EDITOR_HEADER_BACKGROUND = registerColor('editorHeaderBackground', {
	dark: editorBackground,
	light: editorBackground,
	hc: editorBackground
70
}, nls.localize('editorHeaderBackground', "Background color of the editor title header when tabs are disabled."));
B
Benjamin Pasero 已提交
71

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

B
Benjamin Pasero 已提交
78 79 80 81
export const EDITOR_GROUP_BACKGROUND = registerColor('editorGroupBackground', {
	dark: '#2D2D2D',
	light: '#ECECEC',
	hc: null
82
}, nls.localize('editorGroupBackground', "Background color of an editor group. Editor groups are the containers of editors."));
B
Benjamin Pasero 已提交
83 84 85 86 87 88

export const EDITOR_DRAG_AND_DROP_BACKGROUND = registerColor('editorDragAndDropBackground', {
	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 91 92 93 94 95
export const EDITOR_SIDE_BY_SIDE_BORDER = registerColor('editorSideBySideBorder', {
	dark: '#000000',
	light: '#DDDDDD',
	hc: null
}, nls.localize('editorSideBySideBorder', "Border color to separate the details from the master side for side by side editors."));

96 97 98

// < --- Panels --- >

99 100 101 102
export const PANEL_BACKGROUND = registerColor('panelBackground', {
	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_TOP_COLOR = registerColor('panelTopBorder', {
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: highContrastBorder
109
}, nls.localize('panelTopBorder', "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('panelActiveTitleForeground', {
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('panelInactiveTitleForeground', {
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 124 125 126 127 128

export const PANEL_ACTIVE_TITLE_BORDER = registerColor('panelActiveTitleBorder', {
	dark: '#404047',
	light: '#CCCEDA',
	hc: highContrastBorder
}, 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 133 134 135 136
// < --- Status --- >

export const STATUS_BAR_FOREGROUND = registerColor('statusBarForeground', {
	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

export const STATUS_BAR_BACKGROUND = registerColor('statusBarBackground', {
	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 146 147

export const STATUS_BAR_NO_FOLDER_BACKGROUND = registerColor('statusBarNoFolderBackground', {
	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 152 153 154

export const STATUS_BAR_ITEM_ACTIVE_BACKGROUND = registerColor('statusBarItemActiveBackground', {
	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 158 159 160

export const STATUS_BAR_ITEM_HOVER_BACKGROUND = registerColor('statusBarItemHoverBackground', {
	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_INFO_ITEM_BACKGROUND = registerColor('statusBarInfoItemBackground', {
164 165 166
	dark: '#388A34',
	light: '#388A34',
	hc: '#3883A4'
167
}, nls.localize('statusBarInfoItemBackground', "Status bar info item background color. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
168 169 170 171 172

export const STATUS_BAR_INFO_ITEM_HOVER_BACKGROUND = registerColor('statusBarInfoItemHoverBackground', {
	dark: '#369432',
	light: '#369432',
	hc: '#369432'
173
}, nls.localize('statusBarInfoItemHoverBackground', "Status bar info item background color when hovering. The status bar is shown in the bottom of the window."));
B
Benjamin Pasero 已提交
174

175 176 177 178 179 180


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

export const ACTIVITY_BAR_BACKGROUND = registerColor('activityBarBackground', {
	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('activityBarForeground', {
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 192 193 194 195 196
export const ACTIVITY_BAR_DRAG_AND_DROP_BACKGROUND = registerColor('activityBarDragAndDropBackground', {
	dark: '#403F3F',
	light: '#403F3F',
	hc: '#403F3F'
}, 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."));

B
Benjamin Pasero 已提交
197 198 199 200 201 202 203 204 205 206 207 208
export const ACTIVITY_BADGE_BACKGROUND = registerColor('activityBadgeBackground', {
	dark: '#007ACC',
	light: '#007ACC',
	hc: '#000000'
}, nls.localize('activityBadgeBackground', "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."));

export const ACTIVITY_BADGE_FOREGROUND = registerColor('activityBadgeForeground', {
	dark: Color.white,
	light: Color.white,
	hc: Color.white
}, nls.localize('activityBadgeForeground', "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."));

209 210 211 212


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

213 214 215 216 217 218
export const SIDE_BAR_BACKGROUND = registerColor('sideBarBackground', {
	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_TITLE_FOREGROUND = registerColor('sideBarTitleForeground', {
	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 226 227 228 229 230
export const SIDE_BAR_SECTION_HEADER_BACKGROUND = registerColor('sideBarSectionHeaderBackground', {
	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 235 236 237 238


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

export const TITLE_BAR_ACTIVE_FOREGROUND = registerColor('titleBarActiveForeground', {
	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 242 243 244

export const TITLE_BAR_INACTIVE_FOREGROUND = registerColor('titleBarInactiveForeground', {
	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 248 249 250

export const TITLE_BAR_ACTIVE_BACKGROUND = registerColor('titleBarActiveBackground', {
	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 254 255 256

export const TITLE_BAR_INACTIVE_BACKGROUND = registerColor('titleBarInactiveBackground', {
	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 261 262 263 264 265 266 267 268 269 270 271 272
// < --- Notifications --- >

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

export const NOTIFICATIONS_BACKGROUND = registerColor('notificationsBackground', {
	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
}