Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
a0da58be
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,发现更多精彩内容 >>
提交
a0da58be
编写于
2月 21, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
💄
上级
cdd2bde5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
107 addition
and
102 deletion
+107
-102
src/vs/workbench/browser/actions/toggleCenteredLayout.ts
src/vs/workbench/browser/actions/toggleCenteredLayout.ts
+2
-1
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
+86
-83
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+13
-12
src/vs/workbench/services/part/common/partService.ts
src/vs/workbench/services/part/common/partService.ts
+4
-4
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+2
-2
未找到文件。
src/vs/workbench/browser/actions/toggleCenteredLayout.ts
浏览文件 @
a0da58be
...
...
@@ -26,7 +26,8 @@ class ToggleCenteredLayout extends Action {
}
public
run
():
TPromise
<
any
>
{
this
.
partService
.
toggleCenteredLayout
();
this
.
partService
.
toggleCenteredEditorLayout
();
return
TPromise
.
as
(
null
);
}
}
...
...
src/vs/workbench/browser/parts/editor/editorGroupsControl.ts
浏览文件 @
a0da58be
...
...
@@ -89,7 +89,7 @@ export interface IEditorGroupsControl {
dispose
():
void
;
}
interface
CenteredLayoutData
{
interface
Centered
Editor
LayoutData
{
leftMarginRatio
:
number
;
size
:
number
;
}
...
...
@@ -99,7 +99,7 @@ interface CenteredLayoutData {
*/
export
class
EditorGroupsControl
extends
Themable
implements
IEditorGroupsControl
,
IVerticalSashLayoutProvider
,
IHorizontalSashLayoutProvider
{
private
static
readonly
CENTERED_
LAYOUT_DATA_STORAGE_KEY
=
'
workbench.centered
layout.layoutData
'
;
private
static
readonly
CENTERED_
EDITOR_LAYOUT_DATA_STORAGE_KEY
=
'
workbench.centerededitor
layout.layoutData
'
;
private
static
readonly
TITLE_AREA_CONTROL_KEY
=
'
__titleAreaControl
'
;
private
static
readonly
PROGRESS_BAR_CONTROL_KEY
=
'
__progressBar
'
;
...
...
@@ -136,7 +136,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
private
sashTwo
:
Sash
;
private
startSiloThreeSize
:
number
;
// if the centered layout is activated, the editor inside of silo ONE is centered
// if the centered
editor
layout is activated, the editor inside of silo ONE is centered
// the silo will then contain:
// [left margin]|[editor]|[right margin]
// - The size of the editor is defined by centeredEditorSize
...
...
@@ -238,22 +238,6 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
});
}
private
get
centeredEditorAvailableSize
():
number
{
return
this
.
silosSize
[
0
]
-
EditorGroupsControl
.
CENTERED_EDITOR_MIN_MARGIN
*
2
;
}
private
get
centeredEditorSize
():
number
{
return
Math
.
min
(
this
.
centeredEditorAvailableSize
,
this
.
centeredEditorPreferedSize
);
}
private
get
centeredEditorPosition
():
number
{
return
EditorGroupsControl
.
CENTERED_EDITOR_MIN_MARGIN
+
this
.
centeredEditorLeftMarginRatio
*
(
this
.
centeredEditorAvailableSize
-
this
.
centeredEditorSize
);
}
private
get
centeredEditorEndPosition
():
number
{
return
this
.
centeredEditorPosition
+
this
.
centeredEditorSize
;
}
private
get
snapToMinimizeThresholdSize
():
number
{
return
this
.
layoutVertically
?
EditorGroupsControl
.
SNAP_TO_MINIMIZED_THRESHOLD_WIDTH
:
EditorGroupsControl
.
SNAP_TO_MINIMIZED_THRESHOLD_HEIGHT
;
}
...
...
@@ -1014,66 +998,74 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
// Silo Three
this
.
silos
[
Position
.
THREE
]
=
$
(
this
.
parent
).
div
({
class
:
'
one-editor-silo editor-three
'
});
// Center Layout stuff
this
.
centeredEditorSashLeft
=
new
Sash
(
this
.
parent
.
getHTMLElement
(),
this
,
{
baseSize
:
5
,
orientation
:
Orientation
.
VERTICAL
});
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidStart
(()
=>
this
.
onCenterSashLeftDragStart
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidChange
((
e
:
ISashEvent
)
=>
this
.
onCenterSashLeftDrag
(
e
)));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidEnd
(()
=>
this
.
storeCenteredLayoutData
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidReset
(()
=>
this
.
resetCenteredEditor
()));
this
.
centeredEditorSashRight
=
new
Sash
(
this
.
parent
.
getHTMLElement
(),
this
,
{
baseSize
:
5
,
orientation
:
Orientation
.
VERTICAL
});
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidStart
(()
=>
this
.
onCenterSashRightDragStart
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidChange
((
e
:
ISashEvent
)
=>
this
.
onCenterSashRightDrag
(
e
)));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidEnd
(()
=>
this
.
storeCenteredLayoutData
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidReset
(()
=>
this
.
resetCenteredEditor
()));
this
.
centeredEditorActive
=
false
;
this
.
centeredEditorLeftMarginRatio
=
0.5
;
this
.
centeredEditorPreferedSize
=
-
1
;
// set this later if we know the container size
// Restore centered layout position and size
const
centeredLayoutDataString
=
this
.
storageServise
.
get
(
EditorGroupsControl
.
CENTERED_LAYOUT_DATA_STORAGE_KEY
,
StorageScope
.
GLOBAL
);
if
(
centeredLayoutDataString
)
{
const
centeredLayout
=
<
CenteredLayoutData
>
JSON
.
parse
(
centeredLayoutDataString
);
this
.
centeredEditorLeftMarginRatio
=
centeredLayout
.
leftMarginRatio
;
this
.
centeredEditorPreferedSize
=
centeredLayout
.
size
;
}
// For each position
POSITIONS
.
forEach
(
position
=>
{
const
silo
=
this
.
silos
[
position
];
// Containers (they contain everything and can move between silos)
const
container
=
$
(
silo
).
div
({
'
class
'
:
'
container
'
});
this
.
createSilo
(
position
);
});
// InstantiationServices
const
instantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IContextKeyService
,
this
.
contextKeyService
.
createScoped
(
container
.
getHTMLElement
())]
));
container
.
setProperty
(
EditorGroupsControl
.
INSTANTIATION_SERVICE_KEY
,
instantiationService
);
// associate with container
// Update Styles
this
.
updateStyles
();
}
// Title containers
const
titleContainer
=
$
(
container
).
div
({
'
class
'
:
'
title
'
});
if
(
this
.
tabOptions
.
showTabs
)
{
titleContainer
.
addClass
(
'
tabs
'
);
}
if
(
this
.
tabOptions
.
showIcons
)
{
titleContainer
.
addClass
(
'
show-file-icons
'
);
}
this
.
hookTitleDragListener
(
titleContainer
);
private
createSilo
(
position
:
Position
):
void
{
const
silo
=
this
.
silos
[
position
];
// Title Control
this
.
createTitleControl
(
this
.
stacks
.
groupAt
(
position
),
silo
,
titleContainer
,
instantiationService
);
// Containers (they contain everything and can move between silos)
const
container
=
$
(
silo
).
div
({
'
class
'
:
'
container
'
}
);
// Progress Bar
const
progressBar
=
new
ProgressBar
(
$
(
container
));
this
.
toUnbind
.
push
(
attachProgressBarStyler
(
progressBar
,
this
.
themeService
));
progressBar
.
getContainer
().
hide
();
container
.
setProperty
(
EditorGroupsControl
.
PROGRESS_BAR_CONTROL_KEY
,
progressBar
);
// associate with container
});
// InstantiationServices
const
instantiationService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
(
[
IContextKeyService
,
this
.
contextKeyService
.
createScoped
(
container
.
getHTMLElement
())]
));
container
.
setProperty
(
EditorGroupsControl
.
INSTANTIATION_SERVICE_KEY
,
instantiationService
);
// associate with container
// Update Styles
this
.
updateStyles
();
// Title containers
const
titleContainer
=
$
(
container
).
div
({
'
class
'
:
'
title
'
});
if
(
this
.
tabOptions
.
showTabs
)
{
titleContainer
.
addClass
(
'
tabs
'
);
}
if
(
this
.
tabOptions
.
showIcons
)
{
titleContainer
.
addClass
(
'
show-file-icons
'
);
}
this
.
hookTitleDragListener
(
titleContainer
);
// Title Control
this
.
createTitleControl
(
this
.
stacks
.
groupAt
(
position
),
silo
,
titleContainer
,
instantiationService
);
// Progress Bar
const
progressBar
=
new
ProgressBar
(
$
(
container
));
this
.
toUnbind
.
push
(
attachProgressBarStyler
(
progressBar
,
this
.
themeService
));
progressBar
.
getContainer
().
hide
();
container
.
setProperty
(
EditorGroupsControl
.
PROGRESS_BAR_CONTROL_KEY
,
progressBar
);
// associate with container
// Sash for first position to support centered editor layout
if
(
position
===
Position
.
ONE
)
{
// Center Layout stuff
this
.
centeredEditorSashLeft
=
new
Sash
(
container
.
getHTMLElement
(),
this
,
{
baseSize
:
5
,
orientation
:
Orientation
.
VERTICAL
});
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidStart
(()
=>
this
.
onCenterSashLeftDragStart
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidChange
((
e
:
ISashEvent
)
=>
this
.
onCenterSashLeftDrag
(
e
)));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidEnd
(()
=>
this
.
storeCenteredLayoutData
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashLeft
.
onDidReset
(()
=>
this
.
resetCenteredEditor
()));
this
.
centeredEditorSashRight
=
new
Sash
(
container
.
getHTMLElement
(),
this
,
{
baseSize
:
5
,
orientation
:
Orientation
.
VERTICAL
});
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidStart
(()
=>
this
.
onCenterSashRightDragStart
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidChange
((
e
:
ISashEvent
)
=>
this
.
onCenterSashRightDrag
(
e
)));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidEnd
(()
=>
this
.
storeCenteredLayoutData
()));
this
.
toUnbind
.
push
(
this
.
centeredEditorSashRight
.
onDidReset
(()
=>
this
.
resetCenteredEditor
()));
this
.
centeredEditorActive
=
false
;
this
.
centeredEditorLeftMarginRatio
=
0.5
;
this
.
centeredEditorPreferedSize
=
-
1
;
// set this later if we know the container size
// Restore centered layout position and size
const
centeredLayoutDataString
=
this
.
storageServise
.
get
(
EditorGroupsControl
.
CENTERED_EDITOR_LAYOUT_DATA_STORAGE_KEY
,
StorageScope
.
GLOBAL
);
if
(
centeredLayoutDataString
)
{
const
centeredLayout
=
<
CenteredEditorLayoutData
>
JSON
.
parse
(
centeredLayoutDataString
);
this
.
centeredEditorLeftMarginRatio
=
centeredLayout
.
leftMarginRatio
;
this
.
centeredEditorPreferedSize
=
centeredLayout
.
size
;
}
}
}
protected
updateStyles
():
void
{
...
...
@@ -1928,6 +1920,22 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
this
.
sashTwo
.
layout
();
}
private
get
centeredEditorAvailableSize
():
number
{
return
this
.
silosSize
[
Position
.
ONE
]
-
EditorGroupsControl
.
CENTERED_EDITOR_MIN_MARGIN
*
2
;
}
private
get
centeredEditorSize
():
number
{
return
Math
.
min
(
this
.
centeredEditorAvailableSize
,
this
.
centeredEditorPreferedSize
);
}
private
get
centeredEditorPosition
():
number
{
return
EditorGroupsControl
.
CENTERED_EDITOR_MIN_MARGIN
+
this
.
centeredEditorLeftMarginRatio
*
(
this
.
centeredEditorAvailableSize
-
this
.
centeredEditorSize
);
}
private
get
centeredEditorEndPosition
():
number
{
return
this
.
centeredEditorPosition
+
this
.
centeredEditorSize
;
}
private
setCenteredEditorPositionAndSize
(
pos
:
number
,
size
:
number
):
void
{
this
.
centeredEditorPreferedSize
=
Math
.
max
(
this
.
minSize
,
size
);
pos
-=
EditorGroupsControl
.
CENTERED_EDITOR_MIN_MARGIN
;
...
...
@@ -1969,11 +1977,11 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
}
private
storeCenteredLayoutData
():
void
{
const
data
:
CenteredLayoutData
=
{
const
data
:
Centered
Editor
LayoutData
=
{
leftMarginRatio
:
this
.
centeredEditorLeftMarginRatio
,
size
:
this
.
centeredEditorSize
};
this
.
storageServise
.
store
(
EditorGroupsControl
.
CENTERED_LAYOUT_DATA_STORAGE_KEY
,
JSON
.
stringify
(
data
),
StorageScope
.
GLOBAL
);
this
.
storageServise
.
store
(
EditorGroupsControl
.
CENTERED_
EDITOR_
LAYOUT_DATA_STORAGE_KEY
,
JSON
.
stringify
(
data
),
StorageScope
.
GLOBAL
);
}
public
getVerticalSashTop
(
sash
:
Sash
):
number
{
...
...
@@ -2142,12 +2150,8 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
}
});
// Layout centered Editor
const
doCentering
=
this
.
layoutVertically
&&
this
.
editorGroupService
.
getStacksModel
().
groups
.
length
===
1
&&
this
.
partService
.
isLayoutCentered
();
// Layout centered Editor (only in vertical layout when one group is opened)
const
doCentering
=
this
.
layoutVertically
&&
this
.
stacks
.
groups
.
length
===
1
&&
this
.
partService
.
isEditorLayoutCentered
();
if
(
doCentering
&&
!
this
.
centeredEditorActive
)
{
this
.
centeredEditorSashLeft
.
show
();
this
.
centeredEditorSashRight
.
show
();
...
...
@@ -2191,7 +2195,6 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
let
editorHeight
=
(
this
.
layoutVertically
?
this
.
dimension
.
height
:
this
.
silosSize
[
position
])
-
EditorGroupsControl
.
EDITOR_TITLE_HEIGHT
;
let
editorPosition
=
0
;
if
(
this
.
centeredEditorActive
)
{
editorWidth
=
this
.
centeredEditorSize
;
editorPosition
=
this
.
centeredEditorPosition
;
...
...
@@ -2205,7 +2208,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
}
}
editor
.
getContainer
().
style
({
'
margin-left
'
:
editorPosition
+
'
px
'
,
'
width
'
:
editorWidth
+
'
px
'
});
editor
.
getContainer
().
style
({
'
margin-left
'
:
`
${
editorPosition
}
px`
,
'
width
'
:
`
${
editorWidth
}
px`
});
editor
.
layout
(
new
Dimension
(
editorWidth
,
editorHeight
));
}
}
...
...
@@ -2216,7 +2219,7 @@ export class EditorGroupsControl extends Themable implements IEditorGroupsContro
if
(
layout
)
{
this
.
layoutContainers
();
}
this
.
storageServise
.
remove
(
EditorGroupsControl
.
CENTERED_LAYOUT_DATA_STORAGE_KEY
,
StorageScope
.
GLOBAL
);
this
.
storageServise
.
remove
(
EditorGroupsControl
.
CENTERED_
EDITOR_
LAYOUT_DATA_STORAGE_KEY
,
StorageScope
.
GLOBAL
);
}
public
getInstantiationService
(
position
:
Position
):
IInstantiationService
{
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
a0da58be
...
...
@@ -155,7 +155,7 @@ export class Workbench implements IPartService {
private
static
readonly
sidebarRestoreStorageKey
=
'
workbench.sidebar.restore
'
;
private
static
readonly
panelHiddenStorageKey
=
'
workbench.panel.hidden
'
;
private
static
readonly
zenModeActiveStorageKey
=
'
workbench.zenmode.active
'
;
private
static
readonly
centered
LayoutActiveStorageKey
=
'
workbench.centered
layout.active
'
;
private
static
readonly
centered
EditorLayoutActiveStorageKey
=
'
workbench.centered.editor
layout.active
'
;
private
static
readonly
panelPositionStorageKey
=
'
workbench.panel.location
'
;
private
static
readonly
defaultPanelPositionStorageKey
=
'
workbench.panel.defaultLocation
'
;
...
...
@@ -208,13 +208,13 @@ export class Workbench implements IPartService {
private
sideBarVisibleContext
:
IContextKey
<
boolean
>
;
private
hasFilesToCreateOpenOrDiff
:
boolean
;
private
fontAliasing
:
FontAliasingOption
;
private
centeredEditorLayoutActive
:
boolean
;
private
zenMode
:
{
active
:
boolean
;
transitionedToFullScreen
:
boolean
;
wasSideBarVisible
:
boolean
;
wasPanelVisible
:
boolean
;
};
private
centeredLayoutActive
:
boolean
;
constructor
(
parent
:
HTMLElement
,
...
...
@@ -381,9 +381,9 @@ export class Workbench implements IPartService {
this
.
toggleZenMode
(
true
);
}
// Restore Forced Center Mode
if
(
this
.
storageService
.
getBoolean
(
Workbench
.
centeredLayoutActiveStorageKey
,
StorageScope
.
GLOBAL
,
false
))
{
this
.
centeredLayoutActive
=
true
;
// Restore Forced
Editor
Center Mode
if
(
this
.
storageService
.
getBoolean
(
Workbench
.
centered
Editor
LayoutActiveStorageKey
,
StorageScope
.
GLOBAL
,
false
))
{
this
.
centered
Editor
LayoutActive
=
true
;
}
const
onRestored
=
(
error
?:
Error
):
IWorkbenchStartedInfo
=>
{
...
...
@@ -668,8 +668,8 @@ export class Workbench implements IPartService {
wasPanelVisible
:
false
};
// Centered Layout
this
.
centeredLayoutActive
=
false
;
// Centered
Editor
Layout
this
.
centered
Editor
LayoutActive
=
false
;
}
private
setPanelPositionFromStorageOrConfig
()
{
...
...
@@ -1323,13 +1323,14 @@ export class Workbench implements IPartService {
}
}
public
isLayoutCentered
():
boolean
{
return
this
.
centeredLayoutActive
;
public
is
Editor
LayoutCentered
():
boolean
{
return
this
.
centered
Editor
LayoutActive
;
}
public
toggleCenteredLayout
():
void
{
this
.
centeredLayoutActive
=
!
this
.
centeredLayoutActive
;
this
.
storageService
.
store
(
Workbench
.
centeredLayoutActiveStorageKey
,
this
.
centeredLayoutActive
,
StorageScope
.
GLOBAL
);
public
toggleCenteredEditorLayout
():
void
{
this
.
centeredEditorLayoutActive
=
!
this
.
centeredEditorLayoutActive
;
this
.
storageService
.
store
(
Workbench
.
centeredEditorLayoutActiveStorageKey
,
this
.
centeredEditorLayoutActive
,
StorageScope
.
GLOBAL
);
this
.
layout
();
}
...
...
src/vs/workbench/services/part/common/partService.ts
浏览文件 @
a0da58be
...
...
@@ -130,14 +130,14 @@ export interface IPartService {
toggleZenMode
():
void
;
/**
* Returns whether the centered layout is active.
* Returns whether the centered
editor
layout is active.
*/
isLayoutCentered
():
boolean
;
is
Editor
LayoutCentered
():
boolean
;
/**
* Toggles the workbench in and out of centered layout.
* Toggles the workbench in and out of centered
editor
layout.
*/
toggleCenteredLayout
():
void
;
toggleCentered
Editor
Layout
():
void
;
/**
* Resizes currently focused part on main access
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
a0da58be
...
...
@@ -429,8 +429,8 @@ export class TestPartService implements IPartService {
public
toggleZenMode
():
void
{
}
public
isLayoutCentered
():
boolean
{
return
false
;
}
public
toggleCenteredLayout
():
void
{
}
public
is
Editor
LayoutCentered
():
boolean
{
return
false
;
}
public
toggleCentered
Editor
Layout
():
void
{
}
public
resizePart
(
part
:
Parts
,
sizeChange
:
number
):
void
{
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录