Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
4f5c928f
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,发现更多精彩内容 >>
提交
4f5c928f
编写于
6月 08, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sash: use linked sashes as arrays
上级
44b554db
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
89 addition
and
82 deletion
+89
-82
src/vs/base/browser/ui/grid/gridview.ts
src/vs/base/browser/ui/grid/gridview.ts
+19
-18
src/vs/base/browser/ui/sash/sash.css
src/vs/base/browser/ui/sash/sash.css
+8
-8
src/vs/base/browser/ui/sash/sash.ts
src/vs/base/browser/ui/sash/sash.ts
+48
-42
src/vs/base/browser/ui/splitview/splitview.ts
src/vs/base/browser/ui/splitview/splitview.ts
+14
-14
未找到文件。
src/vs/base/browser/ui/grid/gridview.ts
浏览文件 @
4f5c928f
...
...
@@ -72,6 +72,10 @@ export interface IGridViewOptions {
styles
?:
IGridViewStyles
;
}
function
arrayIdentity
<
T
>
(
el
:
T
):
T
[]
{
return
el
?
[
el
]
:
[];
}
class
BranchNode
implements
ISplitView
,
IDisposable
{
readonly
element
:
HTMLElement
;
...
...
@@ -136,10 +140,10 @@ class BranchNode implements ISplitView, IDisposable {
private
splitviewSashResetDisposable
:
IDisposable
=
EmptyDisposable
;
private
childrenSashResetDisposable
:
IDisposable
=
EmptyDisposable
;
get
orthogonalStartSash
():
Sash
|
undefined
{
return
this
.
splitview
.
orthogonalStartSash
;
}
set
orthogonalStartSash
(
sash
:
Sash
|
undefined
)
{
this
.
splitview
.
orthogonalStartSash
=
sash
;
}
get
orthogonalEndSash
():
Sash
|
undefined
{
return
this
.
splitview
.
orthogonalEndSash
;
}
set
orthogonalEndSash
(
sash
:
Sash
|
undefined
)
{
this
.
splitview
.
orthogonalEndSash
=
sash
;
}
get
linkedStartSashes
():
Sash
[]
{
return
this
.
splitview
.
linkedStartSashes
;
}
set
linkedStartSashes
(
sashes
:
Sash
[])
{
this
.
splitview
.
linkedStartSashes
=
sashes
;
}
get
linkedEndSashes
():
Sash
[]
{
return
this
.
splitview
.
linkedEndSashes
;
}
set
linkedEndSashes
(
sashes
:
Sash
[])
{
this
.
splitview
.
linkedEndSashes
=
sashes
;
}
constructor
(
readonly
orientation
:
Orientation
,
...
...
@@ -195,15 +199,15 @@ class BranchNode implements ISplitView, IDisposable {
const
last
=
index
===
this
.
splitview
.
length
;
this
.
splitview
.
addView
(
node
,
size
,
index
);
this
.
children
.
splice
(
index
,
0
,
node
);
node
.
orthogonalStartSash
=
this
.
splitview
.
sashes
[
index
-
1
]
;
node
.
orthogonalEndSash
=
this
.
splitview
.
sashes
[
index
]
;
node
.
linkedStartSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
index
-
1
])
;
node
.
linkedEndSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
index
])
;
if
(
!
first
)
{
this
.
children
[
index
-
1
].
orthogonalEndSash
=
this
.
splitview
.
sashes
[
index
-
1
]
;
this
.
children
[
index
-
1
].
linkedEndSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
index
-
1
])
;
}
if
(
!
last
)
{
this
.
children
[
index
+
1
].
orthogonalStartSash
=
this
.
splitview
.
sashes
[
index
]
;
this
.
children
[
index
+
1
].
linkedStartSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
index
])
;
}
this
.
onDidChildrenChange
();
...
...
@@ -220,11 +224,11 @@ class BranchNode implements ISplitView, IDisposable {
this
.
children
.
splice
(
index
,
1
);
if
(
!
first
)
{
this
.
children
[
index
-
1
].
orthogonalEndSash
=
this
.
splitview
.
sashes
[
index
-
1
]
;
this
.
children
[
index
-
1
].
linkedEndSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
index
-
1
])
;
}
if
(
!
last
)
{
// [0,1,2,3] (2) => [0,1,3]
this
.
children
[
index
].
orthogonalStartSash
=
this
.
splitview
.
sashes
[
Math
.
max
(
index
-
1
,
0
)]
;
this
.
children
[
index
].
linkedStartSashes
=
arrayIdentity
(
this
.
splitview
.
sashes
[
Math
.
max
(
index
-
1
,
0
)])
;
}
this
.
onDidChildrenChange
();
...
...
@@ -244,7 +248,7 @@ class BranchNode implements ISplitView, IDisposable {
}
this
.
splitview
.
swapViews
(
from
,
to
);
[
this
.
children
[
from
].
orthogonalStartSash
,
this
.
children
[
from
].
orthogonalEndSash
,
this
.
children
[
to
].
orthogonalStartSash
,
this
.
children
[
to
].
orthogonalEndSash
]
=
[
this
.
children
[
to
].
orthogonalStartSash
,
this
.
children
[
to
].
orthogonalEndSash
,
this
.
children
[
from
].
orthogonalStartSash
,
this
.
children
[
from
].
orthogonalEndSash
];
[
this
.
children
[
from
].
linkedStartSashes
,
this
.
children
[
from
].
linkedEndSashes
,
this
.
children
[
to
].
linkedStartSashes
,
this
.
children
[
to
].
linkedEndSashes
]
=
[
this
.
children
[
to
].
linkedStartSashes
,
this
.
children
[
to
].
linkedEndSashes
,
this
.
children
[
from
].
linkedStartSashes
,
this
.
children
[
from
].
linkedEndSashes
];
[
this
.
children
[
from
],
this
.
children
[
to
]]
=
[
this
.
children
[
to
],
this
.
children
[
from
]];
}
...
...
@@ -342,13 +346,10 @@ class LeafNode implements ISplitView, IDisposable {
return
mapEvent
(
this
.
view
.
onDidChange
,
this
.
orientation
===
Orientation
.
HORIZONTAL
?
({
width
})
=>
width
:
({
height
})
=>
height
);
}
set
orthogonalStartSash
(
sash
:
Sash
)
{
// noop
}
set
orthogonalEndSash
(
sash
:
Sash
)
{
// noop
}
get
linkedStartSashes
():
Sash
[]
{
return
[];
}
set
linkedStartSashes
(
sashes
:
Sash
[])
{
}
get
linkedEndSashes
():
Sash
[]
{
return
[];
}
set
linkedEndSashes
(
sashes
:
Sash
[])
{
}
layout
(
size
:
number
):
void
{
this
.
_size
=
size
;
...
...
src/vs/base/browser/ui/sash/sash.css
浏览文件 @
4f5c928f
...
...
@@ -51,8 +51,8 @@
cursor
:
n-resize
;
}
.monaco-sash
:not
(
.disabled
)
.
orthogonal
-start
::before
,
.monaco-sash
:not
(
.disabled
)
.
orthogonal
-end
::after
{
.monaco-sash
:not
(
.disabled
)
.
linked
-start
::before
,
.monaco-sash
:not
(
.disabled
)
.
linked
-end
::after
{
content
:
' '
;
height
:
8px
;
width
:
8px
;
...
...
@@ -62,22 +62,22 @@
position
:
absolute
;
}
.monaco-sash.
orthogonal
-start.vertical
::before
{
.monaco-sash.
linked
-start.vertical
::before
{
left
:
-2px
;
top
:
-4px
;
}
.monaco-sash.
orthogonal
-end.vertical
::after
{
.monaco-sash.
linked
-end.vertical
::after
{
left
:
-2px
;
bottom
:
-4px
;
}
.monaco-sash.
orthogonal
-start.horizontal
::before
{
.monaco-sash.
linked
-start.horizontal
::before
{
top
:
-2px
;
left
:
-4px
;
}
.monaco-sash.
orthogonal
-end.horizontal
::after
{
.monaco-sash.
linked
-end.horizontal
::after
{
top
:
-2px
;
right
:
-4px
;
}
...
...
@@ -102,7 +102,7 @@
background
:
cyan
;
}
.monaco-sash.debug
:not
(
.disabled
)
.
orthogonal
-start
::before
,
.monaco-sash.debug
:not
(
.disabled
)
.
orthogonal
-end
::after
{
.monaco-sash.debug
:not
(
.disabled
)
.
linked
-start
::before
,
.monaco-sash.debug
:not
(
.disabled
)
.
linked
-end
::after
{
background
:
red
;
}
\ No newline at end of file
src/vs/base/browser/ui/sash/sash.ts
浏览文件 @
4f5c928f
...
...
@@ -12,11 +12,11 @@ import { isMacintosh } from 'vs/base/common/platform';
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
EventType
,
GestureEvent
,
Gesture
}
from
'
vs/base/browser/touch
'
;
import
{
StandardMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
,
anyEvent
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
getElementsByTagName
,
EventHelper
,
createStyleSheet
,
addDisposableListener
,
Dimension
,
append
,
$
,
addClass
,
removeClass
,
toggleClass
}
from
'
vs/base/browser/dom
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
const
DEBUG
=
fals
e
;
const
DEBUG
=
tru
e
;
export
interface
ISashLayoutProvider
{
}
...
...
@@ -42,8 +42,8 @@ export interface ISashEvent {
export
interface
ISashOptions
{
orientation
?:
Orientation
;
orthogonalStartSash
?:
Sash
;
orthogonalEndSash
?:
Sash
;
linkedStartSashes
?:
Sash
[]
;
linkedEndSashes
?:
Sash
[]
;
}
export
enum
Orientation
{
...
...
@@ -96,36 +96,40 @@ export class Sash {
private
readonly
_onDidEnd
=
new
Emitter
<
void
>
();
readonly
onDidEnd
:
Event
<
void
>
=
this
.
_onDidEnd
.
event
;
private
orthogonalStartSash
Disposables
:
IDisposable
[]
=
[];
private
_
orthogonalStartSash
:
Sash
|
undefined
;
get
orthogonalStartSash
():
Sash
|
undefined
{
return
this
.
_orthogonalStartSash
;
}
set
orthogonalStartSash
(
sash
:
Sash
|
undefined
)
{
this
.
orthogonalStartSashDisposables
=
dispose
(
this
.
orthogonalStartSash
Disposables
);
private
linkedStartSashes
Disposables
:
IDisposable
[]
=
[];
private
_
linkedStartSashes
:
Sash
[]
=
[]
;
get
linkedStartSashes
():
Sash
[]
{
return
this
.
_linkedStartSashes
;
}
set
linkedStartSashes
(
sashes
:
Sash
[]
)
{
this
.
linkedStartSashesDisposables
=
dispose
(
this
.
linkedStartSashes
Disposables
);
if
(
sash
)
{
sash
.
onDidEnablementChange
(
this
.
onOrthogonalStartSashEnablementChange
,
this
,
this
.
orthogonalStartSashDisposables
);
this
.
onOrthogonalStartSashEnablementChange
(
sash
.
state
);
if
(
sashes
.
length
>
0
)
{
mapEvent
(
anyEvent
(...
sashes
.
map
(
s
=>
s
.
onDidEnablementChange
)),
()
=>
sashes
.
map
(
s
=>
s
.
state
))
(
this
.
onLinkedStartSashEnablementChange
,
this
,
this
.
linkedStartSashesDisposables
);
this
.
onLinkedStartSashEnablementChange
(
sashes
.
map
(
s
=>
s
.
state
));
}
else
{
this
.
on
OrthogonalStartSashEnablementChange
(
SashState
.
Disabled
);
this
.
on
LinkedStartSashEnablementChange
([]
);
}
this
.
_
orthogonalStartSash
=
sash
;
this
.
_
linkedStartSashes
=
sashes
;
}
private
orthogonalEndSashDisposables
:
IDisposable
[]
=
[];
private
_orthogonalEndSash
:
Sash
|
undefined
;
get
orthogonalEndSash
():
Sash
|
undefined
{
return
this
.
_orthogonalEndSash
;
}
set
orthogonalEndSash
(
sash
:
Sash
|
undefined
)
{
this
.
orthogonalEndSashDisposables
=
dispose
(
this
.
orthogonalEndSashDisposables
);
private
linkedEndSashDisposables
:
IDisposable
[]
=
[];
private
_linkedEndSash
:
Sash
[]
=
[];
get
linkedEndSash
():
Sash
[]
{
return
this
.
_linkedEndSash
;
}
set
linkedEndSash
(
sashes
:
Sash
[])
{
this
.
linkedEndSashDisposables
=
dispose
(
this
.
linkedEndSashDisposables
);
if
(
sashes
)
{
mapEvent
(
anyEvent
(...
sashes
.
map
(
s
=>
s
.
onDidEnablementChange
)),
()
=>
sashes
.
map
(
s
=>
s
.
state
))
(
this
.
onLinkedEndSashEnablementChange
,
this
,
this
.
linkedEndSashDisposables
);
if
(
sash
)
{
sash
.
onDidEnablementChange
(
this
.
onOrthogonalEndSashEnablementChange
,
this
,
this
.
orthogonalEndSashDisposables
);
this
.
onOrthogonalEndSashEnablementChange
(
sash
.
state
);
this
.
onLinkedEndSashEnablementChange
(
sashes
.
map
(
s
=>
s
.
state
));
}
else
{
this
.
on
OrthogonalEndSashEnablementChange
(
SashState
.
Disabled
);
this
.
on
LinkedEndSashEnablementChange
([]
);
}
this
.
_
orthogonalEndSash
=
sash
;
this
.
_
linkedEndSash
=
sashes
;
}
constructor
(
container
:
HTMLElement
,
layoutProvider
:
ISashLayoutProvider
,
options
:
ISashOptions
=
{})
{
...
...
@@ -151,8 +155,8 @@ export class Sash {
this
.
hidden
=
false
;
this
.
layoutProvider
=
layoutProvider
;
this
.
orthogonalStartSash
=
options
.
orthogonalStartSash
;
this
.
orthogonalEndSash
=
options
.
orthogonalEndSash
;
this
.
linkedStartSashes
=
options
.
linkedStartSashes
||
[]
;
this
.
linkedEndSash
=
options
.
linkedEndSashes
||
[]
;
toggleClass
(
this
.
el
,
'
debug
'
,
DEBUG
);
}
...
...
@@ -178,27 +182,29 @@ export class Sash {
let
isMultisashResize
=
false
;
if
(
!
(
e
as
any
).
__
orthogonal
SashEvent
)
{
let
orthogonalSash
:
Sash
|
undefined
;
if
(
!
(
e
as
any
).
__
linked
SashEvent
)
{
let
linkedSashes
:
Sash
[]
=
[]
;
if
(
this
.
orientation
===
Orientation
.
VERTICAL
)
{
if
(
e
.
offsetY
<=
4
)
{
orthogonalSash
=
this
.
orthogonalStartSash
;
linkedSashes
=
this
.
linkedStartSashes
;
}
else
if
(
e
.
offsetY
>=
this
.
el
.
clientHeight
-
4
)
{
orthogonalSash
=
this
.
orthogonal
EndSash
;
linkedSashes
=
this
.
linked
EndSash
;
}
}
else
{
if
(
e
.
offsetX
<=
4
)
{
orthogonalSash
=
this
.
orthogonalStartSash
;
linkedSashes
=
this
.
linkedStartSashes
;
}
else
if
(
e
.
offsetX
>=
this
.
el
.
clientWidth
-
4
)
{
orthogonalSash
=
this
.
orthogonal
EndSash
;
linkedSashes
=
this
.
linked
EndSash
;
}
}
if
(
orthogonalSash
)
{
isMultisashResize
=
true
;
(
e
as
any
).
__orthogonalSashEvent
=
true
;
orthogonalSash
.
onMouseDown
(
e
);
if
(
linkedSashes
.
length
>
0
)
{
for
(
const
sash
of
linkedSashes
)
{
isMultisashResize
=
true
;
(
e
as
any
).
__linkedSashEvent
=
true
;
sash
.
onMouseDown
(
e
);
}
}
}
...
...
@@ -368,17 +374,17 @@ export class Sash {
return
this
.
hidden
;
}
private
on
OrthogonalStartSashEnablementChange
(
state
:
SashState
):
void
{
toggleClass
(
this
.
el
,
'
orthogonal-start
'
,
state
!==
SashState
.
Disabled
);
private
on
LinkedStartSashEnablementChange
(
states
:
SashState
[]
):
void
{
toggleClass
(
this
.
el
,
'
linked-start
'
,
states
.
some
(
state
=>
state
!==
SashState
.
Disabled
)
);
}
private
on
OrthogonalEndSashEnablementChange
(
state
:
SashState
):
void
{
toggleClass
(
this
.
el
,
'
orthogonal-end
'
,
state
!==
SashState
.
Disabled
);
private
on
LinkedEndSashEnablementChange
(
states
:
SashState
[]
):
void
{
toggleClass
(
this
.
el
,
'
linked-end
'
,
states
.
some
(
state
=>
state
!==
SashState
.
Disabled
)
);
}
dispose
():
void
{
this
.
orthogonalStartSashDisposables
=
dispose
(
this
.
orthogonalStartSash
Disposables
);
this
.
orthogonalEndSashDisposables
=
dispose
(
this
.
orthogonal
EndSashDisposables
);
this
.
linkedStartSashesDisposables
=
dispose
(
this
.
linkedStartSashes
Disposables
);
this
.
linkedEndSashDisposables
=
dispose
(
this
.
linked
EndSashDisposables
);
if
(
this
.
el
&&
this
.
el
.
parentElement
)
{
this
.
el
.
parentElement
.
removeChild
(
this
.
el
);
...
...
src/vs/base/browser/ui/splitview/splitview.ts
浏览文件 @
4f5c928f
...
...
@@ -27,8 +27,8 @@ const defaultStyles: ISplitViewStyles = {
export
interface
ISplitViewOptions
{
orientation
?:
Orientation
;
// default Orientation.VERTICAL
styles
?:
ISplitViewStyles
;
orthogonal
StartSash
?:
Sash
;
orthogonal
EndSash
?:
Sash
;
linked
StartSash
?:
Sash
;
linked
EndSash
?:
Sash
;
}
export
interface
IView
{
...
...
@@ -139,24 +139,24 @@ export class SplitView implements IDisposable {
return
this
.
viewItems
.
length
;
}
private
_
orthogonalStartSash
:
Sash
|
undefined
;
get
orthogonalStartSash
():
Sash
|
undefined
{
return
this
.
_orthogonalStartSash
;
}
set
orthogonalStartSash
(
sash
:
Sash
|
undefined
)
{
private
_
linkedStartSashes
:
Sash
[]
=
[]
;
get
linkedStartSashes
():
Sash
[]
{
return
this
.
_linkedStartSashes
;
}
set
linkedStartSashes
(
sashes
:
Sash
[]
)
{
for
(
const
sashItem
of
this
.
sashItems
)
{
sashItem
.
sash
.
orthogonalStartSash
=
sash
;
sashItem
.
sash
.
linkedStartSashes
=
sashes
;
}
this
.
_
orthogonalStartSash
=
sash
;
this
.
_
linkedStartSashes
=
sashes
;
}
private
_
orthogonalEndSash
:
Sash
|
undefined
;
get
orthogonalEndSash
():
Sash
|
undefined
{
return
this
.
_orthogonalEndSash
;
}
set
orthogonalEndSash
(
sash
:
Sash
|
undefined
)
{
private
_
linkedEndSashes
:
Sash
[]
=
[]
;
get
linkedEndSashes
():
Sash
[]
{
return
this
.
_linkedEndSashes
;
}
set
linkedEndSashes
(
sashes
:
Sash
[]
)
{
for
(
const
sashItem
of
this
.
sashItems
)
{
sashItem
.
sash
.
orthogonalEndSash
=
sash
;
sashItem
.
sash
.
linkedEndSash
=
sashes
;
}
this
.
_
orthogonalEndSash
=
sash
;
this
.
_
linkedEndSashes
=
sashes
;
}
get
sashes
():
Sash
[]
{
...
...
@@ -235,8 +235,8 @@ export class SplitView implements IDisposable {
const
layoutProvider
=
this
.
orientation
===
Orientation
.
VERTICAL
?
{
getHorizontalSashTop
:
sash
=>
this
.
getSashPosition
(
sash
)
}
:
{
getVerticalSashLeft
:
sash
=>
this
.
getSashPosition
(
sash
)
};
const
sash
=
new
Sash
(
this
.
sashContainer
,
layoutProvider
,
{
orientation
,
orthogonalStartSash
:
this
.
orthogonalStartSash
,
orthogonalEndSash
:
this
.
orthogonalEndSash
linkedStartSashes
:
this
.
linkedStartSashes
,
linkedEndSashes
:
this
.
linkedEndSashes
});
const
sashEventMapper
=
this
.
orientation
===
Orientation
.
VERTICAL
?
(
e
:
IBaseSashEvent
)
=>
({
sash
,
start
:
e
.
startY
,
current
:
e
.
currentY
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录