|
6 | 6 | 'use strict'; |
7 | 7 |
|
8 | 8 | import { ITheme, IThemeService } from 'vs/platform/theme/common/themeService'; |
9 | | -import { inputBackground, inputForeground, ColorIdentifier, selectForeground, selectBackground, selectBorder, inputBorder, foreground, editorBackground, contrastBorder, inputActiveOptionBorder, listFocusBackground, listActiveSelectionBackground, listActiveSelectionForeground, listFocusAndSelectionBackground, listInactiveSelectionBackground, listHoverBackground, listDropBackground, pickerGroupBorder, pickerGroupForeground, widgetShadow, inputValidationInfoBorder, inputValidationInfoBackground, inputValidationWarningBorder, inputValidationWarningBackground, inputValidationErrorBorder, inputValidationErrorBackground, activeContrastBorder, buttonForeground, buttonBackground, buttonHoverBackground } from 'vs/platform/theme/common/colorRegistry'; |
| 9 | +import { inputBackground, inputForeground, ColorIdentifier, selectForeground, selectBackground, selectBorder, inputBorder, foreground, editorBackground, contrastBorder, inputActiveOptionBorder, listFocusBackground, listActiveSelectionBackground, listActiveSelectionForeground, listInactiveSelectionBackground, listHoverBackground, listDropBackground, pickerGroupBorder, pickerGroupForeground, widgetShadow, inputValidationInfoBorder, inputValidationInfoBackground, inputValidationWarningBorder, inputValidationWarningBackground, inputValidationErrorBorder, inputValidationErrorBackground, activeContrastBorder, buttonForeground, buttonBackground, buttonHoverBackground, ColorFunction, darken } from 'vs/platform/theme/common/colorRegistry'; |
10 | 10 | import { IDisposable } from 'vs/base/common/lifecycle'; |
11 | 11 | import { SIDE_BAR_SECTION_HEADER_BACKGROUND } from 'vs/workbench/common/theme'; |
12 | 12 |
|
13 | 13 | export interface IThemable { |
14 | 14 | style(colors: { [name: string]: ColorIdentifier }): void; |
15 | 15 | } |
16 | 16 |
|
17 | | -export function attachStyler(themeService: IThemeService, widget: IThemable, optionsMapping: { [optionsKey: string]: ColorIdentifier }): IDisposable { |
| 17 | +export function attachStyler(themeService: IThemeService, widget: IThemable, optionsMapping: { [optionsKey: string]: ColorIdentifier | ColorFunction }): IDisposable { |
18 | 18 | function applyStyles(theme: ITheme): void { |
19 | 19 | const styles = Object.create(null); |
20 | 20 | for (let key in optionsMapping) { |
21 | | - styles[key] = theme.getColor(optionsMapping[key]); |
| 21 | + const value = optionsMapping[key]; |
| 22 | + if (typeof value === 'string') { |
| 23 | + styles[key] = theme.getColor(value); |
| 24 | + } else if (typeof value === 'function') { |
| 25 | + styles[key] = value(theme); |
| 26 | + } |
22 | 27 | } |
23 | 28 |
|
24 | 29 | widget.style(styles); |
@@ -142,7 +147,7 @@ export function attachQuickOpenStyler(widget: IThemable, themeService: IThemeSer |
142 | 147 | listFocusBackground: (style && style.listFocusBackground) || listFocusBackground, |
143 | 148 | listActiveSelectionBackground: (style && style.listActiveSelectionBackground) || listActiveSelectionBackground, |
144 | 149 | listActiveSelectionForeground: (style && style.listActiveSelectionForeground) || listActiveSelectionForeground, |
145 | | - listFocusAndSelectionBackground: (style && style.listFocusAndSelectionBackground) || listFocusAndSelectionBackground, |
| 150 | + listFocusAndSelectionBackground: style && style.listFocusAndSelectionBackground || darken(listActiveSelectionBackground, 0.1), |
146 | 151 | listFocusAndSelectionForeground: (style && style.listFocusAndSelectionForeground) || listActiveSelectionForeground, |
147 | 152 | listInactiveSelectionBackground: (style && style.listInactiveSelectionBackground) || listInactiveSelectionBackground, |
148 | 153 | listHoverBackground: (style && style.listHoverBackground) || listHoverBackground, |
@@ -172,7 +177,7 @@ export function attachListStyler(widget: IThemable, themeService: IThemeService, |
172 | 177 | listFocusBackground: (style && style.listFocusBackground) || listFocusBackground, |
173 | 178 | listActiveSelectionBackground: (style && style.listActiveSelectionBackground) || listActiveSelectionBackground, |
174 | 179 | listActiveSelectionForeground: (style && style.listActiveSelectionForeground) || listActiveSelectionForeground, |
175 | | - listFocusAndSelectionBackground: (style && style.listFocusAndSelectionBackground) || listFocusAndSelectionBackground, |
| 180 | + listFocusAndSelectionBackground: style && style.listFocusAndSelectionBackground || darken(listActiveSelectionBackground, 0.1), |
176 | 181 | listFocusAndSelectionForeground: (style && style.listFocusAndSelectionForeground) || listActiveSelectionForeground, |
177 | 182 | listInactiveFocusBackground: (style && style.listInactiveFocusBackground), |
178 | 183 | listInactiveSelectionBackground: (style && style.listInactiveSelectionBackground) || listInactiveSelectionBackground, |
|
0 commit comments