Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9dbb46e8
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9dbb46e8
编写于
11月 29, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support ThemeIcon in custom view
上级
7f6c6c5a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
19 deletion
+21
-19
src/vs/platform/theme/common/themeService.ts
src/vs/platform/theme/common/themeService.ts
+2
-2
src/vs/workbench/browser/parts/views/customView.ts
src/vs/workbench/browser/parts/views/customView.ts
+19
-17
未找到文件。
src/vs/platform/theme/common/themeService.ts
浏览文件 @
9dbb46e8
...
...
@@ -45,7 +45,7 @@ export namespace ThemeIcon {
return
{
id
:
owner
+
name
};
}
const
_regexAsClassName
=
/^
codicon
\/
([
a-z-
]
+
)(
~
[
a-z
]
+
)?
$/i
;
const
_regexAsClassName
=
/^
(
codicon
\/)?
([
a-z-
]
+
)(
~
[
a-z
]
+
)?
$/i
;
export
function
asClassName
(
icon
:
ThemeIcon
):
string
|
undefined
{
// todo@martin,joh -> this should go into the ThemeService
...
...
@@ -53,7 +53,7 @@ export namespace ThemeIcon {
if
(
!
match
)
{
return
undefined
;
}
const
[
,
name
,
modifier
]
=
match
;
let
[,
,
name
,
modifier
]
=
match
;
let
className
=
`codicon codicon-
${
name
}
`
;
if
(
modifier
)
{
className
+=
`
${
modifier
.
substr
(
1
)}
`
;
...
...
src/vs/workbench/browser/parts/views/customView.ts
浏览文件 @
9dbb46e8
...
...
@@ -26,7 +26,7 @@ import { ResourceLabels, IResourceLabel } from 'vs/workbench/browser/labels';
import
{
ActionBar
,
IActionViewItemProvider
,
ActionViewItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
dirname
,
basename
}
from
'
vs/base/common/resources
'
;
import
{
LIGHT
,
FileThemeIcon
,
FolderThemeIcon
,
registerThemingParticipant
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
LIGHT
,
FileThemeIcon
,
FolderThemeIcon
,
registerThemingParticipant
,
ThemeIcon
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
FileKind
}
from
'
vs/platform/files/common/files
'
;
import
{
WorkbenchAsyncDataTree
,
TreeResourceNavigator2
}
from
'
vs/platform/list/browser/listService
'
;
import
{
ViewletPane
,
IViewletPaneOptions
}
from
'
vs/workbench/browser/parts/views/paneViewlet
'
;
...
...
@@ -40,7 +40,7 @@ import { IListVirtualDelegate, IIdentityProvider } from 'vs/base/browser/ui/list
import
{
ITreeRenderer
,
ITreeNode
,
IAsyncDataSource
,
ITreeContextMenuEvent
}
from
'
vs/base/browser/ui/tree/tree
'
;
import
{
FuzzyScore
,
createMatches
}
from
'
vs/base/common/filters
'
;
import
{
CollapseAllAction
}
from
'
vs/base/browser/ui/tree/treeDefaults
'
;
import
{
escape
,
isFalsyOrWhitespace
}
from
'
vs/base/common/strings
'
;
import
{
isFalsyOrWhitespace
}
from
'
vs/base/common/strings
'
;
import
{
SIDE_BAR_BACKGROUND
}
from
'
vs/workbench/common/theme
'
;
export
class
CustomTreeViewPane
extends
ViewletPane
{
...
...
@@ -780,7 +780,7 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
// reset
templateData
.
actionBar
.
clear
();
if
(
resource
||
node
.
themeIcon
)
{
if
(
resource
||
this
.
isFileKindThemeIcon
(
node
.
themeIcon
)
)
{
const
fileDecorations
=
this
.
configurationService
.
getValue
<
{
colors
:
boolean
,
badges
:
boolean
}
>
(
'
explorer.decorations
'
);
templateData
.
resourceLabel
.
setResource
({
name
:
label
,
description
,
resource
:
resource
?
resource
:
URI
.
parse
(
'
missing:_icon_resource
'
)
},
{
fileKind
:
this
.
getFileKind
(
node
),
title
,
hideIcon
:
!!
iconUrl
,
fileDecorations
,
extraClasses
:
[
'
custom-view-tree-node-item-resourceLabel
'
],
matches
:
matches
?
matches
:
createMatches
(
element
.
filterData
)
});
}
else
{
...
...
@@ -788,25 +788,19 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
}
templateData
.
icon
.
title
=
title
?
title
:
''
;
DOM
.
toggleClass
(
templateData
.
icon
,
'
custom-view-tree-node-item-icon
'
,
!!
iconUrl
);
let
codicon
:
string
|
undefined
;
if
(
iconUrl
?.
scheme
===
'
vscode-icon
'
&&
iconUrl
?.
authority
===
'
codicon
'
)
{
codicon
=
`codicon-
${
escape
(
iconUrl
.
path
.
substr
(
1
))}
`
;
}
if
(
iconUrl
)
{
templateData
.
icon
.
className
=
'
custom-view-tree-node-item-icon
'
;
templateData
.
icon
.
style
.
backgroundImage
=
DOM
.
asCSSUrl
(
iconUrl
);
DOM
.
toggleClass
(
templateData
.
icon
,
'
codicon
'
,
!!
codicon
);
templateData
.
icon
.
classList
.
forEach
((
cls
,
i
,
list
)
=>
{
if
(
cls
!==
codicon
&&
cls
.
indexOf
(
'
codicon-
'
)
===
0
)
{
list
.
remove
(
cls
);
}
else
{
let
iconClass
:
string
|
undefined
;
if
(
node
.
themeIcon
&&
!
this
.
isFileKindThemeIcon
(
node
.
themeIcon
)
)
{
iconClass
=
ThemeIcon
.
asClassName
(
node
.
themeIcon
);
}
});
if
(
codicon
)
{
DOM
.
addClass
(
templateData
.
icon
,
codicon
);
templateData
.
icon
.
className
=
iconClass
?
`custom-view-tree-node-item-icon
${
iconClass
}
`
:
''
;
}
templateData
.
icon
.
style
.
backgroundImage
=
iconUrl
&&
!
codicon
?
DOM
.
asCSSUrl
(
iconUrl
)
:
''
;
templateData
.
actionBar
.
context
=
<
TreeViewItemHandleArg
>
{
$treeViewId
:
this
.
treeViewId
,
$treeItemHandle
:
node
.
handle
};
templateData
.
actionBar
.
push
(
this
.
menus
.
getResourceActions
(
node
),
{
icon
:
true
,
label
:
false
});
if
(
this
.
_actionRunner
)
{
...
...
@@ -820,6 +814,14 @@ class TreeRenderer extends Disposable implements ITreeRenderer<ITreeItem, FuzzyS
DOM
.
toggleClass
(
container
.
parentElement
!
,
'
align-icon-with-twisty
'
,
this
.
aligner
.
alignIconWithTwisty
(
treeItem
));
}
private
isFileKindThemeIcon
(
icon
:
ThemeIcon
|
undefined
):
boolean
{
if
(
icon
)
{
return
icon
.
id
===
FileThemeIcon
.
id
||
icon
.
id
===
FolderThemeIcon
.
id
;
}
else
{
return
false
;
}
}
private
getFileKind
(
node
:
ITreeItem
):
FileKind
{
if
(
node
.
themeIcon
)
{
switch
(
node
.
themeIcon
.
id
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录