From 251b65688c6592f7977cea77e2588867ca7c4392 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 1 Dec 2016 18:02:19 +0100 Subject: [PATCH] git extension icon decorations --- .../resources/icons/light/status-added.svg | 6 ++ .../resources/icons/light/status-conflict.svg | 6 ++ .../resources/icons/light/status-copied.svg | 6 ++ .../resources/icons/light/status-deleted.svg | 6 ++ .../resources/icons/light/status-ignored.svg | 6 ++ .../resources/icons/light/status-modified.svg | 6 ++ .../resources/icons/light/status-renamed.svg | 6 ++ .../icons/light/status-untracked.svg | 6 ++ extensions/git/src/scmProvider.ts | 59 +++++++++++++++---- .../parts/scm/browser/media/scmViewlet.css | 1 + .../workbench/parts/scm/browser/scmViewlet.ts | 4 +- 11 files changed, 98 insertions(+), 14 deletions(-) create mode 100644 extensions/git/resources/icons/light/status-added.svg create mode 100644 extensions/git/resources/icons/light/status-conflict.svg create mode 100644 extensions/git/resources/icons/light/status-copied.svg create mode 100644 extensions/git/resources/icons/light/status-deleted.svg create mode 100644 extensions/git/resources/icons/light/status-ignored.svg create mode 100644 extensions/git/resources/icons/light/status-modified.svg create mode 100644 extensions/git/resources/icons/light/status-renamed.svg create mode 100644 extensions/git/resources/icons/light/status-untracked.svg diff --git a/extensions/git/resources/icons/light/status-added.svg b/extensions/git/resources/icons/light/status-added.svg new file mode 100644 index 00000000000..587fc08f5f5 --- /dev/null +++ b/extensions/git/resources/icons/light/status-added.svg @@ -0,0 +1,6 @@ + + + + A + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-conflict.svg b/extensions/git/resources/icons/light/status-conflict.svg new file mode 100644 index 00000000000..b6088ecd083 --- /dev/null +++ b/extensions/git/resources/icons/light/status-conflict.svg @@ -0,0 +1,6 @@ + + + + C + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-copied.svg b/extensions/git/resources/icons/light/status-copied.svg new file mode 100644 index 00000000000..151fdb2cdbe --- /dev/null +++ b/extensions/git/resources/icons/light/status-copied.svg @@ -0,0 +1,6 @@ + + + + C + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-deleted.svg b/extensions/git/resources/icons/light/status-deleted.svg new file mode 100644 index 00000000000..7ed166accfe --- /dev/null +++ b/extensions/git/resources/icons/light/status-deleted.svg @@ -0,0 +1,6 @@ + + + + D + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-ignored.svg b/extensions/git/resources/icons/light/status-ignored.svg new file mode 100644 index 00000000000..85abc367a29 --- /dev/null +++ b/extensions/git/resources/icons/light/status-ignored.svg @@ -0,0 +1,6 @@ + + + + I + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-modified.svg b/extensions/git/resources/icons/light/status-modified.svg new file mode 100644 index 00000000000..ff338b81410 --- /dev/null +++ b/extensions/git/resources/icons/light/status-modified.svg @@ -0,0 +1,6 @@ + + + + M + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-renamed.svg b/extensions/git/resources/icons/light/status-renamed.svg new file mode 100644 index 00000000000..878067dd4b1 --- /dev/null +++ b/extensions/git/resources/icons/light/status-renamed.svg @@ -0,0 +1,6 @@ + + + + R + + \ No newline at end of file diff --git a/extensions/git/resources/icons/light/status-untracked.svg b/extensions/git/resources/icons/light/status-untracked.svg new file mode 100644 index 00000000000..c6a48e14f08 --- /dev/null +++ b/extensions/git/resources/icons/light/status-untracked.svg @@ -0,0 +1,6 @@ + + + + U + + \ No newline at end of file diff --git a/extensions/git/src/scmProvider.ts b/extensions/git/src/scmProvider.ts index e2d650111f4..57d74e5d3f3 100644 --- a/extensions/git/src/scmProvider.ts +++ b/extensions/git/src/scmProvider.ts @@ -21,6 +21,17 @@ function getIconUri(iconName: string, theme: Theme): Uri { return Uri.file(path.join(iconsRootPath, themeName, `${iconName}.svg`)); } +const Icons = { + Modified: getIconUri('status-modified', Theme.Light), + Added: getIconUri('status-added', Theme.Light), + Deleted: getIconUri('status-deleted', Theme.Light), + Renamed: getIconUri('status-renamed', Theme.Light), + Copied: getIconUri('status-copied', Theme.Light), + Untracked: getIconUri('status-untracked', Theme.Light), + Ignored: getIconUri('status-ignored', Theme.Light), + Conflict: getIconUri('status-conflict', Theme.Light), +}; + enum Status { INDEX_MODIFIED, INDEX_ADDED, @@ -46,21 +57,45 @@ class Resource implements SCMResource { get uri(): Uri { return this._uri; } - get decorations(): SCMResourceDecorations { - let iconPath: Uri | undefined; - let strikeThrough = false; - + private get iconPath(): Uri | undefined { switch (this.type) { - case Status.MODIFIED: - iconPath = getIconUri('refresh', Theme.Light); - break; - case Status.DELETED: - iconPath = getIconUri('refresh', Theme.Light); - strikeThrough = true; - break; + case Status.INDEX_MODIFIED: return Icons.Modified; + case Status.MODIFIED: return Icons.Modified; + case Status.INDEX_ADDED: return Icons.Added; + case Status.INDEX_DELETED: return Icons.Deleted; + case Status.DELETED: return Icons.Deleted; + case Status.INDEX_RENAMED: return Icons.Renamed; + case Status.INDEX_COPIED: return Icons.Copied; + case Status.UNTRACKED: return Icons.Untracked; + case Status.IGNORED: return Icons.Ignored; + case Status.BOTH_DELETED: return Icons.Conflict; + case Status.ADDED_BY_US: return Icons.Conflict; + case Status.DELETED_BY_THEM: return Icons.Conflict; + case Status.ADDED_BY_THEM: return Icons.Conflict; + case Status.DELETED_BY_US: return Icons.Conflict; + case Status.BOTH_ADDED: return Icons.Conflict; + case Status.BOTH_MODIFIED: return Icons.Conflict; + default: return void 0; } + } - return { iconPath, strikeThrough }; + private get strikeThrough(): boolean { + switch (this.type) { + case Status.DELETED: + case Status.BOTH_DELETED: + case Status.DELETED_BY_THEM: + case Status.DELETED_BY_US: + return true; + default: + return false; + } + } + + get decorations(): SCMResourceDecorations { + return { + iconPath: this.iconPath, + strikeThrough: this.strikeThrough + }; } constructor(private _uri: Uri, private type: any) { diff --git a/src/vs/workbench/parts/scm/browser/media/scmViewlet.css b/src/vs/workbench/parts/scm/browser/media/scmViewlet.css index 8f932d82168..7d2b0fa79b6 100644 --- a/src/vs/workbench/parts/scm/browser/media/scmViewlet.css +++ b/src/vs/workbench/parts/scm/browser/media/scmViewlet.css @@ -68,6 +68,7 @@ height: 100%; background-repeat: no-repeat; background-position: 50% 50%; + margin-right: 6px; } .scm-viewlet .monaco-list-row > .resource > .actions .action-label, diff --git a/src/vs/workbench/parts/scm/browser/scmViewlet.ts b/src/vs/workbench/parts/scm/browser/scmViewlet.ts index 0d55a0bdddd..d97cfce39da 100644 --- a/src/vs/workbench/parts/scm/browser/scmViewlet.ts +++ b/src/vs/workbench/parts/scm/browser/scmViewlet.ts @@ -102,9 +102,9 @@ class ResourceRenderer implements IRenderer { renderTemplate(container: HTMLElement): ResourceTemplate { const element = append(container, $('.resource')); + const decorationIcon = append(element, $('.decoration-icon')); const name = append(element, $('.name')); const fileLabel = this.instantiationService.createInstance(FileLabel, name, void 0); - const decorationIcon = append(element, $('.decoration-icon')); const actionsContainer = append(element, $('.actions')); const actionBar = new ActionBar(actionsContainer, { actionItemProvider: this.actionItemProvider }); @@ -120,7 +120,7 @@ class ResourceRenderer implements IRenderer { if (resource.decorations.icon) { template.decorationIcon.style.backgroundImage = `url('${resource.decorations.icon}')`; } else { - delete template.decorationIcon.style.backgroundImage; + template.decorationIcon.style.backgroundImage = ''; } }