Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theming: fix decoration color theming #7330

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface DecorationOptions {
* color of the decoration in the overview ruler.
* use `rgba` values to play well with other decorations.
*/
color: string;
color: string | { id: string };
}

export enum MinimapPosition {
Expand Down
24 changes: 18 additions & 6 deletions packages/scm/src/browser/dirty-diff/dirty-diff-decorator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ export enum DirtyDiffDecorationType {
const AddedLineDecoration = <EditorDecorationOptions>{
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-added-line',
overviewRuler: {
color: 'editorOverviewRuler.addedForeground',
color: {
id: 'editorOverviewRuler.addedForeground'
},
position: OverviewRulerLane.Left,
},
minimap: {
color: 'minimapGutter.addedBackground',
color: {
id: 'minimapGutter.addedBackground'
},
position: MinimapPosition.Gutter
},
isWholeLine: true
Expand All @@ -49,11 +53,15 @@ const AddedLineDecoration = <EditorDecorationOptions>{
const RemovedLineDecoration = <EditorDecorationOptions>{
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-removed-line',
overviewRuler: {
color: 'editorOverviewRuler.deletedForeground',
color: {
id: 'editorOverviewRuler.deletedForeground'
},
position: OverviewRulerLane.Left,
},
minimap: {
color: 'minimapGutter.deletedBackground',
color: {
id: 'minimapGutter.deletedBackground'
},
position: MinimapPosition.Gutter
},
isWholeLine: false
Expand All @@ -62,11 +70,15 @@ const RemovedLineDecoration = <EditorDecorationOptions>{
const ModifiedLineDecoration = <EditorDecorationOptions>{
linesDecorationsClassName: 'dirty-diff-glyph dirty-diff-modified-line',
overviewRuler: {
color: 'editorOverviewRuler.modifiedForeground',
color: {
id: 'editorOverviewRuler.modifiedForeground'
},
position: OverviewRulerLane.Left,
},
minimap: {
color: 'minimapGutter.modifiedBackground',
color: {
id: 'minimapGutter.modifiedBackground'
},
position: MinimapPosition.Gutter
},
isWholeLine: true
Expand Down
25 changes: 18 additions & 7 deletions packages/scm/src/browser/scm-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export namespace SCM_COMMANDS {
};
}

export namespace ScmColors {
export const editorGutterModifiedBackground = 'editorGutter.modifiedBackground';
export const editorGutterAddedBackground = 'editorGutter.addedBackground';
export const editorGutterDeletedBackground = 'editorGutter.deletedBackground';
}

@injectable()
export class ScmContribution extends AbstractViewContribution<ScmWidget> implements FrontendApplicationContribution, ColorContribution {

Expand Down Expand Up @@ -186,24 +192,23 @@ export class ScmContribution extends AbstractViewContribution<ScmWidget> impleme
* It should be aligned with https://github.com/microsoft/vscode/blob/0dfa355b3ad185a6289ba28a99c141ab9e72d2be/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts#L808
*/
registerColors(colors: ColorRegistry): void {
const overviewRulerDefault = Color.rgba(0, 122, 204, 0.6);
colors.register(
{
id: 'editorGutter.modifiedBackground', defaults: {
id: ScmColors.editorGutterModifiedBackground, defaults: {
dark: Color.rgba(12, 125, 157),
light: Color.rgba(102, 175, 224),
hc: Color.rgba(0, 155, 249)
}, description: 'Editor gutter background color for lines that are modified.'
},
{
id: 'editorGutter.addedBackground', defaults: {
id: ScmColors.editorGutterAddedBackground, defaults: {
dark: Color.rgba(88, 124, 12),
light: Color.rgba(129, 184, 139),
hc: Color.rgba(51, 171, 78)
}, description: 'Editor gutter background color for lines that are added.'
},
{
id: 'editorGutter.deletedBackground', defaults: {
id: ScmColors.editorGutterDeletedBackground, defaults: {
dark: Color.rgba(148, 21, 27),
light: Color.rgba(202, 75, 81),
hc: Color.rgba(252, 93, 109)
Expand Down Expand Up @@ -233,17 +238,23 @@ export class ScmContribution extends AbstractViewContribution<ScmWidget> impleme
},
{
id: 'editorOverviewRuler.modifiedForeground', defaults: {
dark: overviewRulerDefault, light: overviewRulerDefault, hc: overviewRulerDefault
dark: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
light: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6),
hc: Color.transparent(ScmColors.editorGutterModifiedBackground, 0.6)
}, description: 'Overview ruler marker color for modified content.'
},
{
id: 'editorOverviewRuler.addedForeground', defaults: {
dark: overviewRulerDefault, light: overviewRulerDefault, hc: overviewRulerDefault
dark: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
light: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6),
hc: Color.transparent(ScmColors.editorGutterAddedBackground, 0.6)
}, description: 'Overview ruler marker color for added content.'
},
{
id: 'editorOverviewRuler.deletedForeground', defaults: {
dark: overviewRulerDefault, light: overviewRulerDefault, hc: overviewRulerDefault
dark: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
light: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6),
hc: Color.transparent(ScmColors.editorGutterDeletedBackground, 0.6)
}, description: 'Overview ruler marker color for deleted content.'
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,9 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {
},
options: {
overviewRuler: {
color: this.colorRegistry.getCurrentColor('editor.findMatchHighlightBackground') || '',
color: {
id: 'editor.findMatchHighlightBackground'
},
position: OverviewRulerLane.Center
},
className: res.selected ? 'current-search-in-workspace-editor-match' : 'search-in-workspace-editor-match',
Expand Down