Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
43dffde3
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43dffde3
编写于
2月 20, 2020
作者:
S
SteVen Batten
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
drag and drop visual feedback
上级
8d9b3130
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
5 deletion
+110
-5
src/vs/base/parts/composite/browser/compositeDnd.ts
src/vs/base/parts/composite/browser/compositeDnd.ts
+1
-0
src/vs/workbench/browser/parts/compositeBar.ts
src/vs/workbench/browser/parts/compositeBar.ts
+84
-5
src/vs/workbench/browser/parts/compositeBarActions.ts
src/vs/workbench/browser/parts/compositeBarActions.ts
+25
-0
未找到文件。
src/vs/base/parts/composite/browser/compositeDnd.ts
浏览文件 @
43dffde3
...
...
@@ -20,4 +20,5 @@ export class CompositeDragAndDropData implements IDragAndDropData {
export
interface
ICompositeDragAndDrop
{
drop
(
data
:
IDragAndDropData
,
target
:
string
|
undefined
,
originalEvent
:
DragEvent
):
void
;
onDragOver
(
data
:
IDragAndDropData
,
target
:
string
|
undefined
,
originalEvent
:
DragEvent
):
boolean
;
}
src/vs/workbench/browser/parts/compositeBar.ts
浏览文件 @
43dffde3
...
...
@@ -37,7 +37,7 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
constructor
(
private
viewDescriptorService
:
IViewDescriptorService
,
private
view
ContainerLocation
:
ViewContainerLocation
,
private
target
ContainerLocation
:
ViewContainerLocation
,
private
openComposite
:
(
id
:
string
,
focus
?:
boolean
)
=>
void
,
private
moveComposite
:
(
from
:
string
,
to
:
string
)
=>
void
,
private
getVisibleCompositeIds
:
()
=>
string
[]
...
...
@@ -50,7 +50,7 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
const
currentContainer
=
viewContainerRegistry
.
get
(
dragData
.
id
)
!
;
const
currentLocation
=
viewContainerRegistry
.
getViewContainerLocation
(
currentContainer
);
if
(
targetCompositeId
)
{
if
(
currentLocation
!==
this
.
viewContainerLocation
&&
this
.
view
ContainerLocation
!==
ViewContainerLocation
.
Panel
)
{
if
(
currentLocation
!==
this
.
targetContainerLocation
&&
this
.
target
ContainerLocation
!==
ViewContainerLocation
.
Panel
)
{
const
destinationContainer
=
viewContainerRegistry
.
get
(
targetCompositeId
);
if
(
destinationContainer
)
{
this
.
viewDescriptorService
.
moveViewsToContainer
(
this
.
viewDescriptorService
.
getViewDescriptors
(
currentContainer
)
!
.
allViewDescriptors
.
filter
(
vd
=>
vd
.
canMoveView
),
destinationContainer
);
...
...
@@ -66,16 +66,16 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
if
(
targetCompositeId
)
{
const
destinationContainer
=
viewContainerRegistry
.
get
(
targetCompositeId
);
if
(
destinationContainer
)
{
if
(
this
.
view
ContainerLocation
===
ViewContainerLocation
.
Sidebar
)
{
if
(
this
.
target
ContainerLocation
===
ViewContainerLocation
.
Sidebar
)
{
this
.
viewDescriptorService
.
moveViewsToContainer
([
viewDescriptor
],
destinationContainer
);
this
.
openComposite
(
targetCompositeId
,
true
);
}
else
{
this
.
viewDescriptorService
.
moveViewToLocation
(
viewDescriptor
,
this
.
view
ContainerLocation
);
this
.
viewDescriptorService
.
moveViewToLocation
(
viewDescriptor
,
this
.
target
ContainerLocation
);
this
.
moveComposite
(
this
.
viewDescriptorService
.
getViewContainer
(
viewDescriptor
.
id
)
!
.
id
,
targetCompositeId
);
}
}
}
else
{
this
.
viewDescriptorService
.
moveViewToLocation
(
viewDescriptor
,
this
.
view
ContainerLocation
);
this
.
viewDescriptorService
.
moveViewToLocation
(
viewDescriptor
,
this
.
target
ContainerLocation
);
const
newCompositeId
=
this
.
viewDescriptorService
.
getViewContainer
(
dragData
.
id
)
!
.
id
;
const
visibleItems
=
this
.
getVisibleCompositeIds
();
const
targetId
=
visibleItems
.
length
?
visibleItems
[
visibleItems
.
length
-
1
]
:
undefined
;
...
...
@@ -89,6 +89,55 @@ export class CompositeDragAndDrop implements ICompositeDragAndDrop {
}
}
onDragOver
(
data
:
CompositeDragAndDropData
,
targetCompositeId
:
string
|
undefined
,
originalEvent
:
DragEvent
):
boolean
{
const
dragData
=
data
.
getData
();
const
viewContainerRegistry
=
Registry
.
as
<
IViewContainersRegistry
>
(
ViewContainerExtensions
.
ViewContainersRegistry
);
if
(
dragData
.
type
===
'
composite
'
)
{
// Dragging a composite
const
currentContainer
=
viewContainerRegistry
.
get
(
dragData
.
id
)
!
;
const
currentLocation
=
viewContainerRegistry
.
getViewContainerLocation
(
currentContainer
);
// ... to the same location
if
(
currentLocation
===
this
.
targetContainerLocation
)
{
return
true
;
}
// ... across view containers but without a destination composite
if
(
!
targetCompositeId
)
{
return
false
;
}
// ... from panel to the sidebar
if
(
this
.
targetContainerLocation
===
ViewContainerLocation
.
Sidebar
)
{
const
destinationContainer
=
viewContainerRegistry
.
get
(
targetCompositeId
);
return
!!
destinationContainer
&&
this
.
viewDescriptorService
.
getViewDescriptors
(
currentContainer
)
!
.
allViewDescriptors
.
some
(
vd
=>
vd
.
canMoveView
);
}
// ... from sidebar to the panel
else
{
return
false
;
}
}
else
{
// Dragging an individual view
const
viewDescriptor
=
this
.
viewDescriptorService
.
getViewDescriptor
(
dragData
.
id
);
// ... that cannot move
if
(
!
viewDescriptor
||
!
viewDescriptor
.
canMoveView
)
{
return
false
;
}
// ... to create a view container
if
(
!
targetCompositeId
)
{
return
this
.
targetContainerLocation
===
ViewContainerLocation
.
Panel
;
}
// ... into a destination
return
true
;
}
return
false
;
}
}
export
interface
ICompositeBarOptions
{
...
...
@@ -210,6 +259,36 @@ export class CompositeBar extends Widget implements ICompositeBar {
}
}));
this
.
_register
(
addDisposableListener
(
parent
,
EventType
.
DRAG_OVER
,
(
e
:
DragEvent
)
=>
{
if
(
this
.
compositeTransfer
.
hasData
(
DraggedCompositeIdentifier
.
prototype
))
{
EventHelper
.
stop
(
e
,
true
);
const
data
=
this
.
compositeTransfer
.
getData
(
DraggedCompositeIdentifier
.
prototype
);
if
(
Array
.
isArray
(
data
))
{
const
draggedCompositeId
=
data
[
0
].
id
;
// Check if drop is allowed
if
(
e
.
dataTransfer
&&
!
this
.
options
.
dndHandler
.
onDragOver
(
new
CompositeDragAndDropData
(
'
composite
'
,
draggedCompositeId
),
undefined
,
e
))
{
e
.
dataTransfer
.
dropEffect
=
'
none
'
;
}
}
}
if
(
this
.
compositeTransfer
.
hasData
(
DraggedViewIdentifier
.
prototype
))
{
EventHelper
.
stop
(
e
,
true
);
const
data
=
this
.
compositeTransfer
.
getData
(
DraggedViewIdentifier
.
prototype
);
if
(
Array
.
isArray
(
data
))
{
const
draggedViewId
=
data
[
0
].
id
;
// Check if drop is allowed
if
(
e
.
dataTransfer
&&
!
this
.
options
.
dndHandler
.
onDragOver
(
new
CompositeDragAndDropData
(
'
view
'
,
draggedViewId
),
undefined
,
e
))
{
e
.
dataTransfer
.
dropEffect
=
'
none
'
;
}
}
}
}));
return
actionBarDiv
;
}
...
...
src/vs/workbench/browser/parts/compositeBarActions.ts
浏览文件 @
43dffde3
...
...
@@ -549,6 +549,31 @@ export class CompositeActionViewItem extends ActivityActionViewItem {
}
},
onDragOver
:
e
=>
{
dom
.
EventHelper
.
stop
(
e
,
true
);
if
(
this
.
compositeTransfer
.
hasData
(
DraggedCompositeIdentifier
.
prototype
))
{
const
data
=
this
.
compositeTransfer
.
getData
(
DraggedCompositeIdentifier
.
prototype
);
if
(
Array
.
isArray
(
data
))
{
const
draggedCompositeId
=
data
[
0
].
id
;
if
(
draggedCompositeId
!==
this
.
activity
.
id
)
{
if
(
e
.
dataTransfer
&&
!
this
.
dndHandler
.
onDragOver
(
new
CompositeDragAndDropData
(
'
composite
'
,
draggedCompositeId
),
this
.
activity
.
id
,
e
))
{
e
.
dataTransfer
.
dropEffect
=
'
none
'
;
}
}
}
}
if
(
this
.
compositeTransfer
.
hasData
(
DraggedViewIdentifier
.
prototype
))
{
const
data
=
this
.
compositeTransfer
.
getData
(
DraggedViewIdentifier
.
prototype
);
if
(
Array
.
isArray
(
data
))
{
const
draggedViewId
=
data
[
0
].
id
;
if
(
e
.
dataTransfer
&&
!
this
.
dndHandler
.
onDragOver
(
new
CompositeDragAndDropData
(
'
view
'
,
draggedViewId
),
this
.
activity
.
id
,
e
))
{
e
.
dataTransfer
.
dropEffect
=
'
none
'
;
}
}
}
},
onDragLeave
:
e
=>
{
if
(
this
.
compositeTransfer
.
hasData
(
DraggedCompositeIdentifier
.
prototype
))
{
this
.
updateFromDragging
(
container
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录