Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d7020488
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,发现更多精彩内容 >>
提交
d7020488
编写于
10月 24, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
layout: better min and max boundary computations
上级
c18a3fd5
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
75 addition
and
38 deletion
+75
-38
src/vs/workbench/browser/layout.ts
src/vs/workbench/browser/layout.ts
+75
-38
未找到文件。
src/vs/workbench/browser/layout.ts
浏览文件 @
d7020488
...
...
@@ -66,14 +66,13 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
private
sashXOne
:
Sash
;
private
sashXTwo
:
Sash
;
private
sashY
:
Sash
;
private
sidebarWidth
:
number
;
private
_
sidebarWidth
:
number
;
private
sidebarHeight
:
number
;
private
titlebarHeight
:
number
;
private
activitybarWidth
:
number
;
private
statusbarHeight
:
number
;
private
panelHeight
:
number
;
private
panelHeightBeforeMaximized
:
number
;
private
panelWidth
:
number
;
private
_panelHeight
:
number
;
private
_panelWidth
:
number
;
private
layoutEditorGroupsVertically
:
boolean
;
// Take parts as an object bag since instatation service does not have typings for constructors with 9+ arguments
...
...
@@ -108,7 +107,6 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this
.
quickopen
=
quickopen
;
this
.
toUnbind
=
[];
this
.
partLayoutInfo
=
this
.
getPartLayoutInfo
();
this
.
panelHeightBeforeMaximized
=
0
;
this
.
sashXOne
=
new
Sash
(
this
.
workbenchContainer
.
getHTMLElement
(),
this
,
{
baseSize
:
5
...
...
@@ -123,9 +121,9 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
orientation
:
Orientation
.
HORIZONTAL
});
this
.
sidebarWidth
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashXOneWidthSettingsKey
,
StorageScope
.
GLOBAL
,
-
1
);
this
.
panelHeight
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
panelWidth
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashXTwoWidthSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
_
sidebarWidth
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashXOneWidthSettingsKey
,
StorageScope
.
GLOBAL
,
-
1
);
this
.
_
panelHeight
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
_
panelWidth
=
this
.
storageService
.
getInteger
(
WorkbenchLayout
.
sashXTwoWidthSettingsKey
,
StorageScope
.
GLOBAL
,
0
);
this
.
layoutEditorGroupsVertically
=
(
this
.
editorGroupService
.
getGroupOrientation
()
!==
'
horizontal
'
);
...
...
@@ -136,6 +134,48 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this
.
registerSashListeners
();
}
private
get
panelHeight
():
number
{
const
panelPosition
=
this
.
partService
.
getPanelPosition
();
if
(
panelPosition
===
Position
.
RIGHT
)
{
return
this
.
sidebarHeight
;
}
return
this
.
_panelHeight
;
}
private
set
panelHeight
(
value
:
number
)
{
const
editorCountForHeight
=
this
.
editorGroupService
.
getGroupOrientation
()
===
'
horizontal
'
?
this
.
editorGroupService
.
getStacksModel
().
groups
.
length
:
1
;
const
maxPanelHeight
=
this
.
sidebarHeight
-
editorCountForHeight
*
MIN_EDITOR_PART_HEIGHT
;
this
.
_panelHeight
=
Math
.
min
(
maxPanelHeight
,
Math
.
max
(
this
.
partLayoutInfo
.
panel
.
minHeight
,
value
));
}
private
get
panelWidth
():
number
{
const
panelPosition
=
this
.
partService
.
getPanelPosition
();
if
(
panelPosition
===
Position
.
BOTTOM
)
{
return
this
.
workbenchSize
.
width
-
this
.
activitybarWidth
-
this
.
sidebarWidth
;
}
return
this
.
_panelWidth
;
}
private
set
panelWidth
(
value
:
number
)
{
const
editorCountForWidth
=
this
.
editorGroupService
.
getGroupOrientation
()
===
'
vertical
'
?
this
.
editorGroupService
.
getStacksModel
().
groups
.
length
:
1
;
const
maxPanelWidth
=
this
.
workbenchSize
.
width
-
editorCountForWidth
*
MIN_EDITOR_PART_WIDTH
-
this
.
sidebarWidth
-
this
.
activitybarWidth
;
this
.
_panelWidth
=
Math
.
min
(
maxPanelWidth
,
Math
.
max
(
this
.
partLayoutInfo
.
panel
.
minWidth
,
value
));
}
private
get
sidebarWidth
():
number
{
if
(
this
.
partService
.
isVisible
(
Parts
.
SIDEBAR_PART
))
{
return
this
.
_sidebarWidth
;
}
return
0
;
}
private
set
sidebarWidth
(
value
:
number
)
{
this
.
_sidebarWidth
=
Math
.
max
(
this
.
partLayoutInfo
.
sidebar
.
minWidth
,
value
);
}
private
getPartLayoutInfo
():
PartLayoutInfo
{
return
{
titlebar
:
{
...
...
@@ -281,7 +321,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
// Otherwise size the panel accordingly
else
{
this
.
panelWidth
=
Math
.
max
(
this
.
partLayoutInfo
.
panel
.
minWidth
,
newSashWidth
);
// Panel can not become smaller than MIN_PART_HEIGHT
this
.
panelWidth
=
newSashWidth
;
doLayout
=
newSashWidth
>=
this
.
partLayoutInfo
.
panel
.
minWidth
;
}
}
...
...
@@ -321,7 +361,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
this
.
toUnbind
.
push
(
this
.
sashXOne
.
addListener
(
'
reset
'
,
()
=>
{
let
activeViewlet
=
this
.
viewletService
.
getActiveViewlet
();
let
optimalWidth
=
activeViewlet
&&
activeViewlet
.
getOptimalWidth
();
this
.
sidebarWidth
=
Math
.
max
(
MIN_SIDEBAR_PART_WIDTH
,
optimalWidth
||
0
)
;
this
.
sidebarWidth
=
optimalWidth
||
0
;
this
.
storageService
.
store
(
WorkbenchLayout
.
sashXOneWidthSettingsKey
,
this
.
sidebarWidth
,
StorageScope
.
GLOBAL
);
this
.
partService
.
setSideBarHidden
(
false
).
done
(()
=>
this
.
layout
(),
errors
.
onUnexpectedError
);
}));
...
...
@@ -374,14 +414,10 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
const
panelPosition
=
this
.
partService
.
getPanelPosition
();
// Sidebar
let
sidebarWidth
:
number
;
if
(
isSidebarHidden
)
{
sidebarWidth
=
0
;
}
else
if
(
this
.
sidebarWidth
!==
-
1
)
{
sidebarWidth
=
Math
.
max
(
this
.
partLayoutInfo
.
sidebar
.
minWidth
,
this
.
sidebarWidth
);
if
(
this
.
sidebarWidth
!==
-
1
)
{
this
.
sidebarWidth
=
Math
.
max
(
this
.
partLayoutInfo
.
sidebar
.
minWidth
,
this
.
sidebarWidth
);
}
else
{
sidebarWidth
=
this
.
workbenchSize
.
width
/
5
;
this
.
sidebarWidth
=
sidebarWidth
;
this
.
sidebarWidth
=
this
.
workbenchSize
.
width
/
5
;
}
this
.
statusbarHeight
=
isStatusbarHidden
?
0
:
this
.
partLayoutInfo
.
statusbar
.
height
;
...
...
@@ -389,7 +425,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
const
previousMaxPanelHeight
=
this
.
sidebarHeight
-
MIN_EDITOR_PART_HEIGHT
;
this
.
sidebarHeight
=
this
.
workbenchSize
.
height
-
this
.
statusbarHeight
-
this
.
titlebarHeight
;
let
sidebarSize
=
new
Dimension
(
sidebarWidth
,
this
.
sidebarHeight
);
let
sidebarSize
=
new
Dimension
(
this
.
sidebarWidth
,
this
.
sidebarHeight
);
// Activity Bar
this
.
activitybarWidth
=
isActivityBarHidden
?
0
:
this
.
partLayoutInfo
.
activitybar
.
width
;
...
...
@@ -413,11 +449,6 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
else
{
panelHeight
=
sidebarSize
.
height
*
DEFAULT_PANEL_SIZE_COEFFICIENT
;
}
if
(
panelHeight
/
maxPanelHeight
<
0.7
)
{
// Remember the previous height only if the panel size is not too large.
// To get a nice minimize effect even if a user dragged the panel sash to maximum.
this
.
panelHeightBeforeMaximized
=
panelHeight
;
}
panelWidth
=
this
.
workbenchSize
.
width
-
sidebarSize
.
width
-
activityBarSize
.
width
;
}
else
{
...
...
@@ -478,10 +509,13 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
if
(
!
isPanelHidden
)
{
this
.
panelHeight
=
panelDimension
.
height
;
this
.
panelWidth
=
panelDimension
.
width
;
this
.
storageService
.
store
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
this
.
panelHeight
,
StorageScope
.
GLOBAL
);
this
.
storageService
.
store
(
WorkbenchLayout
.
sashXTwoWidthSettingsKey
,
this
.
panelWidth
,
StorageScope
.
GLOBAL
);
if
(
panelPosition
===
Position
.
BOTTOM
)
{
this
.
panelHeight
=
panelDimension
.
height
;
this
.
storageService
.
store
(
WorkbenchLayout
.
sashYHeightSettingsKey
,
this
.
panelHeight
,
StorageScope
.
GLOBAL
);
}
else
{
this
.
panelWidth
=
panelDimension
.
width
;
this
.
storageService
.
store
(
WorkbenchLayout
.
sashXTwoWidthSettingsKey
,
this
.
panelWidth
,
StorageScope
.
GLOBAL
);
}
}
// Workbench
...
...
@@ -565,11 +599,13 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
// Sashes
this
.
sashXOne
.
layout
();
if
(
panelPosition
===
Position
.
BOTTOM
)
{
this
.
sashY
.
layout
();
this
.
sashXTwo
.
hide
();
this
.
sashY
.
layout
();
this
.
sashY
.
show
();
}
else
{
this
.
sashY
.
hide
();
this
.
sashXTwo
.
layout
();
this
.
sashXTwo
.
show
();
}
// Propagate to Part Layouts
...
...
@@ -588,18 +624,17 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
public
getVerticalSashLeft
(
sash
:
Sash
):
number
{
let
isSidebarVisible
=
this
.
partService
.
isVisible
(
Parts
.
SIDEBAR_PART
);
let
sidebarPosition
=
this
.
partService
.
getSideBarPosition
();
if
(
sash
===
this
.
sashXOne
)
{
if
(
sidebarPosition
===
Position
.
LEFT
)
{
return
isSidebarVisible
?
this
.
sidebarWidth
+
this
.
activitybarWidth
:
this
.
activitybarWidth
;
return
this
.
sidebarWidth
+
this
.
activitybarWidth
;
}
return
isSidebarVisible
?
this
.
workbenchSize
.
width
-
this
.
sidebarWidth
-
this
.
activitybarWidth
:
this
.
workbenchSize
.
w
idth
-
this
.
activitybarWidth
;
return
this
.
workbenchSize
.
width
-
this
.
sidebarW
idth
-
this
.
activitybarWidth
;
}
return
this
.
workbenchSize
.
width
-
this
.
panelWidth
-
(
sidebarPosition
===
Position
.
RIGHT
&&
isSidebarVisible
?
this
.
sidebarWidth
+
this
.
activitybarWidth
:
0
);
return
this
.
workbenchSize
.
width
-
this
.
panelWidth
-
(
sidebarPosition
===
Position
.
RIGHT
?
this
.
sidebarWidth
+
this
.
activitybarWidth
:
0
);
}
public
getVerticalSashHeight
(
sash
:
Sash
):
number
{
...
...
@@ -612,7 +647,11 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
}
public
getHorizontalSashLeft
(
sash
:
Sash
):
number
{
return
this
.
partService
.
getSideBarPosition
()
===
Position
.
LEFT
?
this
.
getVerticalSashLeft
(
sash
)
:
0
;
if
(
this
.
partService
.
getSideBarPosition
()
===
Position
.
RIGHT
)
{
return
0
;
}
return
this
.
sidebarWidth
+
this
.
activitybarWidth
;
}
public
getHorizontalSashWidth
(
sash
:
Sash
):
number
{
...
...
@@ -626,12 +665,10 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
const
sizeChangePxHeight
=
this
.
workbenchSize
.
height
*
(
sizeChange
/
100
);
let
doLayout
=
false
;
let
newSashSize
:
number
=
0
;
switch
(
part
)
{
case
Parts
.
SIDEBAR_PART
:
newSashSize
=
this
.
sidebarWidth
+
sizeChangePxWidth
;
this
.
sidebarWidth
=
Math
.
max
(
this
.
partLayoutInfo
.
sidebar
.
minWidth
,
newSashSize
);
// Sidebar can not become smaller than MIN_PART_WIDTH
this
.
sidebarWidth
=
this
.
sidebarWidth
+
sizeChangePxWidth
;
// Sidebar can not become smaller than MIN_PART_WIDTH
if
(
this
.
layoutEditorGroupsVertically
&&
(
this
.
workbenchSize
.
width
-
this
.
sidebarWidth
<
visibleEditors
*
MIN_EDITOR_PART_WIDTH
))
{
this
.
sidebarWidth
=
(
this
.
workbenchSize
.
width
-
visibleEditors
*
MIN_EDITOR_PART_WIDTH
);
...
...
@@ -640,8 +677,8 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal
doLayout
=
true
;
break
;
case
Parts
.
PANEL_PART
:
newSashSize
=
this
.
panelHeight
+
sizeChangePxHeight
;
this
.
panel
Height
=
Math
.
max
(
this
.
partLayoutInfo
.
panel
.
minHeight
,
newSashSize
)
;
this
.
panelHeight
=
this
.
panelHeight
+
sizeChangePxHeight
;
this
.
panel
Width
=
this
.
panelWidth
+
sizeChangePxWidth
;
doLayout
=
true
;
break
;
case
Parts
.
EDITOR_PART
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录