Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c01cf1d1
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,发现更多精彩内容 >>
提交
c01cf1d1
编写于
10月 24, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
splitview: support snapSize
上级
92187cf4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
24 addition
and
10 deletion
+24
-10
src/vs/base/browser/ui/splitview/splitview.ts
src/vs/base/browser/ui/splitview/splitview.ts
+24
-10
未找到文件。
src/vs/base/browser/ui/splitview/splitview.ts
浏览文件 @
c01cf1d1
...
...
@@ -47,6 +47,7 @@ export interface IView {
readonly
maximumSize
:
number
;
readonly
onDidChange
:
Event
<
number
|
undefined
>
;
readonly
priority
?:
LayoutPriority
;
readonly
snapSize
?:
number
;
layout
(
size
:
number
,
orientation
:
Orientation
):
void
;
}
...
...
@@ -351,7 +352,7 @@ export class SplitView extends Disposable {
}
else
{
for
(
let
i
=
0
;
i
<
this
.
viewItems
.
length
;
i
++
)
{
const
item
=
this
.
viewItems
[
i
];
item
.
size
=
clamp
(
Math
.
round
(
this
.
proportions
[
i
]
*
size
),
item
.
view
.
minimumSize
,
item
.
view
.
maximumSize
);
item
.
size
=
SplitView
.
clamp
(
item
,
Math
.
round
(
this
.
proportions
[
i
]
*
size
)
);
}
}
...
...
@@ -443,7 +444,7 @@ export class SplitView extends Disposable {
}
size
=
typeof
size
===
'
number
'
?
size
:
item
.
size
;
size
=
clamp
(
size
,
item
.
view
.
minimumSize
,
item
.
view
.
maximumS
ize
);
size
=
SplitView
.
clamp
(
item
,
s
ize
);
if
(
this
.
inverseAltBehavior
&&
index
>
0
)
{
// In this case, we want the view to grow or shrink both sides equally
...
...
@@ -550,27 +551,29 @@ export class SplitView extends Disposable {
const
downItems
=
downIndexes
.
map
(
i
=>
this
.
viewItems
[
i
]);
const
downSizes
=
downIndexes
.
map
(
i
=>
sizes
[
i
]);
const
minDeltaUp
=
upIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
this
.
viewItems
[
i
].
view
.
minimumSize
-
sizes
[
i
]),
0
);
const
minDeltaUp
=
upIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
(
typeof
this
.
viewItems
[
i
].
view
.
snapSize
===
'
number
'
?
0
:
this
.
viewItems
[
i
].
view
.
minimumSize
)
-
sizes
[
i
]),
0
);
const
maxDeltaUp
=
upIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
this
.
viewItems
[
i
].
view
.
maximumSize
-
sizes
[
i
]),
0
);
const
maxDeltaDown
=
downIndexes
.
length
===
0
?
Number
.
POSITIVE_INFINITY
:
downIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
sizes
[
i
]
-
this
.
viewItems
[
i
].
view
.
minimumSize
),
0
);
const
maxDeltaDown
=
downIndexes
.
length
===
0
?
Number
.
POSITIVE_INFINITY
:
downIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
sizes
[
i
]
-
(
typeof
this
.
viewItems
[
i
].
view
.
snapSize
===
'
number
'
?
0
:
this
.
viewItems
[
i
].
view
.
minimumSize
)
),
0
);
const
minDeltaDown
=
downIndexes
.
length
===
0
?
Number
.
NEGATIVE_INFINITY
:
downIndexes
.
reduce
((
r
,
i
)
=>
r
+
(
sizes
[
i
]
-
this
.
viewItems
[
i
].
view
.
maximumSize
),
0
);
const
minDelta
=
Math
.
max
(
minDeltaUp
,
minDeltaDown
,
overloadMinDelta
);
const
maxDelta
=
Math
.
min
(
maxDeltaDown
,
maxDeltaUp
,
overloadMaxDelta
);
delta
=
clamp
(
delta
,
minDelta
,
maxDelta
);
const
tentativeDelta
=
clamp
(
delta
,
minDelta
,
maxDelta
);
let
actualDelta
=
0
;
for
(
let
i
=
0
,
deltaUp
=
d
elta
;
i
<
upItems
.
length
;
i
++
)
{
for
(
let
i
=
0
,
deltaUp
=
tentativeD
elta
;
i
<
upItems
.
length
;
i
++
)
{
const
item
=
upItems
[
i
];
const
size
=
clamp
(
upSizes
[
i
]
+
deltaUp
,
item
.
view
.
minimumSize
,
item
.
view
.
maximumSize
);
const
size
=
SplitView
.
clamp
(
item
,
upSizes
[
i
]
+
deltaUp
/* , upIndexes[i] === index */
);
const
viewDelta
=
size
-
upSizes
[
i
];
actualDelta
+=
viewDelta
;
deltaUp
-=
viewDelta
;
item
.
size
=
size
;
}
for
(
let
i
=
0
,
deltaDown
=
d
elta
;
i
<
downItems
.
length
;
i
++
)
{
for
(
let
i
=
0
,
deltaDown
=
actualD
elta
;
i
<
downItems
.
length
;
i
++
)
{
const
item
=
downItems
[
i
];
const
size
=
clamp
(
downSizes
[
i
]
-
deltaDown
,
item
.
view
.
minimumSize
,
item
.
view
.
maximumSize
);
const
size
=
SplitView
.
clamp
(
item
,
downSizes
[
i
]
-
deltaDown
);
const
viewDelta
=
size
-
downSizes
[
i
];
deltaDown
+=
viewDelta
;
...
...
@@ -580,13 +583,24 @@ export class SplitView extends Disposable {
return
delta
;
}
private
static
clamp
(
item
:
IViewItem
,
size
:
number
):
number
{
const
result
=
clamp
(
size
,
item
.
view
.
minimumSize
,
item
.
view
.
maximumSize
);
if
(
typeof
item
.
view
.
snapSize
!==
'
number
'
||
size
>=
item
.
view
.
minimumSize
)
{
return
result
;
}
const
snapSize
=
Math
.
min
(
item
.
view
.
snapSize
,
item
.
view
.
minimumSize
);
return
size
<
snapSize
?
0
:
item
.
view
.
minimumSize
;
}
private
distributeEmptySpace
():
void
{
let
contentSize
=
this
.
viewItems
.
reduce
((
r
,
i
)
=>
r
+
i
.
size
,
0
);
let
emptyDelta
=
this
.
size
-
contentSize
;
for
(
let
i
=
this
.
viewItems
.
length
-
1
;
emptyDelta
!==
0
&&
i
>=
0
;
i
--
)
{
const
item
=
this
.
viewItems
[
i
];
const
size
=
clamp
(
item
.
size
+
emptyDelta
,
item
.
view
.
minimumSize
,
item
.
view
.
maximumSize
);
const
size
=
SplitView
.
clamp
(
item
,
item
.
size
+
emptyDelta
);
const
viewDelta
=
size
-
item
.
size
;
emptyDelta
-=
viewDelta
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录